Search in sources :

Example 26 with Meta

use of org.hl7.fhir.r4.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);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 27 with Meta

use of org.hl7.fhir.r4.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;
}
Also used : DataElement(org.hl7.fhir.dstu2.model.DataElement) ContactPoint(org.hl7.fhir.dstu2.model.ContactPoint) BundleEntryComponent(org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent) DataElementContactComponent(org.hl7.fhir.dstu2.model.DataElement.DataElementContactComponent)

Example 28 with Meta

use of org.hl7.fhir.r4.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");
}
Also used : Meta(org.hl7.fhir.dstu2016may.model.Meta) Base64(org.apache.commons.codec.binary.Base64) Address(org.hl7.fhir.dstu2016may.model.Address) StringType(org.hl7.fhir.dstu2016may.model.StringType) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Attachment(org.hl7.fhir.dstu2016may.model.Attachment) UriType(org.hl7.fhir.dstu2016may.model.UriType) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) HumanName(org.hl7.fhir.dstu2016may.model.HumanName) ContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint) Identifier(org.hl7.fhir.dstu2016may.model.Identifier) Coding(org.hl7.fhir.dstu2016may.model.Coding) Narrative(org.hl7.fhir.dstu2016may.model.Narrative) SampledData(org.hl7.fhir.dstu2016may.model.SampledData) Ratio(org.hl7.fhir.dstu2016may.model.Ratio) ElementDefinition(org.hl7.fhir.dstu2016may.model.ElementDefinition) InstantType(org.hl7.fhir.dstu2016may.model.InstantType) Enumeration(org.hl7.fhir.dstu2016may.model.Enumeration) Reference(org.hl7.fhir.dstu2016may.model.Reference) BooleanType(org.hl7.fhir.dstu2016may.model.BooleanType) Resource(org.hl7.fhir.dstu2016may.model.Resource) DomainResource(org.hl7.fhir.dstu2016may.model.DomainResource) Quantity(org.hl7.fhir.dstu2016may.model.Quantity) Period(org.hl7.fhir.dstu2016may.model.Period) Range(org.hl7.fhir.dstu2016may.model.Range) Base(org.hl7.fhir.dstu2016may.model.Base) Annotation(org.hl7.fhir.dstu2016may.model.Annotation) IdType(org.hl7.fhir.dstu2016may.model.IdType) Extension(org.hl7.fhir.dstu2016may.model.Extension) DateTimeType(org.hl7.fhir.dstu2016may.model.DateTimeType) CodeType(org.hl7.fhir.dstu2016may.model.CodeType) EventTiming(org.hl7.fhir.dstu2016may.model.Timing.EventTiming) Timing(org.hl7.fhir.dstu2016may.model.Timing) Base64BinaryType(org.hl7.fhir.dstu2016may.model.Base64BinaryType) CodeableConcept(org.hl7.fhir.dstu2016may.model.CodeableConcept)

Example 29 with Meta

use of org.hl7.fhir.r4.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);
}
Also used : Element(org.w3c.dom.Element) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer)

Example 30 with Meta

use of org.hl7.fhir.r4.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;
}
Also used : DataElement(org.hl7.fhir.dstu2016may.model.DataElement) ContactPoint(org.hl7.fhir.dstu2016may.model.ContactPoint) BundleEntryComponent(org.hl7.fhir.dstu2016may.model.Bundle.BundleEntryComponent) DataElementContactComponent(org.hl7.fhir.dstu2016may.model.DataElement.DataElementContactComponent)

Aggregations

Meta (org.hl7.fhir.r4.model.Meta)40 HashMap (java.util.HashMap)36 Date (java.util.Date)35 Meta (org.hl7.fhir.dstu3.model.Meta)31 IBaseMetaType (org.hl7.fhir.instance.model.api.IBaseMetaType)28 Reference (org.hl7.fhir.r4.model.Reference)26 JsonObject (javax.json.JsonObject)24 Path (javax.ws.rs.Path)24 Produces (javax.ws.rs.Produces)24 Code (org.mitre.synthea.world.concepts.HealthRecord.Code)20 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)18 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)17 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)17 ArrayList (java.util.ArrayList)16 Coding (org.hl7.fhir.r4.model.Coding)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)15 Test (org.junit.jupiter.api.Test)15 Test (org.junit.Test)14 NotImplementedException (org.apache.commons.lang3.NotImplementedException)13 GET (javax.ws.rs.GET)12