use of org.hl7.fhir.r4b.model.ConceptMap in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method addExpansionRowToTable.
private void addExpansionRowToTable(XhtmlNode t, ValueSetExpansionContainsComponent c, int i, boolean doSystem, Map<ConceptMap, String> mymaps) {
XhtmlNode tr = t.addTag("tr");
XhtmlNode td = tr.addTag("td");
String tgt = makeAnchor(c.getSystem(), c.getCode());
td.addTag("a").setAttribute("name", tgt).addText(" ");
String s = Utilities.padLeft("", '.', i * 2);
td.addText(s);
Resource e = context.fetchCodeSystem(c.getSystem());
if (e == null)
td.addText(c.getCode());
else {
XhtmlNode a = td.addTag("a");
a.addText(c.getCode());
a.setAttribute("href", prefix + getCsRef(e) + "#" + Utilities.nmtokenize(c.getCode()));
}
if (doSystem) {
td = tr.addTag("td");
td.addText(c.getSystem());
}
td = tr.addTag("td");
if (c.hasDisplayElement())
td.addText(c.getDisplay());
for (ConceptMap m : mymaps.keySet()) {
td = tr.addTag("td");
List<TargetElementComponent> mappings = findMappingsForCode(c.getCode(), m);
boolean first = true;
for (TargetElementComponent mapping : mappings) {
if (!first)
td.addTag("br");
first = false;
XhtmlNode span = td.addTag("span");
span.setAttribute("title", mapping.getEquivalence().toString());
span.addText(getCharForEquivalence(mapping));
XhtmlNode a = td.addTag("a");
a.setAttribute("href", prefix + mymaps.get(m) + "#" + mapping.getCode());
a.addText(mapping.getCode());
if (!Utilities.noString(mapping.getComments()))
td.addTag("i").addText("(" + mapping.getComments() + ")");
}
}
for (ValueSetExpansionContainsComponent cc : c.getContains()) {
addExpansionRowToTable(t, cc, i + 1, doSystem, mymaps);
}
}
use of org.hl7.fhir.r4b.model.ConceptMap in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeConceptMap.
protected void composeConceptMap(Complex parent, String parentType, String name, ConceptMap element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "ConceptMap", name, element, index);
if (element.hasUrlElement())
composeUri(t, "ConceptMap", "url", element.getUrlElement(), -1);
if (element.hasIdentifier())
composeIdentifier(t, "ConceptMap", "identifier", element.getIdentifier(), -1);
if (element.hasVersionElement())
composeString(t, "ConceptMap", "version", element.getVersionElement(), -1);
if (element.hasNameElement())
composeString(t, "ConceptMap", "name", element.getNameElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "ConceptMap", "status", element.getStatusElement(), -1);
if (element.hasExperimentalElement())
composeBoolean(t, "ConceptMap", "experimental", element.getExperimentalElement(), -1);
if (element.hasPublisherElement())
composeString(t, "ConceptMap", "publisher", element.getPublisherElement(), -1);
for (int i = 0; i < element.getContact().size(); i++) composeConceptMapConceptMapContactComponent(t, "ConceptMap", "contact", element.getContact().get(i), i);
if (element.hasDateElement())
composeDateTime(t, "ConceptMap", "date", element.getDateElement(), -1);
if (element.hasDescriptionElement())
composeString(t, "ConceptMap", "description", element.getDescriptionElement(), -1);
for (int i = 0; i < element.getUseContext().size(); i++) composeCodeableConcept(t, "ConceptMap", "useContext", element.getUseContext().get(i), i);
if (element.hasRequirementsElement())
composeString(t, "ConceptMap", "requirements", element.getRequirementsElement(), -1);
if (element.hasCopyrightElement())
composeString(t, "ConceptMap", "copyright", element.getCopyrightElement(), -1);
if (element.hasSource())
composeType(t, "ConceptMap", "source", element.getSource(), -1);
if (element.hasTarget())
composeType(t, "ConceptMap", "target", element.getTarget(), -1);
for (int i = 0; i < element.getElement().size(); i++) composeConceptMapSourceElementComponent(t, "ConceptMap", "element", element.getElement().get(i), i);
}
use of org.hl7.fhir.r4b.model.ConceptMap in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeConceptMapTargetElementComponent.
protected void composeConceptMapTargetElementComponent(Complex parent, String parentType, String name, ConceptMap.TargetElementComponent element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeBackboneElement(t, "target", name, element, index);
if (element.hasSystemElement())
composeUri(t, "ConceptMap", "system", element.getSystemElement(), -1);
if (element.hasVersionElement())
composeString(t, "ConceptMap", "version", element.getVersionElement(), -1);
if (element.hasCodeElement())
composeCode(t, "ConceptMap", "code", element.getCodeElement(), -1);
if (element.hasEquivalenceElement())
composeEnum(t, "ConceptMap", "equivalence", element.getEquivalenceElement(), -1);
if (element.hasCommentsElement())
composeString(t, "ConceptMap", "comments", element.getCommentsElement(), -1);
for (int i = 0; i < element.getDependsOn().size(); i++) composeConceptMapOtherElementComponent(t, "ConceptMap", "dependsOn", element.getDependsOn().get(i), i);
for (int i = 0; i < element.getProduct().size(); i++) composeConceptMapOtherElementComponent(t, "ConceptMap", "product", element.getProduct().get(i), i);
}
use of org.hl7.fhir.r4b.model.ConceptMap in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generate.
public void generate(ConceptMap cm) {
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
x.addTag("h2").addText(cm.getName() + " (" + cm.getUrl() + ")");
XhtmlNode p = x.addTag("p");
p.addText("Mapping from ");
AddVsRef(((Reference) cm.getSource()).getReference(), p);
p.addText(" to ");
AddVsRef(((Reference) cm.getTarget()).getReference(), p);
p = x.addTag("p");
if (cm.getExperimental())
p.addText(Utilities.capitalize(cm.getStatus().toString()) + " (not intended for production usage). ");
else
p.addText(Utilities.capitalize(cm.getStatus().toString()) + ". ");
p.addText("Published on " + cm.getDateElement().toHumanDisplay() + " by " + cm.getPublisher());
if (!cm.getContact().isEmpty()) {
p.addText(" (");
boolean firsti = true;
for (ConceptMapContactComponent ci : cm.getContact()) {
if (firsti)
firsti = false;
else
p.addText(", ");
if (ci.hasName())
p.addText(ci.getName() + ": ");
boolean first = true;
for (ContactPoint c : ci.getTelecom()) {
if (first)
first = false;
else
p.addText(", ");
addTelecom(p, c);
}
p.addText("; ");
}
p.addText(")");
}
p.addText(". ");
p.addText(cm.getCopyright());
if (!Utilities.noString(cm.getDescription()))
x.addTag("p").addText(cm.getDescription());
x.addTag("br");
if (!cm.getElement().isEmpty()) {
SourceElementComponent cc = cm.getElement().get(0);
String src = cc.getSystem();
boolean comments = false;
boolean ok = cc.getTarget().size() == 1;
Map<String, HashSet<String>> sources = new HashMap<String, HashSet<String>>();
sources.put("code", new HashSet<String>());
Map<String, HashSet<String>> targets = new HashMap<String, HashSet<String>>();
targets.put("code", new HashSet<String>());
if (ok) {
String dst = cc.getTarget().get(0).getSystem();
for (SourceElementComponent ccl : cm.getElement()) {
ok = ok && src.equals(ccl.getSystem()) && ccl.getTarget().size() == 1 && dst.equals(ccl.getTarget().get(0).getSystem()) && ccl.getTarget().get(0).getDependsOn().isEmpty() && ccl.getTarget().get(0).getProduct().isEmpty();
if (ccl.hasSystem())
sources.get("code").add(ccl.getSystem());
for (TargetElementComponent ccm : ccl.getTarget()) {
comments = comments || !Utilities.noString(ccm.getComments());
for (OtherElementComponent d : ccm.getDependsOn()) {
if (!sources.containsKey(d.getElement()))
sources.put(d.getElement(), new HashSet<String>());
sources.get(d.getElement()).add(d.getSystem());
}
if (ccm.hasSystem())
targets.get("code").add(ccm.getSystem());
for (OtherElementComponent d : ccm.getProduct()) {
if (!targets.containsKey(d.getElement()))
targets.put(d.getElement(), new HashSet<String>());
targets.get(d.getElement()).add(d.getSystem());
}
}
}
}
String display;
if (ok) {
// simple
XhtmlNode tbl = x.addTag("table").setAttribute("class", "grid");
XhtmlNode tr = tbl.addTag("tr");
tr.addTag("td").addTag("b").addText("Source Code");
tr.addTag("td").addTag("b").addText("Equivalence");
tr.addTag("td").addTag("b").addText("Destination Code");
if (comments)
tr.addTag("td").addTag("b").addText("Comments");
for (SourceElementComponent ccl : cm.getElement()) {
tr = tbl.addTag("tr");
XhtmlNode td = tr.addTag("td");
td.addText(ccl.getCode());
display = getDisplayForConcept(ccl.getSystem(), ccl.getCode());
if (display != null)
td.addText(" (" + display + ")");
TargetElementComponent ccm = ccl.getTarget().get(0);
tr.addTag("td").addText(!ccm.hasEquivalence() ? "" : ccm.getEquivalence().toCode());
td = tr.addTag("td");
td.addText(ccm.getCode());
display = getDisplayForConcept(ccm.getSystem(), ccm.getCode());
if (display != null)
td.addText(" (" + display + ")");
if (comments)
tr.addTag("td").addText(ccm.getComments());
}
} else {
XhtmlNode tbl = x.addTag("table").setAttribute("class", "grid");
XhtmlNode tr = tbl.addTag("tr");
XhtmlNode td;
tr.addTag("td").setAttribute("colspan", Integer.toString(sources.size())).addTag("b").addText("Source Concept");
tr.addTag("td").addTag("b").addText("Equivalence");
tr.addTag("td").setAttribute("colspan", Integer.toString(targets.size())).addTag("b").addText("Destination Concept");
if (comments)
tr.addTag("td").addTag("b").addText("Comments");
tr = tbl.addTag("tr");
if (sources.get("code").size() == 1)
tr.addTag("td").addTag("b").addText("Code " + sources.get("code").toString() + "");
else
tr.addTag("td").addTag("b").addText("Code");
for (String s : sources.keySet()) {
if (!s.equals("code")) {
if (sources.get(s).size() == 1)
tr.addTag("td").addTag("b").addText(getDescForConcept(s) + " " + sources.get(s).toString());
else
tr.addTag("td").addTag("b").addText(getDescForConcept(s));
}
}
tr.addTag("td");
if (targets.get("code").size() == 1)
tr.addTag("td").addTag("b").addText("Code " + targets.get("code").toString());
else
tr.addTag("td").addTag("b").addText("Code");
for (String s : targets.keySet()) {
if (!s.equals("code")) {
if (targets.get(s).size() == 1)
tr.addTag("td").addTag("b").addText(getDescForConcept(s) + " " + targets.get(s).toString() + "");
else
tr.addTag("td").addTag("b").addText(getDescForConcept(s));
}
}
if (comments)
tr.addTag("td");
for (SourceElementComponent ccl : cm.getElement()) {
tr = tbl.addTag("tr");
td = tr.addTag("td");
if (sources.get("code").size() == 1)
td.addText(ccl.getCode());
else
td.addText(ccl.getSystem() + " / " + ccl.getCode());
display = getDisplayForConcept(ccl.getSystem(), ccl.getCode());
if (display != null)
td.addText(" (" + display + ")");
TargetElementComponent ccm = ccl.getTarget().get(0);
for (String s : sources.keySet()) {
if (!s.equals("code")) {
td = tr.addTag("td");
td.addText(getCode(ccm.getDependsOn(), s, sources.get(s).size() != 1));
display = getDisplay(ccm.getDependsOn(), s);
if (display != null)
td.addText(" (" + display + ")");
}
}
tr.addTag("td").addText(ccm.getEquivalence().toString());
td = tr.addTag("td");
if (targets.get("code").size() == 1)
td.addText(ccm.getCode());
else
td.addText(ccm.getSystem() + " / " + ccm.getCode());
display = getDisplayForConcept(ccm.getSystem(), ccm.getCode());
if (display != null)
td.addText(" (" + display + ")");
for (String s : targets.keySet()) {
if (!s.equals("code")) {
td = tr.addTag("td");
td.addText(getCode(ccm.getProduct(), s, targets.get(s).size() != 1));
display = getDisplay(ccm.getProduct(), s);
if (display != null)
td.addText(" (" + display + ")");
}
}
if (comments)
tr.addTag("td").addText(ccm.getComments());
}
}
}
inject(cm, x, NarrativeStatus.GENERATED);
}
use of org.hl7.fhir.r4b.model.ConceptMap in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method addDefineRowToTable.
private boolean addDefineRowToTable(XhtmlNode t, ConceptDefinitionComponent c, int i, boolean hasHierarchy, boolean hasDisplay, boolean comment, boolean deprecated, Map<ConceptMap, String> maps, String system, CodeSystem cs) {
boolean hasExtensions = false;
XhtmlNode tr = t.addTag("tr");
XhtmlNode td = tr.addTag("td");
if (hasHierarchy) {
td.addText(Integer.toString(i + 1));
td = tr.addTag("td");
String s = Utilities.padLeft("", '\u00A0', i * 2);
td.addText(s);
}
td.addText(c.getCode());
XhtmlNode a;
if (c.hasCodeElement()) {
a = td.addTag("a");
a.setAttribute("name", Utilities.nmtokenize(c.getCode()));
a.addText(" ");
}
if (hasDisplay) {
td = tr.addTag("td");
if (c.hasDisplayElement())
td.addText(c.getDisplay());
}
td = tr.addTag("td");
if (c != null)
smartAddText(td, c.getDefinition());
if (deprecated) {
td = tr.addTag("td");
Boolean b = CodeSystemUtilities.isDeprecated(cs, c);
if (b != null && b) {
smartAddText(td, "Deprecated");
hasExtensions = true;
if (ToolingExtensions.hasExtension(c, ToolingExtensions.EXT_REPLACED_BY)) {
Coding cc = (Coding) ToolingExtensions.getExtension(c, ToolingExtensions.EXT_REPLACED_BY).getValue();
td.addText(" (replaced by ");
String url = getCodingReference(cc, system);
if (url != null) {
td.addTag("a").setAttribute("href", url).addText(cc.getCode());
td.addText(": " + cc.getDisplay() + ")");
} else
td.addText(cc.getCode() + " '" + cc.getDisplay() + "' in " + cc.getSystem() + ")");
}
}
}
if (comment) {
td = tr.addTag("td");
String s = ToolingExtensions.getComment(c);
if (s != null) {
smartAddText(td, s);
hasExtensions = true;
}
}
for (ConceptMap m : maps.keySet()) {
td = tr.addTag("td");
List<TargetElementComponent> mappings = findMappingsForCode(c.getCode(), m);
boolean first = true;
for (TargetElementComponent mapping : mappings) {
if (!first)
td.addTag("br");
first = false;
XhtmlNode span = td.addTag("span");
span.setAttribute("title", mapping.hasEquivalence() ? mapping.getEquivalence().toCode() : "");
span.addText(getCharForEquivalence(mapping));
a = td.addTag("a");
a.setAttribute("href", prefix + maps.get(m) + "#" + makeAnchor(mapping.getSystem(), mapping.getCode()));
a.addText(mapping.getCode());
if (!Utilities.noString(mapping.getComments()))
td.addTag("i").addText("(" + mapping.getComments() + ")");
}
}
for (CodeType e : ToolingExtensions.getSubsumes(c)) {
hasExtensions = true;
tr = t.addTag("tr");
td = tr.addTag("td");
String s = Utilities.padLeft("", '.', i * 2);
td.addText(s);
a = td.addTag("a");
a.setAttribute("href", "#" + Utilities.nmtokenize(e.getValue()));
a.addText(c.getCode());
}
for (ConceptDefinitionComponent cc : c.getConcept()) {
hasExtensions = addDefineRowToTable(t, cc, i + 1, hasHierarchy, hasDisplay, comment, deprecated, maps, system, cs) || hasExtensions;
}
return hasExtensions;
}
Aggregations