use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent 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 new Error("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);
ValueSet valueset = vse.getValueset();
if (valueset == null)
throw new TerminologyServiceException("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 new NotImplementedException("not done yet");
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetCheckerSimple method inComponent.
private boolean inComponent(ConceptSetComponent vsi, String system, String code, boolean only) throws FHIRException {
for (UriType uri : vsi.getValueSet()) {
if (inImport(uri.getValue(), system, code))
return true;
}
if (!vsi.hasSystem())
return false;
if (only && system == null) {
// whether we know the system or not, we'll accept the stated codes at face value
for (ConceptReferenceComponent cc : vsi.getConcept()) if (cc.getCode().equals(code))
return true;
}
if (!system.equals(vsi.getSystem()))
return false;
if (vsi.hasFilter()) {
boolean ok = true;
for (ConceptSetFilterComponent f : vsi.getFilter()) if (!codeInFilter(system, f, code)) {
ok = false;
break;
}
if (ok)
return true;
}
CodeSystem def = context.fetchCodeSystem(system);
if (def.getContent() != CodeSystemContentMode.COMPLETE)
throw new FHIRException("Unable to resolve system " + vsi.getSystem() + " - system is not complete");
List<ConceptDefinitionComponent> list = def.getConcept();
boolean ok = validateCodeInConceptList(code, def, list);
if (ok && vsi.hasConcept()) {
for (ConceptReferenceComponent cc : vsi.getConcept()) if (cc.getCode().equals(code))
return true;
return false;
} else
return ok;
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class TerminologyCache method generateExpandToken.
public CacheToken generateExpandToken(ValueSet vs, boolean heirarchical) {
CacheToken ct = new CacheToken();
ValueSet vsc = getVSEssense(vs);
for (ConceptSetComponent inc : vs.getCompose().getInclude()) if (inc.hasSystem())
ct.setName(getNameForSystem(inc.getSystem()));
for (ConceptSetComponent inc : vs.getCompose().getExclude()) if (inc.hasSystem())
ct.setName(getNameForSystem(inc.getSystem()));
for (ValueSetExpansionContainsComponent inc : vs.getExpansion().getContains()) if (inc.hasSystem())
ct.setName(getNameForSystem(inc.getSystem()));
JsonParser json = new JsonParser();
json.setOutputStyle(OutputStyle.PRETTY);
try {
ct.request = "{\"hierarchical\" : " + (heirarchical ? "true" : "false") + ", \"valueSet\" :" + extracted(json, vsc) + "}\r\n";
} catch (IOException e) {
throw new Error(e);
}
ct.key = String.valueOf(hashNWS(ct.request));
return ct;
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class TerminologyCache method getIncSummary.
private String getIncSummary(ConceptSetComponent cc) {
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
for (UriType vs : cc.getValueSet()) b.append(vs.asStringValue());
String vsd = b.length() > 0 ? " where the codes are in the value sets (" + b.toString() + ")" : "";
String system = cc.getSystem();
if (cc.hasConcept())
return Integer.toString(cc.getConcept().size()) + " codes from " + system + vsd;
if (cc.hasFilter()) {
String s = "";
for (ConceptSetFilterComponent f : cc.getFilter()) {
if (!Utilities.noString(s))
s = s + " & ";
s = s + f.getProperty() + " " + (f.hasOp() ? f.getOp().toCode() : "?") + " " + f.getValue();
}
return "from " + system + " where " + s + vsd;
}
return "All codes from " + system + vsd;
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetComparer method addComposeRow.
private void addComposeRow(HierarchicalTableGenerator gen, List<Row> rows, StructuralMatch<Element> t, String name) {
Row r = gen.new Row();
rows.add(r);
r.getCells().add(gen.new Cell(null, null, name, null, null));
if (t.hasLeft() && t.hasRight()) {
ConceptSetComponent csL = (ConceptSetComponent) t.getLeft();
ConceptSetComponent csR = (ConceptSetComponent) t.getRight();
if (csL.hasSystem() && csL.getSystem().equals(csR.getSystem())) {
r.getCells().add(gen.new Cell(null, null, csL.getSystem(), null, null).span(2).center());
} else {
r.getCells().add(gen.new Cell(null, null, csL.getSystem(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
r.getCells().add(gen.new Cell(null, null, csR.getSystem(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
}
if (csL.hasVersion() && csR.hasVersion()) {
if (csL.getVersion().equals(csR.getVersion())) {
r.getCells().add(gen.new Cell(null, null, csL.getVersion(), null, null).span(2).center());
} else {
r.getCells().add(gen.new Cell(null, null, csL.getVersion(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
r.getCells().add(gen.new Cell(null, null, csR.getVersion(), null, null).setStyle("background-color: " + COLOR_DIFFERENT));
}
} else if (csL.hasVersion()) {
r.getCells().add(gen.new Cell(null, null, csL.getVersion(), null, null));
r.getCells().add(missingCell(gen, COLOR_NO_CELL_RIGHT));
} else if (csR.hasVersion()) {
r.getCells().add(missingCell(gen, COLOR_NO_CELL_LEFT));
r.getCells().add(gen.new Cell(null, null, csR.getVersion(), null, null));
} else {
r.getCells().add(missingCell(gen).span(2).center());
}
} else if (t.hasLeft()) {
r.setColor(COLOR_NO_ROW_RIGHT);
ConceptSetComponent cs = (ConceptSetComponent) t.getLeft();
r.getCells().add(gen.new Cell(null, null, cs.getSystem(), null, null));
r.getCells().add(missingCell(gen));
r.getCells().add(gen.new Cell(null, null, cs.hasVersion() ? "Version: " + cs.getVersion() : "", null, null));
r.getCells().add(missingCell(gen));
} else {
r.setColor(COLOR_NO_ROW_LEFT);
ConceptSetComponent cs = (ConceptSetComponent) t.getRight();
r.getCells().add(missingCell(gen));
r.getCells().add(gen.new Cell(null, null, cs.getSystem(), null, null));
r.getCells().add(missingCell(gen));
r.getCells().add(gen.new Cell(null, null, cs.hasVersion() ? "Version: " + cs.getVersion() : "", null, null));
}
r.getCells().add(cellForMessages(gen, t.getMessages()));
for (StructuralMatch<Element> c : t.getChildren()) {
if (c.either() instanceof ConceptReferenceComponent) {
addSetConceptRow(gen, r.getSubRows(), c);
} else {
addSetFilterRow(gen, r.getSubRows(), c);
}
}
}
Aggregations