use of org.hl7.fhir.dstu2.model.ConceptMap.ConceptMapContactComponent in project org.hl7.fhir.core by hapifhir.
the class ConceptMap method setProperty.
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("url"))
// UriType
this.url = castToUri(value);
else if (name.equals("identifier"))
// Identifier
this.identifier = castToIdentifier(value);
else if (name.equals("version"))
// StringType
this.version = castToString(value);
else if (name.equals("name"))
// StringType
this.name = castToString(value);
else if (name.equals("status"))
// Enumeration<ConformanceResourceStatus>
this.status = new ConformanceResourceStatusEnumFactory().fromType(value);
else if (name.equals("experimental"))
// BooleanType
this.experimental = castToBoolean(value);
else if (name.equals("publisher"))
// StringType
this.publisher = castToString(value);
else if (name.equals("contact"))
this.getContact().add((ConceptMapContactComponent) value);
else if (name.equals("date"))
// DateTimeType
this.date = castToDateTime(value);
else if (name.equals("description"))
// StringType
this.description = castToString(value);
else if (name.equals("useContext"))
this.getUseContext().add(castToCodeableConcept(value));
else if (name.equals("requirements"))
// StringType
this.requirements = castToString(value);
else if (name.equals("copyright"))
// StringType
this.copyright = castToString(value);
else if (name.equals("source[x]"))
// Type
this.source = (Type) value;
else if (name.equals("target[x]"))
// Type
this.target = (Type) value;
else if (name.equals("element"))
this.getElement().add((SourceElementComponent) value);
else
super.setProperty(name, value);
}
use of org.hl7.fhir.dstu2.model.ConceptMap.ConceptMapContactComponent 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.dstu2.model.ConceptMap.ConceptMapContactComponent 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.getCodeSystem();
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).getCodeSystem();
for (SourceElementComponent ccl : cm.getElement()) {
ok = ok && src.equals(ccl.getCodeSystem()) && ccl.getTarget().size() == 1 && dst.equals(ccl.getTarget().get(0).getCodeSystem()) && ccl.getTarget().get(0).getDependsOn().isEmpty() && ccl.getTarget().get(0).getProduct().isEmpty();
if (ccl.hasCodeSystem())
sources.get("code").add(ccl.getCodeSystem());
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.getCodeSystem());
}
if (ccm.hasCodeSystem())
targets.get("code").add(ccm.getCodeSystem());
for (OtherElementComponent d : ccm.getProduct()) {
if (!targets.containsKey(d.getElement()))
targets.put(d.getElement(), new HashSet<String>());
targets.get(d.getElement()).add(d.getCodeSystem());
}
}
}
}
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.getCodeSystem(), 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.getCodeSystem(), 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.getCodeSystem() + " / " + ccl.getCode());
display = getDisplayForConcept(ccl.getCodeSystem(), 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.getCodeSystem() + " / " + ccm.getCode());
display = getDisplayForConcept(ccm.getCodeSystem(), 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.dstu2.model.ConceptMap.ConceptMapContactComponent in project org.hl7.fhir.core by hapifhir.
the class ConceptMap method setProperty.
@Override
public void setProperty(String name, Base value) throws FHIRException {
if (name.equals("url"))
// UriType
this.url = castToUri(value);
else if (name.equals("identifier"))
// Identifier
this.identifier = castToIdentifier(value);
else if (name.equals("version"))
// StringType
this.version = castToString(value);
else if (name.equals("name"))
// StringType
this.name = castToString(value);
else if (name.equals("status"))
// Enumeration<ConformanceResourceStatus>
this.status = new ConformanceResourceStatusEnumFactory().fromType(value);
else if (name.equals("experimental"))
// BooleanType
this.experimental = castToBoolean(value);
else if (name.equals("publisher"))
// StringType
this.publisher = castToString(value);
else if (name.equals("contact"))
this.getContact().add((ConceptMapContactComponent) value);
else if (name.equals("date"))
// DateTimeType
this.date = castToDateTime(value);
else if (name.equals("description"))
// StringType
this.description = castToString(value);
else if (name.equals("useContext"))
this.getUseContext().add(castToCodeableConcept(value));
else if (name.equals("requirements"))
// StringType
this.requirements = castToString(value);
else if (name.equals("copyright"))
// StringType
this.copyright = castToString(value);
else if (name.equals("source[x]"))
// Type
this.source = (Type) value;
else if (name.equals("target[x]"))
// Type
this.target = (Type) value;
else if (name.equals("element"))
this.getElement().add((SourceElementComponent) value);
else
super.setProperty(name, value);
}
Aggregations