Search in sources :

Example 76 with Section

use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.

the class BundleRenderer method renderDocument.

private boolean renderDocument(XhtmlNode x, Bundle b) throws UnsupportedEncodingException, FHIRException, IOException, EOperationOutcome {
    // from the spec:
    // 
    // When the document is presented for human consumption, applications SHOULD present the collated narrative portions in order:
    // * The subject resource Narrative
    // * The Composition resource Narrative
    // * The section.text Narratives
    Composition comp = (Composition) b.getEntry().get(0).getResource();
    Resource subject = resolveReference(b, comp.getSubject());
    if (subject != null) {
        XhtmlNode nx = (subject instanceof DomainResource) ? ((DomainResource) subject).getText().getDiv() : null;
        if (nx != null) {
            x.addChildren(nx);
        } else {
            RendererFactory.factory(subject, context).render(x, subject);
        }
    }
    x.hr();
    if (comp.getText().hasDiv()) {
        x.addChildren(comp.getText().getDiv());
        x.hr();
    }
    for (SectionComponent section : comp.getSection()) {
        addSection(x, section, 2, false);
    }
    return false;
}
Also used : Composition(org.hl7.fhir.r5.model.Composition) DomainResource(org.hl7.fhir.r5.model.DomainResource) DomainResource(org.hl7.fhir.r5.model.DomainResource) Resource(org.hl7.fhir.r5.model.Resource) SectionComponent(org.hl7.fhir.r5.model.Composition.SectionComponent) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

Example 77 with Section

use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.

the class Turtle method section.

public Section section(String sn) {
    if (hasSection(sn))
        throw new Error("Duplicate section name " + sn);
    Section s = new Section();
    s.name = sn;
    sections.add(s);
    return s;
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Example 78 with Section

use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.

the class TurtleParser method compose.

public void compose(Element e, Turtle ttl, String base) throws FHIRException {
    ttl.prefix("fhir", FHIR_URI_BASE);
    ttl.prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
    ttl.prefix("owl", "http://www.w3.org/2002/07/owl#");
    ttl.prefix("xsd", "http://www.w3.org/2001/XMLSchema#");
    Section section = ttl.section("resource");
    String subjId = genSubjectId(e);
    String ontologyId = subjId.replace(">", ".ttl>");
    Section ontology = ttl.section("ontology header");
    ontology.triple(ontologyId, "a", "owl:Ontology");
    ontology.triple(ontologyId, "owl:imports", "fhir:fhir.ttl");
    if (ontologyId.startsWith("<" + FHIR_URI_BASE))
        ontology.triple(ontologyId, "owl:versionIRI", ontologyId.replace(FHIR_URI_BASE, FHIR_VERSION_BASE));
    Subject subject = section.triple(subjId, "a", "fhir:" + e.getType());
    subject.linkedPredicate("fhir:nodeRole", "fhir:treeRoot", linkResolver == null ? null : linkResolver.resolvePage("rdf.html#tree-root"));
    for (Element child : e.getChildren()) {
        composeElement(section, subject, child, null);
    }
}
Also used : SpecialElement(org.hl7.fhir.r5.elementmodel.Element.SpecialElement) NamedElement(org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement) Section(org.hl7.fhir.utilities.turtle.Turtle.Section) Subject(org.hl7.fhir.utilities.turtle.Turtle.Subject)

Example 79 with Section

use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.

the class TurtleParser method composeElement.

private void composeElement(Section section, Complex ctxt, Element element, Element parent) throws FHIRException {
    // "Extension".equals(element.getType())?
    // (element.getProperty().getDefinition().getIsModifier()? "modifierExtension" : "extension") ;
    String en = getFormalName(element);
    Complex t;
    if (element.getSpecial() == SpecialElement.BUNDLE_ENTRY && parent != null && parent.getNamedChildValue("fullUrl") != null) {
        String url = "<" + parent.getNamedChildValue("fullUrl") + ">";
        ctxt.linkedPredicate("fhir:" + en, url, linkResolver == null ? null : linkResolver.resolveProperty(element.getProperty()));
        t = section.subject(url);
    } else {
        t = ctxt.linkedPredicate("fhir:" + en, linkResolver == null ? null : linkResolver.resolveProperty(element.getProperty()));
    }
    if (element.getSpecial() != null)
        t.linkedPredicate("a", "fhir:" + element.fhirType(), linkResolver == null ? null : linkResolver.resolveType(element.fhirType()));
    if (element.hasValue())
        t.linkedPredicate("fhir:value", ttlLiteral(element.getValue(), element.getType()), linkResolver == null ? null : linkResolver.resolveType(element.getType()));
    if (element.getProperty().isList() && (!element.isResource() || element.getSpecial() == SpecialElement.CONTAINED))
        t.linkedPredicate("fhir:index", Integer.toString(element.getIndex()), linkResolver == null ? null : linkResolver.resolvePage("rdf.html#index"));
    if ("Coding".equals(element.getType()))
        decorateCoding(t, element, section);
    if (Utilities.existsInList(element.getType(), "Reference"))
        decorateReference(t, element);
    else if (Utilities.existsInList(element.getType(), "canonical"))
        decorateCanonical(t, element);
    if ("canonical".equals(element.getType())) {
        String refURI = element.primitiveValue();
        if (refURI != null) {
            String uriType = getURIType(refURI);
            if (uriType != null && !section.hasSubject(refURI))
                section.triple(refURI, "a", "fhir:" + uriType);
        }
    }
    if ("Reference".equals(element.getType())) {
        String refURI = getReferenceURI(element.getChildValue("reference"));
        if (refURI != null) {
            String uriType = getURIType(refURI);
            if (uriType != null && !section.hasSubject(refURI))
                section.triple(refURI, "a", "fhir:" + uriType);
        }
    }
    for (Element child : element.getChildren()) {
        if ("xhtml".equals(child.getType())) {
            String childfn = getFormalName(child);
            t.predicate("fhir:" + childfn, ttlLiteral(child.getValue(), child.getType()));
        } else
            composeElement(section, t, child, element);
    }
}
Also used : SpecialElement(org.hl7.fhir.r5.elementmodel.Element.SpecialElement) NamedElement(org.hl7.fhir.r5.elementmodel.ParserBase.NamedElement) TTLComplex(org.hl7.fhir.utilities.turtle.Turtle.TTLComplex) Complex(org.hl7.fhir.utilities.turtle.Turtle.Complex)

Example 80 with Section

use of org.hl7.fhir.utilities.turtle.Turtle.Section in project org.hl7.fhir.core by hapifhir.

the class Turtle method section.

public Section section(String sn) {
    if (hasSection(sn))
        throw new Error("Duplicate section name " + sn);
    Section s = new Section();
    s.name = sn;
    sections.add(s);
    return s;
}
Also used : FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError)

Aggregations

ArrayList (java.util.ArrayList)21 Element (org.w3c.dom.Element)11 IOException (java.io.IOException)10 LinkedHashMap (java.util.LinkedHashMap)9 Section (org.hl7.fhir.utilities.xml.SchematronWriter.Section)9 POCDMT000002UK01Section (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Section)8 Rule (org.hl7.fhir.utilities.xml.SchematronWriter.Rule)7 POCDMT000002UK01Component3 (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Component3)7 Reference (org.hl7.fhir.dstu3.model.Reference)6 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)6 SectionComponent (org.hl7.fhir.dstu3.model.Composition.SectionComponent)5 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 HashMap (java.util.HashMap)4 NotImplementedException (org.apache.commons.lang3.NotImplementedException)4 IdType (org.hl7.fhir.dstu3.model.IdType)4 Section (org.hl7.fhir.utilities.turtle.Turtle.Section)4 Subject (org.hl7.fhir.utilities.turtle.Turtle.Subject)4 POCDMT000002UK01Component5 (uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01Component5)4 FileNotFoundException (java.io.FileNotFoundException)3