Skip to content

Commit

Permalink
Medication Request should return Null when Drug Order has dose units …
Browse files Browse the repository at this point in the history
…but not dose
  • Loading branch information
mherman22 committed Feb 22, 2024
1 parent 952698e commit 21b9d33
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Dosage toFhirResource(@Nonnull DrugOrder drugOrder) {
dosage.setRoute(conceptTranslator.toFhirResource(drugOrder.getRoute()));
dosage.setTiming(timingTranslator.toFhirResource(drugOrder));

if (drugOrder.getDose() != null || drugOrder.getDoseUnits() != null) {
if (drugOrder.getDose() != null) {
Dosage.DosageDoseAndRateComponent doseAndRate = new Dosage.DosageDoseAndRateComponent();
Quantity dose = new SimpleQuantity();
dose.setValue(drugOrder.getDose());
Expand All @@ -66,7 +66,7 @@ public Dosage toFhirResource(@Nonnull DrugOrder drugOrder) {
doseAndRate.setDose(dose);
dosage.addDoseAndRate(doseAndRate);
}

return dosage;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.hl7.fhir.r4.utils.client.FHIRToolingClient.DATE_FORMAT;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.when;

import java.text.ParseException;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

import org.apache.commons.lang3.time.DateUtils;
import org.hl7.fhir.r4.model.BooleanType;
import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Coding;
Expand Down Expand Up @@ -211,6 +216,23 @@ public void toFhirResource_shouldTranslateDrugOrderDoseToDoseQuantity() {
assertThat(result.getDoseAndRate().get(0).getDoseQuantity().getCode(), is(CONCEPT_UUID));
}

@Test
public void toFhirResource_shouldReturnDosageWhenSubmittingDrugOrderWithDoseUnitButNoDose() throws ParseException {
Concept mg = new Concept();
mg.addName(new ConceptName("mg", Locale.ENGLISH));
mg.setUuid(CONCEPT_UUID);

drugOrder.setDose(null);
drugOrder.setDoseUnits(mg);
drugOrder.setAsNeeded(Boolean.TRUE);
drugOrder.setDosingInstructions(DOSING_INSTRUCTION);
Dosage result = dosageTranslator.toFhirResource(drugOrder);

assertThat(result, notNullValue());
assertThat(result.getAsNeededBooleanType().booleanValue(), is(true));
assertThat(result.getText(), equalTo(DOSING_INSTRUCTION));
}

@Test
public void toFhirResource_shouldTranslateDrugOrderDoseToDoseQuantityPreferringRxNormIfPresent() {
ConceptMapType sameAs = new ConceptMapType();
Expand Down

0 comments on commit 21b9d33

Please sign in to comment.