Search in sources :

Example 6 with ElementDefn

use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.

the class PageProcessor method genBestPracticeList.

private void genBestPracticeList(StringBuilder b, ElementDefn e) throws Exception {
    for (Invariant inv : e.getInvariants().values()) {
        if ("best-practice".equals(inv.getSeverity())) {
            b.append("<tr>");
            b.append("<td>");
            b.append(inv.getId());
            b.append("</td>");
            b.append("<td>");
            b.append(inv.getEnglish());
            b.append("</td>");
            b.append("<td>");
            b.append(processMarkdown("best-practice-list", inv.getExplanation(), ""));
            b.append("</td>");
            b.append("</tr>\r\n");
        }
    }
    for (ElementDefn c : e.getElements()) {
        genBestPracticeList(b, c);
    }
}
Also used : Invariant(org.hl7.fhir.definitions.model.Invariant) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn)

Example 7 with ElementDefn

use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.

the class PageProcessor method parseConceptMapMapping.

private ConceptMap parseConceptMapMapping(ElementDefn logical, ElementDefinition resource, String src) throws FHIRException {
    if (!src.startsWith("{map:"))
        return null;
    ConceptMap map = new ConceptMap();
    map.setId(logical.getPath() + "2" + resource.getPath());
    map.setUrl("http://hl7.org/fhir/ConceptMap/" + map.getId());
    map.setVersion(version.toCode());
    ConceptMapGroupComponent grp = map.addGroup();
    String[] statements = src.substring(0, src.length() - 1).substring(5).split("\\;");
    if (statements.length == 0)
        throw new FHIRException("Unable to parse map details '" + src + "'");
    for (String s : statements) {
        String[] p = s.split("\\=");
        if (p.length < 2)
            throw new FHIRException("Unable to parse map details '" + src + "'");
        if (":default".equals(p[0].trim())) {
            grp.getUnmapped().setMode(ConceptMapGroupUnmappedMode.FIXED);
            grp.getUnmapped().setCode(p[1].trim());
        } else {
            grp.addElement().setCode(p[0].trim()).addTarget().setRelationship(ConceptMapRelationship.EQUIVALENT).setCode(p[1].trim());
        }
    }
    return map;
}
Also used : ConceptMap(org.hl7.fhir.r5.model.ConceptMap) FHIRException(org.hl7.fhir.exceptions.FHIRException) ConceptMapGroupComponent(org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent)

Example 8 with ElementDefn

use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.

the class PageProcessor method genConstraints.

private String genConstraints(String name, String prefix) throws Exception {
    Map<String, String> invs = new HashMap<String, String>();
    if (definitions.getConstraints().containsKey(name)) {
        ProfiledType cnst = definitions.getConstraints().get(name);
        generateConstraintsTable(name, cnst, invs, true, prefix);
    } else {
        ElementDefn e = definitions.getElementDefn(name);
        generateConstraintsTable(name, e, invs, true, prefix);
    }
    List<String> ids = new ArrayList<String>();
    for (String n : invs.keySet()) {
        ids.add(n);
    }
    Collections.sort(ids, new ConstraintsSorter());
    StringBuilder b = new StringBuilder();
    for (String n : ids) {
        b.append(invs.get(n));
    }
    if (b.length() > 0)
        return "<a name=\"" + name + "-inv\"> </a><table class=\"grid\"><tr><td width=\"60\"><b>id</b></td><td><b>Level</b></td><td><b>Location</b></td><td><b>Description</b></td><td><b><a href=\"" + prefix + "fhirpath.html\">Expression</a></b></td></tr>" + b + "</table>";
    else
        return "";
}
Also used : ProfiledType(org.hl7.fhir.definitions.model.ProfiledType) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) HashMap(java.util.HashMap) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) ArrayList(java.util.ArrayList)

Example 9 with ElementDefn

use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.

the class PageProcessor method getReferences.

private String getReferences(String name) throws Exception {
    List<String> refs = new ArrayList<String>();
    if (definitions.hasLogicalModel(name)) {
        ElementDefn r = definitions.getLogicalModel(name).getResource().getRoot();
        List<String> names = definitions.listAllPatterns(r.getName());
        for (String rn : definitions.sortedResourceNames()) {
            checkPatternReferences(names, refs, rn, definitions.getResourceByName(rn).getRoot(), definitions.getLogicalModel(name).getMappingUrl());
        }
        if (refs.size() == 1)
            return "<h2>References</h2><p>This pattern is implemented by " + renderRef(refs.get(0), name) + ".</p>\r\n";
        else if (refs.size() > 1)
            return "<h2>References</h2><p>This pattern is implemented by " + asLinks(refs, name) + ".</p>\r\n";
        else
            return "<h2>References</h2><p>No resources follow this pattern.</p>";
    } else {
        for (String tn : definitions.sortedTypeNames()) {
            checkReferences(name, refs, tn, definitions.getElementDefn(tn));
        }
        for (String rn : definitions.sortedResourceNames()) {
            checkReferences(name, refs, rn, definitions.getResourceByName(rn).getRoot());
        }
        String r;
        if (refs.size() == 1)
            r = "<h2>References</h2><p>This resource is referenced by " + renderRef(refs.get(0), name) + ".</p>\r\n";
        else if (refs.size() > 1)
            r = "<h2>References</h2><p>This resource is referenced by " + asLinks(refs, name) + ".</p>\r\n";
        else
            r = "<h2>References</h2><p>No resources refer to this resource directly.</p>";
        refs.clear();
        for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
            for (LogicalModel lm : ig.getLogicalModels()) {
                checkPatternUsage(lm.getResource().getRoot().getName(), refs, definitions.getResourceByName(name).getRoot(), lm.getMappingUrl());
            }
        }
        if (refs.size() == 1)
            return r + "<p>This resource implements the " + renderRef(refs.get(0), name) + " pattern.</p>\r\n";
        else if (refs.size() > 1)
            return r + "<p>This resource implements the " + asLinks(refs, name) + " patterns.</p>\r\n";
        else
            return r + "<p>This resource does not implement any patterns.</p>";
    }
}
Also used : LogicalModel(org.hl7.fhir.definitions.model.LogicalModel) ArrayList(java.util.ArrayList) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn)

Example 10 with ElementDefn

use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.

the class PageProcessor method genDTCodes.

private String genDTCodes() {
    StringBuilder html = new StringBuilder();
    List<String> names = new ArrayList<String>();
    names.addAll(definitions.getTypes().keySet());
    names.addAll(definitions.getInfrastructure().keySet());
    Collections.sort(names);
    for (String n : names) {
        if (!definitions.dataTypeIsSharedInfo(n)) {
            ElementDefn c = definitions.getTypes().get(n);
            if (c == null)
                c = definitions.getInfrastructure().get(n);
            if (c.getName().equals("Extension"))
                html.append("  <tr><td><a href=\"extensibility.html\">" + c.getName() + "</a></td><td>" + Utilities.escapeXml(c.getDefinition()) + "</td></tr>");
            else if (c.getName().equals("Narrative"))
                html.append("  <tr><td><a href=\"narrative.html#" + c.getName() + "\">" + c.getName() + "</a></td><td>" + Utilities.escapeXml(c.getDefinition()) + "</td></tr>");
            else if (c.getName().equals("Reference"))
                html.append("  <tr><td><a href=\"references.html#" + c.getName() + "\">" + c.getName() + "</a></td><td>" + Utilities.escapeXml(c.getDefinition()) + "</td></tr>");
            else if (c.getName().equals("canonical"))
                html.append("  <tr><td><a href=\"references.html#" + c.getName() + "\">" + c.getName() + "</a></td><td>" + Utilities.escapeXml(c.getDefinition()) + "</td></tr>");
            else
                html.append("  <tr><td><a href=\"datatypes.html#" + c.getName() + "\">" + c.getName() + "</a></td><td>" + Utilities.escapeXml(c.getDefinition()) + "</td></tr>");
        }
    }
    return html.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ArrayList(java.util.ArrayList) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn)

Aggregations

ElementDefn (org.hl7.fhir.definitions.model.ElementDefn)100 TypeRef (org.hl7.fhir.definitions.model.TypeRef)35 ArrayList (java.util.ArrayList)28 FHIRException (org.hl7.fhir.exceptions.FHIRException)28 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)21 ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)19 Invariant (org.hl7.fhir.definitions.model.Invariant)16 IOException (java.io.IOException)14 BindingSpecification (org.hl7.fhir.definitions.model.BindingSpecification)11 FileNotFoundException (java.io.FileNotFoundException)10 URISyntaxException (java.net.URISyntaxException)10 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)10 ProfiledType (org.hl7.fhir.definitions.model.ProfiledType)9 TransformerException (javax.xml.transform.TransformerException)8 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)8 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)7 NotImplementedException (org.apache.commons.lang3.NotImplementedException)7 UcumException (org.fhir.ucum.UcumException)7 TypeParser (org.hl7.fhir.definitions.parsers.TypeParser)7 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)7