use of org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent in project kindling by HL7.
the class ProfileGenerator method addMapping.
private void addMapping(StructureDefinition p, ElementDefinition definition, String target, String map, Profile pack) {
if (!Utilities.noString(map)) {
String id;
if (pack != null && pack.getMappingSpaces().containsKey(target))
id = pack.getMappingSpaces().get(target).getId();
else
id = definitions.getMapTypes().get(target).getId();
if (!mappingExists(p, id)) {
StructureDefinitionMappingComponent pm = new StructureDefinitionMappingComponent();
p.getMapping().add(pm);
pm.setIdentity(id);
pm.setUri(target);
if (pack != null && pack.getMappingSpaces().containsKey(target))
pm.setName(pack.getMappingSpaces().get(target).getTitle());
else
pm.setName(definitions.getMapTypes().get(target).getTitle());
}
boolean found = false;
for (ElementDefinitionMappingComponent m : definition.getMapping()) {
found = found || (m.getIdentity().equals(id) && m.getMap().equals(map));
}
if (!found) {
ElementDefinitionMappingComponent m = new ElementDefinitionMappingComponent();
m.setIdentity(id);
m.setMap(map);
definition.getMapping().add(m);
}
}
}
use of org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent in project kindling by HL7.
the class PageProcessor method populateLogicalMappingColumn.
private void populateLogicalMappingColumn(StringBuilder b, String n, String page, ElementDefn e, StructureDefinition sd, String rn, String code, String url, StringBuilder b2, IniFile ini, String iniPath) throws FHIRException {
LogicalModelSupportInformation info = new LogicalModelSupportInformation();
for (ElementDefinition ed : sd.getSnapshot().getElement()) {
for (ElementDefinitionMappingComponent m : ed.getMapping()) {
if (m.getIdentity().equals(code)) {
String s = m.getMap();
for (String p : s.split("\\,")) {
String f = p.contains("{") ? p.substring(0, p.indexOf("{")).trim() : p;
String cm = p.contains("{") ? p.substring(p.indexOf("{")) : null;
if (cm != null) {
cm = cm.trim();
}
if (f.equals(e.getPath())) {
checkMapping(info, e, ed, b2 == null, cm);
}
}
}
}
}
for (StructureDefinition ext : workerContext.getExtensionDefinitions()) {
boolean ok = false;
for (StructureDefinitionContextComponent ec : ext.getContext()) {
if (ec.getType() == ExtensionContextType.ELEMENT) {
if (rn.equals(ec.getExpression()))
ok = true;
}
if (ok) {
String map = getWorkflowMapping(ext, url);
if (map != null) {
for (String p : map.split("\\,")) {
String f = p.contains("{") ? p.substring(0, p.indexOf("{")) : p;
if (f.equals(e.getPath())) {
checkExtMapping(info, e, ext);
}
}
}
}
}
}
// color:
// one color when supported and aligned
// one color when not aligned
// one coor when color extension
// blank for no mapping
String color;
if (info.typeMismatch == TypeMappingStatus.ERROR || info.cardinalityProblem)
color = LOGICAL_MAPPING_MISMATCH_COLOR;
else if (info.nameChanged || info.typeMismatch == TypeMappingStatus.NEEDS_MAPPING)
color = LOGICAL_MAPPING_NAMECHANGE_COLOR;
else if (info.extension)
color = LOGICAL_MAPPING_EXTENSION_COLOR;
else if (info.elementcount > 0)
color = LOGICAL_MAPPING_MAPPED_COLOR;
else
color = LOGICAL_MAPPING_NOTMAPPED_COLOR;
if (b != null) {
StringBuilder ns = new StringBuilder();
for (String s : info.notes) {
if (ns.length() > 0)
ns.append("; ");
ns.append(s);
}
b.append(" <td style=\"background-color: " + color + "\" title=\"" + ns.toString() + "\">");
if (info.elementcount > 0)
b.append(info.elementcount);
else if (info.extension)
b.append("E");
b.append(" ");
if (info.nameChanged)
b.append("N");
if (info.typeMismatch == TypeMappingStatus.ERROR)
b.append("T");
if (info.cardinalityProblem)
b.append("C");
b.append("</td>\r\n");
}
StringBuilder ns = new StringBuilder();
for (String s : info.notes) {
ns.append(s);
}
String tasks = ini == null ? null : ini.getStringProperty(iniPath, sd.getName() + ".tasks");
String status = ini == null ? null : ini.getStringProperty(iniPath, sd.getName() + ".status");
String notes = ini == null ? null : ini.getStringProperty(iniPath, sd.getName() + ".notes");
if (b2 != null && !(Utilities.noString(ns.toString()) && Utilities.noString(tasks))) {
b2.append("<tr style=\"background-color: " + color + "\"><td><b><a href=\"" + sd.getName().toLowerCase() + ".html\">" + sd.getName() + "</a></b></td><td><ul>" + ns.toString() + "</ul>");
if (info.extension)
b2.append(" (as an extension)");
b2.append("</td><td>");
if (info.nameChanged || info.typeMismatch != TypeMappingStatus.OK || info.cardinalityProblem) {
boolean first = true;
if (info.nameChanged) {
b2.append("Names are different. ");
first = false;
}
if (info.typeMismatch != TypeMappingStatus.OK) {
if (!first)
b2.append("<br/>");
b2.append("Type Mismatch. ");
first = false;
}
if (info.cardinalityProblem) {
if (!first)
b2.append("<br/>");
b2.append("Cardinality Problem. ");
}
}
b2.append("</td><td>");
boolean first = true;
if (!Utilities.noString(tasks)) {
for (String id : tasks.split("\\;")) {
if (!first)
b2.append(" | ");
b2.append("<a href=\"https://gforge.hl7.org/gf/project/fhir/tracker/?action=TrackerItemEdit&tracker_item_id=" + id.trim() + "\">GF#" + id.trim() + "</a>");
first = false;
}
b2.append("</td><td>");
}
if (!Utilities.noString(status))
b2.append(Utilities.escapeXml(status));
b2.append("</td><td>");
if (!Utilities.noString(notes))
b2.append(Utilities.escapeXml(notes));
b2.append("</td></tr>\r\n");
}
}
use of org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent in project org.hl7.fhir.core by hapifhir.
the class ProfileUtilities method generateDescription.
private Cell generateDescription(HierarchicalTableGenerator gen, Row row, ElementDefinition definition, ElementDefinition fallback, boolean used, String baseURL, String url, StructureDefinition profile, String corePath, String imagePath, boolean root, boolean logicalModel, boolean allInvariants, ElementDefinition valueDefn, boolean snapshot) throws IOException, FHIRException {
Cell c = gen.new Cell();
row.getCells().add(c);
if (used) {
if (logicalModel && ToolingExtensions.hasExtension(profile, "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace")) {
if (root) {
c.getPieces().add(gen.new Piece(null, translate("sd.table", "XML Namespace") + ": ", null).addStyle("font-weight:bold"));
c.getPieces().add(gen.new Piece(null, ToolingExtensions.readStringExtension(profile, "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace"), null));
} else if (!root && ToolingExtensions.hasExtension(definition, "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace") && !ToolingExtensions.readStringExtension(definition, "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace").equals(ToolingExtensions.readStringExtension(profile, "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace"))) {
c.getPieces().add(gen.new Piece(null, translate("sd.table", "XML Namespace") + ": ", null).addStyle("font-weight:bold"));
c.getPieces().add(gen.new Piece(null, ToolingExtensions.readStringExtension(definition, "http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace"), null));
}
}
if (definition.hasContentReference()) {
ElementDefinition ed = getElementByName(profile.getSnapshot().getElement(), definition.getContentReference());
if (ed == null)
c.getPieces().add(gen.new Piece(null, translate("sd.table", "Unknown reference to %s", definition.getContentReference()), null));
else
c.getPieces().add(gen.new Piece("#" + ed.getPath(), translate("sd.table", "See %s", ed.getPath()), null));
}
if (definition.getPath().endsWith("url") && definition.hasFixed()) {
c.getPieces().add(checkForNoChange(definition.getFixed(), gen.new Piece(null, "\"" + buildJson(definition.getFixed()) + "\"", null).addStyle("color: darkgreen")));
} else {
if (definition != null && definition.hasShort()) {
if (!c.getPieces().isEmpty())
c.addPiece(gen.new Piece("br"));
c.addPiece(checkForNoChange(definition.getShortElement(), gen.new Piece(null, gt(definition.getShortElement()), null)));
} else if (fallback != null && fallback.hasShort()) {
if (!c.getPieces().isEmpty())
c.addPiece(gen.new Piece("br"));
c.addPiece(checkForNoChange(fallback.getShortElement(), gen.new Piece(null, gt(fallback.getShortElement()), null)));
}
if (url != null) {
if (!c.getPieces().isEmpty())
c.addPiece(gen.new Piece("br"));
String fullUrl = url.startsWith("#") ? baseURL + url : url;
StructureDefinition ed = context.fetchResource(StructureDefinition.class, url);
String ref = null;
String ref2 = null;
String fixedUrl = null;
if (ed != null) {
String p = ed.getUserString("path");
if (p != null) {
ref = p.startsWith("http:") || igmode ? p : Utilities.pathURL(corePath, p);
}
fixedUrl = getFixedUrl(ed);
if (fixedUrl != null) {
// if its null, we guess that it's not a profiled extension?
if (fixedUrl.equals(url))
fixedUrl = null;
else {
StructureDefinition ed2 = context.fetchResource(StructureDefinition.class, fixedUrl);
if (ed2 != null) {
String p2 = ed2.getUserString("path");
if (p2 != null) {
ref2 = p2.startsWith("http:") || igmode ? p2 : Utilities.pathURL(corePath, p2);
}
}
}
}
}
if (fixedUrl == null) {
c.getPieces().add(gen.new Piece(null, translate("sd.table", "URL") + ": ", null).addStyle("font-weight:bold"));
c.getPieces().add(gen.new Piece(ref, fullUrl, null));
} else {
// reference to a profile take on the extension show the base URL
c.getPieces().add(gen.new Piece(null, translate("sd.table", "URL") + ": ", null).addStyle("font-weight:bold"));
c.getPieces().add(gen.new Piece(ref2, fixedUrl, null));
c.getPieces().add(gen.new Piece(null, translate("sd.table", " profiled by ") + " ", null).addStyle("font-weight:bold"));
c.getPieces().add(gen.new Piece(ref, fullUrl, null));
}
}
if (definition.hasSlicing()) {
if (!c.getPieces().isEmpty())
c.addPiece(gen.new Piece("br"));
c.getPieces().add(gen.new Piece(null, translate("sd.table", "Slice") + ": ", null).addStyle("font-weight:bold"));
c.getPieces().add(gen.new Piece(null, describeSlice(definition.getSlicing()), null));
}
if (definition != null) {
ElementDefinitionBindingComponent binding = null;
if (valueDefn != null && valueDefn.hasBinding() && !valueDefn.getBinding().isEmpty())
binding = valueDefn.getBinding();
else if (definition.hasBinding())
binding = definition.getBinding();
if (binding != null && !binding.isEmpty()) {
if (!c.getPieces().isEmpty())
c.addPiece(gen.new Piece("br"));
BindingResolution br = pkp.resolveBinding(profile, binding, definition.getPath());
c.getPieces().add(checkForNoChange(binding, gen.new Piece(null, translate("sd.table", "Binding") + ": ", null).addStyle("font-weight:bold")));
c.getPieces().add(checkForNoChange(binding, gen.new Piece(br.url == null ? null : Utilities.isAbsoluteUrl(br.url) || !pkp.prependLinks() ? br.url : corePath + br.url, br.display, null)));
if (binding.hasStrength()) {
c.getPieces().add(checkForNoChange(binding, gen.new Piece(null, " (", null)));
c.getPieces().add(checkForNoChange(binding, gen.new Piece(corePath + "terminologies.html#" + binding.getStrength().toCode(), egt(binding.getStrengthElement()), binding.getStrength().getDefinition())));
c.getPieces().add(gen.new Piece(null, ")", null));
}
if (binding.hasExtension(ToolingExtensions.EXT_MAX_VALUESET)) {
br = pkp.resolveBinding(profile, ToolingExtensions.readStringExtension(binding, ToolingExtensions.EXT_MAX_VALUESET), definition.getPath());
c.addPiece(gen.new Piece("br"));
c.getPieces().add(checkForNoChange(binding, gen.new Piece(corePath + "extension-elementdefinition-maxvalueset.html", translate("sd.table", "Max Binding") + ": ", "Max Value Set Extension").addStyle("font-weight:bold")));
c.getPieces().add(checkForNoChange(binding, gen.new Piece(br.url == null ? null : Utilities.isAbsoluteUrl(br.url) || !pkp.prependLinks() ? br.url : corePath + br.url, br.display, null)));
}
if (binding.hasExtension(ToolingExtensions.EXT_MIN_VALUESET)) {
br = pkp.resolveBinding(profile, ToolingExtensions.readStringExtension(binding, ToolingExtensions.EXT_MIN_VALUESET), definition.getPath());
c.addPiece(gen.new Piece("br"));
c.getPieces().add(checkForNoChange(binding, gen.new Piece(corePath + "extension-elementdefinition-minvalueset.html", translate("sd.table", "Min Binding") + ": ", "Min Value Set Extension").addStyle("font-weight:bold")));
c.getPieces().add(checkForNoChange(binding, gen.new Piece(br.url == null ? null : Utilities.isAbsoluteUrl(br.url) || !pkp.prependLinks() ? br.url : corePath + br.url, br.display, null)));
}
}
for (ElementDefinitionConstraintComponent inv : definition.getConstraint()) {
if (!inv.hasSource() || allInvariants) {
if (!c.getPieces().isEmpty())
c.addPiece(gen.new Piece("br"));
c.getPieces().add(checkForNoChange(inv, gen.new Piece(null, inv.getKey() + ": ", null).addStyle("font-weight:bold")));
c.getPieces().add(checkForNoChange(inv, gen.new Piece(null, gt(inv.getHumanElement()), null)));
}
}
if ((definition.hasBase() && definition.getBase().getMax().equals("*")) || (definition.hasMax() && definition.getMax().equals("*"))) {
if (c.getPieces().size() > 0)
c.addPiece(gen.new Piece("br"));
if (definition.hasOrderMeaning()) {
c.getPieces().add(gen.new Piece(null, "This repeating element order: " + definition.getOrderMeaning(), null));
} else {
// don't show this, this it's important: c.getPieces().add(gen.new Piece(null, "This repeating element has no defined order", null));
}
}
if (definition.hasFixed()) {
if (!c.getPieces().isEmpty())
c.addPiece(gen.new Piece("br"));
c.getPieces().add(checkForNoChange(definition.getFixed(), gen.new Piece(null, translate("sd.table", "Fixed Value") + ": ", null).addStyle("font-weight:bold")));
if (!useTableForFixedValues || definition.getFixed().isPrimitive()) {
String s = buildJson(definition.getFixed());
String link = null;
if (Utilities.isAbsoluteUrl(s))
link = pkp.getLinkForUrl(corePath, s);
c.getPieces().add(checkForNoChange(definition.getFixed(), gen.new Piece(link, s, null).addStyle("color: darkgreen")));
} else {
c.getPieces().add(checkForNoChange(definition.getFixed(), gen.new Piece(null, "As shown", null).addStyle("color: darkgreen")));
genFixedValue(gen, row, definition.getFixed(), snapshot, false, corePath);
}
if (isCoded(definition.getFixed()) && !hasDescription(definition.getFixed())) {
Piece p = describeCoded(gen, definition.getFixed());
if (p != null)
c.getPieces().add(p);
}
} else if (definition.hasPattern()) {
if (!c.getPieces().isEmpty())
c.addPiece(gen.new Piece("br"));
c.getPieces().add(checkForNoChange(definition.getPattern(), gen.new Piece(null, translate("sd.table", "Required Pattern") + ": ", null).addStyle("font-weight:bold")));
if (!useTableForFixedValues || definition.getPattern().isPrimitive())
c.getPieces().add(checkForNoChange(definition.getPattern(), gen.new Piece(null, buildJson(definition.getPattern()), null).addStyle("color: darkgreen")));
else {
c.getPieces().add(checkForNoChange(definition.getPattern(), gen.new Piece(null, "At least the following", null).addStyle("color: darkgreen")));
genFixedValue(gen, row, definition.getPattern(), snapshot, true, corePath);
}
} else if (definition.hasExample()) {
for (ElementDefinitionExampleComponent ex : definition.getExample()) {
if (!c.getPieces().isEmpty())
c.addPiece(gen.new Piece("br"));
c.getPieces().add(checkForNoChange(ex, gen.new Piece(null, translate("sd.table", "Example") + ("".equals("General") ? "" : " " + ex.getLabel() + "'") + ": ", null).addStyle("font-weight:bold")));
c.getPieces().add(checkForNoChange(ex, gen.new Piece(null, buildJson(ex.getValue()), null).addStyle("color: darkgreen")));
}
}
if (definition.hasMaxLength() && definition.getMaxLength() != 0) {
if (!c.getPieces().isEmpty())
c.addPiece(gen.new Piece("br"));
c.getPieces().add(checkForNoChange(definition.getMaxLengthElement(), gen.new Piece(null, "Max Length: ", null).addStyle("font-weight:bold")));
c.getPieces().add(checkForNoChange(definition.getMaxLengthElement(), gen.new Piece(null, Integer.toString(definition.getMaxLength()), null).addStyle("color: darkgreen")));
}
if (profile != null) {
for (StructureDefinitionMappingComponent md : profile.getMapping()) {
if (md.hasExtension(ToolingExtensions.EXT_TABLE_NAME)) {
ElementDefinitionMappingComponent map = null;
for (ElementDefinitionMappingComponent m : definition.getMapping()) if (m.getIdentity().equals(md.getIdentity()))
map = m;
if (map != null) {
for (int i = 0; i < definition.getMapping().size(); i++) {
c.addPiece(gen.new Piece("br"));
c.getPieces().add(gen.new Piece(null, ToolingExtensions.readStringExtension(md, ToolingExtensions.EXT_TABLE_NAME) + ": " + map.getMap(), null));
}
}
}
}
}
}
}
}
return c;
}
use of org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method mergeMappings.
private List<ElementDefinitionMappingComponent> mergeMappings(List<ElementDefinitionMappingComponent> left, List<ElementDefinitionMappingComponent> right) {
List<ElementDefinitionMappingComponent> result = new ArrayList<ElementDefinitionMappingComponent>();
result.addAll(left);
for (ElementDefinitionMappingComponent c : right) {
boolean found = false;
for (ElementDefinitionMappingComponent ct : left) if (Utilities.equals(c.getIdentity(), ct.getIdentity()) && Utilities.equals(c.getLanguage(), ct.getLanguage()) && Utilities.equals(c.getMap(), ct.getMap()))
found = true;
if (!found)
result.add(c);
}
return result;
}
use of org.hl7.fhir.dstu2016may.model.ElementDefinition.ElementDefinitionMappingComponent in project org.hl7.fhir.core by hapifhir.
the class ProfileComparer method mergeMappings.
private List<ElementDefinitionMappingComponent> mergeMappings(List<ElementDefinitionMappingComponent> left, List<ElementDefinitionMappingComponent> right) {
List<ElementDefinitionMappingComponent> result = new ArrayList<ElementDefinitionMappingComponent>();
result.addAll(left);
for (ElementDefinitionMappingComponent c : right) {
boolean found = false;
for (ElementDefinitionMappingComponent ct : left) if (Utilities.equals(c.getIdentity(), ct.getIdentity()) && Utilities.equals(c.getLanguage(), ct.getLanguage()) && Utilities.equals(c.getMap(), ct.getMap()))
found = true;
if (!found)
result.add(c);
}
return result;
}
Aggregations