use of org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent 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);
}
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent in project snowstorm by IHTSDO.
the class HapiValueSetMapper method asDesignation.
private ConceptReferenceDesignationComponent asDesignation(Description d) {
ConceptReferenceDesignationComponent designation = new ConceptReferenceDesignationComponent();
designation.setLanguage(d.getLanguageCode());
designation.setValue(d.getTerm());
// Designation use context extension
String descType = FHIRHelper.translateDescType(d.getTypeId());
// For each acceptability of the acceptability map, add an extension instance
// TODO: is there a smart way to control when the extension is intantiated?
d.getAcceptabilityMap().forEach((langRefsetId, acceptability) -> {
// Create designation use context Extension object using the URI
// TODO: are there FHIR constants anywhere?
Extension ducExt = new Extension("http://snomed.info/fhir/StructureDefinition/designation-use-context");
// Add the context, i.e. the language reference set
// TODO: is there a quick way to find a description for an id? Which description? Could be in any module/branch path.
ducExt.addExtension("context", new Coding(SNOMED_URI, langRefsetId, null));
// Add acceptability
switch(acceptability) {
case Concepts.ACCEPTABLE_CONSTANT:
ducExt.addExtension("role", new Coding(SNOMED_URI, Concepts.ACCEPTABLE, Concepts.ACCEPTABLE_CONSTANT));
break;
case Concepts.PREFERRED_CONSTANT:
ducExt.addExtension("role", new Coding(SNOMED_URI, Concepts.PREFERRED, Concepts.PREFERRED_CONSTANT));
}
;
// Add type, this is sometimes but not always redundant to designation.use!
// TODO: currently it is truly redundant but as there are more alternatives for designation.use, e.g. "consumer", this is/will be needed here
ducExt.addExtension("type", new Coding(SNOMED_URI, d.getTypeId(), descType));
designation.addExtension(ducExt);
});
// End editing for designation use case extension
Coding use = new Coding(SNOMED_URI, d.getTypeId(), descType);
designation.setUse(use);
return designation;
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method convertDesignations.
private List<ConceptDefinitionDesignationComponent> convertDesignations(List<ConceptReferenceDesignationComponent> list) {
List<ConceptDefinitionDesignationComponent> res = new ArrayList<CodeSystem.ConceptDefinitionDesignationComponent>();
for (ConceptReferenceDesignationComponent t : list) {
ConceptDefinitionDesignationComponent c = new ConceptDefinitionDesignationComponent();
c.setLanguage(t.getLanguage());
c.setUse(t.getUse());
c.setValue(t.getValue());
}
return res;
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetCheckerSimple method validateCode.
private ValidationResult validateCode(Coding code, CodeSystem cs) {
ConceptDefinitionComponent cc = findCodeInConcept(cs.getConcept(), code.getCode());
if (cc == null)
return new ValidationResult(IssueSeverity.ERROR, "Unknown Code " + gen(code) + " in " + cs.getUrl());
if (code.getDisplay() == null)
return new ValidationResult(cc);
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
if (cc.hasDisplay()) {
b.append(cc.getDisplay());
if (code.getDisplay().equalsIgnoreCase(cc.getDisplay()))
return new ValidationResult(cc);
}
for (ConceptDefinitionDesignationComponent ds : cc.getDesignation()) {
b.append(ds.getValue());
if (code.getDisplay().equalsIgnoreCase(ds.getValue()))
return new ValidationResult(cc);
}
// also check to see if the value set has another display
ConceptReferenceComponent vs = findValueSetRef(code.getSystem(), code.getCode());
if (vs != null && (vs.hasDisplay() || vs.hasDesignation())) {
if (vs.hasDisplay()) {
b.append(vs.getDisplay());
if (code.getDisplay().equalsIgnoreCase(vs.getDisplay()))
return new ValidationResult(cc);
}
for (ConceptReferenceDesignationComponent ds : vs.getDesignation()) {
b.append(ds.getValue());
if (code.getDisplay().equalsIgnoreCase(ds.getValue()))
return new ValidationResult(cc);
}
}
return new ValidationResult(IssueSeverity.WARNING, "Display Name for " + code.getSystem() + "#" + code.getCode() + " should be one of '" + b.toString() + "' instead of " + code.getDisplay(), cc);
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptReferenceDesignationComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method addCode.
private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List<ConceptDefinitionDesignationComponent> designations, Parameters expParams, boolean isAbstract, boolean inactive, List<ValueSet> filters, boolean noInactive) {
if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code))
return null;
if (noInactive && inactive) {
return null;
}
ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
n.setSystem(system);
n.setCode(code);
if (isAbstract)
n.setAbstract(true);
if (inactive)
n.setInactive(true);
if (expParams.getParameterBool("includeDesignations") && designations != null) {
for (ConceptDefinitionDesignationComponent t : designations) {
if (t.getLanguage() != null || t.getValue() != null) {
ConceptReferenceDesignationComponent d = n.addDesignation();
if (t.getLanguage() != null) {
d.setLanguage(t.getLanguage().trim());
}
if (t.getValue() != null) {
d.setValue(t.getValue().trim());
}
}
}
}
ConceptDefinitionDesignationComponent t = expParams.hasLanguage() ? getMatchingLang(designations, expParams.getLanguage()) : null;
if (t == null)
n.setDisplay(display);
else
n.setDisplay(t.getValue());
String s = key(n);
if (map.containsKey(s) || excludeKeys.contains(s)) {
canBeHeirarchy = false;
} else {
codes.add(n);
map.put(s, n);
total++;
}
if (canBeHeirarchy && parent != null) {
parent.getContains().add(n);
} else {
roots.add(n);
}
return n;
}
Aggregations