diff --git a/api/src/main/java/org/openmrs/module/clientregistry/ClientRegistryConfig.java b/api/src/main/java/org/openmrs/module/clientregistry/ClientRegistryConfig.java index 627fc67..884fab2 100644 --- a/api/src/main/java/org/openmrs/module/clientregistry/ClientRegistryConfig.java +++ b/api/src/main/java/org/openmrs/module/clientregistry/ClientRegistryConfig.java @@ -21,29 +21,29 @@ */ @Component public class ClientRegistryConfig { - + public final static String MODULE_PRIVILEGE = "Client Registry Privilege"; - + @Autowired @Qualifier("adminService") AdministrationService administrationService; - + @Value("${CLIENTREGISTRY_SERVERURL}") private String serverUrl; - + @Value("${CLIENTREGISTRY_USERNAME}") private String username; - + @Value("${CLIENTREGISTRY_PASSWORD}") private String password; - + @Value("${CLIENTREGISTRY_IDENTIFIERROOT}") private String identifierRoot; - + public boolean clientRegistryConnectionEnabled() { return StringUtils.isNotBlank(getClientRegistryServerUrl()); } - + public String getClientRegistryServerUrl() { return serverUrl; } @@ -65,11 +65,11 @@ public String getClientRegistryDefaultPatientIdentifierSystem() { public String getClientRegistryUserName() { return username; } - + public String getClientRegistryPassword() { return password; } - + public String getClientRegistryIdentifierRoot() { return identifierRoot; } diff --git a/api/src/main/java/org/openmrs/module/clientregistry/ClientRegistryConstants.java b/api/src/main/java/org/openmrs/module/clientregistry/ClientRegistryConstants.java index 35c486e..293842e 100644 --- a/api/src/main/java/org/openmrs/module/clientregistry/ClientRegistryConstants.java +++ b/api/src/main/java/org/openmrs/module/clientregistry/ClientRegistryConstants.java @@ -2,8 +2,14 @@ public class ClientRegistryConstants { + public static final String CLIENT_REGISTRY_INTERNAL_ID_SYSTEM = "http://clientregistry.org/openmrs"; + + public static final String GP_EXTENSION_UUID_EXTENSION_URLS = "clientregistry.uuidAndExtensionURL"; + public static final String GP_CLIENT_REGISTRY_SERVER_URL = "CLIENTREGISTRY_SERVERURL"; + public static final String GP_FHIR_CLIENT_REGISTRY_GET_PATIENT_ENDPOINT = "clientregistry.fhirGetPatientEndpoint"; + public static final String GP_CLIENT_REGISTRY_DEFAULT_PATIENT_IDENTIFIER_SYSTEM = "clientregistry.defaultPatientIdentifierSystem"; public static final String GP_CLIENT_REGISTRY_USER_NAME = "CLIENTREGISTRY_USERNAME"; @@ -13,8 +19,6 @@ public class ClientRegistryConstants { public static final String GP_CLIENT_REGISTRY_IDENTIFIER_ROOT = "CLIENTREGISTRY_IDENTIFIERROOT"; public static final String GP_CLIENT_REGISTRY_TRANSACTION_METHOD = "clientregistry.transactionMethod"; - - public static final String UPDATE_MESSAGE_DESTINATION = "topic://UPDATED:org.openmrs.Patient"; - public static final String CLIENT_REGISTRY_INTERNAL_ID_SYSTEM = "http://clientregistry.org/openmrs"; + public static final String UPDATE_MESSAGE_DESTINATION = "topic://UPDATED:org.openmrs.Patient"; } diff --git a/api/src/main/java/org/openmrs/module/clientregistry/api/event/PatientCreateUpdateListener.java b/api/src/main/java/org/openmrs/module/clientregistry/api/event/PatientCreateUpdateListener.java index 02615b6..e8b6fa1 100644 --- a/api/src/main/java/org/openmrs/module/clientregistry/api/event/PatientCreateUpdateListener.java +++ b/api/src/main/java/org/openmrs/module/clientregistry/api/event/PatientCreateUpdateListener.java @@ -1,5 +1,7 @@ package org.openmrs.module.clientregistry.api.event; +import java.util.Optional; + import javax.jms.JMSException; import javax.jms.MapMessage; import javax.jms.Message; @@ -107,10 +109,10 @@ private void processMessage(Message message) throws JMSException { patient.setId(openmrsUniqueId.getValue()); - //Configure via GP - String uuidAndExtensionString = "f1c8c615-1c73-4976-8218-a74ca67e22bb|patient_status,11e3f71d-c4b2-4b4b-a26b-59e43f2d5347|patient_status_date"; - String[] uuidAndExtensionPairs = uuidAndExtensionString.split(","); - + String uuidAndExtensionString = Context.getAdministrationService().getGlobalProperty(ClientRegistryConstants.GP_EXTENSION_UUID_EXTENSION_URLS); + String[] uuidAndExtensionPairs = Optional.ofNullable(uuidAndExtensionString) + .map(s -> s.split(",")) + .orElse(new String[0]); for (String pair : uuidAndExtensionPairs) { String[] uuidAndExtension = pair.trim().split("\\|"); if (uuidAndExtension.length == 2) { @@ -145,5 +147,4 @@ private void processMessage(Message message) throws JMSException { } } } - } diff --git a/api/src/main/java/org/openmrs/module/clientregistry/api/impl/FhirCRPatientServiceImpl.java b/api/src/main/java/org/openmrs/module/clientregistry/api/impl/FhirCRPatientServiceImpl.java index 3c39161..34beb01 100644 --- a/api/src/main/java/org/openmrs/module/clientregistry/api/impl/FhirCRPatientServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/clientregistry/api/impl/FhirCRPatientServiceImpl.java @@ -19,7 +19,6 @@ import org.springframework.stereotype.Component; import org.springframework.beans.factory.annotation.Qualifier; - import java.util.Collections; import java.util.List; import java.util.Objects; @@ -32,8 +31,6 @@ public class FhirCRPatientServiceImpl implements CRPatientService { @Qualifier("clientRegistryFhirClient") private IGenericClient fhirClient; - @Autowired - private ClientRegistryConfig config; /** * Get patient identifiers from an external client registry's $ihe-pix implementation. Use the diff --git a/api/src/main/java/org/openmrs/module/clientregistry/providers/r4/FhirCRPatientResourceProvider.java b/api/src/main/java/org/openmrs/module/clientregistry/providers/r4/FhirCRPatientResourceProvider.java index c88cad7..7460570 100644 --- a/api/src/main/java/org/openmrs/module/clientregistry/providers/r4/FhirCRPatientResourceProvider.java +++ b/api/src/main/java/org/openmrs/module/clientregistry/providers/r4/FhirCRPatientResourceProvider.java @@ -14,11 +14,12 @@ import org.hl7.fhir.r4.model.Patient; import ca.uhn.fhir.rest.annotation.Operation; import ca.uhn.fhir.rest.annotation.OperationParam; + +import org.openmrs.api.context.Context; import org.openmrs.module.clientregistry.ClientRegistryConfig; import org.openmrs.module.clientregistry.api.ClientRegistryManager; import org.openmrs.module.clientregistry.providers.FhirCRConstants; import org.openmrs.module.fhir2.api.annotations.R4Provider; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Collections; @@ -33,12 +34,6 @@ @Setter(PACKAGE) public class FhirCRPatientResourceProvider implements IResourceProvider { - @Autowired - private ClientRegistryManager clientRegistryManager; - - @Autowired - private ClientRegistryConfig config; - @Override public Class getResourceType() { return Patient.class; @@ -60,7 +55,11 @@ public List getCRPatientById( @OperationParam(name = FhirCRConstants.SOURCE_IDENTIFIER) TokenParam sourceIdentifierParam, @OperationParam(name = FhirCRConstants.TARGET_SYSTEM) StringOrListParam targetSystemsParam ) { - + ClientRegistryManager clientRegistryManager = Context.getRegisteredComponent("clientRegistryManager", + ClientRegistryManager.class); + + ClientRegistryConfig config = Context.getRegisteredComponent("clientRegistryFhirClient", + ClientRegistryConfig.class); if (sourceIdentifierParam == null || sourceIdentifierParam.getValue() == null) { throw new InvalidRequestException("sourceIdentifier must be specified"); } diff --git a/omod/src/main/resources/config.xml b/omod/src/main/resources/config.xml index 5eafd0d..6cee612 100644 --- a/omod/src/main/resources/config.xml +++ b/omod/src/main/resources/config.xml @@ -87,6 +87,13 @@ + + @MODULE_ID@.uuidAndExtensionURL + + + UUIDs of person attributes that are to be mapped to the fhir extension url like "50fada9c-6d6f-4575-bda6-448a719da919|http://hl7.org/fhir/StructureDefinition/patient-mothersMaidenName,4a4f9e2d-59de-45d2-92f4-015bc388b832|http://hl7.org/fhir/StructureDefinition/patient-sistersName" + +