use of org.hl7.fhir.r4b.model.Meta in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeMeta.
protected void composeMeta(Complex parent, String parentType, String name, Meta element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeElement(t, "Meta", name, element, index);
if (element.hasVersionIdElement())
composeId(t, "Meta", "versionId", element.getVersionIdElement(), -1);
if (element.hasLastUpdatedElement())
composeInstant(t, "Meta", "lastUpdated", element.getLastUpdatedElement(), -1);
for (int i = 0; i < element.getProfile().size(); i++) composeUri(t, "Meta", "profile", element.getProfile().get(i), i);
for (int i = 0; i < element.getSecurity().size(); i++) composeCoding(t, "Meta", "security", element.getSecurity().get(i), i);
for (int i = 0; i < element.getTag().size(); i++) composeCoding(t, "Meta", "tag", element.getTag().get(i), i);
}
use of org.hl7.fhir.r4b.model.Meta in project org.hl7.fhir.core by hapifhir.
the class ResourceUtilities method showDECHeader.
private static DataElement showDECHeader(StringBuilder b, Bundle bundle) {
DataElement meta = new DataElement();
DataElement prototype = (DataElement) bundle.getEntry().get(0).getResource();
meta.setPublisher(prototype.getPublisher());
meta.getContact().addAll(prototype.getContact());
meta.setStatus(prototype.getStatus());
meta.setDate(prototype.getDate());
meta.addElement().getType().addAll(prototype.getElement().get(0).getType());
for (BundleEntryComponent e : bundle.getEntry()) {
DataElement de = (DataElement) e.getResource();
if (!Base.compareDeep(de.getPublisherElement(), meta.getPublisherElement(), false))
meta.setPublisherElement(null);
if (!Base.compareDeep(de.getContact(), meta.getContact(), false))
meta.getContact().clear();
if (!Base.compareDeep(de.getStatusElement(), meta.getStatusElement(), false))
meta.setStatusElement(null);
if (!Base.compareDeep(de.getDateElement(), meta.getDateElement(), false))
meta.setDateElement(null);
if (!Base.compareDeep(de.getElement().get(0).getType(), meta.getElement().get(0).getType(), false))
meta.getElement().get(0).getType().clear();
}
if (meta.hasPublisher() || meta.hasContact() || meta.hasStatus() || meta.hasDate()) /* || meta.hasType() */
{
b.append("<table class=\"grid\">\r\n");
if (meta.hasPublisher())
b.append("<tr><td>Publisher:</td><td>" + meta.getPublisher() + "</td></tr>\r\n");
if (meta.hasContact()) {
b.append("<tr><td>Contacts:</td><td>");
boolean firsti = true;
for (DataElementContactComponent c : meta.getContact()) {
if (firsti)
firsti = false;
else
b.append("<br/>");
if (c.hasName())
b.append(Utilities.escapeXml(c.getName()) + ": ");
boolean first = true;
for (ContactPoint cp : c.getTelecom()) {
if (first)
first = false;
else
b.append(", ");
renderContactPoint(b, cp);
}
}
b.append("</td></tr>\r\n");
}
if (meta.hasStatus())
b.append("<tr><td>Status:</td><td>" + meta.getStatus().toString() + "</td></tr>\r\n");
if (meta.hasDate())
b.append("<tr><td>Date:</td><td>" + meta.getDateElement().asStringValue() + "</td></tr>\r\n");
if (meta.getElement().get(0).hasType())
b.append("<tr><td>Type:</td><td>" + renderType(meta.getElement().get(0).getType()) + "</td></tr>\r\n");
b.append("</table>\r\n");
}
return meta;
}
use of org.hl7.fhir.r4b.model.Meta 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.dstu2016may.model.DateType)
x.addText(((org.hl7.fhir.dstu2016may.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.dstu2016may.model.IntegerType) {
x.addText(Integer.toString(((org.hl7.fhir.dstu2016may.model.IntegerType) e).getValue()));
} else if (e instanceof org.hl7.fhir.dstu2016may.model.DecimalType) {
x.addText(((org.hl7.fhir.dstu2016may.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.fhir.r4b.model.Meta in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method inject.
private void inject(Element er, XhtmlNode x, NarrativeStatus status) {
Element txt = XMLUtil.getNamedChild(er, "text");
if (txt == null) {
txt = er.getOwnerDocument().createElementNS(FormatUtilities.FHIR_NS, "text");
Element n = XMLUtil.getFirstChild(er);
while (n != null && (n.getNodeName().equals("id") || n.getNodeName().equals("meta") || n.getNodeName().equals("implicitRules") || n.getNodeName().equals("language"))) n = XMLUtil.getNextSibling(n);
if (n == null)
er.appendChild(txt);
else
er.insertBefore(txt, n);
}
Element st = XMLUtil.getNamedChild(txt, "status");
if (st == null) {
st = er.getOwnerDocument().createElementNS(FormatUtilities.FHIR_NS, "status");
Element n = XMLUtil.getFirstChild(txt);
if (n == null)
txt.appendChild(st);
else
txt.insertBefore(st, n);
}
st.setAttribute("value", status.toCode());
Element div = XMLUtil.getNamedChild(txt, "div");
if (div == null) {
div = er.getOwnerDocument().createElementNS(FormatUtilities.XHTML_NS, "div");
div.setAttribute("xmlns", FormatUtilities.XHTML_NS);
txt.appendChild(div);
}
if (div.hasChildNodes())
div.appendChild(er.getOwnerDocument().createElementNS(FormatUtilities.XHTML_NS, "hr"));
new XhtmlComposer(true, false).compose(div, x);
}
use of org.hl7.fhir.r4b.model.Meta in project org.hl7.fhir.core by hapifhir.
the class ResourceUtilities method showDECHeader.
private static DataElement showDECHeader(StringBuilder b, Bundle bundle) {
DataElement meta = new DataElement();
DataElement prototype = (DataElement) bundle.getEntry().get(0).getResource();
meta.setPublisher(prototype.getPublisher());
meta.getContact().addAll(prototype.getContact());
meta.setStatus(prototype.getStatus());
meta.setDate(prototype.getDate());
meta.addElement().getType().addAll(prototype.getElement().get(0).getType());
for (BundleEntryComponent e : bundle.getEntry()) {
DataElement de = (DataElement) e.getResource();
if (!Base.compareDeep(de.getPublisherElement(), meta.getPublisherElement(), false))
meta.setPublisherElement(null);
if (!Base.compareDeep(de.getContact(), meta.getContact(), false))
meta.getContact().clear();
if (!Base.compareDeep(de.getStatusElement(), meta.getStatusElement(), false))
meta.setStatusElement(null);
if (!Base.compareDeep(de.getDateElement(), meta.getDateElement(), false))
meta.setDateElement(null);
if (!Base.compareDeep(de.getElement().get(0).getType(), meta.getElement().get(0).getType(), false))
meta.getElement().get(0).getType().clear();
}
if (meta.hasPublisher() || meta.hasContact() || meta.hasStatus() || meta.hasDate()) /* || meta.hasType() */
{
b.append("<table class=\"grid\">\r\n");
if (meta.hasPublisher())
b.append("<tr><td>Publisher:</td><td>" + meta.getPublisher() + "</td></tr>\r\n");
if (meta.hasContact()) {
b.append("<tr><td>Contacts:</td><td>");
boolean firsti = true;
for (DataElementContactComponent c : meta.getContact()) {
if (firsti)
firsti = false;
else
b.append("<br/>");
if (c.hasName())
b.append(Utilities.escapeXml(c.getName()) + ": ");
boolean first = true;
for (ContactPoint cp : c.getTelecom()) {
if (first)
first = false;
else
b.append(", ");
renderContactPoint(b, cp);
}
}
b.append("</td></tr>\r\n");
}
if (meta.hasStatus())
b.append("<tr><td>Status:</td><td>" + meta.getStatus().toString() + "</td></tr>\r\n");
if (meta.hasDate())
b.append("<tr><td>Date:</td><td>" + meta.getDateElement().asStringValue() + "</td></tr>\r\n");
if (meta.getElement().get(0).hasType())
b.append("<tr><td>Type:</td><td>" + renderType(meta.getElement().get(0).getType()) + "</td></tr>\r\n");
b.append("</table>\r\n");
}
return meta;
}
Aggregations