use of org.hl7.fhir.r4.model.StructureDefinition in project kindling by HL7.
the class PageProcessor method mappingsExtension.
private String mappingsExtension(StructureDefinition ed) throws IOException {
MappingsGenerator m = new MappingsGenerator(definitions);
m.generate(ed);
return m.getMappings();
}
use of org.hl7.fhir.r4.model.StructureDefinition in project kindling by HL7.
the class PageProcessor method resolveBinding.
public BindingResolution resolveBinding(StructureDefinition profile, String ref, String description, String path) throws FHIRException {
BindingResolution br = new BindingResolution();
if (ref.contains("|"))
ref = ref.substring(0, ref.indexOf("|"));
if (ref.startsWith("http://terminology.hl7.org/ValueSet/v3-") || ref.startsWith("http://terminology.hl7.org/ValueSet/v2-")) {
ValueSet vs = workerContext.fetchResource(ValueSet.class, ref);
if (vs == null) {
br.url = "v3/" + ref.substring(39) + "/vs.html";
br.display = ref.substring(39);
} else {
br.url = vs.getUserString("path");
br.display = vs.present();
}
} else if (definitions.getValuesets().has(ref)) {
ValueSet vs = definitions.getValuesets().get(ref);
br.url = vs.getUserString("path");
br.display = vs.present();
} else if (ref.startsWith("ValueSet/")) {
ValueSet vs = definitions.getValuesets().get(ref.substring(8));
if (vs == null) {
br.url = ref.substring(9) + ".html";
br.display = ref.substring(9);
} else {
br.url = vs.getUserString("path");
br.display = vs.present();
}
} else if (ref.startsWith("http://hl7.org/fhir/ValueSet/")) {
ValueSet vs = definitions.getValuesets().get(ref);
if (vs == null)
vs = definitions.getExtraValuesets().get(ref);
if (vs != null) {
br.url = vs.getUserString("path");
if (Utilities.noString(br.url))
br.url = ref.substring(23) + ".html";
br.display = vs.present();
} else if (ref.substring(23).equals("use-context")) {
// special case because this happens before the value set is created
br.url = "valueset-" + ref.substring(23) + ".html";
br.display = "Context of Use ValueSet";
} else if (ref.startsWith("http://terminology.hl7.org/ValueSet/v3-")) {
br.url = "v3/" + ref.substring(26) + "/index.html";
br.display = ref.substring(26);
} else if (ref.startsWith("http://terminology.hl7.org/ValueSet/v2-")) {
br.url = "v2/" + ref.substring(26) + "/index.html";
br.display = ref.substring(26);
} else if (ref.startsWith("#")) {
br.url = null;
br.display = ref;
} else {
br.url = ref;
br.display = "????";
getValidationErrors().add(new ValidationMessage(Source.Publisher, IssueType.NOTFOUND, -1, -1, path, "Unresolved Value set " + ref, IssueSeverity.WARNING));
}
} else {
br.url = ref;
if (ref.equals("http://tools.ietf.org/html/bcp47"))
br.display = "IETF BCP-47";
else if (ref.equals("http://www.rfc-editor.org/bcp/bcp13.txt"))
br.display = "IETF BCP-13";
else if (ref.equals("http://www.ncbi.nlm.nih.gov/nuccore?db=nuccore"))
br.display = "NucCore";
else if (ref.equals("https://rtmms.nist.gov/rtmms/index.htm#!rosetta"))
br.display = "Rosetta";
else if (ref.equals("http://www.iso.org/iso/country_codes.htm"))
br.display = "ISO Country Codes";
else if (ref.equals("http://www.ncbi.nlm.nih.gov/clinvar/variation"))
br.display = "ClinVar";
else if (!Utilities.noString(description))
br.display = description;
else
br.display = "????";
}
return br;
}
use of org.hl7.fhir.r4.model.StructureDefinition in project kindling by HL7.
the class PageProcessor method presentContext.
private Object presentContext(StructureDefinition cs, String resource) {
StringBuilder b = new StringBuilder();
boolean first = true;
for (StructureDefinitionContextComponent c : cs.getContext()) {
if (appliesTo(c, resource)) {
if (first)
first = false;
else
b.append(", ");
if (c.getType() != ExtensionContextType.ELEMENT)
b.append("<a href=\"codesystem-extension-context-type.html#" + c.getType().toCode() + "\">" + c.getType().toCode() + "</a>: ");
b.append("<code>" + c.getExpression() + "</code>");
}
}
return b.toString();
}
use of org.hl7.fhir.r4.model.StructureDefinition 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>";
}
use of org.hl7.fhir.r4.model.StructureDefinition 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;
}
Aggregations