Skip to content

Commit

Permalink
FM2-638: Mapping OpenMRS Drug Order instructions to FHIR Dosage instr… (
Browse files Browse the repository at this point in the history
  • Loading branch information
mogoodrich authored Aug 14, 2024
1 parent 98c713f commit 47cc436
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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));
}
}

0 comments on commit 47cc436

Please sign in to comment.