Search in sources :

Example 66 with Section

use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.

the class CCDAConverter method processVitalSignsSection.

protected SectionComponent processVitalSignsSection(Element section) throws Exception {
    ListResource list = new ListResource();
    for (Element entry : cda.getChildren(section, "entry")) {
        Element organizer = cda.getlastChild(entry);
        if (cda.hasTemplateId(organizer, "2.16.840.1.113883.10.20.22.4.26")) {
            processVitalSignsOrganizer(list, organizer);
        } else
            throw new Exception("Unhandled Section template ids: " + cda.showTemplateIds(organizer));
    }
    // todo: text
    SectionComponent s = new Composition.SectionComponent();
    s.setCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")));
    // todo: check subject
    s.addEntry(Factory.makeReference(addReference(list, "Vital Signs", makeUUIDReference())));
    return s;
}
Also used : Element(org.w3c.dom.Element) SectionComponent(org.hl7.fhir.dstu3.model.Composition.SectionComponent)

Example 67 with Section

use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.

the class CCDAConverter method convert.

public Bundle convert(InputStream stream) throws Exception {
    cda = new CDAUtilities(stream);
    doc = cda.getElement();
    cda.checkTemplateId(doc, "2.16.840.1.113883.10.20.22.1.1");
    convert = new Convert(cda, ucumSvc, "Z");
    // check it's a CDA/CCD
    feed = new Bundle();
    feed.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));
    feed.setId(makeUUIDReference());
    // todo-bundle  ("http://hl7.org/fhir/tag", "http://hl7.org/fhir/tag/document", "Document"));
    feed.getMeta().getTag().add(new Coding());
    // process the header
    makeDocument();
    composition.setSubject(Factory.makeReference(makeSubject()));
    for (Element e : cda.getChildren(doc, "author")) composition.getAuthor().add(Factory.makeReference(makeAuthor(e)));
    // todo: data enterer & informant goes in provenance
    composition.setCustodian(Factory.makeReference(makeOrganization(cda.getDescendent(doc, "custodian/assignedCustodian/representedCustodianOrganization"), "Custodian")));
    // todo: informationRecipient
    for (Element e : cda.getChildren(doc, "legalAuthenticator")) composition.getAttester().add(makeAttester(e, CompositionAttestationMode.LEGAL, "Legal Authenticator"));
    for (Element e : cda.getChildren(doc, "authenticator")) composition.getAttester().add(makeAttester(e, CompositionAttestationMode.PROFESSIONAL, "Authenticator"));
    // process the contents
    // we do this by section - keep the original section order
    Element body = cda.getDescendent(doc, "component/structuredBody");
    processComponentSections(composition.getSection(), body);
    return feed;
}
Also used : Convert(org.hl7.fhir.convertors.misc.Convert) CDAUtilities(org.hl7.fhir.convertors.misc.CDAUtilities) Element(org.w3c.dom.Element)

Example 68 with Section

use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.

the class CCDAConverter method processAdverseReactionsSection.

protected SectionComponent processAdverseReactionsSection(Element section) throws Exception {
    ListResource list = new ListResource();
    for (Element entry : cda.getChildren(section, "entry")) {
        Element concern = cda.getChild(entry, "act");
        if (cda.hasTemplateId(concern, "2.16.840.1.113883.10.20.22.4.30")) {
            processAllergyProblemAct(list, concern);
        } else
            throw new Exception("Unhandled Section template ids: " + cda.showTemplateIds(concern));
    }
    // todo: text
    SectionComponent s = new Composition.SectionComponent();
    s.setCode(convert.makeCodeableConceptFromCD(cda.getChild(section, "code")));
    // todo: check subject
    s.addEntry(Factory.makeReference(addReference(list, "Allergies, Adverse Reactions, Alerts", makeUUIDReference())));
    return s;
}
Also used : Element(org.w3c.dom.Element) SectionComponent(org.hl7.fhir.dstu3.model.Composition.SectionComponent)

Example 69 with Section

use of org.hl7.fhir.utilities.xml.SchematronWriter.Section in project org.hl7.fhir.core by hapifhir.

the class ProfileUtilities method generateForChildren.

private void generateForChildren(SchematronWriter sch, String xpath, ElementDefinition ed, StructureDefinition structure, StructureDefinition base) throws IOException {
    // generateForChild(txt, structure, child);
    List<ElementDefinition> children = getChildList(structure, ed);
    String sliceName = null;
    ElementDefinitionSlicingComponent slicing = null;
    for (ElementDefinition child : children) {
        String name = tail(child.getPath());
        if (child.hasSlicing()) {
            sliceName = name;
            slicing = child.getSlicing();
        } else if (!name.equals(sliceName))
            slicing = null;
        ElementDefinition based = getByPath(base, child.getPath());
        boolean doMin = (child.getMin() > 0) && (based == null || (child.getMin() != based.getMin()));
        boolean doMax = child.hasMax() && !child.getMax().equals("*") && (based == null || (!child.getMax().equals(based.getMax())));
        Slicer slicer = slicing == null ? new Slicer(true) : generateSlicer(child, slicing, structure);
        if (slicer.check) {
            if (doMin || doMax) {
                Section s = sch.section(xpath);
                Rule r = s.rule(xpath);
                if (doMin)
                    r.assrt("count(f:" + name + slicer.criteria + ") >= " + Integer.toString(child.getMin()), name + slicer.name + ": minimum cardinality of '" + name + "' is " + Integer.toString(child.getMin()));
                if (doMax)
                    r.assrt("count(f:" + name + slicer.criteria + ") <= " + child.getMax(), name + slicer.name + ": maximum cardinality of '" + name + "' is " + child.getMax());
            }
        }
    }
    for (ElementDefinitionConstraintComponent inv : ed.getConstraint()) {
        if (inv.hasXpath()) {
            Section s = sch.section(ed.getPath());
            Rule r = s.rule(xpath);
            r.assrt(inv.getXpath(), (inv.hasId() ? inv.getId() + ": " : "") + inv.getHuman() + (inv.hasUserData(IS_DERIVED) ? " (inherited)" : ""));
        }
    }
    for (ElementDefinition child : children) {
        String name = tail(child.getPath());
        generateForChildren(sch, xpath + "/f:" + name, child, structure, base);
    }
}
Also used : ElementDefinitionSlicingComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionSlicingComponent) ElementDefinition(org.hl7.fhir.dstu3.model.ElementDefinition) TypeDerivationRule(org.hl7.fhir.dstu3.model.StructureDefinition.TypeDerivationRule) Rule(org.hl7.fhir.utilities.xml.SchematronWriter.Rule) Section(org.hl7.fhir.utilities.xml.SchematronWriter.Section) ElementDefinitionConstraintComponent(org.hl7.fhir.dstu3.model.ElementDefinition.ElementDefinitionConstraintComponent)

Example 70 with Section

use of org.hl7.fhir.utilities.xml.SchematronWriter.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) {
    // "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 ("Reference".equals(element.getType()))
        decorateReference(t, element);
    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.dstu3.elementmodel.Element.SpecialElement) Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex) TTLComplex(org.hl7.fhir.dstu3.utils.formats.Turtle.TTLComplex)

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