use of org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator 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.dstu2.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method buildCoding.
private Coding buildCoding(String uri, String code) throws FHIRException {
// if we can get this as a valueSet, we will
String system = null;
String display = null;
ValueSet vs = Utilities.noString(uri) ? null : worker.fetchResourceWithException(ValueSet.class, uri);
if (vs != null) {
ValueSetExpansionOutcome vse = worker.expandVS(vs, true, false);
if (vse.getError() != null)
throw new FHIRException(vse.getError());
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (ValueSetExpansionContainsComponent t : vse.getValueset().getExpansion().getContains()) {
if (t.hasCode())
b.append(t.getCode());
if (code.equals(t.getCode()) && t.hasSystem()) {
system = t.getSystem();
display = t.getDisplay();
break;
}
if (code.equalsIgnoreCase(t.getDisplay()) && t.hasSystem()) {
system = t.getSystem();
display = t.getDisplay();
break;
}
}
if (system == null)
throw new FHIRException("The code '" + code + "' is not in the value set '" + uri + "' (valid codes: " + b.toString() + "; also checked displays)");
} else
system = uri;
ValidationResult vr = worker.validateCode(system, code, null);
if (vr != null && vr.getDisplay() != null)
display = vr.getDisplay();
return new Coding().setSystem(system).setCode(code).setDisplay(display);
}
use of org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method doServerIncludeCodes.
private void doServerIncludeCodes(ConceptSetComponent inc, boolean heirarchical, List<ValueSetExpansionParameterComponent> params, List<ValueSet> imports, Parameters expParams) throws FHIRException {
ValueSetExpansionOutcome vso = context.expandVS(inc, heirarchical);
if (vso.getError() != null)
throw new TerminologyServiceException("Unable to expand imported value set: " + vso.getError());
ValueSet vs = vso.getValueset();
if (vs.hasVersion())
if (!existsInParams(params, "version", new UriType(vs.getUrl() + "|" + vs.getVersion())))
params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "|" + vs.getVersion())));
for (ValueSetExpansionParameterComponent p : vso.getValueset().getExpansion().getParameter()) {
if (!existsInParams(params, p.getName(), p.getValue()))
params.add(p);
}
for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) {
addCodeAndDescendents(cc, null, expParams, imports);
}
}
use of org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method addCodeAndDescendents.
private void addCodeAndDescendents(CodeSystem cs, String system, ConceptDefinitionComponent def, ValueSetExpansionContainsComponent parent, Parameters expParams, List<ValueSet> filters, ConceptDefinitionComponent exclusion) throws FHIRException {
def.checkNoModifiers("Code in Code System", "expanding");
if (exclusion != null) {
if (exclusion.getCode().equals(def.getCode()))
// excluded.
return;
}
if (!CodeSystemUtilities.isDeprecated(cs, def)) {
ValueSetExpansionContainsComponent np = null;
boolean abs = CodeSystemUtilities.isNotSelectable(cs, def);
boolean inc = CodeSystemUtilities.isInactive(cs, def);
if (canBeHeirarchy || !abs)
np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), expParams, abs, inc, filters);
for (ConceptDefinitionComponent c : def.getConcept()) addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion);
} else {
for (ConceptDefinitionComponent c : def.getConcept()) addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion);
}
}
use of org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method addCodeAndDescendents.
private void addCodeAndDescendents(ValueSetExpansionContainsComponent focus, ValueSetExpansionContainsComponent parent, Parameters expParams, List<ValueSet> filters) throws FHIRException {
focus.checkNoModifiers("Expansion.contains", "expanding");
ValueSetExpansionContainsComponent np = addCode(focus.getSystem(), focus.getCode(), focus.getDisplay(), parent, convert(focus.getDesignation()), expParams, focus.getAbstract(), focus.getInactive(), filters);
for (ValueSetExpansionContainsComponent c : focus.getContains()) addCodeAndDescendents(focus, np, expParams, filters);
}
Aggregations