use of org.hl7.fhir.definitions.model.Example in project kindling by HL7.
the class Publisher method addToResourceFeed.
private void addToResourceFeed(ValueSet vs, Bundle dest, String filename) throws Exception {
maybeFixResourceId(vs, filename);
if (vs.getId() == null)
throw new Exception("Resource has no id: " + vs.getName() + " (" + vs.getUrl() + ")");
if (ResourceUtilities.getById(dest, ResourceType.ValueSet, vs.getId()) != null)
throw new Exception("Attempt to add duplicate value set " + vs.getId() + " (" + vs.getName() + ")");
if (!vs.hasText() || !vs.getText().hasDiv()) {
RendererFactory.factory(vs, page.getRc().copy()).render(vs);
}
if (!vs.hasText() || vs.getText().getDiv() == null)
throw new Exception("Example Value Set " + vs.getId() + " does not have any narrative");
ResourceUtilities.meta(vs).setLastUpdated(page.getGenDate().getTime());
if (vs.getUrl().startsWith("http://hl7.org/fhir/") && !vs.getUrl().equals("http://hl7.org/fhir/" + vs.getResourceType().toString() + "/" + vs.getId()))
throw new Exception("URL mismatch on value set: " + vs.getUrl() + " vs " + "http://hl7.org/fhir/" + vs.getResourceType().toString() + "/" + vs.getId());
dest.getEntry().add(new BundleEntryComponent().setResource(vs).setFullUrl("http://hl7.org/fhir/" + vs.fhirType() + "/" + vs.getId()));
}
use of org.hl7.fhir.definitions.model.Example in project kindling by HL7.
the class Publisher method produceProfile.
private void produceProfile(ResourceDefn resource, Profile pack, ConstraintStructure profile, SectionTracker st, String intro, String notes, String prefix, ImplementationGuideDefn ig) throws Exception {
File tmp = Utilities.createTempFile("tmp", ".tmp");
String title = profile.getId();
int level = (ig == null || ig.isCore()) ? 0 : 1;
// you have to validate a profile, because it has to be merged with it's
// base resource to fill out all the missing bits
// validateProfile(profile);
ByteArrayOutputStream bs = new ByteArrayOutputStream();
XmlSpecGenerator gen = new XmlSpecGenerator(bs, title + "-definitions.html", "", page, ig.isCore() ? "" : "../");
gen.generate(profile.getResource());
gen.close();
String xml = new String(bs.toByteArray());
bs = new ByteArrayOutputStream();
JsonSpecGenerator genJ = new JsonSpecGenerator(bs, title + "-definitions.html", "", page, ig.isCore() ? "" : "../", page.getVersion().toCode());
genJ.generate(profile.getResource());
genJ.close();
String json = new String(bs.toByteArray());
XmlParser comp = new XmlParser();
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + prefix + title + ".profile.xml");
comp.setOutputStyle(OutputStyle.PRETTY).compose(s, profile.getResource());
s.close();
Utilities.copyFile(new CSFile(page.getFolders().dstDir + prefix + title + ".profile.xml"), new CSFile(page.getFolders().dstDir + "examples" + File.separator + title + ".profile.xml"));
JsonParser jcomp = new JsonParser();
s = new FileOutputStream(page.getFolders().dstDir + prefix + title + ".profile.json");
jcomp.setOutputStyle(OutputStyle.PRETTY).compose(s, profile.getResource());
s.close();
// String shex = new ShExGenerator(page.getWorkerContext()).generate(HTMLLinkPolicy.NONE, profile.getResource());
// TextFile.stringToFile(shex, Utilities.changeFileExt(page.getFolders().dstDir + prefix +title + ".profile.shex", ".shex"));
// shexToXhtml(prefix +title + ".profile", "ShEx statement for " + prefix +title, shex, "profile-instance:type:" + title, "Type");
TerminologyNotesGenerator tgen = new TerminologyNotesGenerator(new FileOutputStream(tmp), page);
tgen.generate(level == 0 ? "" : "../", profile);
tgen.close();
String tx = TextFile.fileToString(tmp.getAbsolutePath());
String src = TextFile.fileToString(page.getFolders().templateDir + "template-profile.html");
src = page.processProfileIncludes(profile.getId(), profile.getId(), pack, profile, xml, json, tx, src, title + ".html", (resource == null ? profile.getResource().getType() : resource.getName()) + "/" + pack.getId() + "/" + profile.getId(), intro, notes, ig, false, false);
if (st != null)
src = insertSectionNumbers(src, st, title + ".html", level, null);
else if (ig != null && !ig.isCore()) {
src = addSectionNumbers(title + ".html", title, src, null, 1, null, ig);
st = page.getSectionTrackerCache().get(ig.getCode() + "::" + title);
}
page.getHTMLChecker().registerFile(prefix + title + ".html", "StructureDefinition " + profile.getResource().getName(), HTMLLinkChecker.XHTML_TYPE, false);
TextFile.stringToFile(src, page.getFolders().dstDir + prefix + title + ".html");
new ProfileUtilities(page.getWorkerContext(), page.getValidationErrors(), page).generateSchematrons(new FileOutputStream(page.getFolders().dstDir + prefix + title + ".sch"), profile.getResource());
if (pack.getExamples().size() > 0) {
src = TextFile.fileToString(page.getFolders().templateDir + "template-profile-examples.html");
src = page.processProfileIncludes(profile.getId(), profile.getId(), pack, profile, xml, json, tx, src, title + ".html", (resource == null ? profile.getResource().getType() : resource.getName()) + "/" + pack.getId() + "/" + profile.getId(), intro, notes, ig, false, false);
page.getHTMLChecker().registerFile(prefix + title + "-examples.html", "Examples for StructureDefinition " + profile.getResource().getName(), HTMLLinkChecker.XHTML_TYPE, true);
TextFile.stringToFile(src, page.getFolders().dstDir + prefix + title + "-examples.html");
}
src = TextFile.fileToString(page.getFolders().templateDir + "template-profile-definitions.html");
src = page.processProfileIncludes(profile.getId(), profile.getId(), pack, profile, xml, json, tx, src, title + ".html", (resource == null ? profile.getResource().getType() : resource.getName()) + "/" + pack.getId() + "/" + profile.getId(), intro, notes, ig, false, false);
if (st != null)
src = insertSectionNumbers(src, st, title + "-definitions.html", level, null);
page.getHTMLChecker().registerFile(prefix + title + "-definitions.html", "Definitions for StructureDefinition " + profile.getResource().getName(), HTMLLinkChecker.XHTML_TYPE, true);
TextFile.stringToFile(src, page.getFolders().dstDir + prefix + title + "-definitions.html");
src = TextFile.fileToString(page.getFolders().templateDir + "template-profile-mappings.html");
src = page.processProfileIncludes(profile.getId(), profile.getId(), pack, profile, xml, json, tx, src, title + ".html", (resource == null ? profile.getResource().getType() : resource.getName()) + "/" + pack.getId() + "/" + profile.getId(), intro, notes, ig, false, false);
if (st != null)
src = insertSectionNumbers(src, st, title + "-mappings.html", level, null);
page.getHTMLChecker().registerFile(prefix + title + "-mappings.html", "Mappings for StructureDefinition " + profile.getResource().getName(), HTMLLinkChecker.XHTML_TYPE, true);
TextFile.stringToFile(src, page.getFolders().dstDir + prefix + title + "-mappings.html");
try {
processQuestionnaire(resource, profile.getResource(), st, false, prefix, ig);
} catch (Exception e) {
e.printStackTrace();
page.log("Questionnaire Generation Failed: " + e.getMessage(), LogMessageType.Error);
}
new ReviewSpreadsheetGenerator().generate(page.getFolders().dstDir + prefix + Utilities.changeFileExt((String) profile.getResource().getUserData("filename"), "-review.xls"), "Health Level Seven International", page.getGenDate(), profile.getResource(), page);
// xml to xhtml of xml
// first pass is to strip the xsi: stuff. seems to need double
// processing in order to delete namespace crap
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
Document xdoc = builder.parse(new CSFileInputStream(page.getFolders().dstDir + prefix + title + ".profile.xml"));
XmlGenerator xmlgen = new XmlGenerator();
xmlgen.generate(xdoc.getDocumentElement(), tmp, "http://hl7.org/fhir", xdoc.getDocumentElement().getLocalName());
// reload it now
builder = factory.newDocumentBuilder();
xdoc = builder.parse(new CSFileInputStream(tmp.getAbsolutePath()));
XhtmlGenerator xhtml = new XhtmlGenerator(new ExampleAdorner(page.getDefinitions(), page.genlevel(level)));
ByteArrayOutputStream b = new ByteArrayOutputStream();
xhtml.generate(xdoc, b, "StructureDefinition", profile.getTitle(), 0, true, title + ".profile.xml.html");
String html = TextFile.fileToString(page.getFolders().templateDir + "template-profile-example-xml.html").replace("<%example%>", b.toString());
html = page.processProfileIncludes(title + ".profile.xml.html", profile.getId(), pack, profile, "", "", "", html, title + ".html", (resource == null ? profile.getResource().getType() : resource.getName()) + "/" + pack.getId() + "/" + profile.getId(), intro, notes, ig, false, hasNarrative(xdoc));
TextFile.stringToFile(html, page.getFolders().dstDir + prefix + title + ".profile.xml.html");
page.getHTMLChecker().registerFile(prefix + title + ".profile.xml.html", "StructureDefinition", HTMLLinkChecker.XHTML_TYPE, false);
String n = prefix + title + ".profile";
json = resource2Json(profile.getResource());
json = "<div class=\"example\">\r\n<p>" + Utilities.escapeXml("StructureDefinition for " + profile.getResource().getDescription()) + "</p>\r\n<p><a href=\"" + title + ".profile.json\">Raw JSON</a></p>\r\n<pre class=\"json\">\r\n" + Utilities.escapeXml(json) + "\r\n</pre>\r\n</div>\r\n";
html = TextFile.fileToString(page.getFolders().templateDir + "template-profile-example-json.html").replace("<%example%>", json);
html = page.processProfileIncludes(title + ".profile.json.html", profile.getId(), pack, profile, "", "", "", html, title + ".html", (resource == null ? profile.getResource().getType() : resource.getName()) + "/" + pack.getId() + "/" + profile.getId(), intro, notes, ig, false, false);
TextFile.stringToFile(html, page.getFolders().dstDir + prefix + title + ".profile.json.html");
// page.getEpub().registerFile(n + ".json.html", description, EPubManager.XHTML_TYPE);
page.getHTMLChecker().registerExternal(n + ".json.html");
tmp.delete();
}
use of org.hl7.fhir.definitions.model.Example in project kindling by HL7.
the class Publisher method generateConceptMap.
private void generateConceptMap(ConceptMap cm) throws Exception {
String filename = cm.getUserString("path");
RenderingContext lrc = page.getRc().copy().setLocalPrefix("").setTooCostlyNoteEmpty(PageProcessor.TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(PageProcessor.TOO_MANY_CODES_TEXT_NOT_EMPTY);
RendererFactory.factory(cm, lrc).render(cm);
IParser json = new JsonParser().setOutputStyle(OutputStyle.PRETTY);
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".json"));
json.compose(s, cm);
s.close();
json = new JsonParser().setOutputStyle(OutputStyle.CANONICAL);
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".canonical.json"));
json.compose(s, cm);
s.close();
String n = Utilities.changeFileExt(filename, "");
jsonToXhtml(n, cm.getName(), resource2Json(cm), "conceptmap-instance", "Concept Map", null, wg("vocab"));
ttlToXhtml(n, cm.getName(), resource2Ttl(cm), "conceptmap-instance", "Concept Map", null, wg("vocab"));
IParser xml = new XmlParser().setOutputStyle(OutputStyle.PRETTY);
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".xml"));
xml.compose(s, cm);
s.close();
xml = new XmlParser().setOutputStyle(OutputStyle.CANONICAL);
s = new FileOutputStream(page.getFolders().dstDir + Utilities.changeFileExt(filename, ".canonical.xml"));
xml.compose(s, cm);
s.close();
cloneToXhtml(n, cm.getName(), false, "conceptmap-instance", "Concept Map", null, wg("vocab"));
// now, we create an html page from the narrative
String narrative = new XhtmlComposer(XhtmlComposer.HTML).compose(cm.getText().getDiv());
String html = TextFile.fileToString(page.getFolders().templateDir + "template-example.html").replace("<%example%>", narrative);
html = page.processPageIncludes(Utilities.changeFileExt(filename, ".html"), html, "conceptmap-instance", null, null, null, "Concept Map", null, null, wg("vocab"));
TextFile.stringToFile(html, page.getFolders().dstDir + Utilities.changeFileExt(filename, ".html"));
conceptMapsFeed.getEntry().add(new BundleEntryComponent().setResource(cm).setFullUrl("http://hl7.org/fhir/" + cm.fhirType() + "/" + cm.getId()));
page.getConceptMaps().see(cm, page.packageInfo());
page.getHTMLChecker().registerFile(n + ".html", cm.getName(), HTMLLinkChecker.XHTML_TYPE, false);
}
use of org.hl7.fhir.definitions.model.Example 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.Example in project kindling by HL7.
the class PageProcessor method produceStructureDefinitionExamples.
private String produceStructureDefinitionExamples(ResourceDefn resource) throws Exception {
StringBuilder s = new StringBuilder();
s.append("<div id=\"tabs\">\r\n");
s.append("<ul>\r\n");
s.append(" <li><a href=\"#tabs-1\">Base Types</a></li>\r\n");
s.append(" <li><a href=\"#tabs-2\">Resources</a></li>\r\n");
s.append(" <li><a href=\"#tabs-3\">Constraints</a></li>\r\n");
s.append(" <li><a href=\"#tabs-4\">Extensions</a></li>\r\n");
s.append(" <li><a href=\"#tabs-5\">Examples</a></li>\r\n");
s.append("</ul>\r\n");
s.append("<div id=\"tabs-1\">\r\n");
// base types
s.append("<table class=\"list\">\r\n");
genStructureExampleCategory(s, "Abstract Types", "3");
genStructureExample(s, definitions.getElementLink(), "element.profile", "element", "Element");
genStructureExample(s, definitions.getBackboneLink(), "backboneelement.profile", "backboneelement", "BackBoneElement");
genStructureExample(s, "resource.html", "resource.profile", "resource", "Resource");
genStructureExample(s, "domainresource.html", "domainresource.profile", "domainresource", "DomainResource");
genStructureExampleCategory(s, "Primitive Types", "3");
List<String> names = new ArrayList<String>();
names.addAll(definitions.getPrimitives().keySet());
Collections.sort(names);
for (String n : names) {
DefinedCode dc = definitions.getPrimitives().get(n);
genStructureExample(s, "datatypes.html#" + dc.getCode(), dc.getCode().toLowerCase() + ".profile", dc.getCode().toLowerCase(), dc.getCode());
}
genStructureExampleCategory(s, "Data Types", "3");
names.clear();
names.addAll(definitions.getTypes().keySet());
names.addAll(definitions.getInfrastructure().keySet());
Collections.sort(names);
for (String n : names) {
org.hl7.fhir.definitions.model.TypeDefn t = definitions.getTypes().get(n);
if (t == null)
t = definitions.getInfrastructure().get(n);
genStructureExample(s, getLinkFor("", t.getName()), t.getName().toLowerCase() + ".profile", t.getName().toLowerCase(), t.getName());
}
s.append("</table>\r\n");
s.append("</div>\r\n");
s.append("<div id=\"tabs-2\">\r\n");
s.append("<table class=\"list\">\r\n");
genStructureExampleCategory(s, "Resources", "3");
for (String n : definitions.sortedResourceNames()) {
ResourceDefn r = definitions.getResources().get(n);
genStructureExample(s, r.getName().toLowerCase() + ".html", r.getName().toLowerCase() + ".profile", r.getName().toLowerCase(), r.getName());
}
s.append("</table>\r\n");
s.append("</div>\r\n");
s.append("<div id=\"tabs-3\">\r\n");
s.append("<table class=\"list\">\r\n");
Map<String, ConstraintStructure> constraints = new HashMap<String, ConstraintStructure>();
for (Profile pp : definitions.getPackList()) {
for (ConstraintStructure p : pp.getProfiles()) constraints.put(p.getId(), p);
}
for (String rn : definitions.sortedResourceNames()) for (Profile ap : definitions.getResourceByName(rn).getConformancePackages()) for (ConstraintStructure p : ap.getProfiles()) constraints.put(p.getId(), p);
names.clear();
names.addAll(constraints.keySet());
Collections.sort(names);
for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
boolean started = false;
for (String n : names) {
ConstraintStructure p = constraints.get(n);
if (ig == p.getUsage()) {
if (!started) {
started = true;
genStructureExampleCategory(s, ig.getName(), "3");
}
String prefix = ig.isCore() ? "" : ig.getCode() + "/";
genStructureExample(s, prefix + p.getId().toLowerCase() + ".html", prefix + p.getId().toLowerCase() + ".profile", p.getId().toLowerCase(), p.getTitle());
}
}
}
s.append("</table>\r\n");
s.append("</div>\r\n");
s.append("<div id=\"tabs-4\">\r\n");
s.append("<table class=\"list\">\r\n");
names.clear();
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) names.add(sd.getUrl());
Collections.sort(names);
for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
boolean started = false;
for (String n : names) {
StructureDefinition ed = workerContext.fetchResource(StructureDefinition.class, n);
if (ig.getCode().equals(ToolResourceUtilities.getUsage(ed))) {
if (!started) {
started = true;
genStructureExampleCategory(s, ig.getName(), "3");
}
String prefix = ig.isCore() ? "" : ig.getCode() + "/";
genStructureExample(s, prefix + "extension-" + ed.getId().toLowerCase() + ".html", prefix + "extension-" + ed.getId().toLowerCase(), ed.getId().toLowerCase(), ed.getUrl().startsWith("http://hl7.org/fhir/StructureDefinition/") ? ed.getUrl().substring(40) : ed.getUrl(), ed.getName());
}
}
}
s.append("</table>\r\n");
s.append("</div>\r\n");
s.append("<div id=\"tabs-5\">\r\n");
s.append("<table class=\"list\">\r\n");
for (Example e : resource.getExamples()) {
if (e.isRegistered() && Utilities.noString(e.getIg()))
produceExampleListEntry(s, e, null, null);
}
for (Profile p : resource.getConformancePackages()) {
for (Example e : p.getExamples()) {
produceExampleListEntry(s, e, p, null);
}
}
for (Profile p : definitions.getPackList()) {
ImplementationGuideDefn ig = definitions.getIgs().get(p.getCategory());
for (Example e : p.getExamples()) {
String rn = e.getResourceName();
if (Utilities.noString(rn))
rn = e.getXml().getDocumentElement().getNodeName();
if (rn.equals(resource.getName()))
produceExampleListEntry(s, e, p, ig);
}
}
for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
if (ig.getIg() != null) {
for (ImplementationGuideDefinitionResourceComponent res : ig.getIg().getDefinition().getResource()) {
Example e = (Example) res.getUserData(ToolResourceUtilities.NAME_RES_EXAMPLE);
if (res.hasExample() && e != null && e.getResourceName().equals(resource.getName()))
produceExampleListEntry(s, res, ig);
}
}
}
s.append("</table>\r\n");
s.append("</div>\r\n");
s.append("</div>\r\n");
s.append("\r\n");
s.append("<script src=\"external/jquery/jquery.js\"> </script>\r\n");
s.append("<script src=\"jquery-ui.min.js\"> </script>\r\n");
s.append("<script>\r\n");
s.append("try {\r\n");
s.append(" var currentTabIndex = sessionStorage.getItem('fhir-sdelist-tab-index');\r\n");
s.append("}\r\n");
s.append("catch(exception){\r\n");
s.append("}\r\n");
s.append("\r\n");
s.append("if (!currentTabIndex)\r\n");
s.append(" currentTabIndex = '0';\r\n");
s.append(" \r\n");
s.append("$( '#tabs' ).tabs({\r\n");
s.append(" active: currentTabIndex,\r\n");
s.append(" activate: function( event, ui ) {\r\n");
s.append(" var active = $('.selector').tabs('option', 'active');\r\n");
s.append(" currentTabIndex = ui.newTab.index();\r\n");
s.append(" document.activeElement.blur();\r\n");
s.append(" try {\r\n");
s.append(" sessionStorage.setItem('fhir-sdelist-tab-index', currentTabIndex);\r\n");
s.append(" }\r\n");
s.append(" catch(exception){\r\n");
s.append(" }\r\n");
s.append(" }\r\n");
s.append(" });\r\n");
s.append("</script>\r\n");
s.append("\r\n");
return s.toString();
}
Aggregations