diff --git a/api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java b/api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java index 3500a72d4..538ec6505 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java +++ b/api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java @@ -65,7 +65,9 @@ public class FhirConstants { public static final String OBSERVATION_CATEGORY_VALUE_SET_URI = HL7_FHIR_CODE_SYSTEM_PREFIX + "/observation-category"; public static final String ENCOUNTER_CLASS_VALUE_SET_URI = HL7_FHIR_CODE_SYSTEM_PREFIX + "/v3-ActCode"; - + + public static final String GLOBAL_PROPERTY_IDENTIFIER_SYSTEM = "fhir2.sourceIdentifierSystem"; + @Value("${project.version}") public static String OPENMRS_FHIR_SERVER_VERSION; diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/PatientTranslatorImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/PatientTranslatorImpl.java index ea5f74e8c..83e05f56d 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/PatientTranslatorImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/PatientTranslatorImpl.java @@ -119,8 +119,9 @@ public Patient toFhirResource(@Nonnull org.openmrs.Patient openmrsPatient) { for (PatientIdentifier identifier : openmrsPatient.getActiveIdentifiers()) { patient.addIdentifier(identifierTranslator.toFhirResource(identifier)); } - - patient.addIdentifier().setSystem("urn:ietf:rfc:3986").setValue( + + String identifierSystem = globalPropertyService.getGlobalProperty(FhirConstants.GLOBAL_PROPERTY_IDENTIFIER_SYSTEM, "http://openclientregistry.org/fhir/sourceid"); + patient.addIdentifier().setSystem(identifierSystem).setValue( globalPropertyService.getGlobalProperty(FhirConstants.GLOBAL_PROPERTY_URI_PREFIX, "http://openmrs.org") + '/' + openmrsPatient.getUuid()); diff --git a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PatientTranslatorImplTest.java b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PatientTranslatorImplTest.java index 44a158ee3..35860a741 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PatientTranslatorImplTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PatientTranslatorImplTest.java @@ -53,6 +53,7 @@ import org.openmrs.PersonAttribute; import org.openmrs.PersonAttributeType; import org.openmrs.PersonName; +import org.openmrs.module.fhir2.FhirConstants; import org.openmrs.module.fhir2.api.FhirGlobalPropertyService; import org.openmrs.module.fhir2.api.dao.FhirPersonDao; import org.openmrs.module.fhir2.api.translators.GenderTranslator; @@ -65,7 +66,7 @@ @RunWith(MockitoJUnitRunner.class) public class PatientTranslatorImplTest { - + private static final String PATIENT_UUID = "123456-abcdef-123456"; private static final String PATIENT_IDENTIFIER_UUID = "654321-fedcba-654321"; @@ -87,7 +88,9 @@ public class PatientTranslatorImplTest { private static final String PERSON_ATTRIBUTE_VALUE = "254723723456"; private static final Date PATIENT_DEATH_DATE = Date.from(Instant.ofEpochSecond(872986980L)); - + + public static final String DEFAULT_IDENTIFIER_SYSTEM = "http://openclientregistry.org/fhir/sourceid"; + @Mock private PatientIdentifierTranslator identifierTranslator; @@ -483,4 +486,14 @@ public void shouldTranslateToFHIRBirthDate() { assertThat(result.getBirthDateElement().getYear(), equalTo(dateType.getYear())); assertThat(result.getBirthDateElement().getMonth(), equalTo(dateType.getMonth())); } + + @Test + public void shouldTranslatePatientWithSystemIdentifier() { + org.openmrs.Patient patient = new org.openmrs.Patient(); + + Patient result = patientTranslator.toFhirResource(patient); + assertThat(result.getIdentifier(), not(empty())); + assertThat(result.getIdentifier().get(0).getSystem(), equalTo( + globalPropertyService.getGlobalProperty(FhirConstants.GLOBAL_PROPERTY_IDENTIFIER_SYSTEM, DEFAULT_IDENTIFIER_SYSTEM))); + } } diff --git a/omod/src/main/resources/config.xml b/omod/src/main/resources/config.xml index 077dacbc1..3754ef4eb 100644 --- a/omod/src/main/resources/config.xml +++ b/omod/src/main/resources/config.xml @@ -155,4 +155,9 @@ Path of narrative override properties file + + ${project.parent.artifactId}.sourceIdentifierSystem + http://openclientregistry.org/fhir/sourceid + System for Patient identifier for OpenCR: Source Identifier System +