Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Referring ServiceRequest with Accession Number #583

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Bundle createUpdateFhirResourcesInFhirStore(List<FhirOperations> fhirOperationsL

Optional<Task> getTaskBasedOnServiceRequest(String referringId);

Optional<ServiceRequest> getServiceRequestByReferingId(String referringId);

Optional<Task> getTaskBasedOnTask(String taskId);

Bundle createUpdateFhirResourcesInFhirStore(Map<String, Resource> createResources,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,40 @@ public Optional<Task> getTaskBasedOnServiceRequest(String referringId) {
return Optional.empty();
}

@Override
public Optional<ServiceRequest> getServiceRequestByReferingId(String referringId) {
ServiceRequest serviceRequest = null;
Bundle bundle = localFhirClient.search()//
.forResource(ServiceRequest.class)//
.returnBundle(Bundle.class)//
.where(ServiceRequest.IDENTIFIER.exactly().identifier(referringId))//
.execute();
if (bundle.hasEntry()) {
serviceRequest = (ServiceRequest) bundle.getEntryFirstRep().getResource();
}
if (serviceRequest == null) {
LogEvent.logDebug(this.getClass().getName(), "", "no service request with identifier " + referringId);
for (String remotePath : fhirConfig.getRemoteStorePaths()) {

bundle = localFhirClient.search()//
.forResource(ServiceRequest.class)//
.returnBundle(Bundle.class)//
.where(ServiceRequest.IDENTIFIER.exactly().systemAndIdentifier(remotePath, referringId))//
.execute();
if (bundle.hasEntry()) {
serviceRequest = (ServiceRequest) bundle.getEntryFirstRep().getResource();
}
}
}
if (serviceRequest == null) {
LogEvent.logDebug(this.getClass().getName(), "",
"no service request with identifier " + referringId + " with configured systems");
} else {
return Optional.of(serviceRequest);
}
return Optional.empty();
}

@Override
public Optional<Task> getTaskBasedOnTask(String taskId) {
Bundle bundle = localFhirClient.search()//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ public void transformPersistOrderEntryFhirObjects(SamplePatientUpdateData update
this.addToOperations(fhirOperations, tempIdGenerator, referringTask.get());
}

Optional<ServiceRequest> referingServiceRequest = getReferringServiceRequestForSample(updateData.getSample());
if (referingServiceRequest.isPresent()) {
updateReferringServiceRequestWithSampleInfo(updateData.getSample(), referingServiceRequest.get());
this.addToOperations(fhirOperations, tempIdGenerator, referingServiceRequest.get());
}

// patient
org.hl7.fhir.r4.model.Patient patient = transformToFhirPatient(patientInfo.getPatientPK());
this.addToOperations(fhirOperations, tempIdGenerator, patient);
Expand Down Expand Up @@ -428,6 +434,11 @@ private void updateReferringTaskWithTaskInfo(Task referringTask, Task task) {
}
}

private void updateReferringServiceRequestWithSampleInfo(Sample sample, ServiceRequest serviceRequest) {
serviceRequest.setRequisition(
this.createIdentifier(fhirConfig.getOeFhirSystem() + "/samp_labNo", sample.getAccessionNumber()));
}

private Optional<Task> getReferringTaskForSample(Sample sample) {
List<ElectronicOrder> eOrders = electronicOrderService.getElectronicOrdersByExternalId(sample.getReferringId());
if (eOrders.size() > 0 && ElectronicOrderType.FHIR.equals(eOrders.get(0).getType())) {
Expand All @@ -436,6 +447,14 @@ private Optional<Task> getReferringTaskForSample(Sample sample) {
return Optional.empty();
}

private Optional<ServiceRequest> getReferringServiceRequestForSample(Sample sample) {
List<ElectronicOrder> eOrders = electronicOrderService.getElectronicOrdersByExternalId(sample.getReferringId());
if (eOrders.size() > 0 && ElectronicOrderType.FHIR.equals(eOrders.get(0).getType())) {
return fhirPersistanceService.getServiceRequestByReferingId(sample.getReferringId());
}
return Optional.empty();
}

private Practitioner transformProviderToPractitioner(String providerId) {
return transformProviderToPractitioner(providerService.get(providerId));
}
Expand Down
51 changes: 33 additions & 18 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
#Faclity FHIR server
#org.openelisglobal.facilitylist.fhirstore = https://hub.openelisci.org:5000/gofr/exemple4
#org.openelisglobal.facilitylist.authurl= https://hub.openelisci.org:5000/gofr/token
#org.openelisglobal.facilitylist.username= [email protected]
#org.openelisglobal.facilitylist.password= gofr
#org.openelisglobal.facilitylist.auth= token
facilitylist.schedule.fixedRate=864000000
spring.liquibase.contexts=ci_general,ci_recency_testing,ci_TB

#org.openelisglobal.remote.source.uri=https://hub.openelisci.org:5000/fhir/
##org.openelisglobal.remote.source.identifier=Organization/0c0488e7-81e3-4f29-a22f-f73cf5ef5c20
#org.openelisglobal.fhir.subscriber=https://hub.openelisci.org:5000/fhir/
#Liquibase Profile
#spring.liquibase.contexts=


org.openelisglobal.server.uri=https://oe.openelis.org:8443/OpenELIS-Global/fhir/
org.openelisglobal.datasubscriber.uri=https://datasubscriber.openelis.org:8443/subscription/fhirResourceGroup/
org.openelisglobal.fhirstore.uri=http://localhost:8081/fhir/
#Local FHIR server
#org.openelisglobal.server.uri=https://oe.openelis.org:8443/OpenELIS-Global/fhir/
#org.openelisglobal.datasubscriber.uri=https://datasubscriber.openelis.org:8443/subscription/fhirResourceGroup/
#org.openelisglobal.fhirstore.uri=http://localhost:8081/fhir/

org.openelisglobal.remote.source.identifier=Practitioner/738185ba-eac9-11e5-8f4d-e06995eac916
org.openelisglobal.remote.source.uri=http://185.218.126.190:5001/fhir/
org.openelisglobal.remote.source.updateStatus=false
org.openelisglobal.task.useBasedOn=true
org.openelisglobal.fhirstore.username=openelis
org.openelisglobal.fhirstore.password=Openelis123!
org.openelisglobal.fhir.subscriber.allowHTTP=true
# Remote FHIR server/Consolidated Server
#org.openelisglobal.remote.source.uri=http://185.218.126.190:5001/fhir/
#org.openelisglobal.remote.source.identifier=Practitioner/738185ba-eac9-11e5-8f4d-e06995eac916
#org.openelisglobal.remote.source.updateStatus=false
#org.openelisglobal.task.useBasedOn=true
#org.openelisglobal.fhirstore.username=openelis
#org.openelisglobal.fhirstore.password=Openelis123!
#org.openelisglobal.fhir.subscriber.allowHTTP=true

org.openelisglobal.fhir.subscriber=http://185.218.126.190:5001/fhir/
#org.openelisglobal.fhir.subscriber=http://185.218.126.190:5001/fhir/
#org.openelisglobal.fhir.subscriber.resources=Task,Patient,ServiceRequest,DiagnosticReport,Observation,Specimen,Practitioner,Encounter

org.openelisglobal.fhir.subscriber.resources=Task,Patient,ServiceRequest,DiagnosticReport,Observation,Specimen,Practitioner,Encounter
#provider FHIR server
#org.openelisglobal.providerlist.fhirstore=http://localhost:8081/fhir/
#org.openelisglobal.requester.identifier=Practitioner/f9badd80-ab76-11e2-9e96-0800200c9a66
#org.openelisglobal.requester.lastName=Dr. Mauritius
#org.openelisglobal.requester.firstName=Felix
#org.openelisglobal.requester.phone=230 5123 1234

spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
#Hibernate Config
#spring.jpa.show-sql=true
#spring.jpa.properties.hibernate.format_sql=true

# SSL Config
#server.ssl.key-store = file:/ssl/lf.keystore
#server.ssl.key-store-password = testtest
#server.ssl.key-password = testtest
#server.ssl.trust-store=file:/ssl/lf.truststore
#server.ssl.trust-store-password=testtest