34
34
import java .util .Set ;
35
35
import java .util .UUID ;
36
36
import java .util .function .BiFunction ;
37
+ import java .util .function .Predicate ;
37
38
import java .util .stream .Collectors ;
38
39
39
40
import static in .org .projecteka .hiu .ErrorCode .INVALID_PURPOSE_OF_USE ;
40
41
import static in .org .projecteka .hiu .common .Constants .EMPTY_STRING ;
41
- import static in .org .projecteka .hiu .common .Constants .IST ;
42
42
import static in .org .projecteka .hiu .common .Constants .PATIENT_REQUESTED_PURPOSE_CODE ;
43
43
import static in .org .projecteka .hiu .common .Constants .getCmSuffix ;
44
44
import static java .time .LocalDateTime .now ;
45
+ import static java .time .ZoneOffset .UTC ;
45
46
import static org .springframework .http .HttpStatus .INTERNAL_SERVER_ERROR ;
46
47
import static reactor .core .publisher .Mono .defer ;
47
48
import static reactor .core .publisher .Mono .just ;
@@ -98,7 +99,7 @@ public Mono<Map<String, String>> handlePatientConsentRequest(String requesterId,
98
99
}))
99
100
.flatMapMany (Flux ::fromIterable )
100
101
.flatMap (hipId -> buildConsentRequest (requesterId , hipId ,
101
- now (IST ).minusYears (consentServiceProperties .getConsentRequestFromYears ())))
102
+ now (UTC ).minusYears (consentServiceProperties .getConsentRequestFromYears ())))
102
103
.flatMap (consentRequestData -> generateConsentRequestForSelf (consentRequestData )
103
104
.map (dataReqId -> Map .entry (consentRequestData .getConsent ().getHipId (), dataReqId )))
104
105
.collectList ()
@@ -112,7 +113,7 @@ public Mono<Map<String, String>> handlePatientConsentRequest(String requesterId,
112
113
private List <PatientDataRequestDetail > filterRequestAfterThreshold (List <PatientDataRequestDetail > dataRequestDetails ) {
113
114
return dataRequestDetails .stream ()
114
115
.filter (dataRequestDetail -> !dataRequestDetail .getPatientDataRequestedAt ()
115
- .isAfter (now (IST ).minusMinutes (consentServiceProperties .getConsentRequestDelay ())))
116
+ .isAfter (now (UTC ).minusMinutes (consentServiceProperties .getConsentRequestDelay ())))
116
117
.collect (Collectors .toList ());
117
118
118
119
}
@@ -122,7 +123,7 @@ private List<String> filterEmptyAndNullValues(List<String> ids) {
122
123
}
123
124
124
125
private Mono <ConsentRequestData > handleForReloadConsent (String patientId , String hipId ) {
125
- LocalDateTime now = now (IST );
126
+ LocalDateTime now = now (UTC );
126
127
127
128
return patientConsentRepository .deletePatientConsentRequestFor (patientId )
128
129
.flatMap (patientConsentRepository ::deleteConsentRequestFor )
@@ -149,11 +150,11 @@ private Mono<ConsentRequestData> buildConsentRequest(String requesterId, String
149
150
return just (ConsentRequestData .builder ().consent (Consent .builder ()
150
151
.hiTypes (getAllApplicableHITypes ())
151
152
.patient (Patient .builder ().id (requesterId ).build ())
152
- .permission (Permission .builder ().dataEraseAt (now (IST )
153
+ .permission (Permission .builder ().dataEraseAt (now (UTC )
153
154
.plusMonths (consentServiceProperties .getConsentExpiryInMonths ()))
154
155
.dateRange (DateRange .builder ()
155
156
.from (dateFrom )
156
- .to (now (IST )).build ())
157
+ .to (now (UTC )).build ())
157
158
.build ())
158
159
.purpose (new Purpose (PATIENT_REQUESTED_PURPOSE_CODE ))
159
160
.hipId (hipId )
@@ -205,7 +206,7 @@ private Mono<Void> sendConsentRequestToGateway(
205
206
var patientId = hiRequest .getConsent ().getPatient ().getId ();
206
207
var consentRequest = ConsentRequest .builder ()
207
208
.requestId (gatewayRequestId )
208
- .timestamp (now (IST ))
209
+ .timestamp (now (UTC ))
209
210
.consent (reqInfo )
210
211
.build ();
211
212
var hiuConsentRequest = hiRequest .getConsent ().toConsentRequest (gatewayRequestId .toString (), requesterId );
0 commit comments