Search in sources :

Example 6 with ElementDefinition

use of org.hl7.fhir.r4.model.ElementDefinition in project kindling by HL7.

the class PageProcessor method getInvariantList.

private String getInvariantList(StructureDefinition profile) throws FHIRException, Exception {
    List<String> txlist = new ArrayList<String>();
    Map<String, List<ElementDefinitionConstraintComponent>> txmap = new HashMap<String, List<ElementDefinitionConstraintComponent>>();
    for (ElementDefinition ed : profile.getSnapshot().getElement()) {
        if (!"0".equals(ed.getMax())) {
            List<ElementDefinitionConstraintComponent> list = new ArrayList<ElementDefinition.ElementDefinitionConstraintComponent>();
            for (ElementDefinitionConstraintComponent t : ed.getConstraint()) {
                if (!t.hasSource() || t.getSource().equals(profile.getUrl())) {
                    list.add(t);
                }
            }
            if (!list.isEmpty()) {
                txlist.add(ed.getPath());
                txmap.put(ed.getPath(), list);
            }
        }
    }
    if (txlist.isEmpty())
        return "";
    else {
        StringBuilder b = new StringBuilder();
        b.append("<h4>Constraints</h4>\r\n");
        b.append("<table class=\"list\">\r\n");
        b.append("<tr><td width=\"60\"><b>Id</b></td><td><b>Path</b></td><td><b>Details</b></td><td><b>Requirements</b></td></tr>\r\n");
        for (String path : txlist) {
            List<ElementDefinitionConstraintComponent> invs = txmap.get(path);
            for (ElementDefinitionConstraintComponent inv : invs) {
                b.append("<tr>" + presentLevel(inv) + " <td>").append(inv.getKey()).append("</td><td>").append(path).append("</td><td>").append(Utilities.escapeXml(inv.getHuman())).append("<br/><a href=\"http://hl7.org/fhirpath\">Expression</a>: ").append(Utilities.escapeXml(inv.getExpression())).append("</td><td>").append(Utilities.escapeXml(inv.getRequirements()));
                if (inv.hasExtension(ToolingExtensions.EXT_BEST_PRACTICE_EXPLANATION))
                    b.append(". This is (only) a best practice guideline because: <blockquote>" + processMarkdown("best practice guideline", inv.getExtensionString(ToolingExtensions.EXT_BEST_PRACTICE_EXPLANATION), "") + "</blockquote>");
                b.append("</td></tr>\r\n");
            }
        }
        b.append("</table>\r\n");
        return b.toString();
    }
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) ElementDefinitionConstraintComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionConstraintComponent)

Example 7 with ElementDefinition

use of org.hl7.fhir.r4.model.ElementDefinition in project kindling by HL7.

the class PageProcessor method edHeader.

private String edHeader(String mode) {
    StringBuilder b = new StringBuilder();
    b.append("<ul class=\"nav nav-tabs\">");
    b.append(makeHeaderTab("Element Definition", "elementdefinition.html", mode == null || "base".equals(mode)));
    b.append(makeHeaderTab("Examples", "elementdefinition-examples.html", mode == null || "examples".equals(mode)));
    b.append(makeHeaderTab("Detailed Descriptions", "elementdefinition-definitions.html", mode == null || "definitions".equals(mode)));
    b.append(makeHeaderTab("Mappings", "elementdefinition-mappings.html", mode == null || "mappings".equals(mode)));
    b.append(makeHeaderTab("Extensions", "elementdefinition-extras.html", mode == null || "extensions".equals(mode)));
    b.append("</ul>\r\n");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 8 with ElementDefinition

use of org.hl7.fhir.r4.model.ElementDefinition in project kindling by HL7.

the class PageProcessor method getTerminologyNotes.

private String getTerminologyNotes(StructureDefinition profile, int level) throws FHIRException {
    List<String> txlist = new ArrayList<String>();
    Map<String, ElementDefinitionBindingComponent> txmap = new HashMap<String, ElementDefinitionBindingComponent>();
    for (ElementDefinition ed : profile.getSnapshot().getElement()) {
        if (ed.hasBinding() && !"0".equals(ed.getMax())) {
            String path = ed.getPath();
            if (ed.getType().size() == 1 && ed.getType().get(0).getWorkingCode().equals("Extension"))
                path = path + "<br/>" + ed.getType().get(0).getProfile();
            txlist.add(path);
            txmap.put(path, ed.getBinding());
        }
    }
    if (txlist.isEmpty())
        return "";
    else {
        StringBuilder b = new StringBuilder();
        b.append("<h4>Terminology Bindings</h4>\r\n");
        b.append("<table class=\"list\">\r\n");
        b.append("<tr><td><b>Path</b></td><td><b>Name</b></td><td><b>Conformance</b></td><td><b>ValueSet</b></td></tr>\r\n");
        for (String path : txlist) {
            txItem(level, txmap, b, path);
        }
        b.append("</table>\r\n");
        return b.toString();
    }
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) ElementDefinitionBindingComponent(org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent)

Example 9 with ElementDefinition

use of org.hl7.fhir.r4.model.ElementDefinition in project kindling by HL7.

the class PageProcessor method getElementParent.

private ElementDefinition getElementParent(List<ElementDefinition> list, ElementDefinition element) {
    String targetPath = element.getPath().substring(0, element.getPath().lastIndexOf("."));
    int index = list.indexOf(element) - 1;
    while (index >= 0) {
        if (list.get(index).getPath().equals(targetPath))
            return list.get(index);
        index--;
    }
    return null;
}
Also used : ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

Example 10 with ElementDefinition

use of org.hl7.fhir.r4.model.ElementDefinition in project kindling by HL7.

the class CDAGenerator method buildInfrastructureRoot.

private void buildInfrastructureRoot() throws DefinitionException {
    StructureDefinition sd = new StructureDefinition();
    sd.setId("InfrastructureRoot");
    sd.setUrl("http://hl7.org/fhir/cda/StructureDefinition/InfrastructureRoot");
    library.put(sd.getUrl(), sd);
    sd.setName("Base Type for all classes in the CDA structure");
    sd.setTitle("InfrastructureRoot");
    sd.setStatus(PublicationStatus.ACTIVE);
    sd.setExperimental(false);
    sd.setPublisher("HL7");
    sd.setDescription("Defines the base elements and attributes on all CDA elements (other than data types)");
    sd.setKind(StructureDefinitionKind.LOGICAL);
    sd.setType(sd.getUrl());
    sd.setAbstract(true);
    sd.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace").setValue(new UriType("urn:hl7-org:v3"));
    sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/ANY");
    sd.setDerivation(TypeDerivationRule.SPECIALIZATION);
    ElementDefinition edb = new ElementDefinition();
    edb.setPath(sd.getId());
    seePath(edb);
    edb.setMin(1);
    edb.setMax("*");
    edb.addType().setCode("Element");
    sd.getDifferential().getElement().add(edb);
    ElementDefinition ed = new ElementDefinition();
    ed.setPath("InfrastructureRoot.realmCode");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("*");
    ed.setDefinition("When valued in an instance, this attribute signals the imposition of realm-specific constraints. The value of this attribute identifies the realm in question");
    ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/CS");
    sd.getDifferential().getElement().add(ed);
    ed = new ElementDefinition();
    ed.setPath("InfrastructureRoot.typeId");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("1");
    ed.setDefinition("When valued in an instance, this attribute signals the imposition of constraints defined in an HL7-specified message type. This might be a common type (also known as CMET in the messaging communication environment), or content included within a wrapper. The value of this attribute provides a unique identifier for the type in question.");
    ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/II");
    sd.getDifferential().getElement().add(ed);
    ed = new ElementDefinition();
    ed.setPath("InfrastructureRoot.templateId");
    seePath(ed);
    ed.setMin(0);
    ed.setMax("*");
    ed.setDefinition("When valued in an instance, this attribute signals the imposition of a set of template-defined constraints. The value of this attribute provides a unique identifier for the templates in question");
    ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/II");
    sd.getDifferential().getElement().add(ed);
    new ProfileUtilities(null, null, null).setIds(sd, true);
    structures.add(sd);
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition) UriType(org.hl7.fhir.r5.model.UriType)

Aggregations

ArrayList (java.util.ArrayList)226 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)199 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)120 FHIRException (org.hl7.fhir.exceptions.FHIRException)116 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)92 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)91 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)85 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)82 ElementDefinition (org.hl7.fhir.r4.model.ElementDefinition)68 TypeRefComponent (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent)60 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)57 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)51 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)50 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)46 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)44 ElementDefinition (org.hl7.fhir.dstu2016may.model.ElementDefinition)42 ElementDefinition (org.hl7.fhir.dstu2.model.ElementDefinition)41 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)41 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)38 List (java.util.List)37