use of org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent in project kindling by HL7.
the class PageProcessor method mapOnPageProfile.
private String mapOnPageProfile(StructureDefinition source) {
if (source.getMapping().size() < 2)
return "";
StringBuilder b = new StringBuilder();
b.append("<div class=\"itoc\">\r\n<p>Mappings:</p>\r\n");
for (StructureDefinitionMappingComponent map : source.getMapping()) {
b.append("<p class=\"link\"><a href=\"#").append(map.getIdentity()).append("\">").append(map.getName()).append("</a></p>");
}
b.append("</div>\r\n");
return b.toString();
}
use of org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent in project kindling by HL7.
the class PageProcessor method genImplementationList.
private String genImplementationList(ResourceDefn logical) throws FHIRException {
String url = logical.getMappingUrl();
StringBuilder b = new StringBuilder();
b.append("<table class=\"lines\">\r\n");
for (String s : sorted(definitions.getResources().keySet())) {
ResourceDefn rd = definitions.getResourceByName(s);
StructureDefinition sd = rd.getProfile();
String code = null;
for (StructureDefinitionMappingComponent m : sd.getMapping()) {
if (m.getUri().equals(url))
code = m.getIdentity();
}
if (code != null) {
if (hasLogicalMapping(sd, logical, code)) {
b.append(" <tr>\r\n");
b.append(" <td><a href=\"" + rd.getName().toLowerCase() + ".html\">" + rd.getName() + "</a> </td>\r\n");
b.append(" <td><a href=\"" + rd.getName().toLowerCase() + "-mappings.html#" + url + "\">Mappings</a> </td>\r\n");
b.append(" <td><a href=\"" + rd.getName().toLowerCase() + "-examples.html\">Examples</a></td>\r\n");
b.append(" </tr>\r\n");
}
}
}
b.append("</table>");
return b.toString();
}
use of org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent in project kindling by HL7.
the class MappingsGenerator method generate.
public void generate(StructureDefinition profile) throws IOException {
if (profile.getMapping().isEmpty())
mappings = "<p>No Mappings</p>";
else {
StringBuilder s = new StringBuilder();
for (StructureDefinitionMappingComponent map : profile.getMapping()) {
s.append("<a name=\"" + map.getIdentity() + "\"> </a><h3>" + map.getName() + " (" + map.getUri() + ")</h3>");
if (map.hasComment())
s.append("<p>" + Utilities.escapeXml(map.getComment()) + "</p>");
else if (definitions.getMapTypes().containsKey(map.getUri())) {
XhtmlNode pre = definitions.getMapTypes().get(map.getUri()).getPreamble();
if (pre != null)
s.append(new XhtmlComposer(XhtmlComposer.HTML).compose(pre));
}
s.append("<table class=\"grid\">\r\n");
s.append(" <tr><td colspan=\"3\"><b>" + Utilities.escapeXml(profile.getName()) + "</b></td></tr>\r\n");
String path = null;
for (ElementDefinition e : profile.getSnapshot().getElement()) {
if (path == null || !e.getPath().startsWith(path)) {
path = null;
if (e.hasMax() && e.getMax().equals("0")) {
path = e.getPath() + ".";
} else
genElement(s, e, map.getIdentity());
}
}
s.append("</table>\r\n");
}
mappings = s.toString();
}
}
use of org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent in project kindling by HL7.
the class MappingsGenerator method generateExtension.
public void generateExtension(StructureDefinition ed) throws IOException {
if (ed.getMapping().isEmpty())
mappings = "<p>No Mappings</p>";
else {
StringBuilder s = new StringBuilder();
for (StructureDefinitionMappingComponent map : ed.getMapping()) {
s.append("<a name=\"" + map.getIdentity() + "\"> </a><h3>" + map.getName() + " (" + map.getUri() + ")</h3>");
if (map.hasComment())
s.append("<p>" + Utilities.escapeXml(map.getComment()) + "</p>");
else if (definitions.getMapTypes().containsKey(map.getUri())) {
XhtmlNode pre = definitions.getMapTypes().get(map.getUri()).getPreamble();
if (pre != null)
s.append(new XhtmlComposer(XhtmlComposer.HTML).compose(pre));
}
s.append("<table class=\"grid\">\r\n");
s.append(" <tr><td colspan=\"3\"><b>" + Utilities.escapeXml(ed.getName()) + "</b></td></tr>\r\n");
String path = null;
for (ElementDefinition e : ed.getSnapshot().getElement()) {
if (path == null || !e.getPath().startsWith(path)) {
path = null;
if (e.hasMax() && e.getMax().equals("0")) {
path = e.getPath() + ".";
} else
genElement(s, e, map.getIdentity());
}
}
s.append("</table>\r\n");
}
mappings = s.toString();
}
}
use of org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionMappingComponent in project kindling by HL7.
the class ProfileGenerator method addElementConstraint.
/*
* // resource
// domain resource
for (ElementDefn child : definitions.getBaseResources().get("DomainResource").getRoot().getElements())
defineElement(null, p, p.getSnapshot(), child, r.getRoot().getName()+"."+child.getName(), containedSlices, new ArrayList<ProfileGenerator.SliceHandle>(), SnapShotMode.Resource);
*/
/*
private String registerMapping(ConformancePackage ap, StructureDefinition p, String m) {
for (StructureDefinitionMappingComponent map : p.getMapping()) {
if (map.getUri().equals(m))
return map.getIdentity();
}
StructureDefinitionMappingComponent map = new StructureDefinitionMappingComponent();
MappingSpace space = definitions.getMapTypes().get(m);
if (space != null)
map.setIdentity(space.getId());
else
map.setIdentity("m" + Integer.toString(p.getMapping().size()+1));
map.setUri(m);
String name = ap.metadata(m+"-name");
if (Utilities.noString(name) && space != null)
name = space.getTitle();
if (!Utilities.noString(name))
map.setName(name);
String comments = ap.metadata(m+"-comments");
if (Utilities.noString(comments) && space != null)
comments = space.getPreamble();
if (!Utilities.noString(comments))
map.setComments(comments);
return map.getIdentity();
}
*/
private ElementDefinition addElementConstraint(StructureDefinition sd, ElementDefinition ed) {
if (!ed.getPath().contains(".") && sd.getKind() == StructureDefinitionKind.RESOURCE)
return ed;
if (hasSystemType(ed))
return ed;
if (isResource(ed))
return ed;
if (hasConstraint(ed, "ele-1"))
return ed;
ElementDefinitionConstraintComponent inv = ed.addConstraint();
inv.setKey("ele-1");
inv.setSeverity(ConstraintSeverity.ERROR);
inv.setHuman("All FHIR elements must have a @value or children");
inv.setExpression("hasValue() or (children().count() > id.count())");
inv.setXpath("@value|f:*|h:div");
inv.setSource("http://hl7.org/fhir/StructureDefinition/Element");
return ed;
}
Aggregations