use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetRenderer method addDesignationsToRow.
public void addDesignationsToRow(ValueSetExpansionContainsComponent c, Map<String, String> designations, XhtmlNode tr) {
for (String url : designations.keySet()) {
String d = null;
if (d == null) {
for (ConceptReferenceDesignationComponent dd : c.getDesignation()) {
if (url.equals(getUrlForDesignation(dd))) {
d = dd.getValue();
}
}
}
tr.td().addText(d == null ? "" : d);
}
}
use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetRenderer method generateExpansion.
private boolean generateExpansion(XhtmlNode x, ValueSet vs, boolean header, List<UsedConceptMap> maps) throws FHIRFormatError, DefinitionException, IOException {
boolean hasExtensions = false;
List<String> langs = new ArrayList<String>();
// map of url = description, where url is the designation code. Designations that are for languages won't make it into this list
Map<String, String> designations = new HashMap<>();
if (header) {
XhtmlNode h = x.addTag(getHeader());
h.tx("Value Set Contents");
if (IsNotFixedExpansion(vs))
addMarkdown(x, vs.getDescription());
if (vs.hasCopyright())
generateCopyright(x, vs);
}
if (ToolingExtensions.hasExtension(vs.getExpansion(), ToolingExtensions.EXT_EXP_TOOCOSTLY)) {
List<Extension> exl = vs.getExpansion().getExtensionsByUrl(ToolingExtensions.EXT_EXP_TOOCOSTLY);
boolean other = false;
for (Extension ex : exl) {
if (ex.getValue() instanceof BooleanType) {
x.para().style("border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(vs.getExpansion().getContains().isEmpty() ? getContext().getTooCostlyNoteEmpty() : getContext().getTooCostlyNoteNotEmpty());
} else if (!other) {
x.para().style("border: maroon 1px solid; background-color: #FFCCCC; font-weight: bold; padding: 8px").addText(vs.getExpansion().getContains().isEmpty() ? getContext().getTooCostlyNoteEmptyDependent() : getContext().getTooCostlyNoteNotEmptyDependent());
other = true;
}
}
} else {
Integer count = countMembership(vs);
if (count == null)
x.para().tx("This value set does not contain a fixed number of concepts");
else
x.para().tx("This value set contains " + count.toString() + " concepts");
}
generateContentModeNotices(x, vs.getExpansion());
generateVersionNotice(x, vs.getExpansion());
CodeSystem allCS = null;
boolean doLevel = false;
for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) {
if (cc.hasContains()) {
doLevel = true;
break;
}
}
// checkDoSystem(vs, src);
boolean doSystem = true;
boolean doDefinition = checkDoDefinition(vs.getExpansion().getContains());
if (doSystem && allFromOneSystem(vs)) {
doSystem = false;
XhtmlNode p = x.para();
p.tx("All codes in this table are from the system ");
allCS = getContext().getWorker().fetchCodeSystem(vs.getExpansion().getContains().get(0).getSystem());
String ref = null;
if (allCS != null)
ref = getCsRef(allCS);
if (ref == null)
p.code(vs.getExpansion().getContains().get(0).getSystem());
else
p.ah(context.fixReference(ref)).code(vs.getExpansion().getContains().get(0).getSystem());
}
XhtmlNode t = x.table("codes");
XhtmlNode tr = t.tr();
if (doLevel)
tr.td().b().tx("Level");
tr.td().attribute("style", "white-space:nowrap").b().tx("Code");
if (doSystem)
tr.td().b().tx("System");
XhtmlNode tdDisp = tr.td();
tdDisp.b().tx("Display");
boolean doDesignations = false;
for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
scanForDesignations(c, langs, designations);
}
if (doDefinition) {
tr.td().b().tx("Definition");
doDesignations = false;
} else {
// if we're not doing definitions and we don't have too many languages, we'll do them in line
doDesignations = langs.size() + designations.size() < MAX_DESIGNATIONS_IN_LINE;
if (doDesignations) {
if (vs.hasLanguage()) {
tdDisp.tx(" - " + describeLang(vs.getLanguage()));
}
for (String url : designations.keySet()) {
tr.td().b().addText(designations.get(url));
}
for (String lang : langs) {
tr.td().b().addText(describeLang(lang));
}
}
}
addMapHeaders(tr, maps);
for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
addExpansionRowToTable(t, c, 1, doLevel, doSystem, doDefinition, maps, allCS, langs, designations, doDesignations);
}
if (!doDesignations && langs.size() + designations.size() > 0) {
Collections.sort(langs);
if (designations.size() == 0) {
x.para().b().tx("Additional Language Displays");
} else if (langs.size() == 0) {
x.para().b().tx("Additional Designations");
} else {
x.para().b().tx("Additional Designations and Language Displays");
}
t = x.table("codes");
tr = t.tr();
tr.td().b().tx("Code");
for (String url : designations.keySet()) {
tr.td().b().addText(designations.get(url));
}
for (String lang : langs) {
tr.td().b().addText(describeLang(lang));
}
for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
addDesignationRow(c, t, langs, designations);
}
}
return hasExtensions;
}
use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetRenderer method getConceptForCodeFromExpansion.
private ConceptDefinitionComponent getConceptForCodeFromExpansion(List<ValueSetExpansionContainsComponent> list, String code) {
for (ValueSetExpansionContainsComponent c : list) {
if (code.equals(c.getCode())) {
ConceptDefinitionComponent res = new ConceptDefinitionComponent();
res.setCode(c.getCode());
res.setDisplay(c.getDisplay());
return res;
}
ConceptDefinitionComponent v = getConceptForCodeFromExpansion(c.getContains(), code);
if (v != null)
return v;
}
return null;
}
use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetRenderer method addLangaugesToRow.
public void addLangaugesToRow(ValueSetExpansionContainsComponent c, List<String> langs, XhtmlNode tr) {
for (String lang : langs) {
String d = null;
for (Extension ext : c.getExtension()) {
if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
String l = ToolingExtensions.readStringExtension(ext, "lang");
if (lang.equals(l)) {
d = ToolingExtensions.readStringExtension(ext, "content");
}
}
}
if (d == null) {
for (ConceptReferenceDesignationComponent dd : c.getDesignation()) {
String l = dd.getLanguage();
if (lang.equals(l)) {
d = dd.getValue();
}
}
}
tr.td().addText(d == null ? "" : d);
}
}
use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetRenderer method scanForDesignations.
private void scanForDesignations(ValueSetExpansionContainsComponent c, List<String> langs, Map<String, String> designations) {
for (Extension ext : c.getExtension()) {
if (ToolingExtensions.EXT_TRANSLATION.equals(ext.getUrl())) {
String lang = ToolingExtensions.readStringExtension(ext, "lang");
if (!Utilities.noString(lang) && !langs.contains(lang)) {
langs.add(lang);
}
}
}
for (ConceptReferenceDesignationComponent d : c.getDesignation()) {
String lang = d.getLanguage();
if (!Utilities.noString(lang) && !langs.contains(lang)) {
langs.add(lang);
} else {
// can we present this as a designation that we know?
String disp = getDisplayForDesignation(d);
String url = getUrlForDesignation(d);
if (disp == null) {
disp = getDisplayForUrl(url);
}
if (disp != null && !designations.containsKey(url)) {
designations.put(url, disp);
}
}
}
for (ValueSetExpansionContainsComponent cc : c.getContains()) {
scanForDesignations(cc, langs, designations);
}
}
Aggregations