Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

temporaly fix to pass al tak input values #36

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
Loading