use of org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionContextComponent 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.StructureDefinitionContextComponent in project kindling by HL7.
the class PageProcessor method produceExtensions.
private String produceExtensions(ResourceDefn resource) {
int count = 0;
Map<String, StructureDefinition> map = new HashMap<String, StructureDefinition>();
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
boolean inc = false;
for (StructureDefinitionContextComponent ec : sd.getContext()) {
if (ec.getType() == ExtensionContextType.ELEMENT) {
inc = inc || (ec.getExpression().equals(resource.getName()) || ec.getExpression().startsWith(resource.getName() + "."));
}
if (inc)
map.put(sd.getId(), sd);
}
}
StringBuilder b = new StringBuilder();
for (String s : sorted(map.keySet())) {
StructureDefinition cs = map.get(s);
count++;
b.append(" <tr>\r\n");
String ref = cs.getUserString("path");
b.append(" <td><a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.getId())).append("</a></td>\r\n");
b.append(" <td>").append(presentContext(cs, resource.getName())).append("</td>\r\n");
b.append(" <td>").append(Utilities.escapeXml(cs.getName())).append("</td>\r\n");
Profile ap = (Profile) cs.getUserData("profile");
if (ap == null)
b.append(" <td></td>\r\n");
else {
ImplementationGuideDefn ig = definitions.getIgs().get(ap.getCategory());
b.append(" <td>for <a href=\"" + ig.getPrefix() + ap.getId().toLowerCase() + ".html\">" + Utilities.escapeXml(ap.getTitle()) + "</a></td>\r\n");
}
b.append(" </tr>\r\n");
}
if (count == 0)
b.append("<tr><td>No Extensions defined for this resource</td></tr>");
map.clear();
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
boolean inc = false;
for (StructureDefinitionContextComponent ec : sd.getContext()) inc = inc || (ec.getExpression().equals("Resource") || ec.getExpression().equals("DomainResource") || ec.getExpression().equals("Any"));
if (inc)
map.put(sd.getId(), sd);
}
b.append("<tr><td colspan=\"4\">Extensions for all resources or elements</td></tr>");
for (String s : sorted(map.keySet())) {
StructureDefinition cs = map.get(s);
count++;
b.append(" <tr>\r\n");
String ref = cs.getUserString("path");
b.append(" <td colspan=\"2\"><a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.getId())).append("</a></td>\r\n");
b.append(" <td>").append(Utilities.escapeXml(cs.getName())).append("</td>\r\n");
Profile ap = (Profile) cs.getUserData("profile");
if (ap == null)
b.append(" <td></td>\r\n");
else {
ImplementationGuideDefn ig = definitions.getIgs().get(ap.getCategory());
b.append(" <td>for <a href=\"" + ig.getPrefix() + ap.getId() + ".html\">" + Utilities.escapeXml(ap.getTitle()) + "</a></td>\r\n");
}
b.append(" </tr>\r\n");
}
return b.toString();
}
use of org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionContextComponent in project kindling by HL7.
the class PageProcessor method produceDataTypeExtras.
private String produceDataTypeExtras(String tn, boolean profiles) {
int count = 0;
Map<String, StructureDefinition> map = new HashMap<String, StructureDefinition>();
for (StructureDefinition sd : workerContext.getExtensionDefinitions()) {
boolean inc = false;
for (StructureDefinitionContextComponent ec : sd.getContext()) {
if (ec.getType() == ExtensionContextType.ELEMENT) {
inc = inc || matchesType(tn, ec.getExpression());
}
}
if (inc)
map.put(sd.getId(), sd);
}
StringBuilder b = new StringBuilder();
b.append(" <tr><td colspan=\"3\"><b>Extensions</b> (+ see <a href=\"" + definitions.getElementExtrasLink() + "\">extensions on all Elements</a>)</td></tr>\r\n");
for (String s : sorted(map.keySet())) {
StructureDefinition cs = map.get(s);
count++;
b.append(" <tr>\r\n");
String ref = cs.getUserString("path");
b.append(" <td><a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.getId())).append("</a></td>\r\n");
b.append(" <td>").append(Utilities.escapeXml(cs.getName())).append("</td>\r\n");
Profile ap = (Profile) cs.getUserData("profile");
if (ap == null)
b.append(" <td></td>\r\n");
else {
ImplementationGuideDefn ig = definitions.getIgs().get(ap.getCategory());
b.append(" <td>for <a href=\"" + ig.getPrefix() + ap.getId().toLowerCase() + ".html\">" + Utilities.escapeXml(ap.getTitle()) + "</a></td>\r\n");
}
b.append(" </tr>\r\n");
}
if (count == 0)
b.append("<tr><td>No Extensions defined for " + (tn.equals("primitives") ? "primitive types" : "this type") + " (though see <a href=\"element-extensions.html\">extensions on all Elements</a>)</td></tr>");
if (profiles) {
count = 0;
Map<String, CSPair> pmap = new HashMap<String, CSPair>();
for (Profile ap : definitions.getPackList()) {
for (ConstraintStructure cs : ap.getProfiles()) {
if (coversType(cs, tn))
pmap.put(cs.getTitle(), new CSPair(ap, cs));
}
}
b.append(" <tr><td colspan=\"3\"><b>Profiles</b></td></tr>\r\n");
for (String s : sorted(pmap.keySet())) {
CSPair cs = pmap.get(s);
ImplementationGuideDefn ig = definitions.getIgs().get(cs.p.getCategory());
count++;
b.append(" <tr>\r\n");
String ref = (ig.isCore() ? "" : ig.getCode() + File.separator) + cs.cs.getId() + ".html";
b.append(" <td><a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.cs.getTitle())).append("</a></td>\r\n");
b.append(" <td>").append(Utilities.escapeXml(cs.p.getDescription())).append("</td>\r\n");
ref = (ig.isCore() ? "" : ig.getCode() + File.separator) + cs.p.getId().toLowerCase() + ".html";
b.append(" <td>for <a href=\"").append(ref).append("\">").append(Utilities.escapeXml(cs.p.getTitle())).append("</a></td>\r\n");
b.append(" </tr>\r\n");
}
if (count == 0)
b.append("<tr><td>No Profiles defined for for " + (tn.equals("primitives") ? "primitive types" : "this type") + "</td></tr>");
}
return b.toString();
}
use of org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionContextComponent in project kindling by HL7.
the class PageProcessor method genExtensionRow.
private void genExtensionRow(ImplementationGuideDefn ig, StringBuilder s, StructureDefinition ed) throws Exception {
s.append("<tr>");
s.append("<td><a href=\"" + ed.getUserString("path") + "\" title=\"" + Utilities.escapeXml(ed.getDescription()) + "\">" + ed.getId() + "</a></td>");
s.append("<td>" + displayExtensionCardinality(ed) + "</td>");
s.append("<td>" + determineExtensionType(ed) + "</td>");
s.append("<td>");
boolean first = true;
for (StructureDefinitionContextComponent ec : ed.getContext()) {
if (first)
first = false;
else
s.append(",<br/> ");
if (ec.getType() == ExtensionContextType.ELEMENT) {
String ref = Utilities.oidRoot(ec.getExpression());
if (ref.startsWith("@"))
ref = ref.substring(1);
if (definitions.hasElementDefn(ref))
s.append("<a href=\"" + definitions.getSrcFile(ref) + ".html#" + Utilities.oidRoot(ec.getExpression()) + "\">" + ec.getExpression() + "</a>");
else if (definitions.hasResource(ref))
s.append("<a href=\"" + ref.toLowerCase() + ".html\">" + ec.getExpression() + "</a>");
else
s.append(ec.getExpression());
} else if (ec.getType() == ExtensionContextType.FHIRPATH) {
s.append(Utilities.escapeXml(ec.getExpression()));
} else
throw new Error("Not done yet");
}
s.append("</td>");
String fmm = ToolingExtensions.readStringExtension(ed, ToolingExtensions.EXT_FMM_LEVEL);
s.append("<td>" + (Utilities.noString(fmm) ? "0" : fmm) + "</td>");
// s.append("<td><a href=\"extension-"+ed.getId().toLowerCase()+ ".xml.html\">XML</a></td>");
// s.append("<td><a href=\"extension-"+ed.getId().toLowerCase()+ ".json.html\">JSON</a></td>");
s.append("</tr>");
}
use of org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionContextComponent in project org.hl7.fhir.core by hapifhir.
the class StructureDefinitionSpreadsheetGenerator method addStructureDefinitionMetadata.
private void addStructureDefinitionMetadata(Sheet sheet, StructureDefinition sd) {
for (Coding k : sd.getKeyword()) {
addMetadataRow(sheet, "Keyword", dr.display(k));
}
addMetadataRow(sheet, "FHIR Version", sd.getFhirVersionElement().asStringValue());
addMetadataRow(sheet, "Kind", sd.getKindElement().asStringValue());
addMetadataRow(sheet, "Type", sd.getType());
addMetadataRow(sheet, "Base Definition", sd.getBaseDefinition());
addMetadataRow(sheet, "Abstract", sd.getAbstractElement().asStringValue());
addMetadataRow(sheet, "Derivation", sd.getDerivationElement().asStringValue());
for (StructureDefinitionContextComponent k : sd.getContext()) {
addMetadataRow(sheet, "Context", k.getTypeElement().asStringValue() + ":" + k.getExpression());
}
for (StringType k : sd.getContextInvariant()) {
addMetadataRow(sheet, "Context Inv.", k.getValue());
}
}
Aggregations