use of org.hl7.cql_annotations.r1.Annotation in project org.hl7.fhir.core by hapifhir.
the class DataRenderer method renderAnnotation.
protected void renderAnnotation(XhtmlNode x, Annotation a, boolean showCodeDetails) throws FHIRException {
StringBuilder b = new StringBuilder();
if (a.hasText()) {
b.append(a.getText());
}
if (a.hasText() && (a.hasAuthor() || a.hasTimeElement())) {
b.append(" (");
}
if (a.hasAuthor()) {
b.append("By ");
if (a.hasAuthorReference()) {
b.append(a.getAuthorReference().getReference());
} else if (a.hasAuthorStringType()) {
b.append(a.getAuthorStringType().getValue());
}
}
if (a.hasTimeElement()) {
if (b.length() > 0) {
b.append(" ");
}
b.append("@").append(a.getTimeElement().toHumanDisplay());
}
if (a.hasText() && (a.hasAuthor() || a.hasTimeElement())) {
b.append(")");
}
x.addText(b.toString());
}
use of org.hl7.cql_annotations.r1.Annotation in project org.hl7.fhir.core by hapifhir.
the class ListRenderer method render.
public boolean render(XhtmlNode x, ResourceWrapper list) throws FHIRFormatError, DefinitionException, IOException {
if (list.has("title")) {
x.h2().tx(list.get("title").primitiveValue());
}
XhtmlNode t = x.table("clstu");
XhtmlNode tr = t.tr();
XhtmlNode td = tr.td();
if (list.has("date")) {
td.tx("Date: " + list.get("date").dateTimeValue().toHumanDisplay());
}
if (list.has("mode")) {
td.tx("Mode: " + list.get("mode").primitiveValue());
}
if (list.has("status")) {
td.tx("Status: " + list.get("status").primitiveValue());
}
if (list.has("code")) {
td.tx("Code: " + displayBase(list.get("code")));
}
tr = t.tr();
td = tr.td();
if (list.has("subject")) {
td.tx("Subject: ");
shortForRef(td, list.get("subject"));
}
if (list.has("encounter")) {
td.tx("Encounter: ");
shortForRef(td, list.get("encounter"));
}
if (list.has("source")) {
td.tx("Source: ");
shortForRef(td, list.get("encounter"));
}
if (list.has("orderedBy")) {
td.tx("Order: " + displayBase(list.get("orderedBy")));
}
// for (Annotation a : list.getNote()) {
// renderAnnotation(a, x);
// }
boolean flag = false;
boolean deleted = false;
boolean date = false;
for (BaseWrapper e : list.children("entry")) {
flag = flag || e.has("flag");
deleted = deleted || e.has("deleted");
date = date || e.has("date");
}
t = x.table("grid");
tr = t.tr().style("backgound-color: #eeeeee");
tr.td().b().tx("Items");
if (date) {
tr.td().tx("Date");
}
if (flag) {
tr.td().tx("Flag");
}
if (deleted) {
tr.td().tx("Deleted");
}
for (BaseWrapper e : list.children("entry")) {
tr = t.tr();
shortForRef(tr.td(), e.get("item"));
if (date) {
tr.td().tx(e.has("date") ? e.get("date").dateTimeValue().toHumanDisplay() : "");
}
if (flag) {
tr.td().tx(e.has("flag") ? displayBase(e.get("flag")) : "");
}
if (deleted) {
tr.td().tx(e.has("deleted") ? e.get("deleted").primitiveValue() : "");
}
}
return false;
}
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 displayLeaf.
private boolean displayLeaf(ResourceWrapper res, BaseWrapper ew, ElementDefinition defn, XhtmlNode x, String name, boolean showCodeDetails) throws FHIRException, UnsupportedEncodingException, IOException {
if (ew == null)
return false;
Base e = ew.getBase();
if (e == null)
return false;
Map<String, String> displayHints = readDisplayHints(defn);
if (name.endsWith("[x]"))
name = name.substring(0, name.length() - 3);
if (!showCodeDetails && e instanceof PrimitiveType && isDefault(displayHints, ((PrimitiveType) e)))
return false;
if (e instanceof StringType) {
x.addText(name + ": " + ((StringType) e).getValue());
return true;
} else if (e instanceof CodeType) {
x.addText(name + ": " + ((CodeType) e).getValue());
return true;
} else if (e instanceof IdType) {
x.addText(name + ": " + ((IdType) e).getValue());
return true;
} else if (e instanceof UriType) {
x.addText(name + ": " + ((UriType) e).getValue());
return true;
} else if (e instanceof DateTimeType) {
x.addText(name + ": " + ((DateTimeType) e).toHumanDisplay());
return true;
} else if (e instanceof InstantType) {
x.addText(name + ": " + ((InstantType) e).toHumanDisplay());
return true;
} else if (e instanceof Extension) {
// x.tx("Extensions: todo");
return false;
} else if (e instanceof org.hl7.fhir.dstu3.model.DateType) {
x.addText(name + ": " + ((org.hl7.fhir.dstu3.model.DateType) e).toHumanDisplay());
return true;
} else if (e instanceof Enumeration) {
// todo: look up a display name if there is one
x.addText(((Enumeration<?>) e).getValue().toString());
return true;
} else if (e instanceof BooleanType) {
if (((BooleanType) e).getValue()) {
x.addText(name);
return true;
}
} else if (e instanceof CodeableConcept) {
renderCodeableConcept((CodeableConcept) e, x, showCodeDetails);
return true;
} else if (e instanceof Coding) {
renderCoding((Coding) e, x, showCodeDetails);
return true;
} else if (e instanceof Annotation) {
renderAnnotation((Annotation) e, x, showCodeDetails);
return true;
} else if (e instanceof org.hl7.fhir.dstu3.model.IntegerType) {
x.addText(Integer.toString(((org.hl7.fhir.dstu3.model.IntegerType) e).getValue()));
return true;
} else if (e instanceof org.hl7.fhir.dstu3.model.DecimalType) {
x.addText(((org.hl7.fhir.dstu3.model.DecimalType) e).getValue().toString());
return true;
} else if (e instanceof Identifier) {
renderIdentifier((Identifier) e, x);
return true;
} else if (e instanceof HumanName) {
renderHumanName((HumanName) e, x);
return true;
} else if (e instanceof SampledData) {
renderSampledData((SampledData) e, x);
return true;
} else if (e instanceof Address) {
renderAddress((Address) e, x);
return true;
} else if (e instanceof ContactPoint) {
renderContactPoint((ContactPoint) e, x);
return true;
} else if (e instanceof Timing) {
renderTiming((Timing) e, x);
return true;
} else if (e instanceof Quantity) {
renderQuantity((Quantity) e, x, showCodeDetails);
return true;
} else if (e instanceof Ratio) {
renderQuantity(((Ratio) e).getNumerator(), x, showCodeDetails);
x.tx("/");
renderQuantity(((Ratio) e).getDenominator(), x, showCodeDetails);
return true;
} else if (e instanceof Period) {
Period p = (Period) e;
x.addText(name + ": ");
x.addText(!p.hasStart() ? "??" : p.getStartElement().toHumanDisplay());
x.tx(" --> ");
x.addText(!p.hasEnd() ? "(ongoing)" : p.getEndElement().toHumanDisplay());
return true;
} else if (e instanceof Reference) {
Reference r = (Reference) e;
if (r.hasDisplayElement())
x.addText(r.getDisplay());
else if (r.hasReferenceElement()) {
ResourceWithReference tr = resolveReference(res, r.getReference());
// getDisplayForReference(tr.getReference()));
x.addText(tr == null ? r.getReference() : "????");
} else
x.tx("??");
return true;
} else if (e instanceof Narrative) {
return false;
} else if (e instanceof Resource) {
return false;
} else if (e instanceof ContactDetail) {
return false;
} else if (e instanceof Range) {
return false;
} else if (e instanceof Meta) {
return false;
} else if (e instanceof Dosage) {
return false;
} else if (e instanceof Signature) {
return false;
} else if (e instanceof UsageContext) {
return false;
} else if (e instanceof ElementDefinition) {
return false;
} else if (!(e instanceof Attachment))
throw new NotImplementedException("type " + e.getClass().getName() + " not handled yet");
return false;
}
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());
}
Aggregations