use of org.hl7.fhir.r5.model.ElementDefinition in project kindling by HL7.
the class PageProcessor method getInvariantList.
private String getInvariantList(StructureDefinition profile) throws FHIRException, Exception {
List<String> txlist = new ArrayList<String>();
Map<String, List<ElementDefinitionConstraintComponent>> txmap = new HashMap<String, List<ElementDefinitionConstraintComponent>>();
for (ElementDefinition ed : profile.getSnapshot().getElement()) {
if (!"0".equals(ed.getMax())) {
List<ElementDefinitionConstraintComponent> list = new ArrayList<ElementDefinition.ElementDefinitionConstraintComponent>();
for (ElementDefinitionConstraintComponent t : ed.getConstraint()) {
if (!t.hasSource() || t.getSource().equals(profile.getUrl())) {
list.add(t);
}
}
if (!list.isEmpty()) {
txlist.add(ed.getPath());
txmap.put(ed.getPath(), list);
}
}
}
if (txlist.isEmpty())
return "";
else {
StringBuilder b = new StringBuilder();
b.append("<h4>Constraints</h4>\r\n");
b.append("<table class=\"list\">\r\n");
b.append("<tr><td width=\"60\"><b>Id</b></td><td><b>Path</b></td><td><b>Details</b></td><td><b>Requirements</b></td></tr>\r\n");
for (String path : txlist) {
List<ElementDefinitionConstraintComponent> invs = txmap.get(path);
for (ElementDefinitionConstraintComponent inv : invs) {
b.append("<tr>" + presentLevel(inv) + " <td>").append(inv.getKey()).append("</td><td>").append(path).append("</td><td>").append(Utilities.escapeXml(inv.getHuman())).append("<br/><a href=\"http://hl7.org/fhirpath\">Expression</a>: ").append(Utilities.escapeXml(inv.getExpression())).append("</td><td>").append(Utilities.escapeXml(inv.getRequirements()));
if (inv.hasExtension(ToolingExtensions.EXT_BEST_PRACTICE_EXPLANATION))
b.append(". This is (only) a best practice guideline because: <blockquote>" + processMarkdown("best practice guideline", inv.getExtensionString(ToolingExtensions.EXT_BEST_PRACTICE_EXPLANATION), "") + "</blockquote>");
b.append("</td></tr>\r\n");
}
}
b.append("</table>\r\n");
return b.toString();
}
}
use of org.hl7.fhir.r5.model.ElementDefinition in project kindling by HL7.
the class PageProcessor method edHeader.
private String edHeader(String mode) {
StringBuilder b = new StringBuilder();
b.append("<ul class=\"nav nav-tabs\">");
b.append(makeHeaderTab("Element Definition", "elementdefinition.html", mode == null || "base".equals(mode)));
b.append(makeHeaderTab("Examples", "elementdefinition-examples.html", mode == null || "examples".equals(mode)));
b.append(makeHeaderTab("Detailed Descriptions", "elementdefinition-definitions.html", mode == null || "definitions".equals(mode)));
b.append(makeHeaderTab("Mappings", "elementdefinition-mappings.html", mode == null || "mappings".equals(mode)));
b.append(makeHeaderTab("Extensions", "elementdefinition-extras.html", mode == null || "extensions".equals(mode)));
b.append("</ul>\r\n");
return b.toString();
}
use of org.hl7.fhir.r5.model.ElementDefinition in project kindling by HL7.
the class PageProcessor method getTerminologyNotes.
private String getTerminologyNotes(StructureDefinition profile, int level) throws FHIRException {
List<String> txlist = new ArrayList<String>();
Map<String, ElementDefinitionBindingComponent> txmap = new HashMap<String, ElementDefinitionBindingComponent>();
for (ElementDefinition ed : profile.getSnapshot().getElement()) {
if (ed.hasBinding() && !"0".equals(ed.getMax())) {
String path = ed.getPath();
if (ed.getType().size() == 1 && ed.getType().get(0).getWorkingCode().equals("Extension"))
path = path + "<br/>" + ed.getType().get(0).getProfile();
txlist.add(path);
txmap.put(path, ed.getBinding());
}
}
if (txlist.isEmpty())
return "";
else {
StringBuilder b = new StringBuilder();
b.append("<h4>Terminology Bindings</h4>\r\n");
b.append("<table class=\"list\">\r\n");
b.append("<tr><td><b>Path</b></td><td><b>Name</b></td><td><b>Conformance</b></td><td><b>ValueSet</b></td></tr>\r\n");
for (String path : txlist) {
txItem(level, txmap, b, path);
}
b.append("</table>\r\n");
return b.toString();
}
}
use of org.hl7.fhir.r5.model.ElementDefinition in project kindling by HL7.
the class PageProcessor method getElementParent.
private ElementDefinition getElementParent(List<ElementDefinition> list, ElementDefinition element) {
String targetPath = element.getPath().substring(0, element.getPath().lastIndexOf("."));
int index = list.indexOf(element) - 1;
while (index >= 0) {
if (list.get(index).getPath().equals(targetPath))
return list.get(index);
index--;
}
return null;
}
use of org.hl7.fhir.r5.model.ElementDefinition in project kindling by HL7.
the class CDAGenerator method buildInfrastructureRoot.
private void buildInfrastructureRoot() throws DefinitionException {
StructureDefinition sd = new StructureDefinition();
sd.setId("InfrastructureRoot");
sd.setUrl("http://hl7.org/fhir/cda/StructureDefinition/InfrastructureRoot");
library.put(sd.getUrl(), sd);
sd.setName("Base Type for all classes in the CDA structure");
sd.setTitle("InfrastructureRoot");
sd.setStatus(PublicationStatus.ACTIVE);
sd.setExperimental(false);
sd.setPublisher("HL7");
sd.setDescription("Defines the base elements and attributes on all CDA elements (other than data types)");
sd.setKind(StructureDefinitionKind.LOGICAL);
sd.setType(sd.getUrl());
sd.setAbstract(true);
sd.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace").setValue(new UriType("urn:hl7-org:v3"));
sd.setBaseDefinition("http://hl7.org/fhir/cda/StructureDefinition/ANY");
sd.setDerivation(TypeDerivationRule.SPECIALIZATION);
ElementDefinition edb = new ElementDefinition();
edb.setPath(sd.getId());
seePath(edb);
edb.setMin(1);
edb.setMax("*");
edb.addType().setCode("Element");
sd.getDifferential().getElement().add(edb);
ElementDefinition ed = new ElementDefinition();
ed.setPath("InfrastructureRoot.realmCode");
seePath(ed);
ed.setMin(0);
ed.setMax("*");
ed.setDefinition("When valued in an instance, this attribute signals the imposition of realm-specific constraints. The value of this attribute identifies the realm in question");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/CS");
sd.getDifferential().getElement().add(ed);
ed = new ElementDefinition();
ed.setPath("InfrastructureRoot.typeId");
seePath(ed);
ed.setMin(0);
ed.setMax("1");
ed.setDefinition("When valued in an instance, this attribute signals the imposition of constraints defined in an HL7-specified message type. This might be a common type (also known as CMET in the messaging communication environment), or content included within a wrapper. The value of this attribute provides a unique identifier for the type in question.");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/II");
sd.getDifferential().getElement().add(ed);
ed = new ElementDefinition();
ed.setPath("InfrastructureRoot.templateId");
seePath(ed);
ed.setMin(0);
ed.setMax("*");
ed.setDefinition("When valued in an instance, this attribute signals the imposition of a set of template-defined constraints. The value of this attribute provides a unique identifier for the templates in question");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/II");
sd.getDifferential().getElement().add(ed);
new ProfileUtilities(null, null, null).setIds(sd, true);
structures.add(sd);
}
Aggregations