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

RWA-978 - Push basic registration data to MPI #16

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
28 changes: 27 additions & 1 deletion api/src/main/java/org/openmrs/module/imbemr/ImbEmrConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openmrs.LocationAttributeType;
import org.openmrs.PatientIdentifierType;
import org.openmrs.PersonAttributeType;
import org.openmrs.api.LocationService;
import org.openmrs.api.PatientService;
import org.openmrs.api.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -30,10 +32,14 @@ public class ImbEmrConfig {

private final PatientService patientService;

private final LocationService locationService;

public ImbEmrConfig(@Autowired PatientService patientService,
@Autowired PersonService personService) {
@Autowired PersonService personService,
@Autowired LocationService locationService) {
this.patientService = patientService;
this.personService = personService;
this.locationService = locationService;
}

public PatientIdentifierType getPrimaryCareIdentifierType() {
Expand All @@ -44,6 +50,22 @@ public PatientIdentifierType getNationalId() {
return getPatientIdentifierTypeByUuid(ImbEmrConstants.NATIONAL_ID_UUID);
}

public PatientIdentifierType getNin() {
return getPatientIdentifierTypeByUuid(ImbEmrConstants.NIN_UUID);
}

public PatientIdentifierType getNidApplicationNumber() {
return getPatientIdentifierTypeByUuid(ImbEmrConstants.NID_APPLICATION_NUMBER_UUID);
}

public PatientIdentifierType getUpid() {
return getPatientIdentifierTypeByUuid(ImbEmrConstants.UPID_UUID);
}

public PatientIdentifierType getPassportNumber() {
return getPatientIdentifierTypeByUuid(ImbEmrConstants.PASSPORT_NUMBER_UUID);
}

public PersonAttributeType getTelephoneNumber() {
return getPersonAttributeTypeByUuid(ImbEmrConstants.TELEPHONE_NUMBER_UUID);
}
Expand Down Expand Up @@ -75,4 +97,8 @@ public PatientIdentifierType getPatientIdentifierTypeByUuid(String uuid) {
public PersonAttributeType getPersonAttributeTypeByUuid(String uuid) {
return personService.getPersonAttributeTypeByUuid(uuid);
}

public LocationAttributeType getFosaId() {
return locationService.getLocationAttributeTypeByUuid(ImbEmrConstants.FOSA_ID_UUID);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public class ImbEmrConstants {
public static final String PROFESSION_UUID = "ceb19b28-4327-472f-aac4-4c6c6106c7f9";
public static final String EDUCATION_LEVEL_UUID = "9add985a-cba2-421a-8dd5-6323eb5bda4f";

public static final String CLIENT_REGISTRY_URL_PROPERTY = "imbemr.clientregistry.url";
public static final String CLIENT_REGISTRY_USERNAME_PROPERTY = "imbemr.clientregistry.username";
public static final String CLIENT_REGISTRY_PASSWORD_PROPERTY = "imbemr.clientregistry.password";
public static final String FOSA_ID_UUID = "eb844bfb-b1d9-11ef-8756-0242ac120002";

public static final String MPI_URL_PROPERTY = "imbemr.mpi.url";
public static final String MPI_USERNAME_PROPERTY = "imbemr.mpi.username";
public static final String MPI_PASSWORD_PROPERTY = "imbemr.mpi.password";
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,29 @@
import org.openmrs.PersonAttributeType;
import org.openmrs.PersonName;
import org.openmrs.module.imbemr.ImbEmrConfig;
import org.openmrs.module.imbemr.ImbEmrConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.openmrs.module.imbemr.integration.IntegrationConstants.NIDA_IDENTIFIER_SYSTEMS;

/**
* Implementation of MpiProvider that connects to the Rwanda NIDA
* Translation layer between the FHIR Patient returned from the client registry and an OpenMRS patient
*/
@Component
public class NidaPatientTranslator {
public class ClientRegistryPatientTranslator {

protected Log log = LogFactory.getLog(getClass());

private final ImbEmrConfig imbEmrConfig;

public NidaPatientTranslator(
@Autowired ImbEmrConfig imbEmrConfig
) {
public ClientRegistryPatientTranslator(@Autowired ImbEmrConfig imbEmrConfig) {
this.imbEmrConfig = imbEmrConfig;
}

public static final Map<String, String> IDENTIFIER_SYSTEMS = new HashMap<>();
static {
IDENTIFIER_SYSTEMS.put("NID", ImbEmrConstants.NATIONAL_ID_UUID);
IDENTIFIER_SYSTEMS.put("NID_APPLICATION_NUMBER", ImbEmrConstants.NID_APPLICATION_NUMBER_UUID);
IDENTIFIER_SYSTEMS.put("NIN", ImbEmrConstants.NIN_UUID);
IDENTIFIER_SYSTEMS.put("UPI", ImbEmrConstants.UPID_UUID);
IDENTIFIER_SYSTEMS.put("PASSPORT", ImbEmrConstants.PASSPORT_NUMBER_UUID);
}

public static final String EDUCATION_EXTENSION_URL = "https://fhir.hie.moh.gov.rw/fhir/StructureDefinition/extensions/patient-educational-level";
public static final String RELIGION_EXTENSION_URL = "https://hl7.org/fhir/StructureDefinition/patient-religion";
public static final String PROFESSION_EXTENSION_URL = "https://fhir.hie.moh.gov.rw/fhir/StructureDefinition/extensions/patient-profession";
Expand All @@ -77,7 +65,7 @@ public Patient toOpenmrsType(@Nonnull org.hl7.fhir.r4.model.Patient fhirPatient)
if (StringUtils.isNotBlank(value)) {
String system = identifier.getSystem();
PatientIdentifierType identifierType = null;
String patientIdentifierTypeUuid = IDENTIFIER_SYSTEMS.get(system);
String patientIdentifierTypeUuid = NIDA_IDENTIFIER_SYSTEMS.get(system);
if (StringUtils.isNotBlank(patientIdentifierTypeUuid)) {
identifierType = imbEmrConfig.getPatientIdentifierTypeByUuid(patientIdentifierTypeUuid);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.openmrs.module.imbemr.integration;

import org.openmrs.module.imbemr.ImbEmrConstants;

import java.util.HashMap;
import java.util.Map;

public class IntegrationConstants {

public static final String NID = "NID";
public static final String NID_APPLICATION_NUMBER = "NID_APPLICATION_NUMBER";
public static final String NIN = "NIN";
public static final String UPI = "UPI";
public static final String PASSPORT = "PASSPORT";

public static final Map<String, String> NIDA_IDENTIFIER_SYSTEMS = new HashMap<>();
static {
NIDA_IDENTIFIER_SYSTEMS.put(NID, ImbEmrConstants.NATIONAL_ID_UUID);
NIDA_IDENTIFIER_SYSTEMS.put(NID_APPLICATION_NUMBER, ImbEmrConstants.NID_APPLICATION_NUMBER_UUID);
NIDA_IDENTIFIER_SYSTEMS.put(NIN, ImbEmrConstants.NIN_UUID);
NIDA_IDENTIFIER_SYSTEMS.put(UPI, ImbEmrConstants.UPID_UUID);
NIDA_IDENTIFIER_SYSTEMS.put(PASSPORT, ImbEmrConstants.PASSPORT_NUMBER_UUID);
}

}
Loading