use of org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetComparer method compareCompose.
private void compareCompose(ValueSetComposeComponent left, ValueSetComposeComponent right, ValueSetComparison res, ValueSetComposeComponent union, ValueSetComposeComponent intersection) {
// first, the includes
List<ConceptSetComponent> matchR = new ArrayList<>();
for (ConceptSetComponent l : left.getInclude()) {
ConceptSetComponent r = findInList(right.getInclude(), l, left.getInclude());
if (r == null) {
union.getInclude().add(l);
res.getIncludes().getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed Include", "ValueSet.compose.include")));
} else {
matchR.add(r);
ConceptSetComponent csM = new ConceptSetComponent();
ConceptSetComponent csI = new ConceptSetComponent();
union.getInclude().add(csM);
intersection.getInclude().add(csI);
StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
res.getIncludes().getChildren().add(sm);
compareDefinitions(l, r, sm, csM, csI);
}
}
for (ConceptSetComponent r : right.getInclude()) {
if (!matchR.contains(r)) {
union.getInclude().add(r);
res.getIncludes().getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added Include", "ValueSet.compose.include"), r));
}
}
// now. the excludes
matchR.clear();
for (ConceptSetComponent l : left.getExclude()) {
ConceptSetComponent r = findInList(right.getExclude(), l, left.getExclude());
if (r == null) {
union.getExclude().add(l);
res.getExcludes().getChildren().add(new StructuralMatch<Element>(l, vmI(IssueSeverity.INFORMATION, "Removed Exclude", "ValueSet.compose.exclude")));
} else {
matchR.add(r);
ConceptSetComponent csM = new ConceptSetComponent();
ConceptSetComponent csI = new ConceptSetComponent();
union.getExclude().add(csM);
intersection.getExclude().add(csI);
StructuralMatch<Element> sm = new StructuralMatch<Element>(l, r);
res.getExcludes().getChildren().add(sm);
compareDefinitions(l, r, sm, csM, csI);
}
}
for (ConceptSetComponent r : right.getExclude()) {
if (!matchR.contains(r)) {
union.getExclude().add(r);
res.getExcludes().getChildren().add(new StructuralMatch<Element>(vmI(IssueSeverity.INFORMATION, "Added Exclude", "ValueSet.compose.exclude"), r));
}
}
}
use of org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generateComposition.
private boolean generateComposition(ResourceContext rcontext, XhtmlNode x, ValueSet vs, boolean header) throws FHIRException, IOException {
boolean hasExtensions = false;
List<String> langs = new ArrayList<String>();
if (header) {
XhtmlNode h = x.h2();
h.addText(vs.getName());
addMarkdown(x, vs.getDescription());
if (vs.hasCopyrightElement())
generateCopyright(x, vs);
}
XhtmlNode p = x.para();
p.tx("This value set includes codes from the following code systems:");
XhtmlNode ul = x.ul();
XhtmlNode li;
for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
hasExtensions = genInclude(rcontext, ul, inc, "Include", langs) || hasExtensions;
}
for (ConceptSetComponent exc : vs.getCompose().getExclude()) {
hasExtensions = genInclude(rcontext, ul, exc, "Exclude", langs) || hasExtensions;
}
if (langs.size() > 0) {
Collections.sort(langs);
x.para().b().tx("Additional Language Displays");
XhtmlNode t = x.table("codes");
XhtmlNode tr = t.tr();
tr.td().b().tx("Code");
for (String lang : langs) tr.td().b().addText(describeLang(lang));
for (ConceptSetComponent c : vs.getCompose().getInclude()) {
for (ConceptReferenceComponent cc : c.getConcept()) {
addLanguageRow(cc, t, langs);
}
}
}
return hasExtensions;
}
use of org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class BaseWorkerContext method expandVS.
@Override
public ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean heirachical) throws TerminologyServiceException {
ValueSet vs = new ValueSet();
vs.setCompose(new ValueSetComposeComponent());
vs.getCompose().getInclude().add(inc);
CacheToken cacheToken = txCache.generateExpandToken(vs, heirachical);
ValueSetExpansionOutcome res;
res = txCache.getExpansion(cacheToken);
if (res != null)
return res;
Parameters p = expParameters.copy();
p.setParameter("includeDefinition", false);
p.setParameter("excludeNested", !heirachical);
if (noTerminologyServer)
return new ValueSetExpansionOutcome("Error expanding ValueSet: running without terminology services", TerminologyServiceErrorClass.NOSERVICE);
Map<String, String> params = new HashMap<String, String>();
params.put("_limit", Integer.toString(expandCodesLimit));
params.put("_incomplete", "true");
tlog("$expand on " + txCache.summary(vs));
try {
ValueSet result = txClient.expandValueset(vs, p, params);
res = new ValueSetExpansionOutcome(result).setTxLink(txLog.getLastId());
} catch (Exception e) {
res = new ValueSetExpansionOutcome(e.getMessage() == null ? e.getClass().getName() : e.getMessage(), TerminologyServiceErrorClass.UNKNOWN);
if (txLog != null)
res.setTxLink(txLog.getLastId());
}
txCache.cacheExpansion(cacheToken, res, TerminologyCache.PERMANENT);
return res;
}
use of org.hl7.fhir.r4.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.getOp().toCode() + " " + f.getValue();
}
return "from " + system + " where " + s + vsd;
}
return "All codes from " + system + vsd;
}
use of org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method addCsRef.
private <T extends Resource> void addCsRef(ConceptSetComponent inc, XhtmlNode li, T cs) {
String ref = null;
boolean addHtml = true;
if (cs != null) {
ref = (String) cs.getUserData("external.url");
if (Utilities.noString(ref))
ref = (String) cs.getUserData("filename");
else
addHtml = false;
if (Utilities.noString(ref))
ref = (String) cs.getUserData("path");
}
String spec = getSpecialReference(inc.getSystem());
if (spec != null) {
XhtmlNode a = li.ah(spec);
a.code(inc.getSystem());
} else if (cs != null && ref != null) {
if (!Utilities.noString(prefix) && ref.startsWith("http://hl7.org/fhir/"))
ref = ref.substring(20) + "/index.html";
else if (addHtml && !ref.contains(".html"))
ref = ref + ".html";
XhtmlNode a = li.ah(prefix + ref.replace("\\", "/"));
a.code(inc.getSystem());
} else {
li.code(inc.getSystem());
}
}
Aggregations