Search in sources :

Example 16 with WorkGroup

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

the class ProfileGenerator method generate.

public StructureDefinition generate(Profile pack, ConstraintStructure profile, ResourceDefn resource, String id, String html, ImplementationGuideDefn usage, List<ValidationMessage> issues, ResourceDefn baseResource) throws Exception {
    if (profile.getResource() != null)
        return profile.getResource();
    StructureDefinition p = new StructureDefinition();
    p.setId(FormatUtilities.makeId(id));
    p.setUrl("http://hl7.org/fhir/StructureDefinition/" + id);
    if (usage != null && !usage.isCore()) {
        if (!id.startsWith(usage.getCode() + "-"))
            throw new Exception("Error: " + id + " must start with " + usage.getCode() + "-");
    }
    if (!resource.getRoot().getTypes().isEmpty() && (resource.getRoot().getTypes().get(0).getProfile() != null))
        p.setBaseDefinition(resource.getRoot().getTypes().get(0).getProfile());
    else
        p.setBaseDefinition("http://hl7.org/fhir/StructureDefinition/" + resource.getName());
    if (definitions.hasType(resource.getName()))
        p.setKind(StructureDefinitionKind.COMPLEXTYPE);
    else
        p.setKind(StructureDefinitionKind.RESOURCE);
    p.setType(resource.getName());
    p.setDerivation(TypeDerivationRule.CONSTRAINT);
    p.setAbstract(false);
    p.setUserData("filename", id);
    p.setUserData("path", ((usage == null || usage.isCore()) ? "" : usage.getCode() + File.separator) + id + ".html");
    p.setTitle(pack.metadata("display"));
    p.setFhirVersion(version);
    p.setVersion(version.toCode());
    if (pack.hasMetadata("summary-" + profile.getTitle()))
        ToolingExtensions.addMarkdownExtension(p, "http://hl7.org/fhir/StructureDefinition/structuredefinition-summary", pack.metadata("summary-" + profile.getTitle()));
    ToolResourceUtilities.updateUsage(p, usage.getCode());
    p.setName(pack.metadata("name"));
    p.setPublisher(pack.metadata("author.name"));
    if (pack.hasMetadata("author.reference"))
        p.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, pack.metadata("author.reference")));
    // <code> opt Zero+ Coding assist with indexing and finding</code>
    p.setDescription(resource.getRoot().getShortDefn());
    if (!p.hasDescriptionElement() && pack.hasMetadata("description"))
        p.setDescription(preProcessMarkdown(pack.metadata("description"), "pack.description"));
    p.setPurpose(resource.getRoot().getRequirements());
    if (!p.hasPurpose() && pack.hasMetadata("requirements"))
        p.setPurpose(pack.metadata("requirements"));
    p.setExperimental(Utilities.existsInList(pack.metadata("Experimental"), "y", "Y", "true", "TRUE", "1"));
    if (pack.hasMetadata("date"))
        p.setDateElement(Factory.newDateTime(pack.metadata("date").substring(0, 10)));
    else
        p.setDate(genDate.getTime());
    if (pack.hasMetadata("fmm-level"))
        ToolingExtensions.addIntegerExtension(p, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(pack.getFmmLevel()));
    else if (pack.hasMetadata("fmm"))
        ToolingExtensions.addIntegerExtension(p, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(pack.metadata("fmm")));
    else if (!Utilities.noString(resource.getFmmLevel()))
        ToolingExtensions.addIntegerExtension(p, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(resource.getFmmLevel()));
    else if (baseResource != null && !Utilities.noString(baseResource.getFmmLevel()))
        ToolingExtensions.addIntegerExtension(p, ToolingExtensions.EXT_FMM_LEVEL, Integer.parseInt(baseResource.getFmmLevel()));
    if (pack.hasMetadata("workgroup"))
        ToolingExtensions.setCodeExtension(p, ToolingExtensions.EXT_WORKGROUP, pack.getWg());
    else if (resource.getWg() != null)
        ToolingExtensions.setCodeExtension(p, ToolingExtensions.EXT_WORKGROUP, resource.getWg().getCode());
    else if (baseResource != null && baseResource.getWg() != null)
        ToolingExtensions.setCodeExtension(p, ToolingExtensions.EXT_WORKGROUP, baseResource.getWg().getCode());
    if (pack.hasMetadata("Standards-Status"))
        ToolingExtensions.setStandardsStatus(p, StandardsStatus.fromCode(pack.metadata("Standards-Status")), null);
    else
        ToolingExtensions.setStandardsStatus(p, resource.getStatus(), null);
    if (pack.hasMetadata("status"))
        p.setStatus(PublicationStatus.fromCode(pack.metadata("status")));
    if (pack.getMetadata().containsKey("code"))
        for (String s : pack.getMetadata().get("code")) if (!Utilities.noString(s))
            p.getKeyword().add(Factory.makeCoding(s));
    if (pack.hasMetadata("datadictionary"))
        ToolingExtensions.setStringExtension(p, "http://hl7.org/fhir/StructureDefinition/datadictionary", pack.metadata("datadictionary"));
    Set<String> containedSlices = new HashSet<String>();
    p.setDifferential(new StructureDefinitionDifferentialComponent());
    defineElement(pack, p, p.getDifferential().getElement(), resource.getRoot(), resource.getName(), containedSlices, new ArrayList<ProfileGenerator.SliceHandle>(), SnapShotMode.None, true, null, null, false);
    List<String> names = new ArrayList<String>();
    names.addAll(resource.getSearchParams().keySet());
    Collections.sort(names);
    for (String pn : names) {
        pack.getSearchParameters().add(makeSearchParam(p, pack.getId() + "-" + resource.getName() + "-" + pn, resource.getName(), resource.getSearchParams().get(pn), resource));
    }
    StructureDefinition base = definitions.getSnapShotForBase(p.getBaseDefinition());
    List<String> errors = new ArrayList<String>();
    new ProfileUtilities(context, null, pkp).sortDifferential(base, p, p.getName(), errors, false);
    for (String s : errors) issues.add(new ValidationMessage(Source.ProfileValidator, IssueType.STRUCTURE, -1, -1, p.getUrl(), s, IssueSeverity.WARNING));
    reset();
    // ok, c is the differential. now we make the snapshot
    new ProfileUtilities(context, issues, pkp).generateSnapshot(base, p, "http://hl7.org/fhir/StructureDefinition/" + p.getType(), "http://hl7.org/fhir", p.getName());
    reset();
    p.getDifferential().getElement().get(0).getType().clear();
    p.getSnapshot().getElement().get(0).getType().clear();
    addElementConstraintToSnapshot(p);
    XhtmlNode div = new XhtmlNode(NodeType.Element, "div");
    div.addText("to do");
    p.setText(new Narrative());
    p.getText().setStatus(NarrativeStatus.GENERATED);
    p.getText().setDiv(div);
    new ProfileUtilities(context, issues, pkp).setIds(p, false);
    checkHasTypes(p);
    return p;
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) ArrayList(java.util.ArrayList) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) ProfileUtilities(org.hl7.fhir.r5.conformance.ProfileUtilities) Narrative(org.hl7.fhir.r5.model.Narrative) StructureDefinitionDifferentialComponent(org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionDifferentialComponent) HashSet(java.util.HashSet)

Example 17 with WorkGroup

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

the class PageProcessor method loadXmlNotes.

private String loadXmlNotes(String name, String suffix, boolean checkHeaders, String definition, StructureDefinition sd, List<String> tabs, ImplementationGuideDefn ig, WorkGroup wg) throws Exception {
    String filename;
    if (definitions.hasLogicalModel(name)) {
        LogicalModel lm = definitions.getLogicalModel(name);
        filename = Utilities.changeFileExt(lm.getSource(), "-" + suffix + ".xml");
    } else
        filename = folders.srcDir + name + File.separatorChar + name + "-" + suffix + ".xml";
    return loadXmlNotesFromFile(filename, checkHeaders, definition, null, tabs, ig, wg);
}
Also used : LogicalModel(org.hl7.fhir.definitions.model.LogicalModel)

Example 18 with WorkGroup

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

the class PageProcessor method genWGReport.

private String genWGReport() throws Exception {
    StringBuilder b = new StringBuilder();
    b.append("<table class=\"grid\">\r\n");
    b.append("  <tr><td><b>Resource</b></td><td>FMM</td></tr>\r\n");
    for (String n : sorted(definitions.getWorkgroups().keySet())) {
        WorkGroup wg = definitions.getWorkgroups().get(n);
        b.append(" <tr><td colspan=\"2\"><b>" + n + " (" + wg.getName() + ")</b></td></tr>\r\n");
        for (String rn : definitions.sortedResourceNames()) {
            ResourceDefn r = definitions.getResourceByName(rn);
            if (r.getWg() == wg) {
                b.append("  <tr><td><a href=\"" + rn.toLowerCase() + ".html\">" + rn + "</a></td><td>" + r.getFmmLevel() + "</td></tr>\r\n");
            }
        }
    }
    b.append("</table>\r\n");
    return b.toString();
}
Also used : WorkGroup(org.hl7.fhir.definitions.model.WorkGroup) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 19 with WorkGroup

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

the class PageProcessor method buildCommitteeList.

private String buildCommitteeList() {
    StringBuilder b = new StringBuilder();
    boolean first = true;
    for (String s : sorted(definitions.getWorkgroups().keySet())) {
        WorkGroup wg = definitions.getWorkgroups().get(s);
        if (first)
            first = false;
        else
            b.append(", ");
        b.append("<a href=\"");
        b.append(wg.getUrl());
        b.append("\">");
        b.append(Utilities.escapeXml(wg.getName()));
        b.append("</a>");
    }
    return b.toString();
}
Also used : WorkGroup(org.hl7.fhir.definitions.model.WorkGroup) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder)

Example 20 with WorkGroup

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

the class PageProcessor method jsonToXhtml.

public void jsonToXhtml(String src, String dst, String name, String description, int level, String json, String pageType, String crumbTitle, ImplementationGuideDefn ig, ResourceDefn rd, WorkGroup wg) throws Exception {
    String n = new File(dst).getName();
    n = n.substring(0, n.length() - 10);
    json = "<div class=\"example\">\r\n<p>" + Utilities.escapeXml(description) + "</p>\r\n<pre class=\"json\">\r\n" + Utilities.escapeXml(json) + "\r\n</pre>\r\n</div>\r\n";
    String html = ("<%setlevel " + Integer.toString(level) + "%>" + TextFile.fileToString(folders.srcDir + "template-example-json.html")).replace("<%example%>", json);
    html = processPageIncludes(n + ".json.html", html, pageType, null, null, null, crumbTitle, ig, rd, wg);
    TextFile.stringToFile(html, dst);
    htmlchecker.registerExternal(dst);
}
Also used : IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)13 FileNotFoundException (java.io.FileNotFoundException)9 IOException (java.io.IOException)9 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)9 CSFile (org.hl7.fhir.utilities.CSFile)9 ConstraintStructure (org.hl7.fhir.definitions.model.ConstraintStructure)8 WorkGroup (org.hl7.fhir.definitions.model.WorkGroup)8 File (java.io.File)7 ArrayList (java.util.ArrayList)6 TransformerException (javax.xml.transform.TransformerException)6 TextFile (org.hl7.fhir.utilities.TextFile)6 URISyntaxException (java.net.URISyntaxException)5 CSFileInputStream (org.hl7.fhir.utilities.CSFileInputStream)5 IniFile (org.hl7.fhir.utilities.IniFile)5 Date (java.util.Date)4 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)4 NotImplementedException (org.apache.commons.lang3.NotImplementedException)4 UcumException (org.fhir.ucum.UcumException)4 ResourceDefn (org.hl7.fhir.definitions.model.ResourceDefn)4 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)4