Skip to content

Commit b0ba605

Browse files
Merge pull request #15 from Bahmni-Covid19/revert-14-327-IST-Time
Revert "327|Sameera| Adds. to change from UTC to IST"
2 parents 8dd7e5a + 07a792f commit b0ba605

13 files changed

+43
-45
lines changed

src/main/java/in/org/projecteka/hiu/common/Constants.java

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package in.org.projecteka.hiu.common;
22

3-
import java.time.ZoneOffset;
4-
53
public class Constants {
6-
public static final ZoneOffset IST = ZoneOffset.ofHoursMinutes(5,30);
74
// APIs
85
private static final String CURRENT_VERSION = "/v0.5";
96
public static final String PATH_CONSENT_REQUESTS_ON_INIT = CURRENT_VERSION + "/consent-requests/on-init";

src/main/java/in/org/projecteka/hiu/common/heartbeat/Heartbeat.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
import java.util.concurrent.TimeoutException;
1717

1818
import static in.org.projecteka.hiu.Error.of;
19-
import static in.org.projecteka.hiu.common.Constants.IST;
2019
import static in.org.projecteka.hiu.common.heartbeat.model.Status.DOWN;
2120
import static in.org.projecteka.hiu.common.heartbeat.model.Status.UP;
2221
import static java.lang.String.format;
2322
import static java.time.LocalDateTime.now;
23+
import static java.time.ZoneOffset.UTC;
2424
import static reactor.core.publisher.Mono.just;
2525

2626

@@ -35,12 +35,12 @@ public class Heartbeat {
3535
public Mono<HeartbeatResponse> getStatus() {
3636
try {
3737
if (cacheHealth.isUp() && isRabbitMQUp() && isPostgresUp()) {
38-
return just(HeartbeatResponse.builder().timeStamp(now(IST)).status(UP).build());
38+
return just(HeartbeatResponse.builder().timeStamp(now(UTC)).status(UP).build());
3939
}
40-
return just(HeartbeatResponse.builder().timeStamp(now(IST)).status(DOWN).error(of(SERVICE_DOWN)).build());
40+
return just(HeartbeatResponse.builder().timeStamp(now(UTC)).status(DOWN).error(of(SERVICE_DOWN)).build());
4141
} catch (IOException | TimeoutException e) {
4242
logger.error(format("Heartbeat is not healthy with failure: %s", e.getMessage()), e);
43-
return just(HeartbeatResponse.builder().timeStamp(now(IST)).status(DOWN).error(of(SERVICE_DOWN)).build());
43+
return just(HeartbeatResponse.builder().timeStamp(now(UTC)).status(DOWN).error(of(SERVICE_DOWN)).build());
4444
}
4545
}
4646

src/main/java/in/org/projecteka/hiu/common/heartbeat/HeartbeatController.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import org.springframework.web.bind.annotation.RestController;
99
import reactor.core.publisher.Mono;
1010

11-
import static in.org.projecteka.hiu.common.Constants.IST;
1211
import static in.org.projecteka.hiu.common.heartbeat.model.Status.UP;
1312
import static java.time.LocalDateTime.now;
13+
import static java.time.ZoneOffset.UTC;
1414
import static org.springframework.http.HttpStatus.OK;
1515
import static org.springframework.http.HttpStatus.SERVICE_UNAVAILABLE;
1616

@@ -33,7 +33,7 @@ public Mono<ResponseEntity<HeartbeatResponse>> getReadiness() {
3333
public Mono<ResponseEntity<HeartbeatResponse>> getLiveliness() {
3434
HeartbeatResponse heartbeatResponse = HeartbeatResponse.builder()
3535
.status(UP)
36-
.timeStamp(now(IST))
36+
.timeStamp(now(UTC))
3737
.build();
3838
return Mono.just(new ResponseEntity<>(heartbeatResponse, OK));
3939
}

src/main/java/in/org/projecteka/hiu/consent/ConsentService.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import static in.org.projecteka.hiu.ClientError.consentRequestNotFound;
3232
import static in.org.projecteka.hiu.ErrorCode.INVALID_PURPOSE_OF_USE;
3333
import static in.org.projecteka.hiu.common.Constants.EMPTY_STRING;
34-
import static in.org.projecteka.hiu.common.Constants.IST;
3534
import static in.org.projecteka.hiu.common.Constants.STATUS;
3635
import static in.org.projecteka.hiu.common.Constants.getCmSuffix;
3736
import static in.org.projecteka.hiu.consent.model.ConsentRequestRepresentation.toConsentRequestRepresentation;
@@ -41,6 +40,7 @@
4140
import static in.org.projecteka.hiu.consent.model.ConsentStatus.GRANTED;
4241
import static in.org.projecteka.hiu.consent.model.ConsentStatus.REVOKED;
4342
import static java.time.LocalDateTime.now;
43+
import static java.time.ZoneOffset.UTC;
4444
import static java.util.UUID.fromString;
4545
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
4646
import static reactor.core.publisher.Flux.fromIterable;
@@ -115,7 +115,7 @@ private Mono<Void> sendConsentRequestToGateway(
115115
var patientId = hiRequest.getConsent().getPatient().getId();
116116
var consentRequest = ConsentRequest.builder()
117117
.requestId(gatewayRequestId)
118-
.timestamp(now(IST))
118+
.timestamp(now(UTC))
119119
.consent(reqInfo)
120120
.build();
121121
var hiuConsentRequest = hiRequest.getConsent().toConsentRequest(gatewayRequestId.toString(), requesterId);
@@ -146,7 +146,7 @@ public Mono<Void> updatePostedRequest(ConsentRequestInitResponse response) {
146146
return updatePublisher
147147
.then(patientConsentRepository.updatePatientConsentRequest(dataRequestId,
148148
consentRequestId,
149-
now(IST)));
149+
now(UTC)));
150150
})
151151
.onErrorResume(NoSuchFieldError.class, e -> updatePublisher);
152152
}

src/main/java/in/org/projecteka/hiu/consent/ExpiredConsentTask.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
import reactor.core.publisher.Mono;
1313

1414
import java.time.LocalDateTime;
15+
import java.time.ZoneOffset;
1516
import java.util.ArrayList;
1617
import java.util.List;
1718
import java.util.UUID;
1819

1920
import static in.org.projecteka.hiu.ClientError.consentArtefactNotFound;
20-
import static in.org.projecteka.hiu.common.Constants.IST;
2121
import static in.org.projecteka.hiu.common.Constants.getCmSuffix;
2222
import static in.org.projecteka.hiu.consent.model.ConsentStatus.EXPIRED;
2323
import static in.org.projecteka.hiu.consent.model.consentmanager.ConsentAcknowledgementStatus.OK;
@@ -59,7 +59,7 @@ private ConsentOnNotifyRequest buildConsentOnNotifyRequest(List<ConsentArtefact>
5959
var requestId = UUID.randomUUID();
6060
var consentArtefactRequest = ConsentOnNotifyRequest
6161
.builder()
62-
.timestamp(LocalDateTime.now(IST))
62+
.timestamp(LocalDateTime.now(ZoneOffset.UTC))
6363
.requestId(requestId);
6464
var acknowledgements = new ArrayList<ConsentAcknowledgement>();
6565

src/main/java/in/org/projecteka/hiu/consent/GrantedConsentTask.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import reactor.core.publisher.Mono;
1212

1313
import java.time.LocalDateTime;
14+
import java.time.ZoneOffset;
1415
import java.util.UUID;
1516

16-
import static in.org.projecteka.hiu.common.Constants.IST;
1717
import static in.org.projecteka.hiu.common.Constants.getCmSuffix;
1818
import static in.org.projecteka.hiu.consent.model.ConsentStatus.GRANTED;
1919
import static reactor.core.publisher.Flux.fromIterable;
@@ -40,7 +40,7 @@ private Mono<Void> perform(ConsentArtefactReference reference, String consentReq
4040
var consentArtefactRequest = ConsentArtefactRequest
4141
.builder()
4242
.consentId(reference.getId())
43-
.timestamp(LocalDateTime.now(IST))
43+
.timestamp(LocalDateTime.now(ZoneOffset.UTC))
4444
.requestId(requestId)
4545
.build();
4646
return gatewayClient.requestConsentArtefact(consentArtefactRequest, cmSuffix);

src/main/java/in/org/projecteka/hiu/consent/PatientConsentService.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@
3434
import java.util.Set;
3535
import java.util.UUID;
3636
import java.util.function.BiFunction;
37+
import java.util.function.Predicate;
3738
import java.util.stream.Collectors;
3839

3940
import static in.org.projecteka.hiu.ErrorCode.INVALID_PURPOSE_OF_USE;
4041
import static in.org.projecteka.hiu.common.Constants.EMPTY_STRING;
41-
import static in.org.projecteka.hiu.common.Constants.IST;
4242
import static in.org.projecteka.hiu.common.Constants.PATIENT_REQUESTED_PURPOSE_CODE;
4343
import static in.org.projecteka.hiu.common.Constants.getCmSuffix;
4444
import static java.time.LocalDateTime.now;
45+
import static java.time.ZoneOffset.UTC;
4546
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
4647
import static reactor.core.publisher.Mono.defer;
4748
import static reactor.core.publisher.Mono.just;
@@ -98,7 +99,7 @@ public Mono<Map<String, String>> handlePatientConsentRequest(String requesterId,
9899
}))
99100
.flatMapMany(Flux::fromIterable)
100101
.flatMap(hipId -> buildConsentRequest(requesterId, hipId,
101-
now(IST).minusYears(consentServiceProperties.getConsentRequestFromYears())))
102+
now(UTC).minusYears(consentServiceProperties.getConsentRequestFromYears())))
102103
.flatMap(consentRequestData -> generateConsentRequestForSelf(consentRequestData)
103104
.map(dataReqId -> Map.entry(consentRequestData.getConsent().getHipId(), dataReqId)))
104105
.collectList()
@@ -112,7 +113,7 @@ public Mono<Map<String, String>> handlePatientConsentRequest(String requesterId,
112113
private List<PatientDataRequestDetail> filterRequestAfterThreshold(List<PatientDataRequestDetail> dataRequestDetails) {
113114
return dataRequestDetails.stream()
114115
.filter(dataRequestDetail -> !dataRequestDetail.getPatientDataRequestedAt()
115-
.isAfter(now(IST).minusMinutes(consentServiceProperties.getConsentRequestDelay())))
116+
.isAfter(now(UTC).minusMinutes(consentServiceProperties.getConsentRequestDelay())))
116117
.collect(Collectors.toList());
117118

118119
}
@@ -122,7 +123,7 @@ private List<String> filterEmptyAndNullValues(List<String> ids) {
122123
}
123124

124125
private Mono<ConsentRequestData> handleForReloadConsent(String patientId, String hipId) {
125-
LocalDateTime now = now(IST);
126+
LocalDateTime now = now(UTC);
126127

127128
return patientConsentRepository.deletePatientConsentRequestFor(patientId)
128129
.flatMap(patientConsentRepository::deleteConsentRequestFor)
@@ -149,11 +150,11 @@ private Mono<ConsentRequestData> buildConsentRequest(String requesterId, String
149150
return just(ConsentRequestData.builder().consent(Consent.builder()
150151
.hiTypes(getAllApplicableHITypes())
151152
.patient(Patient.builder().id(requesterId).build())
152-
.permission(Permission.builder().dataEraseAt(now(IST)
153+
.permission(Permission.builder().dataEraseAt(now(UTC)
153154
.plusMonths(consentServiceProperties.getConsentExpiryInMonths()))
154155
.dateRange(DateRange.builder()
155156
.from(dateFrom)
156-
.to(now(IST)).build())
157+
.to(now(UTC)).build())
157158
.build())
158159
.purpose(new Purpose(PATIENT_REQUESTED_PURPOSE_CODE))
159160
.hipId(hipId)
@@ -205,7 +206,7 @@ private Mono<Void> sendConsentRequestToGateway(
205206
var patientId = hiRequest.getConsent().getPatient().getId();
206207
var consentRequest = ConsentRequest.builder()
207208
.requestId(gatewayRequestId)
208-
.timestamp(now(IST))
209+
.timestamp(now(UTC))
209210
.consent(reqInfo)
210211
.build();
211212
var hiuConsentRequest = hiRequest.getConsent().toConsentRequest(gatewayRequestId.toString(), requesterId);

src/main/java/in/org/projecteka/hiu/consent/RevokedConsentTask.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
import reactor.core.publisher.Mono;
1313

1414
import java.time.LocalDateTime;
15+
import java.time.ZoneOffset;
1516
import java.util.ArrayList;
1617
import java.util.List;
1718
import java.util.UUID;
1819

1920
import static in.org.projecteka.hiu.ClientError.consentArtefactNotFound;
20-
import static in.org.projecteka.hiu.common.Constants.IST;
2121
import static in.org.projecteka.hiu.common.Constants.getCmSuffix;
2222
import static in.org.projecteka.hiu.consent.model.ConsentStatus.EXPIRED;
2323
import static in.org.projecteka.hiu.consent.model.ConsentStatus.REVOKED;
@@ -60,7 +60,7 @@ private ConsentOnNotifyRequest buildConsentOnNotifyRequest(List<ConsentArtefact>
6060
var requestId = UUID.randomUUID();
6161
var consentArtefactRequest = ConsentOnNotifyRequest
6262
.builder()
63-
.timestamp(LocalDateTime.now(IST))
63+
.timestamp(LocalDateTime.now(ZoneOffset.UTC))
6464
.requestId(requestId);
6565
var acknowledgements = new ArrayList<ConsentAcknowledgement>();
6666

src/main/java/in/org/projecteka/hiu/dataflow/DataFlowRequestListener.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828

2929
import javax.annotation.PostConstruct;
3030
import java.time.LocalDateTime;
31+
import java.time.ZoneOffset;
3132
import java.util.Optional;
3233
import java.util.UUID;
3334

3435
import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS;
3536
import static in.org.projecteka.hiu.ClientError.queueNotFound;
3637
import static in.org.projecteka.hiu.common.Constants.CORRELATION_ID;
37-
import static in.org.projecteka.hiu.common.Constants.IST;
3838
import static in.org.projecteka.hiu.common.Serializer.to;
3939
import static reactor.core.publisher.Mono.defer;
4040

@@ -113,7 +113,7 @@ public void subscribe() {
113113

114114
private GatewayDataFlowRequest getDataFlowRequest(DataFlowRequest dataFlowRequest) {
115115
var requestId = UUID.randomUUID();
116-
var timestamp = LocalDateTime.now(IST);
116+
var timestamp = LocalDateTime.now(ZoneOffset.UTC);
117117
return new GatewayDataFlowRequest(requestId, timestamp, dataFlowRequest);
118118
}
119119

src/main/java/in/org/projecteka/hiu/dataflow/HealthInfoManager.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@
3030
import static in.org.projecteka.hiu.ClientError.consentArtefactGone;
3131
import static in.org.projecteka.hiu.ClientError.invalidHealthInformationRequest;
3232
import static in.org.projecteka.hiu.ClientError.unauthorizedRequester;
33-
import static in.org.projecteka.hiu.common.Constants.IST;
3433
import static in.org.projecteka.hiu.common.Constants.STATUS;
3534
import static in.org.projecteka.hiu.dataflow.model.DataRequestStatus.ERRORED;
3635
import static in.org.projecteka.hiu.dataflow.model.DataRequestStatus.PROCESSING;
3736
import static in.org.projecteka.hiu.dataflow.model.HealthInfoStatus.PARTIAL;
3837
import static in.org.projecteka.hiu.dataflow.model.HealthInfoStatus.RECEIVED;
3938
import static java.time.LocalDateTime.now;
39+
import static java.time.ZoneOffset.UTC;
4040
import static java.util.UUID.fromString;
4141
import static org.springframework.util.StringUtils.hasText;
4242
import static org.springframework.util.StringUtils.isEmpty;
@@ -167,7 +167,7 @@ public Flux<PatientHealthInfoStatus> fetchHealthInformationStatus(List<String> d
167167
if (dataRequestDetails.stream().anyMatch(this::isStatusNull)) {
168168
logger.info("Some data parts are not yet received for data request id {}",
169169
dataRequestDetail.getDataRequestId());
170-
var status = now(IST)
170+
var status = now(UTC)
171171
.isAfter(dataRequestDetail.getDataFlowRequestedAt()
172172
.plusMinutes(serviceProperties.getDataPartWaitTime())) ?
173173
getStatusFor(dataRequestDetails) : PROCESSING;
@@ -200,7 +200,7 @@ private boolean isStatusNull(PatientDataRequestDetail dataRequestDetail) {
200200
}
201201

202202
private DataRequestStatus getStatusAgainstDate(LocalDateTime dateTime, Integer withinMinutes) {
203-
return now(IST).isAfter(dateTime.plusMinutes(withinMinutes)) ? ERRORED : PROCESSING;
203+
return now(UTC).isAfter(dateTime.plusMinutes(withinMinutes)) ? ERRORED : PROCESSING;
204204
}
205205

206206
private DataRequestStatus getStatusFor(List<PatientDataRequestDetail> dataRequestDetails) {
@@ -235,7 +235,7 @@ private boolean isProcessing(List<HealthInfoStatus> statuses) {
235235

236236
private boolean isConsentNotExpired(Map<String, String> consentDetail) {
237237
var consentExpiryDate = LocalDateTime.parse(consentDetail.get("consentExpiryDate"));
238-
return consentExpiryDate.isAfter(now(IST));
238+
return consentExpiryDate.isAfter(now(UTC));
239239
}
240240

241241
private boolean isGrantedConsent(Map<String, String> consentDetail) {

src/main/java/in/org/projecteka/hiu/dataprocessor/HealthDataProcessor.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.nio.file.Path;
4242
import java.nio.file.Paths;
4343
import java.time.LocalDateTime;
44+
import java.time.ZoneOffset;
4445
import java.util.ArrayList;
4546
import java.util.Arrays;
4647
import java.util.Collections;
@@ -53,7 +54,6 @@
5354
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
5455
import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DATES_AS_TIMESTAMPS;
5556
import static in.org.projecteka.hiu.common.Constants.CORRELATION_ID;
56-
import static in.org.projecteka.hiu.common.Constants.IST;
5757
import static in.org.projecteka.hiu.dataflow.model.HealthInfoStatus.ERRORED;
5858
import static in.org.projecteka.hiu.dataflow.model.HealthInfoStatus.PARTIAL;
5959
import static java.util.stream.Collectors.joining;
@@ -205,11 +205,11 @@ private HealthInfoNotificationRequest getHealthInfoNotificationRequest(DataConte
205205
SessionStatus sessionStatus) {
206206
return HealthInfoNotificationRequest.builder()
207207
.requestId(UUID.randomUUID())
208-
.timestamp(LocalDateTime.now(IST))
208+
.timestamp(LocalDateTime.now(ZoneOffset.UTC))
209209
.notification(Notification.builder()
210210
.consentId(context.getConsentId())
211211
.transactionId(context.getTransactionId())
212-
.doneAt(LocalDateTime.now(IST))
212+
.doneAt(LocalDateTime.now(ZoneOffset.UTC))
213213
.notifier(Notifier.builder()
214214
.type(Type.HIU)
215215
.id(hiuProperties.getId())

src/main/java/in/org/projecteka/hiu/patient/PatientService.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
import reactor.core.publisher.Mono;
2323

2424
import java.time.LocalDateTime;
25+
import java.time.ZoneOffset;
2526
import java.util.UUID;
2627
import java.util.concurrent.TimeoutException;
2728
import java.util.function.Supplier;
2829

2930
import static in.org.projecteka.hiu.ClientError.gatewayTimeOut;
3031
import static in.org.projecteka.hiu.ClientError.unknownError;
3132
import static in.org.projecteka.hiu.ErrorCode.PATIENT_NOT_FOUND;
32-
import static in.org.projecteka.hiu.common.Constants.IST;
3333
import static in.org.projecteka.hiu.common.Constants.getCmSuffix;
3434
import static in.org.projecteka.hiu.common.CustomScheduler.scheduleThis;
3535
import static in.org.projecteka.hiu.common.ErrorMappings.get;
@@ -92,7 +92,7 @@ public Mono<Patient> findPatientWith(String id) {
9292

9393
private FindPatientRequest getFindPatientRequest(String id) {
9494
var requestId = UUID.randomUUID();
95-
var timestamp = LocalDateTime.now(IST);
95+
var timestamp = LocalDateTime.now(ZoneOffset.UTC);
9696
var patient = new in.org.projecteka.hiu.consent.model.Patient(id);
9797
var requester = new Requester("HIU", hiuProperties.getId());
9898
var query = new FindPatientQuery(patient, requester);
@@ -136,7 +136,7 @@ private PatientStatusNotification buildPatientStatusOnNotify(UUID requestID) {
136136
var requestId = UUID.randomUUID();
137137
var patientOnNotifyRequest = PatientStatusNotification
138138
.builder()
139-
.timestamp(LocalDateTime.now(IST))
139+
.timestamp(LocalDateTime.now(ZoneOffset.UTC))
140140
.requestId(requestId);
141141
GatewayResponse gatewayResponse = new GatewayResponse(requestID.toString());
142142
patientOnNotifyRequest.resp(gatewayResponse).build();

0 commit comments

Comments
 (0)