From 5437eeabacab447b302a135a51b2795288018c50 Mon Sep 17 00:00:00 2001 From: Mutesasira Moses Date: Wed, 16 Aug 2023 14:38:12 +0300 Subject: [PATCH] temporaly fix to pass al tak input values --- .../module/labonfhir/api/LabOrderHandler.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderHandler.java b/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderHandler.java index 0d43ab6..0f43b35 100644 --- a/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderHandler.java +++ b/api/src/main/java/org/openmrs/module/labonfhir/api/LabOrderHandler.java @@ -8,8 +8,13 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; +import org.hl7.fhir.r4.model.BooleanType; +import org.hl7.fhir.r4.model.CodeableConcept; +import org.hl7.fhir.r4.model.DecimalType; import org.hl7.fhir.r4.model.Observation; +import org.hl7.fhir.r4.model.Quantity; import org.hl7.fhir.r4.model.Reference; +import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.Task; import org.openmrs.Encounter; import org.openmrs.EncounterProvider; @@ -59,7 +64,21 @@ public Task createOrder(Order order) throws OrderCreationException { Observation observation = observationService.get(obs.getUuid()); Task.ParameterComponent input = new Task.ParameterComponent(); input.setType(observation.getCode()); - input.setValue(observation.getValue()); + //this is a temporaly fix because currentl the TASK api supports ony few value types + //TO DO The OpenMRS task api should support more value types ie ValueQuantity ,valueCodeableConcept , valueboolean + if (observation.getValue() instanceof CodeableConcept) { + CodeableConcept concept = (CodeableConcept) observation.getValue(); + input.setValue(new StringType().setValue(concept.getCodingFirstRep().getDisplay())); + } else if (observation.getValue() instanceof Quantity) { + Double quantity = ((Quantity) observation.getValue()).getValue().doubleValue(); + DecimalType decimal = new DecimalType(); + decimal.setValue(quantity); + input.setValue(decimal); + } else if (observation.getValue() instanceof BooleanType) { + input.setValue(new StringType().setValue(((BooleanType) observation.getValue()).getValueAsString())); + } else { + input.setValue(observation.getValue()); + } taskInputs.add(input); } }