use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class Element method getAsICoding.
public ICoding getAsICoding() throws FHIRException {
if ("code".equals(fhirType())) {
if (property.getDefinition().getBinding().getStrength() != BindingStrength.REQUIRED)
return null;
ICodingImpl c = new ICodingImpl(true, true, false, false);
c.code = primitiveValue();
ValueSetExpansionOutcome vse = property.getContext().expandVS(property.getDefinition().getBinding(), true, false);
if (vse.getValueset() == null)
return null;
for (ValueSetExpansionContainsComponent cc : vse.getValueset().getExpansion().getContains()) {
if (cc.getCode().equals(c.code)) {
c.system = cc.getSystem();
if (cc.hasVersion()) {
c.doesVersion = true;
c.version = cc.getVersion();
}
if (cc.hasDisplay()) {
c.doesDisplay = true;
c.display = cc.getDisplay();
}
}
}
if (c.system == null)
return null;
return c;
} else if ("Coding".equals(fhirType())) {
ICodingImpl c = new ICodingImpl(true, true, true, true);
c.system = getNamedChildValue("system");
c.code = getNamedChildValue("code");
c.display = getNamedChildValue("display");
c.version = getNamedChildValue("version");
return c;
} else if ("Quantity".equals(fhirType())) {
ICodingImpl c = new ICodingImpl(true, true, false, false);
c.system = getNamedChildValue("system");
c.code = getNamedChildValue("code");
return c;
} else
return null;
}
use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetCheckerSimple method findValueSetRef.
private ConceptReferenceComponent findValueSetRef(String system, String code) {
if (valueset == null)
return null;
// if it has an expansion
for (ValueSetExpansionContainsComponent exp : valueset.getExpansion().getContains()) {
if (system.equals(exp.getSystem()) && code.equals(exp.getCode())) {
ConceptReferenceComponent cc = new ConceptReferenceComponent();
cc.setDisplay(exp.getDisplay());
cc.setDesignation(exp.getDesignation());
return cc;
}
}
for (ConceptSetComponent inc : valueset.getCompose().getInclude()) {
if (system.equals(inc.getSystem())) {
for (ConceptReferenceComponent cc : inc.getConcept()) {
if (cc.getCode().equals(code)) {
return cc;
}
}
}
for (CanonicalType url : inc.getValueSet()) {
ConceptReferenceComponent cc = getVs(url.asStringValue()).findValueSetRef(system, code);
if (cc != null) {
return cc;
}
}
}
return null;
}
use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method doExpand.
public ValueSetExpansionOutcome doExpand(ValueSet source, Parameters expParams) throws FHIRException, ETooCostly, FileNotFoundException, IOException {
if (expParams == null)
expParams = makeDefaultExpansion();
source.checkNoModifiers("ValueSet", "expanding");
focus = source.copy();
focus.setExpansion(new ValueSet.ValueSetExpansionComponent());
focus.getExpansion().setTimestampElement(DateTimeType.now());
focus.getExpansion().setIdentifier(Factory.createUUID());
for (ParametersParameterComponent p : expParams.getParameter()) {
if (Utilities.existsInList(p.getName(), "includeDesignations", "excludeNested"))
focus.getExpansion().addParameter().setName(p.getName()).setValue(p.getValue());
}
if (source.hasCompose()) {
handleCompose(source.getCompose(), focus.getExpansion(), expParams, source.getUrl(), focus.getExpansion().getExtension(), source);
}
if (canBeHeirarchy) {
for (ValueSetExpansionContainsComponent c : roots) {
focus.getExpansion().getContains().add(c);
}
} else {
for (ValueSetExpansionContainsComponent c : codes) {
if (map.containsKey(key(c)) && (includeAbstract || !c.getAbstract())) {
// we may have added abstract codes earlier while we still thought it might be heirarchical, but later we gave up, so now ignore them
focus.getExpansion().getContains().add(c);
// make sure any heirarchy is wiped
c.getContains().clear();
}
}
}
if (total > 0) {
focus.getExpansion().setTotal(total);
}
return new ValueSetExpansionOutcome(focus);
}
use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method excludeCode.
private void excludeCode(String theSystem, String theCode) {
ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
n.setSystem(theSystem);
n.setCode(theCode);
String s = key(n);
excludeKeys.add(s);
}
use of org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method addExpansionRowToTable.
private void addExpansionRowToTable(XhtmlNode t, ValueSetExpansionContainsComponent c, int i, boolean doSystem, boolean doDefinition, Map<ConceptMap, String> mymaps, CodeSystem allCS, List<String> langs) {
XhtmlNode tr = t.tr();
XhtmlNode td = tr.td();
String tgt = makeAnchor(c.getSystem(), c.getCode());
td.an(tgt);
String s = Utilities.padLeft("", '\u00A0', i * 2);
td.addText(s);
addCodeToTable(c.getAbstract(), c.getSystem(), c.getCode(), c.getDisplay(), td);
if (doSystem) {
td = tr.td();
td.addText(c.getSystem());
}
td = tr.td();
if (c.hasDisplayElement())
td.addText(c.getDisplay());
if (doDefinition) {
CodeSystem cs = allCS;
if (cs == null)
cs = context.fetchCodeSystem(c.getSystem());
td = tr.td();
if (cs != null)
td.addText(CodeSystemUtilities.getCodeDefinition(cs, c.getCode()));
}
for (ConceptMap m : mymaps.keySet()) {
td = tr.td();
List<TargetElementComponentWrapper> mappings = findMappingsForCode(c.getCode(), m);
boolean first = true;
for (TargetElementComponentWrapper mapping : mappings) {
if (!first)
td.br();
first = false;
XhtmlNode span = td.span(null, mapping.comp.getEquivalence().toString());
span.addText(getCharForEquivalence(mapping.comp));
XhtmlNode a = td.ah(prefix + mymaps.get(m) + "#" + mapping.comp.getCode());
a.addText(mapping.comp.getCode());
if (!Utilities.noString(mapping.comp.getComment()))
td.i().tx("(" + mapping.comp.getComment() + ")");
}
}
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 (ValueSetExpansionContainsComponent cc : c.getContains()) {
addExpansionRowToTable(t, cc, i + 1, doSystem, doDefinition, mymaps, allCS, langs);
}
}
Aggregations