From 842c3bd4db5213374b11da77c38650d7e10197a5 Mon Sep 17 00:00:00 2001 From: Piotr Mankowski Date: Mon, 5 Apr 2021 20:04:34 -0700 Subject: [PATCH] tmp --- api-2.1/pom.xml | 2 +- api-2.2/pom.xml | 2 +- api/pom.xml | 2 +- .../impl/PatientIdentifierTranslatorImpl.java | 12 +++++++++++- .../api/translators/impl/PatientTranslatorImpl.java | 4 ++++ .../impl/PatientIdentifierTranslatorImplTest.java | 5 +++++ integration-tests-2.1/pom.xml | 2 +- integration-tests-2.2/pom.xml | 2 +- integration-tests/pom.xml | 2 +- omod/pom.xml | 2 +- pom.xml | 2 +- test-data/pom.xml | 2 +- 12 files changed, 29 insertions(+), 10 deletions(-) diff --git a/api-2.1/pom.xml b/api-2.1/pom.xml index c6537162e..821e9a529 100644 --- a/api-2.1/pom.xml +++ b/api-2.1/pom.xml @@ -3,7 +3,7 @@ fhir2 org.openmrs.module - 1.2.0-SNAPSHOT + 1.2.1-SNAPSHOT 4.0.0 diff --git a/api-2.2/pom.xml b/api-2.2/pom.xml index b15640e1c..d35e68bb7 100644 --- a/api-2.2/pom.xml +++ b/api-2.2/pom.xml @@ -3,7 +3,7 @@ fhir2 org.openmrs.module - 1.2.0-SNAPSHOT + 1.2.1-SNAPSHOT 4.0.0 diff --git a/api/pom.xml b/api/pom.xml index 9c91e63d7..4d8046d7c 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -3,7 +3,7 @@ org.openmrs.module fhir2 - 1.2.0-SNAPSHOT + 1.2.1-SNAPSHOT fhir2-api diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/PatientIdentifierTranslatorImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/PatientIdentifierTranslatorImpl.java index 2cd8edc68..70ed9c221 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/PatientIdentifierTranslatorImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/PatientIdentifierTranslatorImpl.java @@ -20,6 +20,7 @@ import org.openmrs.PatientIdentifier; import org.openmrs.PatientIdentifierType; import org.openmrs.module.fhir2.FhirConstants; +import org.openmrs.module.fhir2.api.FhirGlobalPropertyService; import org.openmrs.module.fhir2.api.FhirPatientService; import org.openmrs.module.fhir2.api.dao.FhirLocationDao; import org.openmrs.module.fhir2.api.translators.PatientIdentifierTranslator; @@ -28,7 +29,6 @@ @Component @Setter(AccessLevel.PACKAGE) -// TODO Create proper "System" value public class PatientIdentifierTranslatorImpl extends BaseReferenceHandlingTranslator implements PatientIdentifierTranslator { @Autowired @@ -37,6 +37,9 @@ public class PatientIdentifierTranslatorImpl extends BaseReferenceHandlingTransl @Autowired private FhirLocationDao locationDao; + @Autowired + private FhirGlobalPropertyService globalPropertyService; + @Override public Identifier toFhirResource(@Nonnull PatientIdentifier identifier) { if (identifier == null || identifier.getVoided()) { @@ -64,6 +67,13 @@ public Identifier toFhirResource(@Nonnull PatientIdentifier identifier) { .setValue(createLocationReference(identifier.getLocation())); } + if (globalPropertyService.getGlobalProperty(FhirConstants.GLOBAL_PROPERTY_URI_PREFIX) != null + && !globalPropertyService.getGlobalProperty(FhirConstants.GLOBAL_PROPERTY_URI_PREFIX).isEmpty() + && identifier.getIdentifierType() != null) { + + patientIdentifier.setSystem(globalPropertyService.getGlobalProperty(FhirConstants.GLOBAL_PROPERTY_URI_PREFIX) + + '/' + identifier.getIdentifierType().getId() + '-' + identifier.getIdentifierType().getName()); + } return patientIdentifier; } 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 4bc22c670..8870b3fde 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 @@ -120,6 +120,10 @@ public Patient toFhirResource(@Nonnull org.openmrs.Patient openmrsPatient) { patient.addIdentifier(identifierTranslator.toFhirResource(identifier)); } + patient.addIdentifier().setSystem("urn:ietf:rfc:3986").setValue( + globalPropertyService.getGlobalProperty(FhirConstants.GLOBAL_PROPERTY_URI_PREFIX, "http://openmrs.org") + '/' + + openmrsPatient.getUuid()); + for (PersonName name : openmrsPatient.getNames()) { patient.addName(nameTranslator.toFhirResource(name)); } diff --git a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PatientIdentifierTranslatorImplTest.java b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PatientIdentifierTranslatorImplTest.java index a2c72ba7c..58076aa3b 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PatientIdentifierTranslatorImplTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/PatientIdentifierTranslatorImplTest.java @@ -25,6 +25,7 @@ import org.mockito.junit.MockitoJUnitRunner; import org.openmrs.PatientIdentifier; import org.openmrs.PatientIdentifierType; +import org.openmrs.module.fhir2.api.FhirGlobalPropertyService; import org.openmrs.module.fhir2.api.FhirPatientService; @RunWith(MockitoJUnitRunner.class) @@ -43,10 +44,14 @@ public class PatientIdentifierTranslatorImplTest { @Mock private FhirPatientService patientService; + @Mock + private FhirGlobalPropertyService globalPropertyService; + @Before public void setup() { identifierTranslator = new PatientIdentifierTranslatorImpl(); identifierTranslator.setPatientService(patientService); + identifierTranslator.setGlobalPropertyService(globalPropertyService); } @Test diff --git a/integration-tests-2.1/pom.xml b/integration-tests-2.1/pom.xml index 156dd2861..71bf4d6c4 100644 --- a/integration-tests-2.1/pom.xml +++ b/integration-tests-2.1/pom.xml @@ -5,7 +5,7 @@ fhir2 org.openmrs.module - 1.2.0-SNAPSHOT + 1.2.1-SNAPSHOT 4.0.0 diff --git a/integration-tests-2.2/pom.xml b/integration-tests-2.2/pom.xml index 34cdee9d9..769661d7c 100644 --- a/integration-tests-2.2/pom.xml +++ b/integration-tests-2.2/pom.xml @@ -3,7 +3,7 @@ fhir2 org.openmrs.module - 1.2.0-SNAPSHOT + 1.2.1-SNAPSHOT 4.0.0 diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index ac4623a8b..8fcb53fc1 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -3,7 +3,7 @@ fhir2 org.openmrs.module - 1.2.0-SNAPSHOT + 1.2.1-SNAPSHOT 4.0.0 diff --git a/omod/pom.xml b/omod/pom.xml index 8f500077b..871578a60 100644 --- a/omod/pom.xml +++ b/omod/pom.xml @@ -3,7 +3,7 @@ org.openmrs.module fhir2 - 1.2.0-SNAPSHOT + 1.2.1-SNAPSHOT fhir2-omod diff --git a/pom.xml b/pom.xml index bbf0a5688..883d39a46 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.openmrs.module fhir2 - 1.2.0-SNAPSHOT + 1.2.1-SNAPSHOT pom FHIR2 Implementation of FHIR R4 for OpenMRS diff --git a/test-data/pom.xml b/test-data/pom.xml index 197f3276d..0852deeb0 100644 --- a/test-data/pom.xml +++ b/test-data/pom.xml @@ -3,7 +3,7 @@ fhir2 org.openmrs.module - 1.2.0-SNAPSHOT + 1.2.1-SNAPSHOT 4.0.0