diff --git a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/DosageTranslatorImpl.java b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/DosageTranslatorImpl.java index d4d18e788..c3897c2a2 100644 --- a/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/DosageTranslatorImpl.java +++ b/api/src/main/java/org/openmrs/module/fhir2/api/translators/impl/DosageTranslatorImpl.java @@ -51,6 +51,10 @@ public Dosage toFhirResource(@Nonnull DrugOrder drugOrder) { dosage.setRoute(conceptTranslator.toFhirResource(drugOrder.getRoute())); dosage.setTiming(timingTranslator.toFhirResource(drugOrder)); + if (drugOrder.getInstructions() != null) { + dosage.addAdditionalInstruction().setText(drugOrder.getInstructions()); + } + if (drugOrder.getDose() != null) { Dosage.DosageDoseAndRateComponent doseAndRate = new Dosage.DosageDoseAndRateComponent(); Quantity dose = new SimpleQuantity(); @@ -73,6 +77,11 @@ public Dosage toFhirResource(@Nonnull DrugOrder drugOrder) { @Override public DrugOrder toOpenmrsType(@Nonnull DrugOrder drugOrder, @Nonnull Dosage dosage) { drugOrder.setDosingInstructions(dosage.getText()); + + if (dosage.hasAdditionalInstruction()) { + drugOrder.setInstructions(dosage.getAdditionalInstructionFirstRep().getText()); + } + if (dosage.getAsNeededBooleanType() != null) { drugOrder.setAsNeeded(dosage.getAsNeededBooleanType().getValue()); } diff --git a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/DosageTranslatorImplTest.java b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/DosageTranslatorImplTest.java index 30bb8d7f5..ef49b265b 100644 --- a/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/DosageTranslatorImplTest.java +++ b/api/src/test/java/org/openmrs/module/fhir2/api/translators/impl/DosageTranslatorImplTest.java @@ -109,6 +109,14 @@ public void toFhirResource_shouldTranslateDosingInstructionToDosageText() { assertThat(result.getText(), equalTo(DOSING_INSTRUCTION)); } + @Test + public void toFhirResource_shouldTranslateOrdersInstructionToDosageAdditionalInstructions() { + drugOrder.setInstructions(DOSING_INSTRUCTION); + Dosage result = dosageTranslator.toFhirResource(drugOrder); + assertThat(result, notNullValue()); + assertThat(result.getAdditionalInstruction().get(0).getText(), equalTo(DOSING_INSTRUCTION)); + } + @Test public void toFhirResource_shouldTranslateDrugOrderRouteToRoute() { Concept concept = new Concept(); @@ -317,4 +325,16 @@ public void toOpenmrsType_shouldTranslateDoseQuantityUnitsToDrugOrderDoseUnits() assertThat(result, notNullValue()); assertThat(result.getDoseUnits(), equalTo(mg)); } + + @Test + public void toOpenmrsType_shouldTranslateAdditionalInstructionsToOrderInstructions() { + Dosage dosage = new Dosage(); + CodeableConcept additionalInstructions = new CodeableConcept(); + additionalInstructions.setText(DOSING_INSTRUCTION); + dosage.addAdditionalInstruction(additionalInstructions); + + DrugOrder result = dosageTranslator.toOpenmrsType(new DrugOrder(), dosage); + assertThat(result, notNullValue()); + assertThat(result.getInstructions(), equalTo(DOSING_INSTRUCTION)); + } }