use of org.hl7.cql_annotations.r1.Annotation in project openmrs-module-fhir2 by openmrs.
the class MedicationRequestTranslatorImpl method toFhirResource.
@Override
public MedicationRequest toFhirResource(@Nonnull DrugOrder drugOrder) {
notNull(drugOrder, "The DrugOrder object should not be null");
MedicationRequest medicationRequest = new MedicationRequest();
medicationRequest.setId(drugOrder.getUuid());
medicationRequest.setStatus(statusTranslator.toFhirResource(drugOrder));
medicationRequest.setMedication(medicationReferenceTranslator.toFhirResource(drugOrder.getDrug()));
medicationRequest.setPriority(medicationRequestPriorityTranslator.toFhirResource(drugOrder.getUrgency()));
medicationRequest.setRequester(practitionerReferenceTranslator.toFhirResource(drugOrder.getOrderer()));
medicationRequest.setEncounter(encounterReferenceTranslator.toFhirResource(drugOrder.getEncounter()));
medicationRequest.setSubject(patientReferenceTranslator.toFhirResource(drugOrder.getPatient()));
medicationRequest.setIntent(MedicationRequest.MedicationRequestIntent.ORDER);
medicationRequest.addNote(new Annotation().setText(drugOrder.getCommentToFulfiller()));
medicationRequest.addReasonCode(conceptTranslator.toFhirResource(drugOrder.getOrderReason()));
medicationRequest.addDosageInstruction(dosageTranslator.toFhirResource(drugOrder));
if (drugOrder.getPreviousOrder() != null && (drugOrder.getAction() == Order.Action.DISCONTINUE || drugOrder.getAction() == Order.Action.REVISE)) {
medicationRequest.setPriorPrescription(createOrderReference(drugOrder.getPreviousOrder()).setIdentifier(orderIdentifierTranslator.toFhirResource(drugOrder.getPreviousOrder())));
} else if (drugOrder.getPreviousOrder() != null && drugOrder.getAction() == Order.Action.RENEW) {
medicationRequest.setBasedOn(Collections.singletonList(createOrderReference(drugOrder.getPreviousOrder()).setIdentifier(orderIdentifierTranslator.toFhirResource(drugOrder.getPreviousOrder()))));
}
return medicationRequest;
}
use of org.hl7.cql_annotations.r1.Annotation in project org.hl7.fhir.core by hapifhir.
the class DeviceUseStatement10_50 method convertDeviceUseStatement.
public static org.hl7.fhir.dstu2.model.DeviceUseStatement convertDeviceUseStatement(org.hl7.fhir.r5.model.DeviceUsage src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.dstu2.model.DeviceUseStatement tgt = new org.hl7.fhir.dstu2.model.DeviceUseStatement();
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyDomainResource(src, tgt);
if (src.getBodySite().hasConcept())
tgt.setBodySite(ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().convertType(src.getBodySite().getConcept()));
if (src.getDevice().hasReference())
tgt.setDevice(Reference10_50.convertReference(src.getDevice().getReference()));
for (org.hl7.fhir.r5.model.Identifier t : src.getIdentifier()) tgt.addIdentifier(Identifier10_50.convertIdentifier(t));
for (CodeableReference t : src.getReason()) if (t.hasConcept())
tgt.addIndication(CodeableConcept10_50.convertCodeableConcept(t.getConcept()));
for (Annotation t : src.getNote()) tgt.addNotes(t.getText());
if (src.hasDateAssertedElement())
tgt.setRecordedOnElement(DateTime10_50.convertDateTime(src.getDateAssertedElement()));
if (src.hasPatient())
tgt.setSubject(Reference10_50.convertReference(src.getPatient()));
if (src.hasTiming())
tgt.setTiming(ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().convertType(src.getTiming()));
return tgt;
}
use of org.hl7.cql_annotations.r1.Annotation in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method renderAnnotation.
private void renderAnnotation(Annotation a, XhtmlNode x, boolean showCodeDetails) throws FHIRException {
StringBuilder s = new StringBuilder();
if (a.hasAuthor()) {
s.append("Author: ");
if (a.hasAuthorReference())
s.append(a.getAuthorReference().getReference());
else if (a.hasAuthorStringType())
s.append(a.getAuthorStringType().getValue());
}
if (a.hasTimeElement()) {
if (s.length() > 0)
s.append("; ");
s.append("Made: ").append(a.getTimeElement().toHumanDisplay());
}
if (a.hasText()) {
if (s.length() > 0)
s.append("; ");
s.append("Annotation: ").append(a.getText());
}
x.addText(s.toString());
}
use of org.hl7.cql_annotations.r1.Annotation in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method renderLeaf.
private void renderLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, boolean title, boolean showCodeDetails, Map<String, String> displayHints) throws FHIRException, UnsupportedEncodingException, IOException {
if (ew == null)
return;
Base e = ew.getBase();
if (e instanceof StringType)
x.addText(((StringType) e).getValue());
else if (e instanceof CodeType)
x.addText(((CodeType) e).getValue());
else if (e instanceof IdType)
x.addText(((IdType) e).getValue());
else if (e instanceof Extension)
x.addText("Extensions: Todo");
else if (e instanceof InstantType)
x.addText(((InstantType) e).toHumanDisplay());
else if (e instanceof DateTimeType)
x.addText(((DateTimeType) e).toHumanDisplay());
else if (e instanceof Base64BinaryType)
x.addText(new Base64().encodeAsString(((Base64BinaryType) e).getValue()));
else if (e instanceof org.hl7.fhir.dstu2.model.DateType)
x.addText(((org.hl7.fhir.dstu2.model.DateType) e).toHumanDisplay());
else if (e instanceof Enumeration) {
Object ev = ((Enumeration<?>) e).getValue();
// todo: look up a display name if there is one
x.addText(ev == null ? "" : ev.toString());
} else if (e instanceof BooleanType)
x.addText(((BooleanType) e).getValue().toString());
else if (e instanceof CodeableConcept) {
renderCodeableConcept((CodeableConcept) e, x, showCodeDetails);
} else if (e instanceof Coding) {
renderCoding((Coding) e, x, showCodeDetails);
} else if (e instanceof Annotation) {
renderAnnotation((Annotation) e, x);
} else if (e instanceof Identifier) {
renderIdentifier((Identifier) e, x);
} else if (e instanceof org.hl7.fhir.dstu2.model.IntegerType) {
x.addText(Integer.toString(((org.hl7.fhir.dstu2.model.IntegerType) e).getValue()));
} else if (e instanceof org.hl7.fhir.dstu2.model.DecimalType) {
x.addText(((org.hl7.fhir.dstu2.model.DecimalType) e).getValue().toString());
} else if (e instanceof HumanName) {
renderHumanName((HumanName) e, x);
} else if (e instanceof SampledData) {
renderSampledData((SampledData) e, x);
} else if (e instanceof Address) {
renderAddress((Address) e, x);
} else if (e instanceof ContactPoint) {
renderContactPoint((ContactPoint) e, x);
} else if (e instanceof UriType) {
renderUri((UriType) e, x);
} else if (e instanceof Timing) {
renderTiming((Timing) e, x);
} else if (e instanceof Range) {
renderRange((Range) e, x);
} else if (e instanceof Quantity) {
renderQuantity((Quantity) e, x, showCodeDetails);
} else if (e instanceof Ratio) {
renderQuantity(((Ratio) e).getNumerator(), x, showCodeDetails);
x.addText("/");
renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails);
} else if (e instanceof Period) {
Period p = (Period) e;
x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
x.addText(" --> ");
x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
} else if (e instanceof Reference) {
Reference r = (Reference) e;
XhtmlNode c = x;
ResourceWithReference tr = null;
if (r.hasReferenceElement()) {
tr = resolveReference(res, r.getReference());
if (!r.getReference().startsWith("#")) {
if (tr != null && tr.getReference() != null)
c = x.addTag("a").attribute("href", tr.getReference());
else
c = x.addTag("a").attribute("href", r.getReference());
}
}
// what to display: if text is provided, then that. if the reference was resolved, then show the generated narrative
if (r.hasDisplayElement()) {
c.addText(r.getDisplay());
if (tr != null) {
c.addText(". Generated Summary: ");
generateResourceSummary(c, tr.getResource(), true, r.getReference().startsWith("#"));
}
} else if (tr != null) {
generateResourceSummary(c, tr.getResource(), r.getReference().startsWith("#"), r.getReference().startsWith("#"));
} else {
c.addText(r.getReference());
}
} else if (e instanceof Resource) {
return;
} else if (e instanceof ElementDefinition) {
x.addText("todo-bundle");
} else if (e != null && !(e instanceof Attachment) && !(e instanceof Narrative) && !(e instanceof Meta))
throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet");
}
use of org.hl7.cql_annotations.r1.Annotation in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeAnnotation.
protected void composeAnnotation(Complex parent, String parentType, String name, Annotation element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeElement(t, "Annotation", name, element, index);
if (element.hasAuthor())
composeType(t, "Annotation", "author", element.getAuthor(), -1);
if (element.hasTimeElement())
composeDateTime(t, "Annotation", "time", element.getTimeElement(), -1);
if (element.hasTextElement())
composeString(t, "Annotation", "text", element.getTextElement(), -1);
}
Aggregations