use of ca.uhn.fhir.model.api.IDatatype in project synthea by synthetichealth.
the class FhirDstu2 method observation.
/**
* Map the given Observation into a FHIR Observation resource, and add it to the given Bundle.
*
* @param rand
* Source of randomness to use when generating ids etc
* @param personEntry
* The Person Entry
* @param bundle
* The Bundle to add to
* @param encounterEntry
* The current Encounter entry
* @param observation
* The Observation
* @return The added Entry
*/
private static Entry observation(RandomNumberGenerator rand, Entry personEntry, Bundle bundle, Entry encounterEntry, Observation observation) {
ca.uhn.fhir.model.dstu2.resource.Observation observationResource = new ca.uhn.fhir.model.dstu2.resource.Observation();
observationResource.setSubject(new ResourceReferenceDt(personEntry.getFullUrl()));
observationResource.setEncounter(new ResourceReferenceDt(encounterEntry.getFullUrl()));
observationResource.setStatus(ObservationStatusEnum.FINAL);
Code code = observation.codes.get(0);
observationResource.setCode(mapCodeToCodeableConcept(code, LOINC_URI));
Code category = new Code("http://hl7.org/fhir/observation-category", observation.category, observation.category);
observationResource.setCategory(mapCodeToCodeableConcept(category, "http://hl7.org/fhir/observation-category"));
if (observation.value != null) {
IDatatype value = mapValueToFHIRType(observation.value, observation.unit);
observationResource.setValue(value);
} else if (observation.observations != null && !observation.observations.isEmpty()) {
// multi-observation (ex blood pressure)
for (Observation subObs : observation.observations) {
Component comp = new Component();
comp.setCode(mapCodeToCodeableConcept(subObs.codes.get(0), LOINC_URI));
IDatatype value = mapValueToFHIRType(subObs.value, subObs.unit);
comp.setValue(value);
observationResource.addComponent(comp);
}
}
observationResource.setEffective(convertFhirDateTime(observation.start, true));
observationResource.setIssued(new InstantDt(new Date(observation.start)));
Entry entry = newEntry(rand, bundle, observationResource);
observation.fullUrl = entry.getFullUrl();
return entry;
}
Aggregations