use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class ICD11Generator method buildValueSet.
private String buildValueSet(CodeSystem cs, String code, String name, JsonObject o, String dest) throws IOException {
String id = code + "-" + name;
String url = "http://id.who.int/icd11/ValueSet/" + id;
ValueSet vs = new ValueSet();
vs.setId(id);
vs.setUrl(url);
vs.setName("VS" + name + "4" + code);
vs.setTitle("Value Set for " + name + " on " + code);
vs.setStatus(PublicationStatus.ACTIVE);
vs.setExperimental(false);
vs.setDate(cs.getDate());
vs.setPublisher("WHO");
vs.setCopyright("Consult WHO For terms of use");
vs.setVersion(cs.getVersion());
vs.setStatus(cs.getStatus());
ConceptSetComponent inc = vs.getCompose().addInclude();
inc.setSystem(cs.getUrl());
for (JsonElement e : o.getAsJsonArray("scaleEntity")) {
inc.addFilter().setProperty("concept").setOp(FilterOperator.ISA).setValue(tail(e.getAsString()));
}
new XmlParser(XmlVersion.V1_1).setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "vs-" + id + ".xml")), vs);
return url;
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class ISO21090Importer method generateValueSet.
private void generateValueSet(EnumValueSet evs) throws Exception {
ValueSet bvs = ctxt.fetchResource(ValueSet.class, evs.getTemplate());
if (bvs == null)
throw new Exception("Did not find template value set " + evs.getTemplate());
ValueSet vs = bvs.copy();
vs.getCompose().getInclude().clear();
vs.getIdentifier().clear();
vs.setName("ISO 20190 " + evs.getName() + " Enumeration");
vs.setId(evs.getName());
vs.setUrl("http://hl7.org/fhir/iso21090/ValueSet/" + vs.getId());
vs.setDate(new Date());
vs.setExperimental(false);
ConceptSetComponent inc = vs.getCompose().addInclude().setSystem(evs.getSystem());
for (String code : evs.getCodes()) {
inc.addConcept().setCode(code);
}
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path("[tmp]", "iso21090\\ValueSet-" + evs.getName() + ".xml")), vs);
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generateComposition.
private boolean generateComposition(XhtmlNode x, ValueSet vs, boolean header) {
boolean hasExtensions = false;
if (!vs.hasCodeSystem()) {
if (header) {
XhtmlNode h = x.addTag("h2");
h.addText(vs.getName());
XhtmlNode p = x.addTag("p");
smartAddText(p, vs.getDescription());
if (vs.hasCopyrightElement())
generateCopyright(x, vs);
}
XhtmlNode p = x.addTag("p");
p.addText("This value set includes codes from the following code systems:");
} else {
XhtmlNode p = x.addTag("p");
p.addText("In addition, this value set includes codes from other code systems:");
}
XhtmlNode ul = x.addTag("ul");
XhtmlNode li;
for (UriType imp : vs.getCompose().getImport()) {
li = ul.addTag("li");
li.addText("Import all the codes that are contained in ");
AddVsRef(imp.getValue(), li);
}
for (ConceptSetComponent inc : vs.getCompose().getInclude()) {
hasExtensions = genInclude(ul, inc, "Include") || hasExtensions;
}
for (ConceptSetComponent exc : vs.getCompose().getExclude()) {
hasExtensions = genInclude(ul, exc, "Exclude") || hasExtensions;
}
return hasExtensions;
}
use of org.hl7.fhir.r4b.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;
if (cs != null) {
ref = (String) cs.getUserData("filename");
if (Utilities.noString(ref))
ref = (String) cs.getUserData("path");
}
if (cs != null && ref != null) {
if (!Utilities.noString(prefix) && ref.startsWith("http://hl7.org/fhir/"))
ref = ref.substring(20) + "/index.html";
else if (!ref.endsWith(".html"))
ref = ref + ".html";
XhtmlNode a = li.addTag("a");
a.setAttribute("href", prefix + ref.replace("\\", "/"));
a.addText(inc.getSystem().toString());
} else
li.addText(inc.getSystem().toString());
}
use of org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent 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;
}
Aggregations