Search in sources :

Example 1 with Dictionary

use of org.hl7.fhir.definitions.model.Dictionary 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 2 with Dictionary

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

the class PageProcessor method profileDictionaryLink.

private String profileDictionaryLink(ConstraintStructure profile) {
    String uri = ToolingExtensions.readStringExtension(profile.getResource(), "http://hl7.org/fhir/StructureDefinition/datadictionary");
    if (Utilities.noString(uri))
        return "<!-- no uri -->";
    Dictionary dict = definitions.getDictionaries().get(uri);
    if (dict == null)
        return "<p>This profile specifies that the value of the " + profile.getResource().getSnapshot().getElement().get(0).getPath() + " resource must be a valid Observation as defined in the data dictionary (Unknown? - " + uri + ").</p>";
    else
        return "<p>This profile specifies that the value of the " + profile.getResource().getSnapshot().getElement().get(0).getPath() + " resource must be a valid Observation as defined in the data dictionary <a href=\"" + uri + ".html\">" + dict.getName() + "</a>.</p>";
}
Also used : Dictionary(org.hl7.fhir.definitions.model.Dictionary)

Example 3 with Dictionary

use of org.hl7.fhir.definitions.model.Dictionary 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 4 with Dictionary

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

the class PageProcessor method processPageIncludes.

public String processPageIncludes(String file, String src, String type, Map<String, String> others, String pagePath, Resource resource, List<String> tabs, String crumbTitle, Object object, ImplementationGuideDefn ig, ResourceDefn rd, WorkGroup wg) throws Exception {
    String workingTitle = null;
    int level = ig == null ? file.contains(File.separator) ? 1 : 0 : ig.isCore() ? 0 : 1;
    boolean even = false;
    String name = file.substring(0, file.lastIndexOf("."));
    String searchAdditions = "";
    while (src.contains("<%") || src.contains("[%")) {
        int i1 = src.indexOf("<%");
        int i2 = i1 == -1 ? -1 : src.substring(i1).indexOf("%>") + i1;
        if (i1 == -1) {
            i1 = src.indexOf("[%");
            i2 = i1 == -1 ? -1 : src.substring(i1).indexOf("%]") + i1;
        }
        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 (s2.startsWith("!")) {
            src = s1 + s3;
        } else if (com.length == 4 && com[0].equals("edt")) {
            if (tabs != null)
                tabs.add("tabs-" + com[1]);
            src = s1 + orgDT(com[1], xmlForDt(com[1], com[2]), treeForDt(com[1]), umlForDt(com[1], com[3]), umlForDt(com[1], com[3] + "b"), profileRef(com[1]), tsForDt(com[1]), jsonForDt(com[1], com[2]), ttlForDt(com[1], com[2]), diffForDt(com[1], com[2])) + s3;
        } else if (com.length == 3 && com[0].equals("dt")) {
            if (tabs != null)
                tabs.add("tabs-" + com[1]);
            src = s1 + orgDT(com[1], xmlForDt(com[1], file), treeForDt(com[1]), umlForDt(com[1], com[2]), umlForDt(com[1], com[2] + "b"), profileRef(com[1]), tsForDt(com[1]), jsonForDt(com[1], file), ttlForDt(com[1], file), diffForDt(com[1], file)) + s3;
        } else if (com.length == 3 && com[0].equals("adt")) {
            if (tabs != null)
                tabs.add("tabs-" + com[1]);
            src = s1 + orgADT(com[1], treeForDt(com[1]), umlForDt(com[1], com[2]), umlForDt(com[1], com[2] + "b"), diffForDt(com[1], file)) + s3;
        } else if (com.length == 2 && com[0].equals("dt.constraints"))
            src = s1 + genConstraints(com[1], genlevel(level)) + s3;
        else if (com.length == 2 && com[0].equals("dt.restrictions"))
            src = s1 + genRestrictions(com[1]) + s3;
        else if (com.length == 2 && com[0].equals("dictionary"))
            src = s1 + dictForDt(com[1]) + s3;
        else if (com[0].equals("othertabs"))
            src = s1 + genOtherTabs(com[1], tabs) + s3;
        else if (com[0].equals("dtheader"))
            src = s1 + dtHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("atheader"))
            src = s1 + atHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("mdtheader"))
            src = s1 + mdtHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("edheader"))
            src = s1 + edHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("elheader"))
            src = s1 + elHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("belheader"))
            src = s1 + belHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("extheader"))
            src = s1 + extHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("mmheader"))
            src = s1 + mmHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("cdheader"))
            src = s1 + cdHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("diheader"))
            src = s1 + diHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("ctheader"))
            src = s1 + ctHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("ucheader"))
            src = s1 + ucHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("rrheader"))
            src = s1 + rrHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("drheader"))
            src = s1 + drHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("adheader"))
            src = s1 + adHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("pdheader"))
            src = s1 + pdHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("tdheader"))
            src = s1 + tdHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("narrheader"))
            src = s1 + narrHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("statheader"))
            src = s1 + statHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("ordistheader"))
            src = s1 + ordistHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("profilesheader"))
            src = s1 + profilesHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("refheader"))
            src = s1 + refHeader(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("resourcesheader"))
            src = s1 + resourcesHeader(com.length > 1 ? com[1] : null) + s3;
        else // src = s1+resourcesHeader(name, com.length > 1 ? com[1] : null)+s3;
        if (com[0].equals("txheader"))
            src = s1 + txHeader(name, com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("sct-vs-list"))
            src = s1 + getSnomedCTVsList() + s3;
        else if (com[0].equals("sct-concept-list"))
            src = s1 + getSnomedCTConceptList() + s3;
        else if (com[0].equals("txheader0"))
            src = s1 + (level > 0 ? "" : txHeader(name, com.length > 1 ? com[1] : null)) + s3;
        else if (com[0].equals("fmtheader"))
            src = s1 + fmtHeader(name, com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("cmpheader"))
            src = s1 + cmpHeader(name, com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("dictheader"))
            src = s1 + dictHeader(((Bundle) resource).getId().toLowerCase(), com.length > 1 ? com[1] : "") + s3;
        else // src = s1+atomHeader(name, com.length > 1 ? com[1] : null)+s3;
        if (com[0].equals("codelist"))
            src = s1 + codelist((CodeSystem) resource, com.length > 1 ? com[1] : null, false, true, file) + s3;
        else if (com[0].equals("codelist-nh"))
            src = s1 + codelist((CodeSystem) resource, com.length > 1 ? com[1] : null, false, false, file) + s3;
        else if (com[0].equals("linkcodelist"))
            src = s1 + codelist((CodeSystem) resource, com.length > 1 ? com[1] : null, true, false, file) + s3;
        else if (com[0].equals("toc"))
            src = s1 + generateToc() + s3;
        else if (com[0].equals("codetoc"))
            src = s1 + codetoc(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("resheader")) {
            if (resource != null && resource instanceof StructureDefinition)
                src = s1 + resHeader(((StructureDefinition) resource).getId().toLowerCase(), ((StructureDefinition) resource).getId(), com.length > 1 ? com[1] : null) + s3;
            else if (rd != null) {
                src = s1 + resHeader(rd.getName().toLowerCase(), rd.getName(), com.length > 1 ? com[1] : null) + s3;
            } else
                src = s1 + s3;
        } else if (com[0].equals("aresheader"))
            src = s1 + abstractResHeader("document", "Document", com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("onthispage"))
            src = s1 + onThisPage(s2.substring(com[0].length() + 1)) + s3;
        else if (com[0].equals("maponthispage"))
            src = s1 + mapOnThisPage(null) + s3;
        else if (com[0].equals("res-category")) {
            even = false;
            src = s1 + resCategory(s2.substring(com[0].length() + 1)) + s3;
        } else if (com[0].equals("res-item")) {
            even = !even;
            src = s1 + resItem(com[1], even) + s3;
        } else if (com[0].equals("resdesc")) {
            src = s1 + resDesc(com[1]) + s3;
        } else if (com[0].equals("rescat")) {
            src = s1 + resCat(com.length == 1 ? null : s2.substring(7)) + s3;
        } else if (com[0].equals("svg"))
            src = s1 + svgs.get(com[1]) + s3;
        else if (com[0].equals("diagram"))
            src = s1 + new SvgGenerator(this, genlevel(level), null, false, file.contains("datatypes"), version).generate(folders.srcDir + com[1], com[2]) + 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("v2xref"))
            src = s1 + xreferencesForV2(name, com[1]) + s3;
        else if (com[0].equals("vs-warning"))
            src = s1 + vsWarning((ValueSet) resource) + s3;
        else if (com[0].equals("res-status-special"))
            src = s1 + vsSpecialStatus((DomainResource) resource) + s3;
        else if (com[0].equals("conceptmaplistv2"))
            src = s1 + conceptmaplist("http://terminology.hl7.org/ValueSet/v2-" + (name.contains("|") ? name.substring(0, name.indexOf("|")) : name), com[1]) + s3;
        else if (com[0].equals("conceptmaplistv3"))
            src = s1 + conceptmaplist("http://terminology.hl7.org/ValueSet/v3-" + (name.contains("|") ? name.substring(0, name.indexOf("|")) : name), com[1]) + s3;
        else if (com[0].equals("conceptmaplistvs")) {
            ValueSet vs = (ValueSet) resource;
            String ref;
            if (vs == null) {
                ref = "http://hl7.org/fhir/ValueSet/" + Utilities.fileTitle(file);
            } else {
                ref = vs.getUrl();
            }
            src = s1 + conceptmaplist(ref, com[1]) + s3;
        } else if (com[0].equals("settitle")) {
            workingTitle = s2.substring(9).replace("{", "<%").replace("}", "%>");
            src = s1 + s3;
        } else if (com[0].equals("igregistries")) {
            src = s1 + igRegistryList(com[1], com[2]) + s3;
        } else if (com[0].equals("dtmappings")) {
            src = s1 + genDataTypeMappings(com[1]) + s3;
        } else if (com[0].equals("dtusage")) {
            src = s1 + genDataTypeUsage(com[1]) + s3;
        } else if (com[0].equals("v3xref")) {
            src = s1 + xreferencesForV3(name) + s3;
        } else if (com[0].equals("setlevel")) {
            level = Integer.parseInt(com[1]);
            src = s1 + s3;
        } else if (com[0].equals("w5")) {
            src = s1 + genW5("true".equals(com[1])) + s3;
        } else if (com[0].equals("res-ref-list")) {
            src = s1 + genResRefList(com[1]) + s3;
        } else if (com[0].equals("sclist")) {
            src = s1 + genScList(com[1]) + s3;
        } else if (com[0].equals("xcm")) {
            src = s1 + getXcm(com[1]) + s3;
        } else if (com[0].equals("xcmchk")) {
            src = s1 + getXcmChk(com[1]) + s3;
        } else if (com[0].equals("sstatus")) {
            if (com.length == 1) {
                StandardsStatus ss = ToolingExtensions.getStandardsStatus((DomainResource) resource);
                if (ss == null)
                    ss = StandardsStatus.INFORMATIVE;
                if (ss == StandardsStatus.NORMATIVE && ToolingExtensions.hasExtension((DomainResource) resource, ToolingExtensions.EXT_NORMATIVE_VERSION))
                    src = s1 + "<a href=\"" + genlevel(level) + "versions.html#std-process\">" + ss.toDisplay() + "</a> (from v" + ToolingExtensions.readStringExtension((DomainResource) resource, ToolingExtensions.EXT_NORMATIVE_VERSION) + ")" + s3;
                else
                    src = s1 + "<a href=\"" + genlevel(level) + "versions.html#std-process\">" + ss.toDisplay() + "</a>" + s3;
            } else
                src = s1 + getStandardsStatus(com[1]) + s3;
        } else if (com[0].equals("wg")) {
            src = s1 + getWgLink(file, wg == null && com.length > 1 ? wg(com[1]) : wg) + s3;
        } else if (com[0].equals("wgt")) {
            src = s1 + getWgTitle(wg == null && com.length > 1 ? wg(com[1]) : wg) + s3;
        } else if (com[0].equals("ig.registry")) {
            src = s1 + buildIgRegistry(ig, com[1]) + s3;
        } else if (com[0].equals("search-link")) {
            src = s1 + searchLink(s2) + 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].equals("profileheader")) {
            src = s1 + profileHeader(((StructureDefinition) resource).getId().toLowerCase(), com[1], hasExamples((StructureDefinition) resource, ig)) + s3;
        } else if (com[0].equals("resource-table")) {
            src = s1 + genResourceTable(definitions.getResourceByName(com[1]), genlevel(level)) + s3;
        } else if (com[0].equals("dtextras")) {
            src = s1 + produceDataTypeExtras(com[1], false) + s3;
        } else if (com[0].equals("dtextensions")) {
            src = s1 + produceDataTypeExtras(com[1], true) + s3;
        } else if (com[0].equals("tx")) {
            src = s1 + produceDataTypeTx(com[1]) + s3;
        } else if (com[0].equals("extension-diff")) {
            StructureDefinition ed = workerContext.fetchResource(StructureDefinition.class, com[1]);
            src = s1 + generateExtensionTable(ed, "extension-" + com[1], "false", genlevel(level)) + s3;
        } else if (com[0].equals("profile-diff")) {
            ConstraintStructure p = definitions.findProfile(com[1]);
            src = s1 + generateProfileStructureTable(p, true, com[1] + ".html", com[1], genlevel(level)) + s3;
        } else if (com[0].equals("example")) {
            String[] parts = com[1].split("\\/");
            Example e = findExample(parts[0], parts[1]);
            src = s1 + genExample(e, com.length > 2 ? Integer.parseInt(com[2]) : 0, genlevel(level)) + s3;
        } else if (com[0].equals("r3r4transform")) {
            src = s1 + dtR3R4Transform(com[1]) + s3;
        } else if (com[0].equals("fmm-style")) {
            String fmm = resource == null ? "N/A" : ToolingExtensions.readStringExtension((DomainResource) resource, ToolingExtensions.EXT_FMM_LEVEL);
            StandardsStatus ss = ToolingExtensions.getStandardsStatus((DomainResource) resource);
            src = s1 + fmmBarColorStyle(ss, fmm) + s3;
        } else if (com[0].equals("fmm")) {
            String fmm = resource == null || !(resource instanceof CanonicalResource) ? getFmm(com[1], false) : ToolingExtensions.readStringExtension((DomainResource) resource, ToolingExtensions.EXT_FMM_LEVEL);
            StandardsStatus ss = ToolingExtensions.getStandardsStatus((DomainResource) resource);
            if (StandardsStatus.EXTERNAL == ss)
                src = s1 + getFmmFromlevel(genlevel(level), "N/A") + s3;
            else if (StandardsStatus.NORMATIVE == ss)
                src = s1 + getFmmFromlevel(genlevel(level), "<a href=\"" + genlevel(level) + "versions.html#std-process\">N</a>") + s3;
            else
                src = s1 + getFmmFromlevel(genlevel(level), fmm) + s3;
        } else if (com[0].equals("fmmna")) {
            String fmm = "N/A";
            src = s1 + getFmmFromlevel(genlevel(level), fmm) + s3;
        } else if (com[0].equals("mostlynormative")) {
            String p = null;
            String wt = workingTitle;
            if (com.length >= 3) {
                if (!com[2].equals("%check"))
                    p = com[2];
                else if (StandardsStatus.NORMATIVE == ToolingExtensions.getStandardsStatus((DomainResource) resource)) {
                    p = resource.getUserString("ballot.package");
                    wt = ((CanonicalResource) resource).fhirType() + " " + ((CanonicalResource) resource).present();
                }
            }
            src = s1 + (p == null ? "" : getMostlyNormativeNote(genlevel(level), p, com[1], wt, file)) + s3;
        } else if (com[0].equals("mixednormative")) {
            String p = null;
            String wt = workingTitle;
            if (com.length >= 3) {
                if (!com[2].equals("%check"))
                    p = com[2];
                else if (StandardsStatus.NORMATIVE == ToolingExtensions.getStandardsStatus((DomainResource) resource)) {
                    p = resource.getUserString("ballot.package");
                    wt = ((CanonicalResource) resource).fhirType() + " " + ((CanonicalResource) resource).present();
                }
            }
            src = s1 + (p == null ? "" : getMixedNormativeNote(genlevel(level), p, com[1], wt, file)) + s3;
        } else if (com[0].equals("normative")) {
            String p = object instanceof Object ? rd.getNormativePackage() : null;
            String wt = object instanceof Object ? rd.getName() + " Operation " + ((Operation) object).getName() : workingTitle;
            if (com.length >= 3) {
                if (!com[2].equals("%check"))
                    p = com[2];
                else if (StandardsStatus.NORMATIVE == ToolingExtensions.getStandardsStatus((DomainResource) resource)) {
                    p = resource.getUserString("ballot.package");
                    wt = ((CanonicalResource) resource).fhirType() + " " + ((CanonicalResource) resource).present();
                }
            }
            src = s1 + (p == null && com.length != 2 ? "" : getNormativeNote(genlevel(level), p, com[1], wt, file)) + s3;
        } else if (com[0].equals("normative-op")) {
            String p = rd.getNormativePackage();
            String wt = rd.getName() + " Operation " + ((Operation) object).getName();
            StandardsStatus st = ((Operation) object).getStandardsStatus();
            if (st == null)
                st = ToolingExtensions.getStandardsStatus((DomainResource) resource);
            src = s1 + (st == StandardsStatus.NORMATIVE ? getNormativeNote(genlevel(level), p, com[1], wt, file) : "") + s3;
        } else if (com[0].equals("fmmshort")) {
            String fmm = resource == null || !(resource instanceof CanonicalResource) ? getFmm(com[1], true) : ToolingExtensions.readStringExtension((DomainResource) resource, ToolingExtensions.EXT_FMM_LEVEL);
            String npr = resource == null || !(resource instanceof CanonicalResource) ? getNormativePackageRef(com[1]) : "";
            src = s1 + getFmmShortFromlevel(genlevel(level), fmm) + npr + s3;
        } else if (com[0].equals("normative-pages")) {
            src = s1 + getNormativeList(genlevel(level), com[1]) + s3;
        } else if (s2.startsWith("search-additions\r\n")) {
            searchAdditions = s2.substring(16).trim();
            src = s1 + s3;
        } else if (com[0].equals("complinks")) {
            src = s1 + (rd == null ? "" : getCompLinks(rd, com.length > 1 ? com[1] : null)) + s3;
        } else if (com[0].equals("diff")) {
            String p = com[1];
            String pd = p.contains("#") ? p.substring(0, p.indexOf("#")) : p;
            String t = s2.substring(com[0].length() + com[1].length() + 2);
            src = s1 + "<a href=\"" + p + "\">" + t + "</a> <a href=\"http://services.w3.org/htmldiff?doc1=http%3A%2F%2Fhl7.org%2Ffhir%2F2018May%2F" + pd + "&amp;doc2=http%3A%2F%2Fbuild.fhir.org%2F" + pd + "\" no-external=\"true\" style=\"border: 1px solid lightgrey; white-space: nowrap; background-color: #EDFDFE; padding: 2px 2px 2px 2px\">&Delta;B</a>" + s3;
        } else if (com[0].equals("diffx")) {
            String p1 = com[1];
            String pd = p1.contains("#") ? p1.substring(0, p1.indexOf("#")) : p1;
            String p2 = com[2];
            String t = s2.substring(com[0].length() + com[1].length() + 2);
            src = s1 + "<a href=\"" + p1 + "\">" + t + "</a> <a href=\"http://services.w3.org/htmldiff?doc1=http%3A%2F%2Fhl7.org%2Ffhir%2F2018May%2F" + p2 + "&amp;doc2=http%3A%2F%2Fbuild.fhir.org%2F" + pd + "\" no-external=\"true\" style=\"border: 1px solid lightgrey; white-space: nowrap; background-color: #EDFDFE; padding: 2px 2px 2px 2px\">&Delta;B</a>" + s3;
        } else if (com[0].equals("StandardsStatus")) {
            src = s1 + getStandardsStatusNote(genlevel(level), com[1], com[2], com.length == 4 ? com[3] : null) + s3;
        } else if (com[0].equals("circular-references")) {
            src = s1 + buildCircularReferenceList(com[1].equals("null") ? null : Boolean.valueOf(com[1])) + s3;
        } else if (com[0].equals("shortparameterlist")) {
            src = s1 + buildShortParameterList(com[1]) + s3;
        } else if (com[0].equals("op-example-link")) {
            src = s1 + buildOpReferenceList(com[1]) + s3;
        } else if (com[0].equals("pattern-impls")) {
            src = s1 + buildPatternList(com[1]) + s3;
        } else if (com[0].equals("diff-analysis")) {
            if ("*".equals(com[1])) {
                updateDiffEngineDefinitions();
                src = s1 + diffEngine.getDiffAsHtml(this) + s3;
            } else {
                StructureDefinition sd = workerContext.fetchTypeDefinition(com[1]);
                if (sd == null)
                    throw new Exception("diff-analysis not found: " + com[1]);
                src = s1 + diffEngine.getDiffAsHtml(this, sd) + s3;
            }
        } else if (com.length != 1)
            throw new Exception("Instruction <%" + s2 + "%> not understood parsing page " + file);
        else if (com[0].equals("pageheader"))
            src = s1 + pageHeader(name.toUpperCase().substring(0, 1) + name.substring(1)) + 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(name.toUpperCase().substring(0, 1) + name.substring(1)) : workingTitle) + s3;
        else if (com[0].equals("xtitle"))
            src = s1 + Utilities.escapeXml(name.toUpperCase().substring(0, 1) + name.substring(1)) + s3;
        else if (com[0].equals("name"))
            src = s1 + name + s3;
        else if (com[0].equals("name.tail"))
            src = s1 + fileTail(name) + s3;
        else if (com[0].equals("piperesources"))
            src = s1 + pipeResources() + s3;
        else if (com[0].equals("enteredInErrorTable"))
            src = s1 + enteredInErrorTable() + s3;
        else if (com[0].equals("canonicalname"))
            src = s1 + makeCanonical(name) + s3;
        else if (com[0].equals("prettyname"))
            src = s1 + makePretty(name) + s3;
        else if (com[0].equals("jsonldname"))
            src = s1 + makeJsonld(name) + s3;
        else if (com[0].equals("version"))
            src = s1 + version + s3;
        else if (com[0].equals("gendate"))
            src = s1 + Config.DATE_FORMAT().format(new Date()) + s3;
        else if (com[0].equals("maindiv"))
            src = s1 + "<div class=\"content\">" + s3;
        else if (com[0].equals("/maindiv"))
            src = s1 + "</div>" + s3;
        else if (com[0].equals("mappings-table"))
            src = s1 + genMappingsTable() + s3;
        else if (com[0].equals("id"))
            src = s1 + (name.contains("|") ? name.substring(0, name.indexOf("|")) : name) + s3;
        else if (com[0].equals("ver"))
            src = s1 + (name.contains("|") ? name.substring(name.indexOf("|") + 1) : "??") + s3;
        else if (com[0].equals("events"))
            src = s1 + getEventsTable(pagePath) + s3;
        else if (com[0].equals("resourcecodes"))
            src = s1 + genResCodes() + s3;
        else if (com[0].equals("datatypecodes"))
            src = s1 + genDTCodes() + s3;
        else if (com[0].equals("allparams"))
            src = s1 + allParamlist() + s3;
        else // src = s1 + genBindingsTable() + s3;
        if (com[0].equals("codeslist"))
            src = s1 + genCodeSystemsTable() + s3;
        else if (com[0].equals("valuesetslist"))
            src = s1 + genValueSetsTable(ig) + s3;
        else if (com[0].equals("namespacelist"))
            src = s1 + genNSList() + s3;
        else if (com[0].equals("extensionslist"))
            src = s1 + genExtensionsTable() + s3;
        else if (com[0].equals("igvaluesetslist"))
            src = s1 + genIGValueSetsTable() + s3;
        else if (com[0].equals("conceptmapslist"))
            src = s1 + genConceptMapsTable() + s3;
        else // src = s1 + genBindingTable(false) + s3;
        if (com[0].equals("resimplall"))
            src = s1 + genResImplList() + s3;
        else if (com[0].equals("txurl"))
            src = s1 + "http://hl7.org/fhir/" + Utilities.fileTitle(file) + s3;
        else if (com[0].equals("vstxurl"))
            src = s1 + "http://hl7.org/fhir/ValueSet/" + Utilities.fileTitle(file) + s3;
        else if (com[0].equals("csurl")) {
            if (resource instanceof CodeSystem)
                src = s1 + ((CodeSystem) resource).getUrl() + s3;
            else {
                CodeSystem cs = (CodeSystem) ((ValueSet) resource).getUserData("cs");
                src = s1 + (cs == null ? "" : cs.getUrl()) + s3;
            }
        } else if (com[0].equals("vsurl")) {
            if (resource == null)
                src = s1 + s3;
            else if (resource instanceof CodeSystem)
                src = s1 + ((CodeSystem) resource).getUrl() + s3;
            else
                src = s1 + ((ValueSet) resource).getUrl() + s3;
        } else if (com[0].equals("txdef"))
            src = s1 + generateCodeDefinition(Utilities.fileTitle(file)) + s3;
        else if (com[0].equals("vsdef"))
            if (resource instanceof CodeSystem)
                src = s1 + processMarkdown("vsdef", ((CodeSystem) resource).getDescription(), genlevel(level)) + s3;
            else
                src = s1 + processMarkdown("vsdef", ((ValueSet) resource).getDescription(), genlevel(level)) + s3;
        else if (com[0].equals("txoid"))
            src = s1 + generateOID((CodeSystem) resource) + s3;
        else if (com[0].equals("vsoid"))
            src = s1 + generateOID((ValueSet) resource) + s3;
        else if (com[0].equals("txname"))
            src = s1 + Utilities.fileTitle(file) + s3;
        else if (com[0].equals("vsname"))
            if (resource instanceof CodeSystem)
                src = s1 + ((CodeSystem) resource).present() + s3;
            else
                src = s1 + ((ValueSet) resource).present() + s3;
        else if (com[0].equals("vsnamed"))
            if (resource instanceof CodeSystem)
                src = s1 + ((CodeSystem) resource).getName() + s3;
            else
                src = s1 + ((ValueSet) resource).getName() + s3;
        else if (com[0].equals("vstitle"))
            if (resource instanceof CodeSystem)
                src = s1 + checkTitle(((CodeSystem) resource).getTitle()) + s3;
            else
                src = s1 + checkTitle(((ValueSet) resource).getTitle()) + s3;
        else if (com[0].equals("vsver"))
            if (resource instanceof CodeSystem)
                src = s1 + ((CodeSystem) resource).getVersion() + s3;
            else
                src = s1 + ((ValueSet) resource).getVersion() + s3;
        else if (com[0].equals("vsref")) {
            src = s1 + Utilities.fileTitle((String) resource.getUserData("filename")) + s3;
        } else if (com[0].equals("vsdesc"))
            src = s1 + (resource != null ? new XhtmlComposer(XhtmlComposer.HTML).compose(((ValueSet) resource).getText().getDiv()) : generateVSDesc(Utilities.fileTitle(file))) + s3;
        else if (com[0].equals("txusage"))
            src = s1 + generateValueSetUsage((ValueSet) resource, genlevel(level), true) + s3;
        else if (com[0].equals("vsusage"))
            src = s1 + generateValueSetUsage((ValueSet) resource, genlevel(level), true) + s3;
        else if (com[0].equals("csusage"))
            src = s1 + generateCSUsage((CodeSystem) resource, genlevel(level)) + s3;
        else if (com[0].equals("vssummary"))
            src = s1 + "todo" + s3;
        else if (com[0].equals("compartmentlist"))
            src = s1 + compartmentlist() + s3;
        else if (com[0].equals("qa"))
            src = s1 + qa.report(this, validationErrors) + s3;
        else if (com[0].equals("comp-title"))
            src = s1 + compTitle(name) + s3;
        else if (com[0].equals("comp-name"))
            src = s1 + compName(name) + s3;
        else if (com[0].equals("comp-desc"))
            src = s1 + compDesc(name) + s3;
        else if (com[0].equals("comp-uri"))
            src = s1 + compUri(name) + s3;
        else if (com[0].equals("comp-identity"))
            src = s1 + compIdentity(name) + s3;
        else if (com[0].equals("comp-membership"))
            src = s1 + compMembership(name) + s3;
        else if (com[0].equals("comp-resources"))
            src = s1 + compResourceMap(name) + s3;
        else if (com[0].equals("breadcrumb"))
            src = s1 + breadCrumbManager.make(name) + s3;
        else if (com[0].equals("navlist"))
            src = s1 + breadCrumbManager.navlist(name, genlevel(level)) + s3;
        else if (com[0].equals("breadcrumblist")) {
            if (object instanceof Operation)
                src = s1 + ((ig == null || ig.isCore()) ? breadCrumbManager.makelist(rd.getName().toLowerCase(), type, genlevel(level), crumbTitle) : ig.makeList(name, type, genlevel(level), crumbTitle)) + s3;
            else
                src = s1 + ((ig == null || ig.isCore()) ? breadCrumbManager.makelist(name, type, genlevel(level), crumbTitle) : ig.makeList(name, type, genlevel(level), crumbTitle)) + 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("pub-type"))
            src = s1 + publicationType + s3;
        else if (com[0].equals("pub-notice"))
            src = s1 + publicationNotice + s3;
        else if (com[0].equals("vssource"))
            if (resource instanceof CodeSystem)
                src = s1 + csSource((CodeSystem) resource) + s3;
            else
                src = s1 + vsSource((ValueSet) resource) + s3;
        else if (com[0].equals("vsxref"))
            src = s1 + xreferencesForFhir(name) + s3;
        else if (com[0].equals("vsexpansion"))
            src = s1 + expandValueSet(Utilities.fileTitle(file), resource == null ? null : ((ValueSet) resource), genlevel(level)) + s3;
        else if (com[0].equals("vscld"))
            src = s1 + vsCLD(Utilities.fileTitle(file), resource == null ? null : ((ValueSet) resource), genlevel(level)) + s3;
        else if (com[0].equals("cs-content"))
            src = s1 + csContent(Utilities.fileTitle(file), ((CodeSystem) resource), genlevel(level)) + s3;
        else if (com[0].equals("vsexpansionig"))
            src = s1 + expandValueSetIG((ValueSet) resource, true) + s3;
        else if (com[0].equals("level"))
            src = s1 + genlevel(level) + s3;
        else if (com[0].equals("archive"))
            src = s1 + makeArchives() + 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("profilelist"))
            src = s1 + genProfilelist() + s3;
        else if (com[0].equals("igprofileslist"))
            src = s1 + genIGProfilelist() + s3;
        else if (com[0].equals("operationslist"))
            src = s1 + genOperationList() + s3;
        else if (com[0].equals("example.profile.link"))
            src = s1 + genExampleProfileLink(resource) + s3;
        else if (com[0].equals("id_regex"))
            src = s1 + FormatUtilities.ID_REGEX + s3;
        else if (com[0].equals("resourcecount"))
            src = s1 + Integer.toString(definitions.getResources().size()) + s3;
        else if (others != null && others.containsKey(com[0]))
            src = s1 + others.get(com[0]) + s3;
        else if (com[0].equals("status-codes"))
            src = s1 + genStatusCodes() + s3;
        else if (com[0].equals("dictionary.name")) {
            String n = name.contains(File.separator) ? name.substring(name.lastIndexOf(File.separator) + 1) : name;
            src = s1 + definitions.getDictionaries().get(n).getName() + s3;
        // } else if (com[0].equals("dictionary.view"))
        // src = s1 + ResourceUtilities.representDataElementCollection(this.workerContext, (Bundle) resource, true, "hspc-qnlab-de") + s3;
        } else if (com[0].equals("search-param-pack") && resource instanceof SearchParameter)
            src = s1 + ((SearchParameter) resource).getUserData("pack") + s3;
        else if (com[0].equals("search-param-name") && resource instanceof SearchParameter)
            src = s1 + ((SearchParameter) resource).getName() + s3;
        else if (com[0].equals("search-param-url") && resource instanceof SearchParameter)
            src = s1 + ((SearchParameter) resource).getUrl() + s3;
        else if (com[0].equals("search-param-type") && resource instanceof SearchParameter)
            src = s1 + ((SearchParameter) resource).getType().toCode() + s3;
        else if (com[0].equals("search-param-definition") && resource instanceof SearchParameter)
            src = s1 + ((SearchParameter) resource).getDescription() + s3;
        else if (com[0].equals("search-param-paths") && resource instanceof SearchParameter)
            src = s1 + (((SearchParameter) resource).hasXpath() ? ((SearchParameter) resource).getXpath() : "") + s3;
        else if (com[0].equals("search-param-targets") && resource instanceof SearchParameter) {
            CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
            for (CodeType t : ((SearchParameter) resource).getTarget()) b.append(t.asStringValue());
            src = s1 + b.toString() + s3;
        } else if (com[0].startsWith("!"))
            src = s1 + s3;
        else if (com[0].equals("txsummary"))
            if (resource instanceof CodeSystem)
                src = s1 + txsummary((CodeSystem) resource, genlevel(level)) + s3;
            else
                src = s1 + txsummary((ValueSet) resource, genlevel(level)) + s3;
        else if (com[0].equals("identifierlist"))
            src = s1 + genIdentifierList() + s3;
        else if (com[0].equals("allsearchparams"))
            src = s1 + genAllSearchParams() + s3;
        else if (com[0].equals("internalsystemlist"))
            src = s1 + genCSList() + s3;
        else if (com[0].equals("internalsystemlistx"))
            src = s1 + genCSListX() + s3;
        else if (com[0].equals("example-usage"))
            src = s1 + s3;
        else if (com[0].equals("ig.title"))
            src = s1 + ig.getName() + s3;
        else if (com[0].equals("ig.wglink"))
            src = s1 + igLink(ig) + s3;
        else if (com[0].equals("ig.wgt"))
            src = s1 + ig.getCommittee() + s3;
        else if (com[0].equals("ig.fmm"))
            src = s1 + getFmmFromlevel(genlevel(level), ig.getFmm()) + s3;
        else if (com[0].equals("ig.ballot"))
            src = s1 + ig.getBallot() + s3;
        else if (com[0].equals("operations")) {
            Profile p = (Profile) object;
            src = s1 + genOperations(p.getOperations(), p.getTitle(), p.getId(), false, null, "../", "") + s3;
        } else if (com[0].equals("operations-summary"))
            src = s1 + genOperationsSummary(((Profile) object).getOperations(), rd) + s3;
        else if (com[0].equals("ig.opcount"))
            src = s1 + genOpCount(((Profile) object).getOperations()) + s3;
        else if (com[0].equals("ig-toc"))
            src = s1 + genIgToc(ig) + s3;
        else if (com[0].equals("fhir-path"))
            src = s1 + "../" + s3;
        else if (com[0].equals("vscommittee"))
            src = s1 + vscommittee(resource) + s3;
        else if (com[0].equals("modifier-list"))
            src = s1 + genModifierList() + s3;
        else if (com[0].equals("missing-element-list"))
            src = s1 + genMeaningWhenMissingList() + s3;
        else if (com[0].equals("wgreport"))
            src = s1 + genWGReport() + s3;
        else if (com[0].equals("r3maps-summary"))
            src = s1 + genR3MapsSummary() + s3;
        else if (com[0].equals("wg")) {
            src = s1 + (wg == null || !definitions.getWorkgroups().containsKey(wg) ? "(No assigned work group) (" + wg + " (1))" : "<a _target=\"blank\" href=\"" + definitions.getWorkgroups().get(wg).getUrl() + "\">" + definitions.getWorkgroups().get(wg).getName() + "</a> Work Group") + s3;
        } else if (com[0].equals("profile-context"))
            src = s1 + getProfileContext((CanonicalResource) resource, genlevel(level)) + s3;
        else if (com[0].equals("res-list-maturity"))
            src = s1 + buildResListByMaturity() + s3;
        else if (com[0].equals("res-list-security"))
            src = s1 + buildResListBySecurity() + s3;
        else if (com[0].equals("res-list-fmg"))
            src = s1 + buildResListByFMG() + s3;
        else if (com[0].equals("res-list-ballot"))
            src = s1 + buildResListByBallot() + s3;
        else if (com[0].equals("res-list-committee"))
            src = s1 + buildResListByCommittee() + s3;
        else if (com[0].equals("wglist"))
            src = s1 + buildCommitteeList() + s3;
        else if (com[0].equals("opName"))
            src = s1 + ((Operation) object).getName() + s3;
        else if (com[0].equals("rName"))
            src = s1 + rd.getName() + s3;
        else if (com[0].equals("operation-summary"))
            src = s1 + ((Operation) object).getName() + " summary" + s3;
        else if (com[0].equals("extension-type-list"))
            src = s1 + genExtensionTypeList() + s3;
        else if (com[0].equals("best-practice-list"))
            src = s1 + genBestPracticeList() + s3;
        else if (com[0].equals("wildcard-type-list"))
            src = s1 + genWildcardTypeList() + s3;
        else if (com[0].startsWith("GF#"))
            src = s1 + "<a href=\"https://gforge.hl7.org/gf/project/fhir/tracker/?action=TrackerItemEdit&amp;tracker_item_id=" + com[0].substring(3) + "\">" + com[0] + "</a>" + s3;
        else if (com[0].startsWith("GFT#"))
            src = s1 + "<a href=\"https://gforge.hl7.org/gf/project/fhir/tracker/?action=TrackerItemEdit&amp;tracker_item_id=" + com[0].substring(3) + "\">Task</a>" + s3;
        else if (com[0].equals("operation")) {
            Operation op = (Operation) object;
            src = s1 + genOperation(op, rd.getName(), rd.getName().toLowerCase(), false, rd.getStatus(), genlevel(level), rd.getNormativePackage()) + s3;
        } else if (com[0].equals("past-narrative-link")) {
            if (object == null || !(object instanceof Boolean))
                src = s1 + s3;
            else
                src = s1 + "<p><a href=\"#DomainResource.text.div-end\">Jump past Narrative</a></p>" + s3;
        } else if (others != null && others.containsKey(s2))
            src = s1 + others.get(s2) + s3;
        else if (com[0].equals("canonical-resources"))
            src = s1 + listCanonicalResources() + s3;
        else if (com[0].equals("metadata-resources"))
            src = s1 + listCanonicalResources() + s3;
        else if (com[0].equals("special-search-parameters")) {
            src = s1 + listSpecialParameters() + s3;
        } else if (com[0].equals("diff-links-all")) {
            src = s1 + genDiffLinks() + s3;
        } else if (com[0].equals("res-type-count")) {
            src = s1 + definitions.getResources().size() + s3;
        } else if (com[0].equals("patterns-analysis")) {
            src = s1 + patternFinder.generateReport() + s3;
        } else if (macros.containsKey(com[0])) {
            src = s1 + macros.get(com[0]) + s3;
        } else
            throw new Exception("Instruction <%" + s2 + "%> not understood parsing page " + file);
    }
    return src;
}
Also used : DomainResource(org.hl7.fhir.r5.model.DomainResource) Operation(org.hl7.fhir.definitions.model.Operation) Profile(org.hl7.fhir.definitions.model.Profile) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) XhtmlComposer(org.hl7.fhir.utilities.xhtml.XhtmlComposer) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure) SearchParameter(org.hl7.fhir.r5.model.SearchParameter) ValueSet(org.hl7.fhir.r5.model.ValueSet) StandardsStatus(org.hl7.fhir.utilities.StandardsStatus) FHIRFormatError(org.hl7.fhir.exceptions.FHIRFormatError) TransformerFactoryConfigurationError(javax.xml.transform.TransformerFactoryConfigurationError) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) 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) CodeType(org.hl7.fhir.r5.model.CodeType) JsonObject(com.google.gson.JsonObject) IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile) CanonicalResource(org.hl7.fhir.r5.model.CanonicalResource) SimpleDateFormat(java.text.SimpleDateFormat)

Example 5 with Dictionary

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

the class PageProcessor method processPageIncludesForBook.

String processPageIncludesForBook(String file, String src, String type, Resource resource, ImplementationGuideDefn ig, WorkGroup wg) throws Exception {
    String workingTitle = null;
    int level = 0;
    boolean even = false;
    List<String> tabs = new ArrayList<String>();
    while (src.contains("<%") || src.contains("[%")) {
        int i1 = src.indexOf("<%");
        int i2 = i1 == -1 ? -1 : src.substring(i1).indexOf("%>") + i1;
        if (i1 == -1) {
            i1 = src.indexOf("[%");
            i2 = i1 == -1 ? -1 : src.substring(i1).indexOf("%]") + i1;
        }
        String s1 = src.substring(0, i1);
        String s2 = src.substring(i1 + 2, i2).trim();
        String s3 = src.substring(i2 + 2);
        String name = file.substring(0, file.indexOf("."));
        String[] com = s2.split(" ");
        if (s2.startsWith("!")) {
            src = s1 + s3;
        } else if (com.length == 3 && com[0].equals("edt")) {
            if (tabs != null)
                tabs.add("tabs-" + com[1]);
            src = s1 + orgDT(com[1], xmlForDt(com[1], com[2]), treeForDt(com[1]), umlForDt(com[1], com[2]), umlForDt(com[1], com[2] + "b"), profileRef(com[1]), tsForDt(com[1]), jsonForDt(com[1], com[2]), ttlForDt(com[1], com[2]), diffForDt(com[1], com[2])) + s3;
        } else if (com.length == 3 && com[0].equals("dt")) {
            if (tabs != null)
                tabs.add("tabs-" + com[1]);
            src = s1 + xmlForDt(com[1], null) + tsForDt(com[1]) + s3;
        } else if (com.length == 3 && com[0].equals("adt")) {
            if (tabs != null)
                tabs.add("tabs-" + com[1]);
            src = s1 + xmlForDt(com[1], null) + tsForDt(com[1]) + s3;
        } else if (com.length == 2 && com[0].equals("dt.constraints"))
            src = s1 + genConstraints(com[1], genlevel(level)) + s3;
        else if (com.length == 2 && com[0].equals("dt.restrictions"))
            src = s1 + genRestrictions(com[1]) + s3;
        else if (com.length == 2 && com[0].equals("dictionary"))
            src = s1 + dictForDt(com[1]) + s3;
        else if (Utilities.existsInList(com[0], "pageheader", "dtheader", "atheader", "mdtheader", "edheader", "mmheader", "drheader", "elheader", "belheader", "extheader", "resourcesheader", "formatsheader", "narrheader", "refheader", "extrasheader", "profilesheader", "txheader", "txheader0", "fmtheader", "igheader", "cmpheader", "atomheader", "dictheader", "ctheader", "adheader", "pdheader", "tdheader", "cdheader", "diheader", "statheader", "ordistheader", "ucheader", "rrheader"))
            src = s1 + s3;
        else if (com[0].equals("resheader"))
            src = s1 + s3;
        else if (com[0].equals("aresheader"))
            src = s1 + s3;
        else if (com[0].equals("othertabs"))
            src = s1 + genOtherTabs(com[1], tabs) + s3;
        else if (com[0].equals("diff")) {
            String p = com[1];
            String pd = p.contains("#") ? p.substring(0, p.indexOf("#")) : p;
            String t = s2.substring(com[0].length() + com[1].length() + 2);
            src = s1 + "<a href=\"" + p + "\">" + t + "</a> <a href=\"http://services.w3.org/htmldiff?doc1=http%3A%2F%2Fhl7.org%2Ffhir%2F2018May%2F" + pd + "&amp;doc2=http%3A%2F%2Fbuild.fhir.org%2F" + pd + "\" no-external=\"true\" style=\"border: 1px solid lightgrey; white-space: nowrap; background-color: #EDFDFE; padding: 2px 2px 2px 2px\">&Delta;B</a>" + s3;
        } else if (com[0].equals("diffx")) {
            String p1 = com[1];
            String pd = p1.contains("#") ? p1.substring(0, p1.indexOf("#")) : p1;
            String p2 = com[2];
            String t = s2.substring(com[0].length() + com[1].length() + 2);
            src = s1 + "<a href=\"" + p1 + "\">" + t + "</a> <a href=\"http://services.w3.org/htmldiff?doc1=http%3A%2F%2Fhl7.org%2Ffhir%2F2018May%2F" + p2 + "&amp;doc2=http%3A%2F%2Fbuild.fhir.org%2F" + pd + "\" no-external=\"true\" style=\"border: 1px solid lightgrey; white-space: nowrap; background-color: #EDFDFE; padding: 2px 2px 2px 2px\">&Delta;B</a>" + s3;
        } else if (com[0].equals("dtmappings"))
            src = s1 + genDataTypeMappings(com[1]) + s3;
        else if (com[0].equals("sct-vs-list"))
            src = s1 + getSnomedCTVsList() + s3;
        else if (com[0].equals("sct-concept-list"))
            src = s1 + getSnomedCTConceptList() + s3;
        else if (com[0].equals("circular-references"))
            src = s1 + buildCircularReferenceList(com[1].equals("null") ? null : Boolean.valueOf(com[1])) + s3;
        else if (com[0].equals("dtusage"))
            src = s1 + genDataTypeUsage(com[1]) + s3;
        else if (com[0].equals("w5"))
            src = s1 + genW5("true".equals(com[1])) + s3;
        else if (com[0].equals("codelist"))
            src = s1 + codelist((CodeSystem) resource, com.length > 1 ? com[1] : null, false, true, file) + s3;
        else if (com[0].equals("codelist-nh"))
            src = s1 + codelist((CodeSystem) resource, com.length > 1 ? com[1] : null, false, false, file) + s3;
        else if (com[0].equals("linkcodelist"))
            src = s1 + codelist((CodeSystem) resource, com.length > 1 ? com[1] : null, true, false, file) + s3;
        else if (com[0].equals("codetoc"))
            src = s1 + codetoc(com.length > 1 ? com[1] : null) + s3;
        else if (com[0].equals("vs-warning"))
            src = s1 + vsWarning((ValueSet) resource) + s3;
        else if (com[0].equals("res-status-special"))
            src = s1 + vsSpecialStatus((DomainResource) resource) + s3;
        else if (com[0].equals("maponthispage"))
            src = s1 + s3;
        else if (com[0].equals("onthispage"))
            src = s1 + s3;
        else if (com[0].equals("conceptmaplistvs")) {
            ValueSet vs = (ValueSet) resource;
            String ref;
            if (vs == null) {
                ref = "http://hl7.org/fhir/ValueSet/" + Utilities.fileTitle(file);
            } else {
                ref = vs.getUrl();
            }
            src = s1 + conceptmaplist(ref, com[1]) + s3;
        } else if (com[0].equals("res-category")) {
            src = s1 + resCategory(s2.substring(com[0].length() + 1)) + s3;
            even = false;
        } else if (com[0].equals("res-item")) {
            even = !even;
            src = s1 + resItem(com[1], even) + s3;
        } else if (com[0].equals("resdesc")) {
            src = s1 + resDesc(com[1]) + s3;
        } else if (com[0].equals("rescat")) {
            src = s1 + resCat(com.length == 1 ? null : s2.substring(7)) + s3;
        } else if (com[0].equals("sidebar"))
            src = s1 + s3;
        else if (com[0].equals("svg"))
            src = s1 + svgs.get(com[1]) + s3;
        else if (com[0].equals("diagram"))
            src = s1 + new SvgGenerator(this, genlevel(level), null, false, file.contains("datatypes"), version).generate(folders.srcDir + com[1], com[2]) + s3;
        else if (com[0].equals("file"))
            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("res-ref-list")) {
            src = s1 + genResRefList(com[1]) + s3;
        } else if (com[0].equals("sclist")) {
            src = s1 + genScList(com[1]) + s3;
        } else if (com[0].equals("xcm")) {
            src = s1 + getXcm(com[1]) + s3;
        } else if (com[0].equals("xcmchk")) {
            src = s1 + getXcmChk(com[1]) + s3;
        } else if (com[0].equals("fmm")) {
            src = s1 + getFmm(com[1], false) + s3;
        } else if (com[0].equals("fmmshort")) {
            src = s1 + getFmmShort(com[1]) + s3;
        } else if (com[0].equals("sstatus")) {
            src = s1 + getStandardsStatus(com[1]) + s3;
        } else if (com[0].equals("wg")) {
            src = s1 + getWgLink(file, wg == null && com.length > 0 ? wg(com[1]) : wg) + s3;
        } else if (com[0].equals("wgt")) {
            src = s1 + getWgTitle(wg == null && com.length > 0 ? wg(com[1]) : wg) + s3;
        } else if (com[0].equals("search-link")) {
            src = s1 + searchLink(s2) + 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].equals("toc")) {
            src = s1 + generateToc() + s3;
        } else if (com[0].equals("igregistries")) {
            src = s1 + igRegistryList(com[1], com[2]) + s3;
        } else if (com[0].equals("ig.registry")) {
            src = s1 + buildIgRegistry(ig, com[1]) + s3;
        } else if (com[0].equals("dtextras")) {
            src = s1 + produceDataTypeExtras(com[1], true) + s3;
        } else if (com[0].equals("dtextensions")) {
            src = s1 + produceDataTypeExtras(com[1], false) + s3;
        } else if (com[0].equals("resource-table")) {
            src = s1 + genResourceTable(definitions.getResourceByName(com[1]), genlevel(level)) + s3;
        } else if (com[0].equals("profile-diff")) {
            ConstraintStructure p = definitions.findProfile(com[1]);
            src = s1 + generateProfileStructureTable(p, true, com[1] + ".html", com[1], genlevel(level)) + s3;
        } else if (com[0].equals("example")) {
            String[] parts = com[1].split("\\/");
            Example e = findExample(parts[0], parts[1]);
            src = s1 + genExample(e, com.length > 2 ? Integer.parseInt(com[2]) : 0, genlevel(level)) + s3;
        } else if (com[0].equals("extension-diff")) {
            StructureDefinition ed = workerContext.fetchResource(StructureDefinition.class, com[1]);
            src = s1 + generateExtensionTable(ed, "extension-" + com[1], "false", genlevel(level)) + s3;
        } else if (com[0].equals("setlevel")) {
            level = Integer.parseInt(com[1]);
            src = s1 + s3;
        } else if (com[0].equals("r3r4transform")) {
            src = s1 + dtR3R4Transform(com[1]) + s3;
        } else if (com[0].equals("normative-pages")) {
            src = s1 + getNormativeList(genlevel(level), com[1]) + s3;
        } else if (com[0].equals("tx")) {
            src = s1 + produceDataTypeTx(com[1]) + s3;
        } else if (com[0].equals("normative")) {
            src = s1 + s3;
        } else if (com[0].equals("mostlynormative")) {
            src = s1 + s3;
        } else if (com[0].equals("mixednormative")) {
            src = s1 + s3;
        } else if (com[0].equals("pattern-impls")) {
            src = s1 + buildPatternList(com[1]) + s3;
        } else if (com[0].equals("StandardsStatus")) {
            src = s1 + getStandardsStatusNote(genlevel(level), com[1], com[2], com.length == 4 ? com[3] : null) + s3;
        } else if (com[0].equals("diff-analysis")) {
            if ("*".equals(com[1])) {
                updateDiffEngineDefinitions();
                src = s1 + diffEngine.getDiffAsHtml(this) + s3;
            } else {
                StructureDefinition sd = workerContext.fetchTypeDefinition(com[1]);
                if (sd == null)
                    throw new Exception("diff-analysis not found: " + com[1]);
                src = s1 + diffEngine.getDiffAsHtml(this, sd) + s3;
            }
        } else if (com.length != 1)
            throw new Exception("Instruction <%" + s2 + "%> not understood parsing page " + file);
        else if (com[0].equals("header"))
            src = s1 + s3;
        else if (com[0].equals("newheader"))
            src = s1 + s3;
        else if (com[0].equals("newheader1"))
            src = s1 + s3;
        else if (com[0].equals("footer"))
            src = s1 + s3;
        else if (com[0].equals("newfooter"))
            src = s1 + s3;
        else if (com[0].equals("footer1"))
            src = s1 + s3;
        else if (com[0].equals("footer2"))
            src = s1 + s3;
        else if (com[0].equals("footer3"))
            src = s1 + s3;
        else if (com[0].equals("title"))
            src = s1 + (workingTitle == null ? Utilities.escapeXml(name.toUpperCase().substring(0, 1) + name.substring(1)) : workingTitle) + s3;
        else if (com[0].equals("xtitle"))
            src = s1 + Utilities.escapeXml(name.toUpperCase().substring(0, 1) + name.substring(1)) + s3;
        else if (com[0].equals("name"))
            src = s1 + name + 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("maindiv"))
            src = s1 + s3;
        else if (com[0].equals("/maindiv"))
            src = s1 + s3;
        else if (com[0].equals("events"))
            src = s1 + getEventsTable(file) + s3;
        else if (com[0].equals("resourcecodes"))
            src = s1 + genResCodes() + s3;
        else if (com[0].equals("enteredInErrorTable"))
            src = s1 + enteredInErrorTable() + s3;
        else if (com[0].equals("datatypecodes"))
            src = s1 + genDTCodes() + s3;
        else // src = s1 + genBindingTable(true) + s3;
        if (com[0].equals("codeslist"))
            src = s1 + genCodeSystemsTable() + s3;
        else if (com[0].equals("valuesetslist"))
            src = s1 + genValueSetsTable(ig) + s3;
        else if (com[0].equals("igvaluesetslist"))
            src = s1 + genIGValueSetsTable() + s3;
        else if (com[0].equals("namespacelist"))
            src = s1 + s3;
        else if (com[0].equals("conceptmapslist"))
            src = s1 + genConceptMapsTable() + s3;
        else // src = s1 + genBindingTable(false) + s3;
        if (com[0].equals("vsxref"))
            src = s1 + xreferencesForFhir(name) + s3;
        else if (com[0].equals("resimplall"))
            src = s1 + genResImplList() + s3;
        else if (com[0].equals("txurl"))
            src = s1 + "http://hl7.org/fhir/" + Utilities.fileTitle(file) + s3;
        else if (com[0].equals("vstxurl"))
            src = s1 + "http://hl7.org/fhir/ValueSet/" + Utilities.fileTitle(file) + s3;
        else if (com[0].equals("csurl")) {
            if (resource instanceof CodeSystem)
                src = s1 + ((CodeSystem) resource).getUrl() + s3;
            else
                src = s1 + ((ValueSet) resource).getUrl() + s3;
        } else if (com[0].equals("vsurl")) {
            if (resource == null)
                src = s1 + s3;
            else if (resource instanceof CodeSystem)
                src = s1 + ((CodeSystem) resource).getUrl() + s3;
            else
                src = s1 + ((ValueSet) resource).getUrl() + s3;
        } else if (com[0].equals("txdef"))
            src = s1 + generateCodeDefinition(Utilities.fileTitle(file)) + s3;
        else if (com[0].equals("vsexpansion"))
            src = s1 + expandValueSet(Utilities.fileTitle(file), resource == null ? null : (ValueSet) resource, genlevel(level)) + s3;
        else if (com[0].equals("vsexpansionig"))
            src = s1 + expandValueSetIG((ValueSet) resource, true) + s3;
        else if (com[0].equals("vsdef"))
            if (resource instanceof CodeSystem)
                src = s1 + Utilities.escapeXml(((CodeSystem) resource).getDescription()) + s3;
            else
                src = s1 + Utilities.escapeXml(((ValueSet) resource).getDescription()) + s3;
        else if (com[0].equals("txoid"))
            src = s1 + generateOID((CodeSystem) resource) + s3;
        else if (com[0].equals("vsoid"))
            src = s1 + generateOID((ValueSet) resource) + s3;
        else if (com[0].equals("txname"))
            src = s1 + Utilities.fileTitle(file) + s3;
        else if (com[0].equals("vsname"))
            if (resource instanceof CodeSystem)
                src = s1 + ((CodeSystem) resource).present() + s3;
            else
                src = s1 + ((ValueSet) resource).present() + s3;
        else if (com[0].equals("vsnamed"))
            if (resource instanceof CodeSystem)
                src = s1 + ((CodeSystem) resource).getName() + s3;
            else
                src = s1 + ((ValueSet) resource).getName() + s3;
        else if (com[0].equals("vstitle"))
            if (resource instanceof CodeSystem)
                src = s1 + checkTitle(((CodeSystem) resource).getTitle()) + s3;
            else
                src = s1 + checkTitle(((ValueSet) resource).getTitle()) + s3;
        else if (com[0].equals("vsver"))
            if (resource instanceof CodeSystem)
                src = s1 + ((CodeSystem) resource).getVersion() + s3;
            else
                src = s1 + ((ValueSet) resource).getVersion() + s3;
        else if (com[0].equals("vsref")) {
            src = s1 + Utilities.fileTitle((String) resource.getUserData("filename")) + s3;
        } else if (com[0].equals("vsdesc"))
            src = s1 + (resource != null ? Utilities.escapeXml(((ValueSet) resource).getDescription()) : generateVSDesc(Utilities.fileTitle(file))) + s3;
        else if (com[0].equals("txusage"))
            src = s1 + generateValueSetUsage((ValueSet) resource, genlevel(level), true) + s3;
        else if (com[0].equals("vsusage"))
            src = s1 + generateValueSetUsage((ValueSet) resource, genlevel(level), true) + s3;
        else if (com[0].equals("csusage"))
            src = s1 + generateCSUsage((CodeSystem) resource, genlevel(level)) + s3;
        else if (com[0].equals("mappings-table"))
            src = s1 + genMappingsTable() + s3;
        else if (com[0].equals("vssummary"))
            src = s1 + "todo" + s3;
        else if (com[0].equals("compartmentlist"))
            src = s1 + compartmentlist() + s3;
        else if (com[0].equals("comp-title"))
            src = s1 + compTitle(name) + s3;
        else if (com[0].equals("comp-desc"))
            src = s1 + compDesc(name) + s3;
        else if (com[0].equals("comp-uri"))
            src = s1 + compUri(name) + s3;
        else if (com[0].equals("comp-identity"))
            src = s1 + compIdentity(name) + s3;
        else if (com[0].equals("comp-membership"))
            src = s1 + compMembership(name) + s3;
        else if (com[0].equals("comp-resources"))
            src = s1 + compResourceMap(name) + s3;
        else if (com[0].equals("breadcrumb"))
            src = s1 + breadCrumbManager.make(name) + s3;
        else if (com[0].equals("navlist"))
            src = s1 + breadCrumbManager.navlist(name, genlevel(level)) + s3;
        else if (com[0].equals("breadcrumblist")) {
            String crumbTitle = (workingTitle == null ? Utilities.escapeXml(name.toUpperCase().substring(0, 1) + name.substring(1)) : workingTitle);
            src = s1 + ((ig == null || ig.isCore()) ? breadCrumbManager.makelist(name, type, genlevel(level), crumbTitle) : ig.makeList(name, type, genlevel(level), crumbTitle)) + 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("piperesources"))
            src = s1 + pipeResources() + s3;
        else if (com[0].equals("archive"))
            src = s1 + makeArchives() + 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("profilelist"))
            src = s1 + genProfilelist() + s3;
        else if (com[0].equals("extensionslist"))
            src = s1 + genExtensionsTable() + s3;
        else if (com[0].equals("igprofileslist"))
            src = s1 + genIGProfilelist() + s3;
        else if (com[0].equals("operationslist"))
            src = s1 + genOperationList() + s3;
        else if (com[0].equals("id_regex"))
            src = s1 + FormatUtilities.ID_REGEX + s3;
        else if (com[0].equals("allparams"))
            src = s1 + allParamlist() + s3;
        else if (com[0].equals("resourcecount"))
            src = s1 + Integer.toString(definitions.getResources().size()) + s3;
        else if (com[0].equals("status-codes"))
            src = s1 + genStatusCodes() + s3;
        else if (com[0].equals("dictionary.name"))
            src = s1 + definitions.getDictionaries().get(name) + s3;
        else // src = s1 + ResourceUtilities.representDataElementCollection(this.workerContext, (Bundle) resource, true, "hspc-QuantitativeLab-dataelements") + s3;
        if (com[0].startsWith("!"))
            src = s1 + s3;
        else if (com[0].equals("identifierlist"))
            src = s1 + genIdentifierList() + s3;
        else if (com[0].equals("allsearchparams"))
            src = s1 + genAllSearchParams() + s3;
        else if (com[0].equals("internalsystemlist"))
            src = s1 + genCSList() + s3;
        else if (com[0].equals("internalsystemlistx"))
            src = s1 + genCSListX() + s3;
        else if (com[0].equals("baseURLn"))
            src = s1 + Utilities.appendForwardSlash(baseURL) + s3;
        else if (com[0].equals("ig.title"))
            src = s1 + ig.getName() + s3;
        else if (com[0].equals("ig.wglink"))
            src = s1 + igLink(ig) + s3;
        else if (com[0].equals("ig.wgt"))
            src = s1 + ig.getCommittee() + s3;
        else if (com[0].equals("ig.fmm"))
            src = s1 + ig.getFmm() + s3;
        else if (com[0].equals("comp-name"))
            src = s1 + compName(name) + s3;
        else if (com[0].equals("ig.ballot"))
            src = s1 + ig.getBallot() + s3;
        else if (com[0].equals("fhir-path"))
            src = s1 + "../" + s3;
        else if (com[0].equals("modifier-list"))
            src = s1 + genModifierList() + s3;
        else if (com[0].equals("missing-element-list"))
            src = s1 + genMeaningWhenMissingList() + s3;
        else if (com[0].equals("wgreport"))
            src = s1 + genWGReport() + s3;
        else if (com[0].equals("r3maps-summary"))
            src = s1 + genR3MapsSummary() + s3;
        else if (com[0].equals("res-list-maturity"))
            src = s1 + buildResListByMaturity() + s3;
        else if (com[0].equals("res-list-security"))
            src = s1 + buildResListBySecurity() + s3;
        else if (com[0].equals("res-list-fmg"))
            src = s1 + buildResListByFMG() + s3;
        else if (com[0].equals("res-list-ballot"))
            src = s1 + buildResListByBallot() + s3;
        else if (com[0].equals("res-list-committee"))
            src = s1 + buildResListByCommittee() + s3;
        else if (com[0].equals("wglist"))
            src = s1 + buildCommitteeList() + s3;
        else if (com[0].equals("best-practice-list"))
            src = s1 + genBestPracticeList() + s3;
        else if (com[0].equals("extension-type-list"))
            src = s1 + genExtensionTypeList() + s3;
        else if (com[0].equals("wildcard-type-list"))
            src = s1 + genWildcardTypeList() + s3;
        else if (com[0].startsWith("GF#"))
            src = s1 + "<a href=\"https://gforge.hl7.org/gf/project/fhir/tracker/?action=TrackerItemEdit&amp;tracker_item_id=" + com[0].substring(3) + "\">" + com[0] + "</a>" + s3;
        else if (com[0].startsWith("GFT#"))
            src = s1 + "<a href=\"https://gforge.hl7.org/gf/project/fhir/tracker/?action=TrackerItemEdit&amp;tracker_item_id=" + com[0].substring(3) + "\">Task</a>" + s3;
        else if (com[0].equals("canonical-resources"))
            src = s1 + listCanonicalResources() + s3;
        else if (com[0].equals("special-search-parameters")) {
            src = s1 + listSpecialParameters() + s3;
        } else if (com[0].equals("patterns-analysis")) {
            src = s1 + patternFinder.generateReport() + 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 page " + file);
    }
    return src;
}
Also used : ArrayList(java.util.ArrayList) CodeSystem(org.hl7.fhir.r5.model.CodeSystem) 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) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) SvgGenerator(org.hl7.fhir.definitions.generators.specification.SvgGenerator) Example(org.hl7.fhir.definitions.model.Example) OperationExample(org.hl7.fhir.definitions.model.Operation.OperationExample) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure) ValueSet(org.hl7.fhir.r5.model.ValueSet) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

File (java.io.File)7 FileNotFoundException (java.io.FileNotFoundException)7 IOException (java.io.IOException)7 FHIRException (org.hl7.fhir.exceptions.FHIRException)7 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)7 CSFile (org.hl7.fhir.utilities.CSFile)7 URISyntaxException (java.net.URISyntaxException)6 Date (java.util.Date)6 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)6 TransformerException (javax.xml.transform.TransformerException)6 NotImplementedException (org.apache.commons.lang3.NotImplementedException)6 UcumException (org.fhir.ucum.UcumException)6 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)6 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)6 ValueSet (org.hl7.fhir.r5.model.ValueSet)6 IniFile (org.hl7.fhir.utilities.IniFile)6 TextFile (org.hl7.fhir.utilities.TextFile)6 SimpleDateFormat (java.text.SimpleDateFormat)5 StandardsStatus (org.hl7.fhir.utilities.StandardsStatus)5 ArrayList (java.util.ArrayList)4