Skip to content

Commit

Permalink
Updated system for patient identifier fro OpenCR. Made it a Global Co…
Browse files Browse the repository at this point in the history
…nfig Value
  • Loading branch information
moshonk committed Apr 27, 2021
1 parent 0b0b04b commit d81d79d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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;

Expand Down Expand Up @@ -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)));
}
}
5 changes: 5 additions & 0 deletions omod/src/main/resources/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,9 @@
<description>Path of narrative override properties file</description>
</globalProperty>

<globalProperty>
<property>${project.parent.artifactId}.sourceIdentifierSystem</property>
<defaultValue>http://openclientregistry.org/fhir/sourceid</defaultValue>
<description>System for Patient identifier for OpenCR: Source Identifier System</description>
</globalProperty>
</module>

0 comments on commit d81d79d

Please sign in to comment.