Skip to content

Commit

Permalink
rename interface method and start on correct parsing of operation res…
Browse files Browse the repository at this point in the history
…ponse
  • Loading branch information
pmanko2 authored and samuelmale committed Mar 19, 2024
1 parent f0bf239 commit ffec8b6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package org.openmrs.module.clientregistry.api;

import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import org.hl7.fhir.r4.model.Patient;
import org.openmrs.module.fhir2.api.search.param.PatientSearchParams;

import java.util.List;

public interface CRPatientService {

List<Patient> getCRPatient(String sourceIdentifier, String sourceIdentifierSystem, List<String> extraTargetSystems);
List<Patient> getCRPatients(String sourceIdentifier, String sourceIdentifierSystem, List<String> extraTargetSystems);

List<Patient> searchCRForPatients(PatientSearchParams patientSearchParams);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ca.uhn.fhir.rest.gclient.IQuery;
import org.hl7.fhir.instance.model.api.IBaseBundle;
import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Parameters;
import org.hl7.fhir.r4.model.Patient;
import org.openmrs.module.clientregistry.ClientRegistryConfig;
import org.openmrs.module.clientregistry.api.CRPatientService;
Expand All @@ -30,7 +31,16 @@ public class FhirCRPatientServiceImpl implements CRPatientService {
* that match the given source identifier/system and target systems.
*/
@Override
public List<Patient> getCRPatient(String sourceIdentifier, String sourceIdentifierSystem, List<String> targetSystems) {
public List<Patient> getCRPatients(String sourceIdentifier, String sourceIdentifierSystem, List<String> targetSystems) {


Parameters betterCrRequest = fhirClient
.operation()
.onInstance(String.format("%s|%s", sourceIdentifierSystem, sourceIdentifier))
.named(FhirCRConstants.IHE_PIX_OPERATION)
.withNoParameters(Parameters.class)
.execute();

// construct and send request to external client registry
IQuery<IBaseBundle> crRequest = fhirClient
.search()
Expand All @@ -39,7 +49,7 @@ public List<Patient> getCRPatient(String sourceIdentifier, String sourceIdentifi
.where(
FhirCRConstants.SOURCE_IDENTIFIER_PARAM.exactly().systemAndIdentifier(sourceIdentifierSystem,
sourceIdentifier));

if (!targetSystems.isEmpty()) {
crRequest.and(FhirCRConstants.TARGET_SYSTEM_PARAM.matches().values(targetSystems));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Class<? extends IBaseResource> getResourceType() {
/**
* FHIR endpoint to get Patient references from external client registry Example request: GET
* [fhirbase
* ]/Patient/$ihe-pix?sourceIdentifier=1234{|sourceSystem}[&targetSystem=system1,system2]
* ]/Patient/$ihe-pix?sourceIdentifier={sourceSystem|}1234[&targetSystem=system1,system2]
*
* @param sourceIdentifierParam patient identifier token. If source system is included in token,
* we will use it to override the module defined source system.
Expand Down Expand Up @@ -81,7 +81,7 @@ public List<Patient> getCRPatientById(
"the sourceIdentifier request param");
}

List<Patient> patients = clientRegistryManager.getPatientService().getCRPatient(
List<Patient> patients = clientRegistryManager.getPatientService().getCRPatients(
sourceIdentifierParam.getValue(), sourceIdentifierSystem, targetSystems
);

Expand Down

0 comments on commit ffec8b6

Please sign in to comment.