use of org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome in project kindling by HL7.
the class PageProcessor method expandVS.
public String expandVS(ValueSet vs, String prefix, String base) {
try {
ValueSetExpansionOutcome result = workerContext.expandVS(vs, true, true);
if (result.getError() != null)
return "<hr/>\r\n" + VS_INC_START + "<!--3-->" + processExpansionError(result.getError()) + VS_INC_END;
if (result.getValueset() == null)
return "<hr/>\r\n" + VS_INC_START + "<!--4-->" + processExpansionError("(no error returned)") + VS_INC_END;
ValueSet exp = result.getValueset();
if (exp == vs)
throw new Exception("Expansion cannot be the same instance");
exp.setCompose(null);
exp.setText(null);
exp.setDescription("Value Set Contents (Expansion) for " + vs.present() + " at " + Config.DATE_FORMAT().format(new Date()));
int i = countContains(exp.getExpansion().getContains());
IniFile sini = new IniFile(Utilities.path(folders.rootDir, "temp", "stats.ini"));
sini.setIntegerProperty("valuesets", vs.getId(), i, null);
sini.save();
RenderingContext lrc = rc.copy().setLocalPrefix(prefix).setTooCostlyNoteEmpty(TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(TOO_MANY_CODES_TEXT_NOT_EMPTY);
RendererFactory.factory(exp, lrc).render(exp);
return "<hr/>\r\n" + VS_INC_START + "" + new XhtmlComposer(XhtmlComposer.HTML).compose(exp.getText().getDiv()) + VS_INC_END;
} catch (Exception e) {
e.printStackTrace();
return "<hr/>\r\n" + VS_INC_START + "<!--5-->" + processExpansionError(e instanceof NullPointerException ? "NullPointerException" : e.getMessage()) + " " + Utilities.escapeXml(stack(e)) + VS_INC_END;
}
}
use of org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome in project kindling by HL7.
the class PageProcessor method expandValueSetIG.
private String expandValueSetIG(ValueSet vs, boolean heirarchy) throws Exception {
if (!hasDynamicContent(vs))
return "";
try {
ValueSetExpansionOutcome result = workerContext.expandVS(vs, true, heirarchy);
if (result.getError() != null)
return "<hr/>\r\n" + VS_INC_START + "<!--1-->" + processExpansionError(result.getError()) + VS_INC_END;
ValueSet exp = result.getValueset();
if (exp == vs)
throw new Exception("Expansion cannot be the same instance");
exp.setCompose(null);
exp.setText(null);
exp.setDescription("Value Set Contents (Expansion) for " + vs.present() + " at " + Config.DATE_FORMAT().format(new Date()));
RenderingContext lrc = rc.copy().setTooCostlyNoteEmpty(TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(TOO_MANY_CODES_TEXT_NOT_EMPTY);
RendererFactory.factory(exp, lrc).render(exp);
return "<hr/>\r\n" + VS_INC_START + "" + new XhtmlComposer(XhtmlComposer.HTML).compose(exp.getText().getDiv()) + VS_INC_END;
} catch (Exception e) {
return "<hr/>\r\n" + VS_INC_START + "<!--2-->" + processExpansionError(e.getMessage()) + VS_INC_END;
}
}
use of org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method countMembership.
private Integer countMembership(ValueSet vs) {
int count = 0;
if (vs.hasExpansion())
count = count + conceptCount(vs.getExpansion().getContains());
else {
if (vs.hasCodeSystem())
count = count + countConcepts(vs.getCodeSystem().getConcept());
if (vs.hasCompose()) {
if (vs.getCompose().hasExclude()) {
try {
ValueSetExpansionOutcome vse = context.expandVS(vs, true);
count = 0;
count += conceptCount(vse.getValueset().getExpansion().getContains());
return count;
} catch (Exception e) {
return null;
}
}
for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
if (inc.hasFilter())
return null;
if (!inc.hasConcept())
return null;
count = count + inc.getConcept().size();
}
}
}
return count;
}
use of org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome in project org.hl7.fhir.core by hapifhir.
the class BaseWorkerContext method expandVS.
@Override
public ValueSetExpansionOutcome expandVS(ValueSet vs, boolean cacheOk) {
try {
Map<String, String> params = new HashMap<String, String>();
params.put("_limit", "10000");
params.put("_incomplete", "true");
params.put("profile", "http://www.healthintersections.com.au/fhir/expansion/no-details");
ValueSet result = txServer.expandValueset(vs, null, params);
return new ValueSetExpansionOutcome(result);
} catch (Exception e) {
return new ValueSetExpansionOutcome("Error expanding ValueSet \"" + vs.getUrl() + ": " + e.getMessage());
}
}
use of org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome in project org.hl7.fhir.core by hapifhir.
the class BaseWorkerContext method expandVS.
@Override
public ValueSetExpansionComponent expandVS(ConceptSetComponent inc) {
ValueSet vs = new ValueSet();
vs.setCompose(new ValueSetComposeComponent());
vs.getCompose().getInclude().add(inc);
ValueSetExpansionOutcome vse = expandVS(vs, true);
return vse.getValueset().getExpansion();
}
Aggregations