use of org.hl7.fhir.definitions.model.ResourceDefn 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;
}
use of org.hl7.fhir.definitions.model.ResourceDefn 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();
}
use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.
the class PageProcessor method buildResListByBallot.
private String buildResListByBallot() throws FHIRException {
List<String> res = new ArrayList<String>();
for (ResourceDefn rd : definitions.getBaseResources().values()) res.add(rd.getName());
for (ResourceDefn rd : definitions.getResources().values()) res.add(rd.getName());
Collections.sort(res);
StringBuilder b = new StringBuilder();
StandardsStatus[] values = StandardsStatus.values();
for (int i = values.length - 1; i >= 0; i--) {
StandardsStatus next = values[i];
boolean first = true;
for (String rn : res) {
ResourceDefn rd = definitions.getResourceByName(rn);
if (rd.getStatus() == next) {
if (first) {
b.append("<p><b>");
b.append(next.toDisplay());
b.append("</b></p>\r\n<ul style=\"width: 90%; -moz-column-count: 4; -moz-column-gap: 10px; -webkit-column-count: 4; -webkit-column-gap: 10px; column-count: 4; column-gap: 10px\">\r\n");
first = false;
}
if (rd.getNormativePackage() != null || rd.getNormativeVersion() != null)
b.append(" <li><a title=\"[%resdesc " + rn + "%]\" href=\"" + rn.toLowerCase() + ".html\">" + rn + "</a> <a href=\"versions.html#std-process\" title=\"Normative Content\" class=\"normative-flag\">N</a></li>\r\n");
else
b.append(" <li><a title=\"[%resdesc " + rn + "%]\" href=\"" + rn.toLowerCase() + ".html\">" + rn + "</a></li>\r\n");
}
}
if (!first)
b.append("</ul>\r\n");
}
return b.toString();
}
use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.
the class PageProcessor method genBestPracticeList.
private void genBestPracticeList(StringBuilder b, ResourceDefn r) throws Exception {
StringBuilder b1 = new StringBuilder();
genBestPracticeList(b1, r.getRoot());
if (b1.length() > 0) {
b.append("<tr>");
b.append("<td colspan=\"3\">");
b.append("<b><a href=\"");
b.append(r.getName().toLowerCase());
b.append(".html\">");
b.append(r.getName());
b.append("</a></b>");
b.append("</td>");
b.append("</tr>\r\n");
b.append(b1.toString());
}
}
use of org.hl7.fhir.definitions.model.ResourceDefn in project kindling by HL7.
the class PageProcessor method compResourceMap.
private String compResourceMap(String name) throws Exception {
String n = name.split("\\-")[1];
StringBuilder in = new StringBuilder();
StringBuilder out = new StringBuilder();
Map<ResourceDefn, String> map = definitions.getCompartmentByName(n).getResources();
for (String rn : definitions.sortedResourceNames()) {
ResourceDefn rd = definitions.getResourceByName(rn);
String rules = map.get(rd);
if (Utilities.noString(rules)) {
out.append(" <li><a href=\"").append(rd.getName().toLowerCase()).append(".html\">").append(rd.getName()).append("</a></li>\r\n");
} else if (!rules.equals("{def}")) {
in.append(" <tr><td><a href=\"").append(rd.getName().toLowerCase()).append(".html\">").append(rd.getName()).append("</a></td><td>").append(rules.replace("|", "or")).append("</td></tr>\r\n");
}
}
return "<p>\r\nThe following resources may be in this compartment:\r\n</p>\r\n" + "<table class=\"grid\">\r\n" + " <tr><td><b>Resource</b></td><td><b>Inclusion Criteria</b></td></tr>\r\n" + in.toString() + "</table>\r\n" + "<p>\r\nA resource is in this compartment if the nominated search parameter (or chain) refers to the patient resource that defines the compartment.\r\n</p>\r\n" + "<p>\r\n\r\n</p>\r\n" + "<p>\r\nThe following resources are never in this compartment:\r\n</p>\r\n" + "<ul>\r\n" + out.toString() + "</ul>\r\n";
}
Aggregations