use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project kindling by HL7.
the class Publisher method generateCodeSystemPart2.
private void generateCodeSystemPart2(CodeSystem cs) throws Exception {
String n = cs.getUserString("filename");
if (n == null)
n = "codesystem-" + cs.getId();
ImplementationGuideDefn ig = (ImplementationGuideDefn) cs.getUserData(ToolResourceUtilities.NAME_RES_IG);
if (ig != null)
n = ig.getCode() + File.separator + n;
if (cs.getText().getDiv().allChildrenAreText() && (Utilities.noString(cs.getText().getDiv().allText()) || !cs.getText().getDiv().allText().matches(".*\\w.*"))) {
RenderingContext lrc = page.getRc().copy().setLocalPrefix(ig != null ? "../" : "").setTooCostlyNoteEmpty(PageProcessor.TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(PageProcessor.TOO_MANY_CODES_TEXT_NOT_EMPTY);
RendererFactory.factory(cs, lrc).render(cs);
}
page.getVsValidator().validate(page.getValidationErrors(), n, cs, true, false);
if (isGenerate) {
// page.log(" ... "+n, LogMessageType.Process);
addToResourceFeed(cs, valueSetsFeed, null);
if (cs.getUserData("path") == null)
cs.setUserData("path", n + ".html");
page.setId(cs.getId());
String sf;
WorkGroup wg = wg(cs, "vocab");
try {
sf = page.processPageIncludes(n + ".html", TextFile.fileToString(page.getFolders().templateDir + "template-cs.html"), "codeSystem", null, n + ".html", cs, null, "Value Set", ig, null, wg);
} catch (Exception e) {
throw new Exception("Error processing " + n + ".html: " + e.getMessage(), e);
}
sf = addSectionNumbers(n + ".html", "template-codesystem", sf, csCounter(), ig == null ? 0 : 1, null, ig);
TextFile.stringToFile(sf, page.getFolders().dstDir + n + ".html");
try {
String src = page.processPageIncludesForBook(n + ".html", TextFile.fileToString(page.getFolders().templateDir + "template-cs-book.html"), "codeSystem", cs, ig, null);
cachePage(n + ".html", src, "Code System " + n, false);
page.setId(null);
} catch (Exception e) {
throw new Exception("Error processing " + n + ".html: " + e.getMessage(), e);
}
IParser json = new JsonParser().setOutputStyle(OutputStyle.PRETTY);
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + n + ".json");
json.compose(s, cs);
s.close();
json = new JsonParser().setOutputStyle(OutputStyle.CANONICAL);
s = new FileOutputStream(page.getFolders().dstDir + n + ".canonical.json");
json.compose(s, cs);
s.close();
IParser xml = new XmlParser().setOutputStyle(OutputStyle.PRETTY);
s = new FileOutputStream(page.getFolders().dstDir + n + ".xml");
xml.compose(s, cs);
s.close();
xml = new XmlParser().setOutputStyle(OutputStyle.CANONICAL);
s = new FileOutputStream(page.getFolders().dstDir + n + ".canonical.xml");
xml.compose(s, cs);
s.close();
// System.out.println(vs.getUrl());
cloneToXhtml(n, "Definition for Code System " + cs.getName(), false, "codesystem-instance", "Code System", null, wg);
jsonToXhtml(n, "Definition for Code System " + cs.getName(), resource2Json(cs), "codesystem-instance", "Code System", null, wg);
ttlToXhtml(n, "Definition for Code System " + cs.getName(), resource2Ttl(cs), "codesystem-instance", "Code System", null, wg);
}
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project kindling by HL7.
the class Publisher method generateCodeSystemsPart1.
private void generateCodeSystemsPart1() throws Exception {
page.log(" ...code systems", LogMessageType.Process);
for (CodeSystem cs : page.getDefinitions().getCodeSystems().getList()) {
if (cs != null && !cs.hasUserData("external.url")) {
if (!cs.hasText()) {
cs.setText(new Narrative());
cs.getText().setStatus(NarrativeStatus.EMPTY);
}
if (!cs.getText().hasDiv()) {
cs.getText().setDiv(new XhtmlNode(NodeType.Element));
cs.getText().getDiv().setName("div");
}
// if (ToolingExtensions.getOID(cs) == null)
// throw new Exception("No OID on code system "+cs.getUrl());
}
}
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project kindling by HL7.
the class PageProcessor method generateValueSetUsage.
private String generateValueSetUsage(ValueSet vs, String prefix, boolean addTitle) throws Exception {
List<String> items = new ArrayList<>();
if (vs.hasUrl()) {
for (CodeSystem cs : getCodeSystems().getList()) {
if (cs != null) {
if (vs.getUrl().equals(cs.getValueSet())) {
String p = cs.getUserString("path");
addItem(items, "<li>CodeSystem: This value set is the designated 'entire code system' value set for <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cs.getName() + "</a> " + "</li>\r\n");
}
}
}
}
for (ConceptMap cm : getConceptMaps().getList()) {
String p = cm.getUserString("path");
if (cm.hasSourceUriType() && cm.getSourceUriType().equals(vs.getUrl())) {
addItem(items, "<li>ConceptMap: Translation source in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.present() + "</a> " + "</li>\r\n");
} else if (cm.hasSourceCanonicalType() && (cm.getSourceCanonicalType().getValue().equals(vs.getUrl()) || vs.getUrl().endsWith("/" + cm.getSourceCanonicalType().getValue()))) {
addItem(items, "<li>ConceptMap: Translation source in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.getName() + "</a> " + "</li>\r\n");
}
}
for (ConceptMap cm : getConceptMaps().getList()) {
String p = cm.getUserString("path");
if (cm.hasTargetUriType() && cm.getTargetUriType().equals(vs.getUrl())) {
addItem(items, "<li>ConceptMap: Translation target in <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.present() + "</a> " + "</li>\r\n");
} else if (cm.hasTargetCanonicalType() && (cm.getTargetCanonicalType().getValue().equals(vs.getUrl()) || vs.getUrl().endsWith("/" + cm.getTargetCanonicalType().getValue()))) {
addItem(items, "<li>ConceptMap: Translation target ConceptMap <a href=\"" + (Utilities.isAbsoluteUrl(p) ? "" : prefix) + p + "\">" + cm.getName() + "</a> " + "</li>\r\n");
}
}
for (ResourceDefn r : definitions.getBaseResources().values()) {
scanForUsage(items, vs, r.getRoot(), r.getName().toLowerCase() + "-definitions.html", prefix);
scanForOperationUsage(items, vs, r, r.getName().toLowerCase() + "-operation-", prefix);
scanForProfileUsage(items, vs, r, prefix);
}
for (ResourceDefn r : definitions.getResources().values()) {
scanForUsage(items, vs, r.getRoot(), r.getName().toLowerCase() + "-definitions.html", prefix);
scanForOperationUsage(items, vs, r, r.getName().toLowerCase() + "-operation-", prefix);
scanForProfileUsage(items, vs, r, prefix);
}
for (ElementDefn e : definitions.getInfrastructure().values()) {
scanForUsage(items, vs, e, definitions.getSrcFile(e.getName()) + "-definitions.html", prefix);
}
for (ElementDefn e : definitions.getTypes().values()) {
if (!definitions.dataTypeIsSharedInfo(e.getName())) {
scanForUsage(items, vs, e, definitions.getSrcFile(e.getName()) + "-definitions.html", prefix);
}
}
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
scanForUsage(items, vs, sd, sd.getUserString("path"), prefix);
}
for (ValueSet vsi : definitions.getValuesets().getList()) {
String path = (String) vsi.getUserData("path");
if (vs.hasCompose()) {
for (ConceptSetComponent t : vs.getCompose().getInclude()) {
for (UriType uri : t.getValueSet()) {
if (uri.getValue().equals(vs.getUrl())) {
addItem(items, "<li>ValueSet: Included in <a href=\"" + prefix + path + "\">" + Utilities.escapeXml(vs.present()) + "</a></li>\r\n");
}
}
}
for (ConceptSetComponent t : vs.getCompose().getExclude()) {
for (UriType uri : t.getValueSet()) {
if (uri.getValue().equals(vs.getUrl())) {
addItem(items, "<li>ValueSet: Excluded from <a href=\"" + prefix + path + "\">" + Utilities.escapeXml(vs.present()) + "</a></li>\r\n");
}
}
}
// for (ConceptSetComponent t : vsi.getCompose().getInclude()) {
// if (vs.hasCodeSystem() && t.getSystem().equals(vs.getCodeSystem().getSystem()))
// b.append(" <li>Included in Valueset <a href=\""+prefix+path+"\">"+Utilities.escapeXml(vs.getName())+"</a></li>\r\n");
// }
// for (ConceptSetComponent t : vsi.getCompose().getExclude()) {
// if (vs.hasCodeSystem() && t.getSystem().equals(vs.getCodeSystem().getSystem()))
// b.append(" <li>Excluded in Valueset <a href=\""+prefix+path+"\">"+Utilities.escapeXml(vs.getName())+"</a></li>\r\n");
// }
}
}
if (ini.getPropertyNames(vs.getUrl()) != null) {
for (String n : ini.getPropertyNames(vs.getUrl())) {
addItem(items, "<li>" + ini.getStringProperty(vs.getUrl(), n) + "</li>\r\n");
}
}
if (items.size() == 0)
return "<p>\r\nThis value set is not currently used\r\n</p>\r\n";
else {
StringBuilder b = new StringBuilder();
for (String s : items) {
b.append(" " + s);
}
return (addTitle ? "<p>\r\nThis value set is used in the following places:\r\n</p>\r\n" : "") + "<ul>\r\n" + b.toString() + "</ul>\r\n";
}
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project kindling by HL7.
the class PageProcessor method genNSList.
private String genNSList() throws Exception {
StringBuilder b = new StringBuilder();
b.append("<p>Redirects on this page:</p>\r\n");
b.append("<ul>\r\n");
b.append(" <li>Resources</li>\r\n");
b.append(" <li>Data Types</li>\r\n");
b.append(" <li>Code Systems</li>\r\n");
b.append(" <li>Value Sets</li>\r\n");
b.append(" <li>Extensions</li>\r\n");
b.append(" <li>Profiles</li>\r\n");
b.append(" <li>Naming Systems</li>\r\n");
b.append(" <li>Examples</li>\r\n");
b.append(" <li>Compartments</li>\r\n");
b.append(" <li>Data Elements</li>\r\n");
b.append(" <li>Search Parameters</li>\r\n");
b.append(" <li>Implementation Guides</li>\r\n");
b.append(" <li>SIDs</li>\r\n");
b.append(" <li>Others From publish.ini</li>\r\n");
b.append("</ul>\r\n");
b.append("<table class=\"grid\">\r\n");
b.append(" <tr><td><b>URL</b></td><td><b>Thing</b></td><td><b>Page</b></td></tr>");
for (String n : definitions.sortedResourceNames()) definitions.addNs("http://hl7.org/fhir/" + n, n + " Resource", n.toLowerCase() + ".html");
for (String n : definitions.getTypes().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
for (String n : definitions.getPrimitives().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Primitive Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
for (String n : definitions.getConstraints().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type Profile " + n, definitions.getSrcFile(n) + ".html#" + n);
for (String n : definitions.getInfrastructure().keySet()) definitions.addNs("http://hl7.org/fhir/" + n, "Data Type " + n, definitions.getSrcFile(n) + ".html#" + n);
for (CodeSystem cs : getCodeSystems().getList()) if (cs != null && cs.getUrl().startsWith("http://hl7.org/fhir"))
definitions.addNs(cs.getUrl(), "CodeSystem " + cs.getName(), cs.getUserString("path"));
for (ValueSet vs : getValueSets().getList()) if (vs.getUrl().startsWith("http://hl7.org/fhir"))
definitions.addNs(vs.getUrl(), "ValueSet " + vs.present(), vs.getUserString("path"));
for (ConceptMap cm : getConceptMaps().getList()) if (cm.getUrl().startsWith("http://hl7.org/fhir"))
definitions.addNs(cm.getUrl(), "Concept Map" + cm.getName(), cm.getUserString("path"));
for (StructureDefinition sd : profiles.getList()) if (sd.getUrl().startsWith("http://hl7.org/fhir") && !definitions.getResourceTemplates().containsKey(sd.getName()))
definitions.addNs(sd.getUrl(), "Profile " + sd.getName(), sd.getUserString("path"));
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) if (sd.getUrl().startsWith("http://hl7.org/fhir"))
definitions.addNs(sd.getUrl(), "Profile " + sd.getName(), sd.getUserString("path"));
for (NamingSystem nss : definitions.getNamingSystems()) {
String url = null;
definitions.addNs("http://hl7.org/fhir/NamingSystem/" + nss.getId(), "System " + nss.getName(), nss.getUserString("path"));
for (NamingSystemUniqueIdComponent t : nss.getUniqueId()) {
if (t.getType() == NamingSystemIdentifierType.URI)
url = t.getValue();
}
if (url != null && url.startsWith("http://hl7.org/fhir"))
definitions.addNs(url, "System " + nss.getName(), nss.getUserString("path"));
}
for (String n : ini.getPropertyNames("redirects")) {
String[] parts = ini.getStringProperty("redirects", n).split("\\;");
definitions.addNs(n, "System " + parts[0], parts[1]);
}
for (ImplementationGuideDefn ig : definitions.getIgs().values()) {
if (!ig.isCore()) {
definitions.addNs("http://hl7.org/fhir/ImplementationGuide/" + ig.getCode(), ig.getName(), ig.getHomePage());
definitions.addNs("http://hl7.org/fhir/" + ig.getCode(), ig.getName(), ig.getHomePage());
}
}
for (Compartment t : definitions.getCompartments()) {
definitions.addNs(t.getUri(), t.getName(), "compartmentdefinition.html#" + t.getName());
}
List<String> list = new ArrayList<String>();
list.addAll(definitions.getRedirectList().keySet());
Collections.sort(list);
for (String url : list) {
NamespacePair p = definitions.getRedirectList().get(url);
b.append(" <tr><td>" + Utilities.escapeXml(url) + "</td><td>" + hsplt(Utilities.escapeXml(p.desc)) + "</td><td><a href=\"" + p.page + "\">" + hsplt(Utilities.escapeXml(p.page)) + "</a></td></tr>\r\n");
}
b.append("</table>\r\n");
b.append("<p>" + Integer.toString(list.size()) + " Entries</p>\r\n");
return b.toString();
}
use of org.hl7.gravity.refimpl.sdohexchange.sdohmappings.System in project kindling by HL7.
the class OldSpreadsheetParser method readOperations.
private void readOperations(List<Operation> oplist, Sheet sheet) throws Exception {
Map<String, Operation> ops = new HashMap<String, Operation>();
Map<String, OperationParameter> params = new HashMap<String, OperationParameter>();
if (sheet != null) {
for (int row = 0; row < sheet.rows.size(); row++) {
String name = sheet.getColumn(row, "Name");
String use = sheet.getColumn(row, "Use");
String doco = sheet.getColumn(row, "Documentation");
String type = sheet.getColumn(row, "Type");
List<OperationExample> examples = loadOperationExamples(sheet.getColumn(row, "Example.Request"), sheet.getColumn(row, "Example.Response"));
List<OperationExample> examples2 = loadOperationExamples(sheet.getColumn(row, "Example2.Request"), sheet.getColumn(row, "Example2.Response"));
if (name != null && !name.equals("") && !name.startsWith("!")) {
if (!name.contains(".")) {
if (!type.equals("operation"))
throw new Exception("Invalid type on operation " + type + " at " + getLocation(row));
if (!name.toLowerCase().equals(name))
throw new Exception("Invalid name on operation " + name + " - must be all lower case (use dashes) at " + getLocation(row));
params.clear();
boolean system = false;
boolean istype = false;
boolean instance = false;
for (String c : use.split("\\|")) {
c = c.trim();
if ("system".equalsIgnoreCase(c))
system = true;
else if ("resource".equalsIgnoreCase(c))
istype = true;
else if ("instance".equalsIgnoreCase(c))
instance = true;
else
throw new Exception("unknown operation use code " + c + " at " + getLocation(row));
}
Operation op = new Operation(name, system, istype, instance, sheet.getColumn(row, "Type"), sheet.getColumn(row, "Title"), doco, sheet.getColumn(row, "Footer"), examples, parseBoolean(sheet.getColumn(row, "Idempotent"), row, false));
op.setStandardsStatus(StandardsStatus.fromCode(sheet.getColumn(row, "Standards-Status")));
op.setNormativeVersion(sheet.getColumn(row, "Normative-Version"));
op.setFooter2(sheet.getColumn(row, "Footer2"));
op.setFmm(sheet.getColumn(row, "fmm"));
op.getExamples2().addAll(examples2);
oplist.add(op);
ops.put(name, op);
} else {
String context = name.substring(0, name.lastIndexOf('.'));
String pname = name.substring(name.lastIndexOf('.') + 1);
Operation operation;
List<OperationParameter> plist;
if (context.contains(".")) {
String opname = name.substring(0, name.indexOf('.'));
// inside of a tuple
if (!Utilities.noString(use))
throw new Exception("Tuple parameters: use must be blank at " + getLocation(row));
operation = ops.get(opname);
if (operation == null)
throw new Exception("Unknown Operation '" + opname + "' at " + getLocation(row));
OperationParameter param = params.get(context);
if (param == null)
throw new Exception("Tuple parameter '" + context + "' not found at " + getLocation(row));
if (!param.getFhirType().equals("Tuple"))
throw new Exception("Tuple parameter '" + context + "' type must be Tuple at " + getLocation(row));
plist = param.getParts();
} else {
if (!use.equals("in") && !use.equals("out"))
throw new Exception("Only allowed use is 'in' or 'out' at " + getLocation(row));
operation = ops.get(context);
if (operation == null)
throw new Exception("Unknown Operation '" + context + "' at " + getLocation(row));
plist = operation.getParameters();
}
String profile = sheet.getColumn(row, "Profile");
String min = sheet.getColumn(row, "Min");
String max = sheet.getColumn(row, "Max");
OperationParameter p = new OperationParameter(pname, use, doco, Integer.parseInt(min), max, type, sheet.getColumn(row, "Search Type"), profile);
String bs = sheet.getColumn(row, "Binding");
if (!Utilities.noString(bs))
p.setBs(bindings.get(bs));
plist.add(p);
params.put(name, p);
}
}
}
}
}
Aggregations