Search in sources :

Example 6 with ImplementationGuideDefn

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

the class Publisher method addSectionNumbers.

@Override
public String addSectionNumbers(String file, String logicalName, String src, String id, int level, DocumentHolder doch, ImplementationGuideDefn ig) throws Exception {
    if (ig != null)
        logicalName = ig.getCode() + "::" + logicalName;
    if (!page.getSectionTrackerCache().containsKey(logicalName)) {
        // String prefix =
        // page.getNavigation().getIndexPrefixForFile(logicalName+".html");
        String prefix;
        if (ig != null)
            prefix = ig.getIndexPrefixForFile(file, logicalName + ".html");
        else
            prefix = page.getBreadCrumbManager().getIndexPrefixForFile(logicalName + ".html");
        if (Utilities.noString(prefix))
            throw new Exception("No indexing home for logical place " + logicalName);
        page.getSectionTrackerCache().put(logicalName, new SectionTracker(prefix, ig != null));
    }
    SectionTracker st = page.getSectionTrackerCache().get(logicalName);
    st.start(id);
    src = insertSectionNumbers(src, st, file, level, doch);
    return src;
}
Also used : TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 7 with ImplementationGuideDefn

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

the class Publisher method execute.

/**
 * Entry point to the publisher. This classes Java Main() calls this function
 * to actually produce the specification
 *
 * @param folder
 * @throws IOException
 */
public void execute(String folder) throws IOException {
    tester = new PublisherTestSuites();
    page.log("Publish FHIR in folder " + folder + " @ " + Config.DATE_FORMAT().format(page.getGenDate().getTime()), LogMessageType.Process);
    if (web)
        page.log("Build final copy for HL7 web site", LogMessageType.Process);
    else
        page.log("Build local copy", LogMessageType.Process);
    if (outputdir != null) {
        page.log("Create output in " + outputdir, LogMessageType.Process);
    }
    page.log("Detected Java version: " + System.getProperty("java.version") + " from " + System.getProperty("java.home") + " on " + System.getProperty("os.arch"), LogMessageType.Process);
    try {
        tester.initialTests();
        page.setFolders(new FolderManager(folder, outputdir));
        if (!initialize(folder))
            throw new Exception("Unable to publish as preconditions aren't met");
        cache = new IniFile(page.getFolders().rootDir + "temp" + File.separator + "build.cache");
        loadSuppressedMessages(page.getFolders().rootDir);
        boolean doAny = false;
        for (String n : dates.keySet()) {
            Long d = cache.getLongProperty("dates", n);
            boolean b = d == null || (dates.get(n) > d);
            cache.setLongProperty("dates", n, dates.get(n).longValue(), null);
            buildFlags.put(n.toLowerCase(), b);
            doAny = doAny || b;
        }
        cache.save();
        if (noPartialBuild || !doAny || !(new File(page.getFolders().dstDir + "qa.html").exists()))
            // nothing - build all
            buildFlags.put("all", true);
        if (singlePage != null) {
            for (String n : buildFlags.keySet()) buildFlags.put(n, false);
            buildFlags.put("page-" + singlePage.toLowerCase(), true);
        } else if (singleResource != null) {
            for (String n : buildFlags.keySet()) buildFlags.put(n, false);
            buildFlags.put(singleResource.toLowerCase(), true);
        }
        if (!buildFlags.get("all")) {
            if (!noSound) {
                AudioUtilities.tone(1000, 10);
                AudioUtilities.tone(1400, 10);
                AudioUtilities.tone(1800, 10);
                AudioUtilities.tone(1000, 10);
                AudioUtilities.tone(1400, 10);
                AudioUtilities.tone(1800, 10);
            }
            page.log("Partial Build (if you want a full build, just run the build again)", LogMessageType.Process);
            CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
            for (String n : buildFlags.keySet()) if (buildFlags.get(n))
                b.append(n);
            page.log("  Build: " + b.toString(), LogMessageType.Process);
        } else {
            if (!noSound)
                AudioUtilities.tone(1200, 30);
            page.log("Full Build", LogMessageType.Process);
        }
        if (isGenerate && page.getBuildId() == null)
            page.setBuildId(getGitBuildId());
        page.log("Version " + page.getVersion() + "-" + page.getBuildId(), LogMessageType.Hint);
        Utilities.createDirectory(page.getFolders().dstDir);
        Utilities.deleteTempFiles();
        page.getBreadCrumbManager().parse(page.getFolders().srcDir + "hierarchy.xml");
        page.loadSnomed();
        page.loadLoinc();
        page.loadUcum();
        buildFeedsAndMaps();
        prsr.setExternals(externals);
        prsr.parse(page.getGenDate(), page.getValidationErrors());
        for (String n : page.getDefinitions().sortedResourceNames()) if (!page.getBreadCrumbManager().knowsResource(n))
            page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "hierarchy.xml", "Resource not found: " + n, IssueSeverity.ERROR));
        for (String n : prsr.getErrors()) page.getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.INVALID, -1, -1, "source spreadsheets", n, IssueSeverity.ERROR));
        if (web) {
            page.log("Clear Directory", LogMessageType.Process);
            Utilities.clearDirectory(page.getFolders().dstDir);
        }
        if (web || (isGenerate && buildFlags.get("all"))) {
            Utilities.createDirectory(page.getFolders().dstDir + "html");
            Utilities.createDirectory(page.getFolders().dstDir + "examples");
        }
        for (ImplementationGuideDefn ig : page.getDefinitions().getSortedIgs()) if (!ig.isCore())
            Utilities.createDirectory(page.getFolders().dstDir + ig.getCode());
        if (buildFlags.get("all")) {
            copyStaticContent();
        }
        page.makeRenderingContext();
        loadValueSets1();
        prsr.getRegistry().commit();
        generateSCMaps();
        validate();
        processProfiles();
        checkAllOk();
        if (isGenerate) {
            produceSpecification();
            checkAllOk();
        }
        if (doValidate)
            validationProcess();
        page.saveSnomed();
        page.getWorkerContext().saveCache();
        processWarnings(false);
        if (isGenerate && buildFlags.get("all"))
            produceQA();
        if (!buildFlags.get("all")) {
            page.log("This was a Partial Build", LogMessageType.Process);
            CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
            for (String n : buildFlags.keySet()) if (buildFlags.get(n))
                b.append(n);
            page.log("  Build: " + b.toString(), LogMessageType.Process);
        } else
            page.log("This was a Full Build", LogMessageType.Process);
        if (!noSound) {
            AudioUtilities.tone(800, 10);
            AudioUtilities.tone(1000, 10);
            AudioUtilities.tone(1200, 10);
            AudioUtilities.tone(1000, 10);
            AudioUtilities.tone(800, 10);
        }
        page.log("Finished publishing FHIR @ " + Config.DATE_FORMAT().format(Calendar.getInstance().getTime()), LogMessageType.Process);
    } catch (Exception e) {
        if (!(e instanceof NullPointerException)) {
            // because NullPointerException is unexpected...
            try {
                processWarnings(e instanceof EValidationFailed);
            } catch (Exception e2) {
                page.log("  ERROR: Unable to process warnings: " + e2.getMessage(), LogMessageType.Error);
                e2.printStackTrace();
            }
        }
        if (buildFlags.containsKey("all") && !buildFlags.get("all")) {
            page.log("This was a Partial Build", LogMessageType.Process);
            CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
            for (String n : buildFlags.keySet()) if (buildFlags.get(n))
                b.append(n);
            page.log("  Build: " + b.toString(), LogMessageType.Process);
        } else
            page.log("This was a Full Build", LogMessageType.Process);
        if (!noSound) {
            AudioUtilities.tone(800, 20);
            AudioUtilities.tone(1000, 20);
            AudioUtilities.tone(1200, 20);
        }
        try {
            Thread.sleep(50);
        } catch (InterruptedException e1) {
        }
        if (!noSound) {
            AudioUtilities.tone(800, 20);
            AudioUtilities.tone(1000, 20);
            AudioUtilities.tone(1200, 20);
        }
        try {
            Thread.sleep(50);
        } catch (InterruptedException e1) {
        }
        if (!noSound) {
            AudioUtilities.tone(800, 20);
            AudioUtilities.tone(1000, 20);
            AudioUtilities.tone(1200, 20);
        }
        page.log("FHIR build failure @ " + Config.DATE_FORMAT().format(Calendar.getInstance().getTime()), LogMessageType.Process);
        System.out.println("Error: " + e.getMessage());
        e.printStackTrace();
        TextFile.stringToFile(StringUtils.defaultString(e.getMessage()), Utilities.path(folder, "publish", "simple-error.txt"));
        System.exit(1);
    }
}
Also used : ValidationMessage(org.hl7.fhir.utilities.validation.ValidationMessage) IniFile(org.hl7.fhir.utilities.IniFile) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) EValidationFailed(org.hl7.fhir.tools.publisher.ExampleInspector.EValidationFailed) IniFile(org.hl7.fhir.utilities.IniFile) File(java.io.File) CSFile(org.hl7.fhir.utilities.CSFile) TextFile(org.hl7.fhir.utilities.TextFile)

Example 8 with ImplementationGuideDefn

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

the class Publisher method processProfiles.

@SuppressWarnings("unchecked")
private void processProfiles() throws Exception {
    page.log(" ...process profiles (base)", LogMessageType.Process);
    // first, for each type and resource, we build it's master profile
    for (DefinedCode t : page.getDefinitions().getPrimitives().values()) {
        if (t instanceof PrimitiveType)
            genPrimitiveTypeProfile((PrimitiveType) t);
        else
            genPrimitiveTypeProfile((DefinedStringPattern) t);
    }
    genXhtmlProfile();
    for (TypeDefn t : page.getDefinitions().getTypes().values()) genTypeProfile(t);
    for (TypeDefn t : page.getDefinitions().getInfrastructure().values()) genTypeProfile(t);
    page.log(" ...process profiles (resources)", LogMessageType.Process);
    for (ResourceDefn r : page.getDefinitions().getBaseResources().values()) {
        r.setConformancePack(makeConformancePack(r));
        r.setProfile(new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(r.getConformancePack(), r, "core", false));
        if (page.getProfiles().has(r.getProfile().getUrl()))
            throw new Exception("Duplicate Profile URL " + r.getProfile().getUrl());
        page.getProfiles().see(r.getProfile(), page.packageInfo());
        ResourceTableGenerator rtg = new ResourceTableGenerator(page.getFolders().dstDir, page, null, true, page.getVersion());
        r.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
        r.getProfile().getText().getDiv().getChildNodes().add(rtg.generate(r, "", false));
    }
    for (String rn : page.getDefinitions().sortedResourceNames()) {
        ResourceDefn r = page.getDefinitions().getResourceByName(rn);
        r.setConformancePack(makeConformancePack(r));
        r.setProfile(new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(r.getConformancePack(), r, "core", false));
        if (page.getProfiles().has(r.getProfile().getUrl()))
            throw new Exception("Duplicate Profile URL " + r.getProfile().getUrl());
        page.getProfiles().see(r.getProfile(), page.packageInfo());
        ResourceTableGenerator rtg = new ResourceTableGenerator(page.getFolders().dstDir, page, null, true, page.getVersion());
        r.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
        r.getProfile().getText().getDiv().getChildNodes().add(rtg.generate(r, "", false));
    }
    for (ResourceDefn r : page.getDefinitions().getResourceTemplates().values()) {
        r.setConformancePack(makeConformancePack(r));
        r.setProfile(new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generate(r.getConformancePack(), r, "core", true));
        ResourceTableGenerator rtg = new ResourceTableGenerator(page.getFolders().dstDir, page, null, true, page.getVersion());
        r.getProfile().getText().setDiv(new XhtmlNode(NodeType.Element, "div"));
        r.getProfile().getText().getDiv().getChildNodes().add(rtg.generate(r, "", true));
        if (page.getProfiles().has(r.getProfile().getUrl()))
            throw new Exception("Duplicate Profile URL " + r.getProfile().getUrl());
        page.getProfiles().see(r.getProfile(), page.packageInfo());
    }
    for (ProfiledType pt : page.getDefinitions().getConstraints().values()) {
        genProfiledTypeProfile(pt);
    }
    page.log(" ...process profiles (extensions)", LogMessageType.Process);
    for (StructureDefinition ex : page.getWorkerContext().getExtensionDefinitions()) processExtension(ex);
    for (ResourceDefn r : page.getDefinitions().getResources().values()) {
        // boolean logged = false;
        for (Profile ap : r.getConformancePackages()) {
            // logged = true;
            for (ConstraintStructure p : ap.getProfiles()) processProfile(ap, p, ap.getId(), r);
        }
    }
    page.log(" ...process profiles (packs)", LogMessageType.Process);
    // we have profiles scoped by resources, and stand alone profiles
    for (Profile ap : page.getDefinitions().getPackList()) {
        // page.log(" ...  pack "+ap.getId(), LogMessageType.Process);
        for (ConstraintStructure p : ap.getProfiles()) processProfile(ap, p, ap.getId(), null);
    }
    page.log(" ...process logical models", LogMessageType.Process);
    for (ImplementationGuideDefn ig : page.getDefinitions().getSortedIgs()) {
        for (LogicalModel lm : ig.getLogicalModels()) {
            page.log(" ...process logical model " + lm.getId(), LogMessageType.Process);
            if (lm.getDefinition() == null)
                lm.setDefinition(new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc()).generateLogicalModel(ig, lm.getResource()));
        }
    }
    // now, validate the profiles
    for (Profile ap : page.getDefinitions().getPackList()) for (ConstraintStructure p : ap.getProfiles()) validateProfile(p);
    for (ResourceDefn r : page.getDefinitions().getResources().values()) for (Profile ap : r.getConformancePackages()) for (ConstraintStructure p : ap.getProfiles()) validateProfile(p);
    page.log(" ...Check FHIR Path Expressions", LogMessageType.Process);
    StringBuilder b = new StringBuilder();
    FHIRPathEngine fp = new FHIRPathEngine(page.getWorkerContext());
    fp.setHostServices(page.getExpressionResolver());
    for (FHIRPathUsage p : fpUsages) {
        checkExpression(b, fp, p);
    }
    TextFile.stringToFile(b.toString(), Utilities.path(page.getFolders().dstDir, "fhirpaths.txt"));
    checkAllOk();
}
Also used : TypeDefn(org.hl7.fhir.definitions.model.TypeDefn) ProfileGenerator(org.hl7.fhir.definitions.generators.specification.ProfileGenerator) ProfiledType(org.hl7.fhir.definitions.model.ProfiledType) CommaSeparatedStringBuilder(org.hl7.fhir.utilities.CommaSeparatedStringBuilder) FHIRPathEngine(org.hl7.fhir.r5.utils.FHIRPathEngine) ResourceTableGenerator(org.hl7.fhir.definitions.generators.specification.ResourceTableGenerator) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn) TransformerException(javax.xml.transform.TransformerException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Profile(org.hl7.fhir.definitions.model.Profile) XhtmlNode(org.hl7.fhir.utilities.xhtml.XhtmlNode) LogicalModel(org.hl7.fhir.definitions.model.LogicalModel) StructureDefinition(org.hl7.fhir.r5.model.StructureDefinition) DefinedStringPattern(org.hl7.fhir.definitions.model.DefinedStringPattern) DefinedCode(org.hl7.fhir.definitions.model.DefinedCode) PrimitiveType(org.hl7.fhir.definitions.model.PrimitiveType) FHIRPathUsage(org.hl7.fhir.definitions.validation.FHIRPathUsage) ConstraintStructure(org.hl7.fhir.definitions.model.ConstraintStructure)

Example 9 with ImplementationGuideDefn

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

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

the class PageProcessor method genOperationList.

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

Aggregations

ImplementationGuideDefn (org.hl7.fhir.definitions.model.ImplementationGuideDefn)34 FHIRException (org.hl7.fhir.exceptions.FHIRException)25 FileNotFoundException (java.io.FileNotFoundException)22 IOException (java.io.IOException)22 TransformerException (javax.xml.transform.TransformerException)21 CSFile (org.hl7.fhir.utilities.CSFile)21 StructureDefinition (org.hl7.fhir.r5.model.StructureDefinition)19 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)18 ContactPoint (org.hl7.fhir.r5.model.ContactPoint)17 File (java.io.File)16 ArrayList (java.util.ArrayList)16 Profile (org.hl7.fhir.definitions.model.Profile)16 ValueSet (org.hl7.fhir.r5.model.ValueSet)15 IniFile (org.hl7.fhir.utilities.IniFile)15 TextFile (org.hl7.fhir.utilities.TextFile)15 Example (org.hl7.fhir.definitions.model.Example)14 UnsupportedEncodingException (java.io.UnsupportedEncodingException)11 URISyntaxException (java.net.URISyntaxException)11 HashMap (java.util.HashMap)10 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)10