Search in sources :

Example 1 with ElementDefn

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

the class Publisher method produceCoverageWarnings.

private void produceCoverageWarnings() throws Exception {
    for (ElementDefn e : page.getDefinitions().getTypes().values()) produceCoverageWarning("", e);
    for (String s : page.getDefinitions().sortedResourceNames()) {
        ResourceDefn e = page.getDefinitions().getResourceByName(s);
        produceCoverageWarning("", e.getRoot());
    }
}
Also used : ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 2 with ElementDefn

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

the class PageProcessor method genStatusCodes.

private String genStatusCodes() throws Exception {
    StringBuilder b = new StringBuilder();
    b.append("<table border=\"1\">\r\n");
    int colcount = 0;
    for (ArrayList<String> row : definitions.getStatusCodes().values()) {
        int rc = 0;
        for (int i = 0; i < row.size(); i++) if (!Utilities.noString(row.get(i)))
            rc = i;
        if (rc > colcount)
            colcount = rc;
    }
    // b.append("<tr>");
    // b.append("<td>Path</td>");
    // for (int i = 0; i < colcount; i++)
    // b.append("<td>c").append(Integer.toString(i + 1)).append("</td>");
    // b.append("</tr>\r\n");
    List<String> names = new ArrayList<String>();
    for (String n : definitions.getStatusCodes().keySet()) names.add(n);
    Collections.sort(names);
    ArrayList<String> row = definitions.getStatusCodes().get("@code");
    b.append("<tr>");
    b.append("<td><b>code</b></td>");
    for (int i = 0; i < colcount; i++) b.append("<td><b><a href=\"codesystem-resource-status.html#resource-status-" + row.get(i) + "\">").append(row.get(i)).append("</a></b></td>");
    b.append("</tr>\r\n");
    row = definitions.getStatusCodes().get("@codes");
    b.append("<tr>");
    b.append("<td><b>stated codes</b></td>");
    for (int i = 0; i < colcount; i++) b.append("<td>").append(i < row.size() ? row.get(i) : "").append("</td>");
    b.append("</tr>\r\n");
    b.append("<tr>");
    b.append("<td>actual codes</td>");
    for (int i = 0; i < colcount; i++) {
        Set<String> codeset = new HashSet<String>();
        for (String n : names) {
            if (!n.startsWith("@")) {
                row = definitions.getStatusCodes().get(n);
                String c = row.get(i);
                if (!Utilities.noString(c)) {
                    codeset.add(c);
                }
            }
        }
        b.append("<td>").append(separated(codeset, ", ")).append("</td>");
    }
    b.append("</tr>\r\n");
    row = definitions.getStatusCodes().get("@issues");
    b.append("<tr>");
    b.append("<td><b>Issues?</b></td>");
    for (int i = 0; i < colcount; i++) {
        String s = i < row.size() ? row.get(i) : "";
        b.append("<td").append(Utilities.noString(s) ? "" : " style=\"background-color: #ffcccc\"").append(">").append(s).append("</td>");
    }
    b.append("</tr>\r\n");
    for (String n : names) {
        if (!n.startsWith("@")) {
            b.append("<tr>");
            ElementDefn ed = getElementDefn(n);
            if (ed == null || !ed.isModifier())
                b.append("<td>").append(linkToPath(n)).append("</td>");
            else
                b.append("<td><b>").append(linkToPath(n)).append("</b></td>");
            row = definitions.getStatusCodes().get(n);
            for (int i = 0; i < colcount; i++) b.append("<td>").append(i < row.size() ? row.get(i) : "").append("</td>");
            b.append("</tr>\r\n");
        }
    }
    b.append("</table>\r\n");
    CodeSystem cs = getCodeSystems().get("http://hl7.org/fhir/resource-status");
    row = definitions.getStatusCodes().get("@code");
    for (int i = 0; i < colcount; i++) {
        String code = row.get(i);
        String definition = CodeSystemUtilities.getCodeDefinition(cs, code);
        Set<String> dset = new HashSet<String>();
        for (String n : names) {
            if (!n.startsWith("@")) {
                ArrayList<String> rowN = definitions.getStatusCodes().get(n);
                String c = rowN.get(i);
                String d = getDefinition(n, c);
                if (!Utilities.noString(d))
                    dset.add(d);
            }
        }
        b.append("<hr/>\r\n");
        b.append("<h4>").append(code).append("</h4>\r\n");
        b.append("<p>").append(Utilities.escapeXml(definition)).append("</p>\r\n");
        b.append("<p>Definitions for matching codes:</p>\r\n");
        b.append("<ul>\r\n");
        for (String s : sorted(dset)) b.append("<li>").append(Utilities.escapeXml(s)).append("</li>\r\n");
        b.append("</ul>\r\n");
    }
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ArrayList(java.util.ArrayList) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) HashSet(java.util.HashSet)

Example 3 with ElementDefn

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

the class PageProcessor method genResRefList.

private String genResRefList(String n) throws Exception {
    ResourceDefn e = definitions.getResourceByName(n);
    StringBuilder b = new StringBuilder();
    b.append("<ul>\r\n");
    for (ElementDefn c : e.getRoot().getElements()) genResRefItem(b, n.toLowerCase(), n, c);
    b.append("</ul>\r\n");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 4 with ElementDefn

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

the class PageProcessor method listAllbackboneClasses.

private void listAllbackboneClasses(List<String> classes, ElementDefn e, String path) {
    for (ElementDefn c : e.getElements()) {
        if (c.getElements().size() > 0) {
            String p = path + "." + c.getName();
            String n = Utilities.capitalize(c.getName());
            if (c.hasStatedType())
                n = c.getStatedType();
            classes.add(p + ":" + n);
            listAllbackboneClasses(classes, c, p);
        }
    }
}
Also used : ElementDefn(org.hl7.fhir.definitions.model.ElementDefn)

Example 5 with ElementDefn

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

the class PageProcessor method getElementDefn.

private ElementDefn getElementDefn(String n) throws Exception {
    String[] path = n.split("\\.");
    ElementDefn ed = definitions.getElementDefn(path[0]);
    for (int i = 1; i < path.length; i++) {
        if (ed == null)
            return null;
        ed = ed.getElementByName(definitions, path[i], true, false);
    }
    return ed;
}
Also used : ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) ContactPoint(org.hl7.fhir.r5.model.ContactPoint)

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