use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class PageProcessor method genBestPracticeList.
private void genBestPracticeList(StringBuilder b, ElementDefn e) throws Exception {
for (Invariant inv : e.getInvariants().values()) {
if ("best-practice".equals(inv.getSeverity())) {
b.append("<tr>");
b.append("<td>");
b.append(inv.getId());
b.append("</td>");
b.append("<td>");
b.append(inv.getEnglish());
b.append("</td>");
b.append("<td>");
b.append(processMarkdown("best-practice-list", inv.getExplanation(), ""));
b.append("</td>");
b.append("</tr>\r\n");
}
}
for (ElementDefn c : e.getElements()) {
genBestPracticeList(b, c);
}
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class PageProcessor method parseConceptMapMapping.
private ConceptMap parseConceptMapMapping(ElementDefn logical, ElementDefinition resource, String src) throws FHIRException {
if (!src.startsWith("{map:"))
return null;
ConceptMap map = new ConceptMap();
map.setId(logical.getPath() + "2" + resource.getPath());
map.setUrl("http://hl7.org/fhir/ConceptMap/" + map.getId());
map.setVersion(version.toCode());
ConceptMapGroupComponent grp = map.addGroup();
String[] statements = src.substring(0, src.length() - 1).substring(5).split("\\;");
if (statements.length == 0)
throw new FHIRException("Unable to parse map details '" + src + "'");
for (String s : statements) {
String[] p = s.split("\\=");
if (p.length < 2)
throw new FHIRException("Unable to parse map details '" + src + "'");
if (":default".equals(p[0].trim())) {
grp.getUnmapped().setMode(ConceptMapGroupUnmappedMode.FIXED);
grp.getUnmapped().setCode(p[1].trim());
} else {
grp.addElement().setCode(p[0].trim()).addTarget().setRelationship(ConceptMapRelationship.EQUIVALENT).setCode(p[1].trim());
}
}
return map;
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class PageProcessor method genConstraints.
private String genConstraints(String name, String prefix) throws Exception {
Map<String, String> invs = new HashMap<String, String>();
if (definitions.getConstraints().containsKey(name)) {
ProfiledType cnst = definitions.getConstraints().get(name);
generateConstraintsTable(name, cnst, invs, true, prefix);
} else {
ElementDefn e = definitions.getElementDefn(name);
generateConstraintsTable(name, e, invs, true, prefix);
}
List<String> ids = new ArrayList<String>();
for (String n : invs.keySet()) {
ids.add(n);
}
Collections.sort(ids, new ConstraintsSorter());
StringBuilder b = new StringBuilder();
for (String n : ids) {
b.append(invs.get(n));
}
if (b.length() > 0)
return "<a name=\"" + name + "-inv\"> </a><table class=\"grid\"><tr><td width=\"60\"><b>id</b></td><td><b>Level</b></td><td><b>Location</b></td><td><b>Description</b></td><td><b><a href=\"" + prefix + "fhirpath.html\">Expression</a></b></td></tr>" + b + "</table>";
else
return "";
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class PageProcessor method getReferences.
private String getReferences(String name) throws Exception {
List<String> refs = new ArrayList<String>();
if (definitions.hasLogicalModel(name)) {
ElementDefn r = definitions.getLogicalModel(name).getResource().getRoot();
List<String> names = definitions.listAllPatterns(r.getName());
for (String rn : definitions.sortedResourceNames()) {
checkPatternReferences(names, refs, rn, definitions.getResourceByName(rn).getRoot(), definitions.getLogicalModel(name).getMappingUrl());
}
if (refs.size() == 1)
return "<h2>References</h2><p>This pattern is implemented by " + renderRef(refs.get(0), name) + ".</p>\r\n";
else if (refs.size() > 1)
return "<h2>References</h2><p>This pattern is implemented by " + asLinks(refs, name) + ".</p>\r\n";
else
return "<h2>References</h2><p>No resources follow this pattern.</p>";
} else {
for (String tn : definitions.sortedTypeNames()) {
checkReferences(name, refs, tn, definitions.getElementDefn(tn));
}
for (String rn : definitions.sortedResourceNames()) {
checkReferences(name, refs, rn, definitions.getResourceByName(rn).getRoot());
}
String r;
if (refs.size() == 1)
r = "<h2>References</h2><p>This resource is referenced by " + renderRef(refs.get(0), name) + ".</p>\r\n";
else if (refs.size() > 1)
r = "<h2>References</h2><p>This resource is referenced by " + asLinks(refs, name) + ".</p>\r\n";
else
r = "<h2>References</h2><p>No resources refer to this resource directly.</p>";
refs.clear();
for (ImplementationGuideDefn ig : definitions.getSortedIgs()) {
for (LogicalModel lm : ig.getLogicalModels()) {
checkPatternUsage(lm.getResource().getRoot().getName(), refs, definitions.getResourceByName(name).getRoot(), lm.getMappingUrl());
}
}
if (refs.size() == 1)
return r + "<p>This resource implements the " + renderRef(refs.get(0), name) + " pattern.</p>\r\n";
else if (refs.size() > 1)
return r + "<p>This resource implements the " + asLinks(refs, name) + " patterns.</p>\r\n";
else
return r + "<p>This resource does not implement any patterns.</p>";
}
}
use of org.hl7.fhir.definitions.model.ElementDefn in project kindling by HL7.
the class PageProcessor method genDTCodes.
private String genDTCodes() {
StringBuilder html = new StringBuilder();
List<String> names = new ArrayList<String>();
names.addAll(definitions.getTypes().keySet());
names.addAll(definitions.getInfrastructure().keySet());
Collections.sort(names);
for (String n : names) {
if (!definitions.dataTypeIsSharedInfo(n)) {
ElementDefn c = definitions.getTypes().get(n);
if (c == null)
c = definitions.getInfrastructure().get(n);
if (c.getName().equals("Extension"))
html.append(" <tr><td><a href=\"extensibility.html\">" + c.getName() + "</a></td><td>" + Utilities.escapeXml(c.getDefinition()) + "</td></tr>");
else if (c.getName().equals("Narrative"))
html.append(" <tr><td><a href=\"narrative.html#" + c.getName() + "\">" + c.getName() + "</a></td><td>" + Utilities.escapeXml(c.getDefinition()) + "</td></tr>");
else if (c.getName().equals("Reference"))
html.append(" <tr><td><a href=\"references.html#" + c.getName() + "\">" + c.getName() + "</a></td><td>" + Utilities.escapeXml(c.getDefinition()) + "</td></tr>");
else if (c.getName().equals("canonical"))
html.append(" <tr><td><a href=\"references.html#" + c.getName() + "\">" + c.getName() + "</a></td><td>" + Utilities.escapeXml(c.getDefinition()) + "</td></tr>");
else
html.append(" <tr><td><a href=\"datatypes.html#" + c.getName() + "\">" + c.getName() + "</a></td><td>" + Utilities.escapeXml(c.getDefinition()) + "</td></tr>");
}
}
return html.toString();
}
Aggregations