Search in sources :

Example 21 with StructureDefinition

use of org.hl7.fhir.dstu2016may.model.StructureDefinition in project kindling by HL7.

the class Publisher method minifyProfile.

private void minifyProfile(StructureDefinition p) {
    p.getContact().clear();
    p.setDescriptionElement(null);
    p.getKeyword().clear();
    p.setPurposeElement(null);
    p.getMapping().clear();
    p.setDifferential(null);
    for (ElementDefinition ed : p.getSnapshot().getElement()) {
        ed.setShortElement(null);
        ed.setDefinitionElement(null);
        ed.setCommentElement(null);
        ed.setRequirementsElement(null);
        ed.getAlias().clear();
        ed.setMeaningWhenMissingElement(null);
        ed.getMapping().clear();
    }
}
Also used : ElementDefinition(org.hl7.fhir.r5.model.ElementDefinition)

Example 22 with StructureDefinition

use of org.hl7.fhir.dstu2016may.model.StructureDefinition in project kindling by HL7.

the class Publisher method genPrimitiveTypeProfile.

private void genPrimitiveTypeProfile(DefinedStringPattern t) throws Exception {
    StructureDefinition profile = new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(t);
    if (page.getProfiles().has(profile.getUrl()))
        throw new Exception("Duplicate Profile URL " + profile.getUrl());
    page.getProfiles().see(profile, page.packageInfo());
    t.setProfile(profile);
// DataTypeTableGenerator dtg = new DataTypeTableGenerator(page.getFolders().dstDir, page, t.getCode(), true);
// t.setProfile(profile);
// t.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
// t.getProfile().getText().getDiv().getChildNodes().add(dtg.generate(t));
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileGenerator(org.hl7.fhir.definitions.generators.specification.ProfileGenerator) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 23 with StructureDefinition

use of org.hl7.fhir.dstu2016may.model.StructureDefinition in project kindling by HL7.

the class PageProcessor method produceDataTypeExtras.

private String produceDataTypeExtras(String tn, boolean profiles) {
    int count = 0;
    Map<String, StructureDefinition> map = new HashMap<String, StructureDefinition>();
    for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
        boolean inc = false;
        for (StructureDefinitionContextComponent ec : sd.getContext()) {
            if (ec.getType() == ExtensionContextType.ELEMENT) {
                inc = inc || matchesType(tn, ec.getExpression());
            }
        }
        if (inc)
            map.put(sd.getId(), sd);
    }
    StringBuilder b = new StringBuilder();
    b.append("  <tr><td colspan=\"3\"><b>Extensions</b> (+ see <a href=\"" + definitions.getElementExtrasLink() + "\">extensions on all Elements</a>)</td></tr>\r\n");
    for (String s : sorted(map.keySet())) {
        StructureDefinition cs = map.get(s);
        count++;
        b.append("  <tr>\r\n");
        String ref = cs.getUserString("path");
        b.append("    <td><a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.getId())).append("</a></td>\r\n");
        b.append("    <td>").append(Utilities.escapeXml(cs.getName())).append("</td>\r\n");
        Profile ap = (Profile) cs.getUserData("profile");
        if (ap == null)
            b.append("    <td></td>\r\n");
        else {
            ImplementationGuideDefn ig = definitions.getIgs().get(ap.getCategory());
            b.append("    <td>for <a href=\"" + ig.getPrefix() + ap.getId().toLowerCase() + ".html\">" + Utilities.escapeXml(ap.getTitle()) + "</a></td>\r\n");
        }
        b.append(" </tr>\r\n");
    }
    if (count == 0)
        b.append("<tr><td>No Extensions defined for " + (tn.equals("primitives") ? "primitive types" : "this type") + " (though see <a href=\"element-extensions.html\">extensions on all Elements</a>)</td></tr>");
    if (profiles) {
        count = 0;
        Map<String, CSPair> pmap = new HashMap<String, CSPair>();
        for (Profile ap : definitions.getPackList()) {
            for (ConstraintStructure cs : ap.getProfiles()) {
                if (coversType(cs, tn))
                    pmap.put(cs.getTitle(), new CSPair(ap, cs));
            }
        }
        b.append("  <tr><td colspan=\"3\"><b>Profiles</b></td></tr>\r\n");
        for (String s : sorted(pmap.keySet())) {
            CSPair cs = pmap.get(s);
            ImplementationGuideDefn ig = definitions.getIgs().get(cs.p.getCategory());
            count++;
            b.append("  <tr>\r\n");
            String ref = (ig.isCore() ? "" : ig.getCode() + File.separator) + cs.cs.getId() + ".html";
            b.append("    <td><a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.cs.getTitle())).append("</a></td>\r\n");
            b.append("    <td>").append(Utilities.escapeXml(cs.p.getDescription())).append("</td>\r\n");
            ref = (ig.isCore() ? "" : ig.getCode() + File.separator) + cs.p.getId().toLowerCase() + ".html";
            b.append("    <td>for <a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.p.getTitle())).append("</a></td>\r\n");
            b.append(" </tr>\r\n");
        }
        if (count == 0)
            b.append("<tr><td>No Profiles defined for for " + (tn.equals("primitives") ? "primitive types" : "this type") + "</td></tr>");
    }
    return b.toString();
}
Also used : StructureDefinitionContextComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionContextComponent) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) HashMap(java.util.HashMap) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) Profile(org.hl7.fhir.definitions.model.Profile) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure)

Example 24 with StructureDefinition

use of org.hl7.fhir.dstu2016may.model.StructureDefinition in project kindling by HL7.

the class PageProcessor method genExtensionsTable.

private String genExtensionsTable() throws Exception {
    StringBuilder s = new StringBuilder();
    s.append("<table class=\"list\">\r\n");
    s.append("<tr>");
    s.append("<td><b>Identity</b></td>");
    s.append("<td><b><a href=\"defining-extensions.html#cardinality\">Conf.</a></b></td>");
    s.append("<td><b>Type</b></td>");
    s.append("<td><b><a href=\"defining-extensions.html#context\">Context</a></b></td>");
    s.append("<td><b><a href=\"versions.html#maturity\">FMM</a></b></td>");
    s.append("</tr>");
    List<String> names = new ArrayList<String>();
    for (StructureDefinition sd : workerContext.getExtensionDefinitions()) names.add(sd.getUrl());
    Collections.sort(names);
    Set<StructureDefinition> processed = new HashSet<StructureDefinition>();
    for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
        // if (ig.isCore()) {
        for (String n : names) {
            StructureDefinition ed = workerContext.fetchResource(StructureDefinition.class, n);
            if (!processed.contains(ed)) {
                processed.add(ed);
                // if (ig.getCode().equals(ToolResourceUtilities.getUsage(ed))) {
                genExtensionRow(ig, s, ed);
            // }
            }
        }
    // }
    }
    s.append("</table>\r\n");
    return s.toString();
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ArrayList(java.util.ArrayList) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) HashSet(java.util.HashSet)

Example 25 with StructureDefinition

use of org.hl7.fhir.dstu2016may.model.StructureDefinition in project kindling by HL7.

the class PageProcessor method genExampleProfileLink.

private String genExampleProfileLink(Resource resource) throws FHIRException {
    if (resource == null || !(resource instanceof StructureDefinition))
        return "";
    StructureDefinition sd = (StructureDefinition) resource;
    if (!sd.hasBaseDefinition())
        return "";
    String pack = "";
    if (sd.hasUserData("pack")) {
        Profile p = (Profile) sd.getUserData("pack");
        ImplementationGuideDefn ig = definitions.getIgs().get(p.getCategory());
        if (Utilities.noString(ig.getHomePage()))
            pack = " (" + ig.getName() + "))";
        else
            pack = " (<a href=\"" + ig.getHomePage() + "\">" + ig.getName() + "</a>)";
        if (!p.getTitle().equals(sd.getName()))
            pack = " in <a href=\"" + p.getId().toLowerCase() + ".html\">" + p.getTitle() + "</a> " + pack;
    }
    if (sd.hasUserData("path"))
        return "This example conforms to the <a href=\"" + sd.getUserData("path") + "\">profile " + (sd.getName()) + "</a>" + pack + ".";
    else
        return "This example conforms to the <a href=\"" + sd.getId().toLowerCase() + ".html\">profile " + (sd.getName()) + "</a>" + pack + ".";
}
Also used : StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) Profile(org.hl7.fhir.definitions.model.Profile)

Aggregations

ArrayList (java.util.ArrayList)307 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)241 FHIRException (org.hl7.fhir.exceptions.FHIRException)226 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)158 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)144 StructureDefinition (org.hl7.fhir.r4b.model.StructureDefinition)105 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)98 IOException (java.io.IOException)91 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)91 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)87 StructureDefinition (org.hl7.fhir.r4.model.StructureDefinition)83 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)70 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)69 ElementDefinition (org.hl7.fhir.r4b.model.ElementDefinition)67 FHIRFormatError (org.hl7.fhir.exceptions.FHIRFormatError)58 ElementDefinition (org.hl7.fhir.r4.model.ElementDefinition)56 TypeRefComponent (org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent)50 Piece (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Piece)49 ProfileUtilities (org.hl7.fhir.r5.conformance.ProfileUtilities)46 Cell (org.hl7.fhir.utilities.xhtml.HierarchicalTableGenerator.Cell)46