diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirMedicationRequestDaoImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirMedicationRequestDaoImpl.java index 745876efa..102a450ef 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirMedicationRequestDaoImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirMedicationRequestDaoImpl.java @@ -52,13 +52,13 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams entry.getValue().forEach(d -> handleMedicationReference("d", (ReferenceAndListParam) d.getParam()) .ifPresent(c -> criteria.createAlias("drug", "d").add(c))); break; - case FhirConstants.COMMON_SEARCH_HANDLER: - handleCommonSearchParameters(entry.getValue()).ifPresent(criteria::add); - break; case FhirConstants.IDENTIFIER: entry.getValue().forEach(orderNumber -> handleOrderNumber((TokenAndListParam) orderNumber.getParam()) .ifPresent(criteria::add)); break; + case FhirConstants.COMMON_SEARCH_HANDLER: + handleCommonSearchParameters(entry.getValue()).ifPresent(criteria::add); + break; } }); } diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirServiceRequestDaoImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirServiceRequestDaoImpl.java index def5d1c26..b28135ba3 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirServiceRequestDaoImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/dao/impl/FhirServiceRequestDaoImpl.java @@ -56,13 +56,13 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams entry.getValue().forEach(dateRangeParam -> handleDateRange((DateRangeParam) dateRangeParam.getParam()) .ifPresent(criteria::add)); break; - case FhirConstants.COMMON_SEARCH_HANDLER: - handleCommonSearchParameters(entry.getValue()).ifPresent(criteria::add); - break; case FhirConstants.IDENTIFIER: entry.getValue().forEach(orderNumber -> handleOrderNumber((TokenAndListParam) orderNumber.getParam()) .ifPresent(criteria::add)); break; + case FhirConstants.COMMON_SEARCH_HANDLER: + handleCommonSearchParameters(entry.getValue()).ifPresent(criteria::add); + break; } }); } diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/OrderIdentifierTranslatorImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/OrderIdentifierTranslatorImpl.java index 1b60621a4..f466ea56a 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/OrderIdentifierTranslatorImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/OrderIdentifierTranslatorImpl.java @@ -42,4 +42,5 @@ public Identifier toFhirResource(@Nonnull Order order) { public Order toOpenmrsType(Identifier resource) { throw new InvalidRequestException("Order Identifier cannot be manualy set"); } + } diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/ServiceRequestTranslatorImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/ServiceRequestTranslatorImpl.java index 7923ea658..1c5a301e9 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/ServiceRequestTranslatorImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/ServiceRequestTranslatorImpl.java @@ -74,7 +74,7 @@ public ServiceRequest toFhirResource(@Nonnull TestOrder order) { ServiceRequest serviceRequest = new ServiceRequest(); serviceRequest.setId(order.getUuid()); - + if (order.getOrderNumber() != null) { serviceRequest.addIdentifier(orderIdentifierTranslator.toFhirResource(order)); } diff --git a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/MedicationRequestTranslatorImplTest.java b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/MedicationRequestTranslatorImplTest.java index 2fe3c9d86..95227d0d3 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/MedicationRequestTranslatorImplTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/MedicationRequestTranslatorImplTest.java @@ -63,8 +63,6 @@ public class MedicationRequestTranslatorImplTest { private static final String PRIOR_MEDICATION_REQUEST_REFERENCE = FhirConstants.MEDICATION + "/" + DRUG_ORDER_UUID; - private static final String DRUG_ORDER_NUMBER = "ORD-1"; - private static final String DRUG_UUID = "99fdc8ad-fe4d-499b-93a8-8a991c1d477g"; private static final String CONCEPT_UUID = "33fdc8ad-fe4d-499b-93a8-8a991c1d488g"; @@ -79,6 +77,12 @@ public class MedicationRequestTranslatorImplTest { private static final String DOSING_INSTRUCTIONS = "Dosing instructions"; + private static final String IDENTIFIER_SYSTEM = "http://terminology.hl7.org/CodeSystem/v2-0203"; + + private static final String IDENTIFIER_CODE = "PLAC"; + + private static final String IDENTIFIER_DISPLAY = "Placer Identifier"; + @Mock private PractitionerReferenceTranslator providerPractitionerReferenceTranslator; @@ -156,6 +160,10 @@ public void toFhirResource_shouldTranslateToFhirResource() { assertThat(result.getId(), notNullValue()); assertThat(result.getId(), equalTo(DRUG_ORDER_UUID)); assertThat(result.getIdentifier().get(0).getValue(), equalTo(DRUG_ORDER_NUMBER)); + assertThat(result.getIdentifier().get(0).getType().getCoding().get(0).getSystem(), equalTo(IDENTIFIER_SYSTEM)); + assertThat(result.getIdentifier().get(0).getType().getCoding().get(0).getCode(), equalTo(IDENTIFIER_CODE)); + assertThat(result.getIdentifier().get(0).getType().getCoding().get(0).getDisplay(), equalTo(IDENTIFIER_DISPLAY)); + assertThat(result.getIdentifier().get(0).getUse().getDisplay(), equalTo("Usual")); } @Test diff --git a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/ServiceRequestTranslatorImplTest.java b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/ServiceRequestTranslatorImplTest.java index 42813b0d4..d236488be 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/ServiceRequestTranslatorImplTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/ServiceRequestTranslatorImplTest.java @@ -69,8 +69,6 @@ public class ServiceRequestTranslatorImplTest { private static final String PRIOR_SERVICE_REQUEST_REFERENCE = FhirConstants.SERVICE_REQUEST + "/" + SERVICE_REQUEST_UUID; - private static final String TEST_ORDER_NUMBER = "ORD-1"; - private static final String LOINC_CODE = "1000-1"; private static final String PATIENT_UUID = "14d4f066-15f5-102d-96e4-000c29c2a5d7"; @@ -85,6 +83,12 @@ public class ServiceRequestTranslatorImplTest { private static final int COUNT = 1; + private static final String IDENTIFIER_SYSTEM = "http://terminology.hl7.org/CodeSystem/v2-0203"; + + private static final String IDENTIFIER_CODE = "PLAC"; + + private static final String IDENTIFIER_DISPLAY = "Placer Identifier"; + private ServiceRequestTranslatorImpl translator; @Mock @@ -515,6 +519,10 @@ public void toFhirResource_shouldTranslateOrderNumber() { assertThat(result, notNullValue()); assertThat(result.getValue(), containsString(TEST_ORDER_NUMBER)); + assertThat(result.getType().getCoding().get(0).getSystem(), equalTo(IDENTIFIER_SYSTEM)); + assertThat(result.getType().getCoding().get(0).getCode(), equalTo(IDENTIFIER_CODE)); + assertThat(result.getType().getCoding().get(0).getDisplay(), equalTo(IDENTIFIER_DISPLAY)); + assertThat(result.getUse().getDisplay(), equalTo("Usual")); } private List setUpBasedOnScenario(Task.TaskStatus status) {