Search in sources :

Example 71 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) {
    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.dstu3.elementmodel.Element.SpecialElement) Section(org.hl7.fhir.dstu3.utils.formats.Turtle.Section) Subject(org.hl7.fhir.dstu3.utils.formats.Turtle.Subject)

Example 72 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 : NamedElement(org.hl7.fhir.r4b.elementmodel.ParserBase.NamedElement) SpecialElement(org.hl7.fhir.r4b.elementmodel.Element.SpecialElement) Section(org.hl7.fhir.utilities.turtle.Turtle.Section) Subject(org.hl7.fhir.utilities.turtle.Turtle.Subject)

Example 73 with Section

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

the class RdfParserBase method compose.

@Override
public void compose(OutputStream stream, Resource resource) throws IOException {
    Turtle ttl = new Turtle();
    // ttl.setFormat(FFormat);
    ttl.prefix("fhir", "http://hl7.org/fhir/");
    ttl.prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
    Section section = ttl.section("resource");
    Subject subject;
    if (url != null)
        subject = section.triple("<" + url + ">", "a", "fhir:" + resource.getResourceType().toString());
    else
        subject = section.triple("[]", "a", "fhir:" + resource.getResourceType().toString());
    composeResource(subject, resource);
    try {
        ttl.commit(stream, false);
    } catch (Exception e) {
        throw new IOException(e);
    }
}
Also used : Turtle(org.hl7.fhir.dstu3.utils.formats.Turtle) IOException(java.io.IOException) Section(org.hl7.fhir.dstu3.utils.formats.Turtle.Section) Subject(org.hl7.fhir.dstu3.utils.formats.Turtle.Subject) IOException(java.io.IOException)

Example 74 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 75 with Section

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

the class BundleRenderer method addSection.

private void addSection(XhtmlNode x, BaseWrapper section, int level, boolean nested) throws UnsupportedEncodingException, FHIRException, IOException {
    if (section.has("title") || section.has("code") || section.has("text") || section.has("section")) {
        XhtmlNode div = x.div();
        if (section.has("title")) {
            div.h(level).tx(section.get("title").primitiveValue());
        } else if (section.has("code")) {
            renderBase(div.h(level), section.get("code"));
        }
        if (section.has("text")) {
            Base narrative = section.get("text");
            x.addChildren(narrative.getXhtml());
        }
        if (section.has("section")) {
            List<BaseWrapper> sections = section.children("section");
            for (BaseWrapper child : sections) {
                if (nested) {
                    addSection(x.blockquote().para(), child, level + 1, true);
                } else {
                    addSection(x, child, level + 1, true);
                }
            }
        }
    }
// children
}
Also used : BaseWrapper(org.hl7.fhir.r5.renderers.utils.BaseWrappers.BaseWrapper) Base(org.hl7.fhir.r5.model.Base) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode)

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