use of org.hl7.fhir.dstu2016may.model.ValueSet.ValueSetExpansionParameterComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method excludeCodes.
private void excludeCodes(ConceptSetComponent exc, List<ValueSetExpansionParameterComponent> params, String ctxt) throws FHIRException {
exc.checkNoModifiers("Compose.exclude", "expanding");
if (exc.hasSystem() && exc.getConcept().size() == 0 && exc.getFilter().size() == 0) {
excludeSystems.add(exc.getSystem());
}
if (exc.hasValueSet())
throw fail("Processing Value set references in exclude is not yet done in " + ctxt);
// importValueSet(imp.getValue(), params, expParams);
CodeSystem cs = context.fetchCodeSystem(exc.getSystem());
if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(exc.getSystem())) {
ValueSetExpansionOutcome vse = context.expandVS(exc, false, false);
ValueSet valueset = vse.getValueset();
if (valueset == null)
throw failTSE("Error Expanding ValueSet: " + vse.getError());
excludeCodes(valueset.getExpansion(), params);
return;
}
for (ConceptReferenceComponent c : exc.getConcept()) {
excludeCode(exc.getSystem(), c.getCode());
}
if (exc.getFilter().size() > 0)
throw fail("not done yet - multiple filters");
}
use of org.hl7.fhir.dstu2016may.model.ValueSet.ValueSetExpansionParameterComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method importValueSet.
private ValueSet importValueSet(String value, ValueSetExpansionComponent exp, Parameters expParams, boolean noInactive, ValueSet valueSet) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException, FHIRFormatError {
if (value == null)
throw fail("unable to find value set with no identity");
ValueSet vs = context.fetchResource(ValueSet.class, value);
if (vs == null) {
if (context.fetchResource(CodeSystem.class, value) != null) {
throw fail("Cannot include value set " + value + " because it's actually a code system");
} else {
throw fail("Unable to find imported value set " + value);
}
}
if (noInactive) {
expParams = expParams.copy();
expParams.addParameter("activeOnly", true);
}
ValueSetExpansionOutcome vso = new ValueSetExpanderSimple(context, allErrors).expand(vs, expParams);
if (vso.getError() != null) {
addErrors(vso.getAllErrors());
throw fail("Unable to expand imported value set " + vs.getUrl() + ": " + vso.getError());
}
if (vs.hasVersion())
if (!existsInParams(exp.getParameter(), "version", new UriType(vs.getUrl() + "|" + vs.getVersion())))
exp.getParameter().add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "|" + vs.getVersion())));
for (Extension ex : vso.getValueset().getExpansion().getExtension()) {
if (ex.getUrl().equals(ToolingExtensions.EXT_EXP_TOOCOSTLY)) {
if (ex.getValue() instanceof BooleanType) {
exp.getExtension().add(new Extension(ToolingExtensions.EXT_EXP_TOOCOSTLY).setValue(new UriType(value)));
} else {
exp.getExtension().add(ex);
}
}
}
for (ValueSetExpansionParameterComponent p : vso.getValueset().getExpansion().getParameter()) {
if (!existsInParams(exp.getParameter(), p.getName(), p.getValue()))
exp.getParameter().add(p);
}
if (isValueSetUnionImports(valueSet)) {
copyExpansion(vso.getValueset().getExpansion().getContains());
}
// if we're importing a value set, we have to be combining, so we won't try for a heirarchy
canBeHeirarchy = false;
return vso.getValueset();
}
use of org.hl7.fhir.dstu2016may.model.ValueSet.ValueSetExpansionParameterComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method doServerIncludeCodes.
private void doServerIncludeCodes(ConceptSetComponent inc, boolean heirarchical, ValueSetExpansionComponent exp, List<ValueSet> imports, Parameters expParams, List<Extension> extensions, boolean noInactive) throws FHIRException {
ValueSetExpansionOutcome vso = context.expandVS(inc, heirarchical, noInactive);
if (vso.getError() != null) {
throw failTSE("Unable to expand imported value set: " + vso.getError());
}
ValueSet vs = vso.getValueset();
if (vs.hasVersion()) {
if (!existsInParams(exp.getParameter(), "version", new UriType(vs.getUrl() + "|" + vs.getVersion()))) {
exp.getParameter().add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "|" + vs.getVersion())));
}
}
for (ValueSetExpansionParameterComponent p : vso.getValueset().getExpansion().getParameter()) {
if (!existsInParams(exp.getParameter(), p.getName(), p.getValue())) {
exp.getParameter().add(p);
}
}
for (Extension ex : vs.getExpansion().getExtension()) {
if (Utilities.existsInList(ex.getUrl(), ToolingExtensions.EXT_EXP_TOOCOSTLY, "http://hl7.org/fhir/StructureDefinition/valueset-unclosed")) {
if (!hasExtension(extensions, ex.getUrl())) {
extensions.add(ex);
}
}
}
for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) {
addCodeAndDescendents(cc, null, expParams, imports, noInactive);
}
}
use of org.hl7.fhir.dstu2016may.model.ValueSet.ValueSetExpansionParameterComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method addFragmentWarning.
private void addFragmentWarning(ValueSetExpansionComponent exp, CodeSystem cs) {
String url = cs.getVersionedUrl();
for (ValueSetExpansionParameterComponent p : exp.getParameter()) {
if ("fragment".equals(p.getName()) && p.hasValueUriType() && url.equals(p.getValue().primitiveValue())) {
return;
}
}
exp.addParameter().setName("fragment").setValue(new UriType(url));
}
use of org.hl7.fhir.dstu2016may.model.ValueSet.ValueSetExpansionParameterComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetRenderer method generateVersionNotice.
@SuppressWarnings("rawtypes")
private void generateVersionNotice(XhtmlNode x, ValueSetExpansionComponent expansion) {
Multimap<String, String> versions = HashMultimap.create();
for (ValueSetExpansionParameterComponent p : expansion.getParameter()) {
if (p.getName().equals("version")) {
String[] parts = ((PrimitiveType) p.getValue()).asStringValue().split("\\|");
if (parts.length == 2)
versions.put(parts[0], parts[1]);
}
}
if (versions.size() > 0) {
XhtmlNode div = null;
XhtmlNode ul = null;
boolean first = true;
for (String s : versions.keySet()) {
if (versions.size() == 1 && versions.get(s).size() == 1) {
for (String v : versions.get(s)) {
// though there'll only be one
XhtmlNode p = x.para().style("border: black 1px dotted; background-color: #EEEEEE; padding: 8px; margin-bottom: 8px");
p.tx("Expansion based on ");
expRef(p, s, v);
}
} else {
for (String v : versions.get(s)) {
if (first) {
div = x.div().style("border: black 1px dotted; background-color: #EEEEEE; padding: 8px; margin-bottom: 8px");
div.para().tx("Expansion based on: ");
ul = div.ul();
first = false;
}
expRef(ul.li(), s, v);
}
}
}
}
}
Aggregations