Search in sources :

Example 11 with Base

use of org.hl7.fhir.dstu2.model.Base in project kindling by HL7.

the class PageProcessor method processResourceIncludes.

String processResourceIncludes(String name, ResourceDefn resource, String xml, String json, String ttl, String tx, String dict, String src, String mappings, String mappingsList, String type, String pagePath, ImplementationGuideDefn ig, Map<String, String> otherValues, WorkGroup wg, Map<String, String> examples) throws Exception {
    String workingTitle = Utilities.escapeXml(resource.getName());
    List<String> tabs = new ArrayList<String>();
    int level = (ig == null || ig.isCore()) ? 0 : 1;
    while (src.contains("<%") || src.contains("[%")) {
        int i1 = src.indexOf("<%");
        int i2 = src.indexOf("%>");
        if (i1 == -1) {
            i1 = src.indexOf("[%");
            i2 = src.indexOf("%]");
        }
        String s1 = src.substring(0, i1);
        String s2 = src.substring(i1 + 2, i2).trim();
        String s3 = src.substring(i2 + 2);
        String[] com = s2.split(" ");
        String searchAdditions = "";
        if (com[0].equals("resheader"))
            src = s1 + resHeader(name, resource.getName(), com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("aresheader"))
            src = s1 + abstractResHeader(name, resource.getName(), com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("lmheader"))
            src = s1 + lmHeader(name, resource.getName(), com.length > 1 ? com[1] : null, false) + s3;
        else if (com[0].equals("file")) {
            if (new File(folders.templateDir + com[1] + ".html").exists()) {
                src = s1 + TextFile.fileToString(folders.templateDir + com[1] + ".html") + s3;
            } else {
                src = s1 + TextFile.fileToString(folders.srcDir + com[1] + ".html") + s3;
            }
        } else if (com[0].equals("settitle")) {
            workingTitle = s2.substring(9).replace("{", "<%").replace("}", "%>");
            src = s1 + s3;
        } else if (com[0].equals("complinks"))
            src = s1 + getCompLinks(resource, com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("othertabs"))
            src = s1 + genOtherTabs(com[1], tabs) + s3;
        else if (com[0].equals("svg"))
            src = s1 + new SvgGenerator(this, genlevel(level), resource.getLayout(), true, false, version).generate(resource, com[1]) + s3;
        else if (com[0].equals("normative")) {
            String np = null;
            if (com[2].equals("%check") || com[2].equals("%check-op")) {
                StandardsStatus st = resource.getStatus();
                boolean mixed = false;
                if (com[2].equals("%check-op") && st == StandardsStatus.NORMATIVE) {
                    for (Operation op : resource.getOperations()) {
                        if (op.getStandardsStatus() != null)
                            mixed = true;
                    }
                }
                if (st != null && (resource.getNormativePackage() != null || resource.getNormativeVersion() != null)) {
                    if (mixed)
                        np = getMixedNormativeNote(genlevel(level), resource.getNormativePackage(), com[1], workingTitle, name + ".html") + s3;
                    else
                        np = getNormativeNote(genlevel(level), resource.getNormativePackage(), com[1], workingTitle, name + ".html") + s3;
                }
            } else
                np = getNormativeNote(genlevel(level), resource.getNormativePackage(), com[1], workingTitle, name + ".html");
            if (np == null)
                src = s1 + s3;
            else
                src = s1 + np + s3;
        } else if (com.length != 1)
            throw new Exception("Instruction <%" + s2 + "%> not understood parsing resource " + name);
        else if (com[0].equals("pageheader"))
            src = s1 + pageHeader(resource.getName()) + s3;
        else if (com[0].equals("maponthispage"))
            src = s1 + mapOnThisPage(mappingsList) + s3;
        else if (com[0].equals("newheader"))
            src = s1 + TextFile.fileToString(folders.srcDir + "newheader.html") + s3;
        else if (com[0].equals("newheader1"))
            src = s1 + TextFile.fileToString(folders.srcDir + "newheader1.html") + s3;
        else if (com[0].equals("footer"))
            src = s1 + TextFile.fileToString(folders.srcDir + "footer.html") + s3;
        else if (com[0].equals("newfooter"))
            src = s1 + TextFile.fileToString(folders.srcDir + "newfooter.html") + s3;
        else if (com[0].equals("footer1"))
            src = s1 + TextFile.fileToString(folders.srcDir + "footer1.html") + s3;
        else if (com[0].equals("footer2"))
            src = s1 + TextFile.fileToString(folders.srcDir + "footer2.html") + s3;
        else if (com[0].equals("footer3"))
            src = s1 + TextFile.fileToString(folders.srcDir + "footer3.html") + s3;
        else if (com[0].equals("title"))
            src = s1 + workingTitle + s3;
        else if (com[0].equals("xtitle"))
            src = s1 + Utilities.escapeXml(resource.getName()) + s3;
        else if (com[0].equals("status"))
            src = s1 + resource.getStatus() + s3;
        else if (com[0].equals("draft-note"))
            src = s1 + getDraftNote(resource) + s3;
        else if (com[0].equals("introduction"))
            src = s1 + loadXmlNotes(name, "introduction", true, resource.getRoot().getDefinition(), resource, tabs, null, wg) + s3;
        else if (com[0].equals("notes"))
            src = s1 + loadXmlNotes(name, "notes", false, null, resource, tabs, null, wg) + s3;
        else if (com[0].equals("examples"))
            src = s1 + produceExamples(resource) + s3;
        else if (com[0].equals("profilelist"))
            src = s1 + produceProfiles(resource) + s3;
        else if (com[0].equals("extensionlist"))
            src = s1 + produceExtensions(resource) + s3;
        else if (com[0].equals("extensionreflist"))
            src = s1 + produceRefExtensions(resource) + s3;
        else if (com[0].equals("searchextensionlist"))
            src = s1 + produceSearchExtensions(resource) + s3;
        else if (com[0].equals("wg"))
            src = s1 + (resource.getWg() == null ? "null" : resource.getWg().getUrl()) + s3;
        else if (com[0].equals("wgt"))
            src = s1 + (resource.getWg() == null ? "null" : resource.getWg().getName()) + s3;
        else if (com[0].equals("fmm"))
            if (resource.getNormativeVersion() != null)
                src = s1 + "<a href=\"versions.html#maturity\">Maturity Level</a>: <a href=\"versions.html#std-process\">N</a>" + s3;
            else
                src = s1 + "<a href=\"versions.html#maturity\">Maturity Level</a>: " + resource.getFmmLevel() + "" + s3;
        else if (com[0].equals("sec-cat"))
            src = s1 + (resource.getSecurityCategorization() == null ? "" : "<a href=\"security.html#SecPrivConsiderations\">Security Category</a>: " + resource.getSecurityCategorization().toDisplay()) + s3;
        else if (com[0].equals("sstatus"))
            src = s1 + getStandardsStatus(resource.getName()) + s3;
        else if (com[0].equals("example-list"))
            src = s1 + produceExampleList(resource) + s3;
        else if (com[0].equals("name"))
            src = s1 + name + s3;
        else if (com[0].equals("cname"))
            src = s1 + resource.getName() + s3;
        else if (com[0].equals("search-additions")) {
            searchAdditions = s2.substring(16).trim();
            src = s1 + s3;
        } else if (com[0].equals("search"))
            src = s1 + getSearch(resource, searchAdditions) + s3;
        else if (com[0].equals("asearch"))
            src = s1 + getAbstractSearch(resource, searchAdditions) + s3;
        else if (com[0].equals("version"))
            src = s1 + ini.getStringProperty("FHIR", "version") + s3;
        else if (com[0].equals("gendate"))
            src = s1 + Config.DATE_FORMAT().format(new Date()) + s3;
        else if (com[0].equals("definition"))
            src = s1 + processMarkdown("resource.definition", resource.getRoot().getDefinition(), "", true) + s3;
        else if (com[0].equals("xml"))
            src = s1 + xml + s3;
        else if (com[0].equals("json"))
            src = s1 + json + s3;
        else if (com[0].equals("ttl"))
            src = s1 + ttl + s3;
        else if (com[0].equals("tx"))
            src = s1 + tx + s3;
        else if (com[0].equals("inv"))
            src = s1 + genResourceConstraints(resource, genlevel(level)) + s3;
        else if (com[0].equals("resource-table"))
            src = s1 + genResourceTable(resource, genlevel(level)) + s3;
        else if (com[0].equals("plural"))
            src = s1 + Utilities.pluralizeMe(name) + s3;
        else if (com[0].equals("dictionary"))
            src = s1 + dict + s3;
        else if (com[0].equals("mappings"))
            src = s1 + mappings + s3;
        else if (com[0].equals("mappingslist"))
            src = s1 + mappingsList + s3;
        else if (com[0].equals("breadcrumb"))
            src = s1 + breadCrumbManager.make(name) + s3;
        else if (com[0].equals("ext-link"))
            src = s1 + getExtensionsLink(resource) + s3;
        else if (com[0].equals("navlist"))
            src = s1 + breadCrumbManager.navlist(name, genlevel(level)) + s3;
        else if (com[0].equals("breadcrumblist"))
            src = s1 + ((ig == null || ig.isCore()) ? breadCrumbManager.makelist(name, type, genlevel(level), workingTitle) : ig.makeList(name, type, genlevel(level), workingTitle)) + s3;
        else if (com[0].equals("year"))
            src = s1 + new SimpleDateFormat("yyyy").format(new Date()) + s3;
        else if (com[0].equals("buildId"))
            src = s1 + buildId + s3;
        else if (com[0].equals("level"))
            src = s1 + genlevel(level) + s3;
        else if (com[0].equals("atitle"))
            src = s1 + abstractResourceTitle(resource) + s3;
        else if (com[0].equals("pub-type"))
            src = s1 + publicationType + s3;
        else if (com[0].equals("example-header"))
            src = s1 + loadXmlNotesFromFile(Utilities.path(folders.srcDir, name.toLowerCase(), name + "-examples-header.xml"), false, null, resource, tabs, null, wg) + s3;
        else if (com[0].equals("pub-notice"))
            src = s1 + publicationNotice + s3;
        else if (com[0].equals("resref"))
            src = s1 + getReferences(resource.getName()) + s3;
        else if (com[0].equals("pagepath"))
            src = s1 + pagePath + s3;
        else if (com[0].equals("rellink")) {
            if (!pagePath.contains(".html"))
                throw new Error("Invalid link: " + pagePath + " at " + workingTitle);
            src = s1 + Utilities.URLEncode(pagePath) + s3;
        } else if (com[0].equals("baseURL"))
            src = s1 + Utilities.URLEncode(baseURL) + s3;
        else if (com[0].equals("baseURLn"))
            src = s1 + Utilities.appendForwardSlash(baseURL) + s3;
        else if (com[0].equals("operations")) {
            List<Operation> oplist = resource.getOperations();
            String n = resource.getName();
            String id = resource.getName().toLowerCase();
            boolean mixed = false;
            if (resource.getStatus() == StandardsStatus.NORMATIVE) {
                for (Operation op : resource.getOperations()) {
                    if (op.getStandardsStatus() != null)
                        mixed = true;
                }
            }
            src = s1 + genOperations(oplist, n, id, mixed, resource.getStatus(), "", resource.getNormativePackage()) + s3;
        } else if (com[0].equals("operations-summary"))
            src = s1 + genOperationsSummary(resource.getOperations(), resource) + s3;
        else if (com[0].equals("opcount"))
            src = s1 + genOpCount(resource.getOperations()) + s3;
        else if (com[0].startsWith("!"))
            src = s1 + s3;
        else if (com[0].equals("search-footer"))
            src = s1 + searchFooter(level) + s3;
        else if (com[0].equals("pattern-title"))
            src = s1 + resource.getName() + s3;
        else if (com[0].equals("search-header"))
            src = s1 + searchHeader(level) + s3;
        else if (com[0].equals("diff-analysis"))
            src = s1 + diffEngine.getDiffAsHtml(this, resource.getProfile()) + s3;
        else if (com[0].equals("r3r4transforms"))
            src = s1 + getR3r4transformNote(resource.getName()) + s3;
        else if (com[0].equals("fmm-style"))
            src = s1 + fmmBarColorStyle(resource) + s3;
        else if (otherValues.containsKey(com[0]))
            src = s1 + otherValues.get(com[0]) + s3;
        else if (com[0].equals("lmimplementations"))
            src = s1 + genImplementationList(resource) + s3;
        else if (com[0].equals("json-schema"))
            src = s1 + jsonSchema(resource.getName()) + s3;
        else if (com[0].equals("dependency-graph"))
            src = s1 + genDependencyGraph(resource, genlevel(level)) + s3;
        else if (com[0].equals("logical-mappings"))
            src = s1 + genLogicalMappings(resource, genlevel(level)) + s3;
        else if (com[0].equals("no-extensions-base-warning"))
            src = s1 + genNoExtensionsWarning(resource) + s3;
        else if (com[0].equals("res-ext-link"))
            src = s1 + genResExtLink(resource) + s3;
        else if (com[0].equals("pattern-analysis"))
            src = s1 + genLogicalAnalysis(resource, genlevel(level)) + s3;
        else if (com[0].equals("resurl")) {
            if (isAggregationEndpoint(resource.getName()))
                src = s1 + s3;
            else
                src = s1 + "<p>The resource name as it appears in a  RESTful URL is <a href=\"http.html#root\">[root]</a>/" + name + "/</p>" + s3;
        } else if (com[0].equals("res-type-count")) {
            src = s1 + definitions.getResources().size() + s3;
        } else if (macros.containsKey(com[0])) {
            src = s1 + macros.get(com[0]) + s3;
        } else
            throw new Exception("Instruction <%" + s2 + "%> not understood parsing resource " + name);
    }
    return src;
}
Also used : ArrayList(java.util.ArrayList) FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError) TransformerFactoryConfigurationError(javax.xml.transform.TransformerFactoryConfigurationError) Operation(org.hl7.fhir.definitions.model.Operation) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) UcumException(org.fhir.ucum.UcumException) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) FileNotFoundException(java.io.FileNotFoundException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Date(java.util.Date) SvgGenerator(org.hl7.fhir.definitions.generators.specification.SvgGenerator) IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile) StandardsStatus(org.hl7.fhir.utilities.StandardsStatus) SimpleDateFormat(java.text.SimpleDateFormat)

Example 12 with Base

use of org.hl7.fhir.dstu2.model.Base in project kindling by HL7.

the class PageProcessor method genOperationList.

private String genOperationList() throws Exception {
    StringBuilder b = new StringBuilder();
    b.append("<table class=\"grid\">");
    b.append(" <tr><td colspan=\"2\"><b>Base Operations (All resource types)</b></td></tr>\r\n");
    for (ResourceDefn r : definitions.getBaseResources().values()) {
        genOperationDetails(b, r.getName(), r.getOperations(), true);
    }
    b.append(" <tr><td colspan=\"2\"><b>Operations Defined by Resource Types</b></td></tr>\r\n");
    for (String n : definitions.sortedResourceNames()) {
        ResourceDefn r = definitions.getResourceByName(n);
        genOperationDetails(b, n, r.getOperations(), false);
    }
    // b.append(" <tr><td colspan=\"2\"><b>Operations Defined by Implementation Guides</b></td></tr>\r\n");
    // for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
    // for (Profile p : ig.getProfiles()) {
    // if (!p.getOperations().isEmpty())
    // genOperationDetails(b, ig.getCode()+File.separator+p.getId(), p.getOperations(), false);
    // }
    // }
    b.append("</table>");
    return b.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 13 with Base

use of org.hl7.fhir.dstu2.model.Base in project kindling by HL7.

the class PageProcessor method genOperationDetails.

private void genOperationDetails(StringBuilder b, String n, List<Operation> oplist, boolean isAbstract) {
    for (Operation op : oplist) {
        b.append("<tr><td><a href=\"").append(n.toLowerCase()).append("-operation-").append(op.getName()).append(".html\">");
        b.append(Utilities.escapeXml(op.getTitle()));
        b.append("</a></td><td>");
        boolean first = true;
        if (op.isSystem()) {
            first = false;
            b.append("[base]/$");
            b.append(op.getName());
        }
        if (op.isType()) {
            if (first)
                first = false;
            else
                b.append(" | ");
            b.append("[base]/");
            if (isAbstract)
                b.append("[" + n + "]");
            else
                b.append(n);
            b.append("/$");
            b.append(op.getName());
        }
        if (op.isInstance()) {
            if (first)
                first = false;
            else
                b.append(" | ");
            b.append("[base]/");
            if (isAbstract)
                b.append("[" + n + "]");
            else
                b.append(n);
            b.append("/[id]/$");
            b.append(op.getName());
        }
        b.append("</td></tr>");
    }
}
Also used : Operation(org.hl7.fhir.definitions.model.Operation)

Example 14 with Base

use of org.hl7.fhir.dstu2.model.Base in project kindling by HL7.

the class PageProcessor method processProfileIncludes.

public String processProfileIncludes(String filename, String fileid, Profile pack, ConstraintStructure profile, String xml, String json, String tx, String src, String master, String path, String intro, String notes, ImplementationGuideDefn ig, boolean isDict, boolean hasNarrative) throws Exception {
    String workingTitle = null;
    int level = (ig == null || ig.isCore()) ? 0 : 1;
    while (src.contains("<%") || src.contains("[%")) {
        int i1 = src.indexOf("<%");
        int i2 = src.indexOf("%>");
        if (i1 == -1) {
            i1 = src.indexOf("[%");
            i2 = src.indexOf("%]");
        }
        String s1 = src.substring(0, i1);
        String s2 = src.substring(i1 + 2, i2).trim();
        String s3 = src.substring(i2 + 2);
        String[] com = s2.split(" ");
        if (com[0].equals("profileheader"))
            src = s1 + profileHeader(fileid, com.length > 1 ? com[1] : "", hasExamples(pack)) + s3;
        else if (com[0].equals("file")) {
            if (new File(folders.templateDir + com[1] + ".html").exists()) {
                src = s1 + TextFile.fileToString(folders.templateDir + com[1] + ".html") + s3;
            } else {
                src = s1 + TextFile.fileToString(folders.srcDir + com[1] + ".html") + s3;
            }
        } else if (com[0].equals("settitle")) {
            workingTitle = s2.substring(9).replace("{", "<%").replace("}", "%>");
            src = s1 + s3;
        } else if (com.length != 1)
            throw new Exception("Instruction <%" + s2 + "%> not understood parsing resource " + filename);
        else if (com[0].equals("pageheader"))
            src = s1 + pageHeader(pack.metadata("name")) + s3;
        else if (com[0].equals("level"))
            src = s1 + genlevel(level) + s3;
        else if (com[0].equals("newheader"))
            src = s1 + TextFile.fileToString(folders.srcDir + "newheader.html") + s3;
        else if (com[0].equals("newheader1"))
            src = s1 + TextFile.fileToString(folders.srcDir + "newheader1.html") + s3;
        else if (com[0].equals("footer"))
            src = s1 + TextFile.fileToString(folders.srcDir + "footer.html") + s3;
        else if (com[0].equals("newfooter"))
            src = s1 + TextFile.fileToString(folders.srcDir + "newfooter.html") + s3;
        else if (com[0].equals("footer1"))
            src = s1 + TextFile.fileToString(folders.srcDir + "footer1.html") + s3;
        else if (com[0].equals("footer2"))
            src = s1 + TextFile.fileToString(folders.srcDir + "footer2.html") + s3;
        else if (com[0].equals("footer3"))
            src = s1 + TextFile.fileToString(folders.srcDir + "footer3.html") + s3;
        else if (com[0].equals("title"))
            src = s1 + (workingTitle == null ? Utilities.escapeXml("StructureDefinition: " + profile.getTitle()) : workingTitle) + s3;
        else if (com[0].equals("xtitle"))
            src = s1 + (workingTitle == null ? Utilities.escapeXml("StructureDefinition: " + profile.getTitle()) : Utilities.escapeXml(workingTitle)) + s3;
        else if (com[0].equals("profiletitle"))
            src = s1 + Utilities.escapeXml(pack.metadata("name")) + s3;
        else if (com[0].equals("filetitle"))
            src = s1 + (filename.contains(".") ? filename.substring(0, filename.lastIndexOf(".")) : filename) + s3;
        else if (com[0].equals("name"))
            src = s1 + filename + s3;
        else if (com[0].equals("date")) {
            if (!Utilities.noString(pack.metadata("date"))) {
                Date d = new SimpleDateFormat("yyyy-MM-dd").parse(pack.metadata("date"));
                src = s1 + Config.DATE_FORMAT().format(d) + s3;
            } else
                src = s1 + "[no date]" + s3;
        } else if (com[0].equals("version"))
            src = s1 + ini.getStringProperty("FHIR", "version") + s3;
        else if (com[0].equals("gendate"))
            src = s1 + Config.DATE_FORMAT().format(new Date()) + s3;
        else if (com[0].equals("definition"))
            src = s1 + Utilities.escapeXml(pack.metadata("description")) + s3;
        else if (com[0].equals("status"))
            src = s1 + describeStatus(pack.metadata("status")) + s3;
        else if (com[0].equals("author"))
            src = s1 + Utilities.escapeXml(pack.metadata("author.name")) + s3;
        else if (com[0].equals("xml"))
            src = s1 + xml + s3;
        else if (com[0].equals("json"))
            src = s1 + json + s3;
        else if (com[0].equals("profiledesc")) {
            src = s1 + Utilities.escapeXml(profile.getResource().getDescription()) + s3;
        } else if (com[0].equals("tx"))
            src = s1 + tx + s3;
        else if (com[0].equals("inv"))
            src = s1 + genProfileConstraints(profile.getResource()) + s3;
        else if (com[0].equals("plural"))
            src = s1 + Utilities.pluralizeMe(filename) + s3;
        else if (com[0].equals("notes"))
            src = s1 + "todo" + /*Utilities.fileToString(folders.srcDir + filename+File.separatorChar+filename+".html")*/
            s3;
        else if (com[0].equals("dictionary"))
            src = s1 + "todo" + s3;
        else if (com[0].equals("breadcrumb"))
            src = s1 + breadCrumbManager.make(filename) + s3;
        else if (com[0].equals("navlist"))
            src = s1 + breadCrumbManager.navlist(filename, genlevel(level)) + s3;
        else if (com[0].equals("breadcrumblist"))
            src = s1 + ((ig == null || ig.isCore()) ? breadCrumbManager.makelist(filename, "profile:" + path, genlevel(0), profile.getResource().getName()) : ig.makeList(filename, "profile:" + path, genlevel(level), profile.getResource().getName())) + s3;
        else if (com[0].equals("year"))
            src = s1 + new SimpleDateFormat("yyyy").format(new Date()) + s3;
        else if (com[0].equals("buildId"))
            src = s1 + buildId + s3;
        else if (com[0].equals("level"))
            src = s1 + genlevel(0) + s3;
        else if (com[0].equals("pub-type"))
            src = s1 + publicationType + s3;
        else if (com[0].equals("pub-notice"))
            src = s1 + publicationNotice + s3;
        else if (com[0].equals("profileurl"))
            src = s1 + profile.getResource().getUrl() + s3;
        else if (com[0].equals("baseURL"))
            src = s1 + Utilities.URLEncode(baseURL) + s3;
        else if (com[0].equals("baseURLn"))
            src = s1 + Utilities.appendForwardSlash(baseURL) + s3;
        else if (com[0].equals("base-link"))
            src = s1 + baseLink(profile.getResource(), genlevel(level)) + s3;
        else if (com[0].equals("profile-structure-table-diff"))
            src = s1 + generateProfileStructureTable(profile, true, filename, pack.getId(), genlevel(level)) + s3;
        else if (com[0].equals("profile-structure-table"))
            src = s1 + generateProfileStructureTable(profile, false, filename, pack.getId(), genlevel(level)) + s3;
        else if (com[0].equals("maponthispage"))
            src = s1 + mapOnPageProfile(profile.getResource()) + s3;
        else if (com[0].equals("mappings"))
            src = s1 + mappingsProfile(profile.getResource()) + s3;
        else if (com[0].equals("definitions"))
            src = s1 + definitionsProfile(profile.getResource(), genlevel(level)) + s3;
        else if (com[0].equals("profile.review"))
            src = s1 + profileReviewLink(profile) + s3;
        else if (com[0].equals("profile.datadictionary"))
            src = s1 + profileDictionaryLink(profile) + s3;
        else if (com[0].equals("profile.tx"))
            src = s1 + getTerminologyNotes(profile.getResource(), level) + s3;
        else if (com[0].equals("profile.inv"))
            src = s1 + getInvariantList(profile.getResource()) + s3;
        else if (com[0].equals("draft-note"))
            src = s1 + getDraftNote(pack, genlevel(level)) + s3;
        else if (com[0].equals("pagepath"))
            src = s1 + filename + s3;
        else if (com[0].equals("rellink")) {
            if (!filename.contains(".html"))
                src = s1 + filename + ".html" + s3;
            else
                src = s1 + filename + s3;
        } else if (com[0].equals("schematron"))
            src = s1 + (isDict ? "<i>None</i>" : "<a href=\"" + filename + ".sch\">Schematron</a>") + s3;
        else if (com[0].equals("summary"))
            src = s1 + generateHumanSummary(profile.getResource(), genlevel(level)) + s3;
        else if (com[0].equals("profile-examples"))
            src = s1 + generateProfileExamples(pack, profile) + s3;
        else if (com[0].equals("profile-extensions-table"))
            src = s1 + "<p><i>Todo</i></p>" + s3;
        else if (com[0].equals("definitionsonthispage"))
            src = s1 + "<p><i>Todo</i></p>" + s3;
        else if (com[0].equals("profile.intro"))
            src = s1 + genProfileDoco(pack, intro) + s3;
        else if (com[0].equals("profile.notes"))
            src = s1 + genProfileDoco(pack, notes) + s3;
        else if (com[0].equals("search-footer"))
            src = s1 + searchFooter(level) + s3;
        else if (com[0].equals("search-header"))
            src = s1 + searchHeader(level) + s3;
        else if (com[0].startsWith("!"))
            src = s1 + s3;
        else if (com[0].equals("wg")) {
            String wg = profile.getWg().getCode();
            if (Utilities.noString(wg))
                pack.getWg();
            if (Utilities.noString(wg) && profile.getDefn() != null)
                wg = profile.getDefn().getWg().getCode();
            if (wg == null || !definitions.getWorkgroups().containsKey(wg))
                src = s1 + "(No assigned work group) (" + wg + ") (4)" + s3;
            else
                src = s1 + "<a _target=\"blank\" href=\"" + definitions.getWorkgroups().get(wg).getUrl() + "\">" + definitions.getWorkgroups().get(wg).getName() + "</a> Work Group" + s3;
        } else if (com[0].equals("fmm-style")) {
            String fmm = ToolingExtensions.readStringExtension(profile.getResource(), ToolingExtensions.EXT_FMM_LEVEL);
            StandardsStatus ss = ToolingExtensions.getStandardsStatus(profile.getResource());
            src = s1 + fmmBarColorStyle(ss, fmm) + s3;
        } else if (com[0].equals("fmm")) {
            String fmm = profile.getFmm();
            if (Utilities.noString(fmm))
                fmm = pack.getFmmLevel();
            src = s1 + getFmmFromlevel(genlevel(level), fmm) + s3;
        } else if (com[0].equals("profile-context"))
            src = s1 + getProfileContext(pack.getCandidateResource(), genlevel(level)) + s3;
        else if (com[0].equals("sstatus")) {
            StandardsStatus ss = ToolingExtensions.getStandardsStatus(profile.getResource());
            if (ss == null)
                ss = StandardsStatus.INFORMATIVE;
            if (ss == StandardsStatus.NORMATIVE && ToolingExtensions.hasExtension(profile.getResource(), ToolingExtensions.EXT_NORMATIVE_VERSION))
                src = s1 + "<a href=\"" + genlevel(level) + "versions.html#std-process\">" + ss.toDisplay() + "</a> (from v" + ToolingExtensions.readStringExtension(profile.getResource(), ToolingExtensions.EXT_NORMATIVE_VERSION) + ")" + s3;
            else
                src = s1 + "<a href=\"" + genlevel(level) + "versions.html#std-process\">" + ss.toDisplay() + "</a>" + s3;
        } else if (com[0].equals("past-narrative-link")) {
            if (hasNarrative)
                src = s1 + s3;
            else
                src = s1 + "<p><a href=\"#DomainResource.text.div-end\">Jump past Narrative</a></p>" + s3;
        } else if (com[0].equals("resurl")) {
            if (Utilities.noString(pack.metadata("id")))
                src = s1 + s3;
            else
                src = s1 + "The id of this profile is " + pack.metadata("id") + s3;
        } else if (com[0].equals("res-type-count")) {
            src = s1 + definitions.getResources().size() + s3;
        } else if (macros.containsKey(com[0])) {
            src = s1 + macros.get(com[0]) + s3;
        } else
            throw new Exception("Instruction <%" + s2 + "%> not understood parsing resource " + filename);
    }
    return src;
}
Also used : IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile) SimpleDateFormat(java.text.SimpleDateFormat) StandardsStatus(org.hl7.fhir.utilities.StandardsStatus) ContactPoint(org.hl7.fhir.r5.model.ContactPoint) UcumException(org.fhir.ucum.UcumException) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) URISyntaxException(java.net.URISyntaxException) PathEngineException(org.hl7.fhir.exceptions.PathEngineException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) FileNotFoundException(java.io.FileNotFoundException) NotImplementedException(org.apache.commons.lang3.NotImplementedException) Date(java.util.Date)

Example 15 with Base

use of org.hl7.fhir.dstu2.model.Base in project kindling by HL7.

the class PageProcessor method produceStructureDefinitionExamples.

private String produceStructureDefinitionExamples(ResourceDefn resource) throws Exception {
    StringBuilder s = new StringBuilder();
    s.append("<div id=\"tabs\">\r\n");
    s.append("<ul>\r\n");
    s.append("  <li><a href=\"#tabs-1\">Base Types</a></li>\r\n");
    s.append("  <li><a href=\"#tabs-2\">Resources</a></li>\r\n");
    s.append("  <li><a href=\"#tabs-3\">Constraints</a></li>\r\n");
    s.append("  <li><a href=\"#tabs-4\">Extensions</a></li>\r\n");
    s.append("  <li><a href=\"#tabs-5\">Examples</a></li>\r\n");
    s.append("</ul>\r\n");
    s.append("<div id=\"tabs-1\">\r\n");
    // base types
    s.append("<table class=\"list\">\r\n");
    genStructureExampleCategory(s, "Abstract Types", "3");
    genStructureExample(s, definitions.getElementLink(), "element.profile", "element", "Element");
    genStructureExample(s, definitions.getBackboneLink(), "backboneelement.profile", "backboneelement", "BackBoneElement");
    genStructureExample(s, "resource.html", "resource.profile", "resource", "Resource");
    genStructureExample(s, "domainresource.html", "domainresource.profile", "domainresource", "DomainResource");
    genStructureExampleCategory(s, "Primitive Types", "3");
    List<String> names = new ArrayList<String>();
    names.addAll(definitions.getPrimitives().keySet());
    Collections.sort(names);
    for (String n : names) {
        DefinedCode dc = definitions.getPrimitives().get(n);
        genStructureExample(s, "datatypes.html#" + dc.getCode(), dc.getCode().toLowerCase() + ".profile", dc.getCode().toLowerCase(), dc.getCode());
    }
    genStructureExampleCategory(s, "Data Types", "3");
    names.clear();
    names.addAll(definitions.getTypes().keySet());
    names.addAll(definitions.getInfrastructure().keySet());
    Collections.sort(names);
    for (String n : names) {
        org.hl7.fhir.definitions.model.TypeDefn t = definitions.getTypes().get(n);
        if (t == null)
            t = definitions.getInfrastructure().get(n);
        genStructureExample(s, getLinkFor("", t.getName()), t.getName().toLowerCase() + ".profile", t.getName().toLowerCase(), t.getName());
    }
    s.append("</table>\r\n");
    s.append("</div>\r\n");
    s.append("<div id=\"tabs-2\">\r\n");
    s.append("<table class=\"list\">\r\n");
    genStructureExampleCategory(s, "Resources", "3");
    for (String n : definitions.sortedResourceNames()) {
        ResourceDefn r = definitions.getResources().get(n);
        genStructureExample(s, r.getName().toLowerCase() + ".html", r.getName().toLowerCase() + ".profile", r.getName().toLowerCase(), r.getName());
    }
    s.append("</table>\r\n");
    s.append("</div>\r\n");
    s.append("<div id=\"tabs-3\">\r\n");
    s.append("<table class=\"list\">\r\n");
    Map<String, ConstraintStructure> constraints = new HashMap<String, ConstraintStructure>();
    for (Profile pp : definitions.getPackList()) {
        for (ConstraintStructure p : pp.getProfiles()) constraints.put(p.getId(), p);
    }
    for (String rn : definitions.sortedResourceNames()) for (Profile ap : definitions.getResourceByName(rn).getConformancePackages()) for (ConstraintStructure p : ap.getProfiles()) constraints.put(p.getId(), p);
    names.clear();
    names.addAll(constraints.keySet());
    Collections.sort(names);
    for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
        boolean started = false;
        for (String n : names) {
            ConstraintStructure p = constraints.get(n);
            if (ig == p.getUsage()) {
                if (!started) {
                    started = true;
                    genStructureExampleCategory(s, ig.getName(), "3");
                }
                String prefix = ig.isCore() ? "" : ig.getCode() + "/";
                genStructureExample(s, prefix + p.getId().toLowerCase() + ".html", prefix + p.getId().toLowerCase() + ".profile", p.getId().toLowerCase(), p.getTitle());
            }
        }
    }
    s.append("</table>\r\n");
    s.append("</div>\r\n");
    s.append("<div id=\"tabs-4\">\r\n");
    s.append("<table class=\"list\">\r\n");
    names.clear();
    for (StructureDefinition sd : workerContext.getExtensionDefinitions()) names.add(sd.getUrl());
    Collections.sort(names);
    for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
        boolean started = false;
        for (String n : names) {
            StructureDefinition ed = workerContext.fetchResource(StructureDefinition.class, n);
            if (ig.getCode().equals(ToolResourceUtilities.getUsage(ed))) {
                if (!started) {
                    started = true;
                    genStructureExampleCategory(s, ig.getName(), "3");
                }
                String prefix = ig.isCore() ? "" : ig.getCode() + "/";
                genStructureExample(s, prefix + "extension-" + ed.getId().toLowerCase() + ".html", prefix + "extension-" + ed.getId().toLowerCase(), ed.getId().toLowerCase(), ed.getUrl().startsWith("http://hl7.org/fhir/StructureDefinition/") ? ed.getUrl().substring(40) : ed.getUrl(), ed.getName());
            }
        }
    }
    s.append("</table>\r\n");
    s.append("</div>\r\n");
    s.append("<div id=\"tabs-5\">\r\n");
    s.append("<table class=\"list\">\r\n");
    for (Example e : resource.getExamples()) {
        if (e.isRegistered() && Utilities.noString(e.getIg()))
            produceExampleListEntry(s, e, null, null);
    }
    for (Profile p : resource.getConformancePackages()) {
        for (Example e : p.getExamples()) {
            produceExampleListEntry(s, e, p, null);
        }
    }
    for (Profile p : definitions.getPackList()) {
        ImplementationGuideDefn ig = definitions.getIgs().get(p.getCategory());
        for (Example e : p.getExamples()) {
            String rn = e.getResourceName();
            if (Utilities.noString(rn))
                rn = e.getXml().getDocumentElement().getNodeName();
            if (rn.equals(resource.getName()))
                produceExampleListEntry(s, e, p, ig);
        }
    }
    for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
        if (ig.getIg() != null) {
            for (ImplementationGuideDefinitionResourceComponent res : ig.getIg().getDefinition().getResource()) {
                Example e = (Example) res.getUserData(ToolResourceUtilities.NAME_RES_EXAMPLE);
                if (res.hasExample() && e != null && e.getResourceName().equals(resource.getName()))
                    produceExampleListEntry(s, res, ig);
            }
        }
    }
    s.append("</table>\r\n");
    s.append("</div>\r\n");
    s.append("</div>\r\n");
    s.append("\r\n");
    s.append("<script src=\"external/jquery/jquery.js\"> </script>\r\n");
    s.append("<script src=\"jquery-ui.min.js\"> </script>\r\n");
    s.append("<script>\r\n");
    s.append("try {\r\n");
    s.append("  var currentTabIndex = sessionStorage.getItem('fhir-sdelist-tab-index');\r\n");
    s.append("}\r\n");
    s.append("catch(exception){\r\n");
    s.append("}\r\n");
    s.append("\r\n");
    s.append("if (!currentTabIndex)\r\n");
    s.append("  currentTabIndex = '0';\r\n");
    s.append("  \r\n");
    s.append("$( '#tabs' ).tabs({\r\n");
    s.append("         active: currentTabIndex,\r\n");
    s.append("         activate: function( event, ui ) {\r\n");
    s.append("             var active = $('.selector').tabs('option', 'active');\r\n");
    s.append("             currentTabIndex = ui.newTab.index();\r\n");
    s.append("             document.activeElement.blur();\r\n");
    s.append("             try {\r\n");
    s.append("               sessionStorage.setItem('fhir-sdelist-tab-index', currentTabIndex);\r\n");
    s.append("             }\r\n");
    s.append("             catch(exception){\r\n");
    s.append("             }\r\n");
    s.append("         }\r\n");
    s.append("     });\r\n");
    s.append("</script>\r\n");
    s.append("\r\n");
    return s.toString();
}
Also used : CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) Profile(org.hl7.fhir.definitions.model.Profile) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) DefinedCode(org.hl7.fhir.definitions.model.DefinedCode) Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) TypeDefn(org.hl7.fhir.definitions.model.TypeDefn) ImplementationGuideDefinitionResourceComponent(org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionResourceComponent) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure)

Aggregations

ArrayList (java.util.ArrayList)324 FHIRException (org.hl7.fhir.exceptions.FHIRException)177 Base (org.hl7.fhir.r4b.model.Base)87 Base (org.hl7.fhir.r5.model.Base)87 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)76 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)70 ValidationMessage (org.hl7.fhir.utilities.validation.ValidationMessage)66 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)64 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)55 NotImplementedException (org.apache.commons.lang3.NotImplementedException)47 Base (org.hl7.fhir.dstu2016may.model.Base)47 UcumException (org.fhir.ucum.UcumException)43 ElementDefinition (org.hl7.fhir.r5.model.ElementDefinition)41 Base (org.hl7.fhir.dstu2.model.Base)40 BigDecimal (java.math.BigDecimal)39 IOException (java.io.IOException)37 ParserBase (org.hl7.fhir.dstu2016may.metamodel.ParserBase)34 FileOutputStream (java.io.FileOutputStream)29 ElementDefinition (org.hl7.fhir.dstu3.model.ElementDefinition)28 StructureDefinition (org.hl7.fhir.dstu3.model.StructureDefinition)28