use of org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSet10_40 method processConcept.
public static void processConcept(List<ValueSet.ConceptDefinitionComponent> concepts, ConceptDefinitionComponent cs, CodeSystem srcCS) throws FHIRException {
org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent ct = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent();
concepts.add(ct);
ct.setCode(cs.getCode());
ct.setDisplay(cs.getDisplay());
ct.setDefinition(cs.getDefinition());
if (CodeSystemUtilities.isNotSelectable(srcCS, cs))
ct.setAbstract(true);
for (org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) {
org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent();
cst.setLanguage(csd.getLanguage());
cst.setUse(Coding10_40.convertCoding(csd.getUse()));
cst.setValue(csd.getValue());
}
for (ConceptDefinitionComponent csc : cs.getConcept()) processConcept(ct.getConcept(), csc, srcCS);
}
use of org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSet10_40 method convertCodeSystemConcept.
public static ValueSet.ConceptDefinitionComponent convertCodeSystemConcept(CodeSystem cs, ConceptDefinitionComponent src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
ValueSet.ConceptDefinitionComponent tgt = new ValueSet.ConceptDefinitionComponent();
ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
tgt.setAbstract(CodeSystemUtilities.isNotSelectable(cs, src));
tgt.setCode(src.getCode());
tgt.setDefinition(src.getDefinition());
tgt.setDisplay(src.getDisplay());
for (ConceptDefinitionComponent cc : src.getConcept()) tgt.addConcept(convertCodeSystemConcept(cs, cc));
for (CodeSystem.ConceptDefinitionDesignationComponent cc : src.getDesignation()) tgt.addDesignation(convertCodeSystemDesignation(cc));
return tgt;
}
use of org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSet10_40 method processConcept.
public static void processConcept(List<ConceptDefinitionComponent> concepts, org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent cs, CodeSystem tgtcs) throws FHIRException {
org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent ct = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent();
concepts.add(ct);
ct.setCode(cs.getCode());
ct.setDisplay(cs.getDisplay());
ct.setDefinition(cs.getDefinition());
if (cs.getAbstract())
CodeSystemUtilities.setNotSelectable(tgtcs, ct);
for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionDesignationComponent csd : cs.getDesignation()) {
org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent cst = new org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent();
cst.setLanguage(csd.getLanguage());
cst.setUse(Coding10_40.convertCoding(csd.getUse()));
cst.setValue(csd.getValue());
}
for (org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent csc : cs.getConcept()) processConcept(ct.getConcept(), csc, tgtcs);
}
use of org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent 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;
}
use of org.hl7.fhir.dstu2016may.model.CodeSystem.ConceptDefinitionComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generateDefinition.
private boolean generateDefinition(XhtmlNode x, CodeSystem cs, boolean header) {
boolean hasExtensions = false;
Map<ConceptMap, String> mymaps = new HashMap<ConceptMap, String>();
for (ConceptMap a : context.findMapsForSource(cs.getValueSet())) {
String url = "";
ValueSet vsr = context.fetchResource(ValueSet.class, ((Reference) a.getTarget()).getReference());
if (vsr != null)
url = (String) vsr.getUserData("filename");
mymaps.put(a, url);
}
// also, look in the contained resources for a concept map
for (Resource r : cs.getContained()) {
if (r instanceof ConceptMap) {
ConceptMap cm = (ConceptMap) r;
if (((Reference) cm.getSource()).getReference().equals(cs.getValueSet())) {
String url = "";
ValueSet vsr = context.fetchResource(ValueSet.class, ((Reference) cm.getTarget()).getReference());
if (vsr != null)
url = (String) vsr.getUserData("filename");
mymaps.put(cm, url);
}
}
}
List<String> langs = new ArrayList<String>();
if (header) {
XhtmlNode h = x.addTag("h2");
h.addText(cs.getName());
XhtmlNode p = x.addTag("p");
smartAddText(p, cs.getDescription());
if (cs.hasCopyright())
generateCopyright(x, cs);
}
XhtmlNode p = x.addTag("p");
p.addText("This code system " + cs.getUrl() + " defines the following codes:");
XhtmlNode t = x.addTag("table").setAttribute("class", "codes");
boolean commentS = false;
boolean deprecated = false;
boolean display = false;
boolean hierarchy = false;
for (ConceptDefinitionComponent c : cs.getConcept()) {
commentS = commentS || conceptsHaveComments(c);
deprecated = deprecated || conceptsHaveDeprecated(cs, c);
display = display || conceptsHaveDisplay(c);
hierarchy = hierarchy || c.hasConcept();
scanLangs(c, langs);
}
addMapHeaders(addTableHeaderRowStandard(t, hierarchy, display, true, commentS, deprecated), mymaps);
for (ConceptDefinitionComponent c : cs.getConcept()) {
hasExtensions = addDefineRowToTable(t, c, 0, hierarchy, display, commentS, deprecated, mymaps, cs.getUrl(), cs) || hasExtensions;
}
if (langs.size() > 0) {
Collections.sort(langs);
x.addTag("p").addTag("b").addText("Additional Language Displays");
t = x.addTag("table").setAttribute("class", "codes");
XhtmlNode tr = t.addTag("tr");
tr.addTag("td").addTag("b").addText("Code");
for (String lang : langs) tr.addTag("td").addTag("b").addText(lang);
for (ConceptDefinitionComponent c : cs.getConcept()) {
addLanguageRow(c, t, langs);
}
}
return hasExtensions;
}
Aggregations