Skip to content

Commit

Permalink
Fix dependency injection
Browse files Browse the repository at this point in the history
  • Loading branch information
reagan-meant committed May 6, 2024
1 parent 3d59678 commit fb9137e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -65,11 +65,11 @@ public String getClientRegistryDefaultPatientIdentifierSystem() {
public String getClientRegistryUserName() {
return username;
}

public String getClientRegistryPassword() {
return password;
}

public String getClientRegistryIdentifierRoot() {
return identifierRoot;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -145,5 +147,4 @@ private void processMessage(Message message) throws JMSException {
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,12 +34,6 @@
@Setter(PACKAGE)
public class FhirCRPatientResourceProvider implements IResourceProvider {

@Autowired
private ClientRegistryManager clientRegistryManager;

@Autowired
private ClientRegistryConfig config;

@Override
public Class<? extends IBaseResource> getResourceType() {
return Patient.class;
Expand All @@ -60,7 +55,11 @@ public List<Patient> 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");
}
Expand Down
7 changes: 7 additions & 0 deletions omod/src/main/resources/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
</description>
</globalProperty>

<globalProperty>
<property>@[email protected]</property>
<defaultValue></defaultValue>
<description>
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"
</description>
</globalProperty>

<!-- Internationalization -->
<!-- All message codes should start with @MODULE_ID@.* -->
Expand Down

0 comments on commit fb9137e

Please sign in to comment.