use of org.hl7.fhir.r4.model.ValueSet in project org.hl7.fhir.core by hapifhir.
the class ICD11Generator method processMMSEntity.
private void processMMSEntity(CodeSystem cs, String base, String ref, org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent cc, String dest) throws IOException {
System.out.print(".");
JsonObject entity = fetchJson(url(base, ref));
cc.setId(tail(ref));
if (entity.has("code") && !Utilities.noString(entity.get("code").getAsString())) {
cc.setCode(entity.get("code").getAsString());
} else if (entity.has("blockId") && !Utilities.noString(entity.get("blockId").getAsString())) {
cc.setCode(entity.get("blockId").getAsString());
} else {
cc.setCode(cc.getId());
cc.addProperty().setCode("abstract").setValue(new BooleanType(true));
}
if (entity.has("classKind") && !Utilities.noString(entity.get("classKind").getAsString()) && !"category".equals(entity.get("classKind").getAsString())) {
cc.addProperty().setCode("kind").setValue(new CodeType(entity.get("classKind").getAsString()));
}
cc.setDisplay(readString(entity, "title"));
StringBuilder defn = new StringBuilder();
String d = readString(entity, "definition");
if (d != null) {
defn.append(d);
}
if (d == null && (entity.has("inclusion") || entity.has("exclusion"))) {
defn.append(cc.getDisplay());
}
if (entity.has("inclusion")) {
defn.append(". Includes: ");
boolean first = true;
for (JsonElement child : entity.getAsJsonArray("inclusion")) {
if (first)
first = false;
else
defn.append(", ");
defn.append(readString((JsonObject) child, "label"));
}
}
if (entity.has("exclusion")) {
defn.append(". Excludes: ");
boolean first = true;
for (JsonElement child : entity.getAsJsonArray("exclusion")) {
if (first)
first = false;
else
defn.append(", ");
JsonObject co = (JsonObject) child;
String v = readString(co, "label");
if (v != null) {
defn.append(v);
if (co.has("linearizationReference")) {
cc.addProperty().setValue(new Coding().setSystem("http://id.who.int/icd11/mms").setCode(tail(co.get("linearizationReference").getAsString())).setDisplay(v)).setCode("exclusion");
}
}
}
}
cc.setDefinition(defn.toString());
addDesignation(readString(entity, "longDefinition"), cc, "http://id.who.int/icd11/mms/designation", "longDefinition");
addDesignation(readString(entity, "fullySpecifiedName"), cc, "http://snomed.info/sct", "900000000000003001");
addProperty(readString(entity, "codingNote"), cc, "codingNote");
if (entity.has("indexTerm")) {
// }
for (JsonElement child : entity.getAsJsonArray("indexTerm")) {
processIndexTerm(cc, (JsonObject) child);
}
}
if (entity.has("postcoordinationScale")) {
for (JsonElement child : entity.getAsJsonArray("postcoordinationScale")) {
JsonObject o = (JsonObject) child;
String name = tail(o.get("axisName").getAsString());
ConceptPropertyComponent prop = cc.addProperty();
prop.setCode("postcoordinationScale");
prop.setValue(new CodeType(name));
ToolingExtensions.addBooleanExtension(prop, "http://id.who.int/icd11/extensions/required", o.get("requiredPostcoordination").getAsBoolean());
ToolingExtensions.addBooleanExtension(prop, "http://id.who.int/icd11/extensions/repeats", o.get("allowMultipleValues").getAsBoolean());
if (o.has("scaleEntity")) {
ToolingExtensions.addUriExtension(prop, "http://id.who.int/icd11/extensions/valueSet", buildValueSet(cs, cc.getCode(), name, o, dest));
}
}
}
if (entity.has("child")) {
for (JsonElement child : entity.getAsJsonArray("child")) {
processMMSEntity(cs, base, child.getAsString(), cc.addConcept(), dest);
}
}
}
use of org.hl7.fhir.r4.model.ValueSet 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.r4.model.ValueSet 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.r4.model.ValueSet 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.r4.model.ValueSet in project org.hl7.fhir.core by hapifhir.
the class BaseWorkerContext method validateCode.
@Override
public ValidationResult validateCode(String system, String code, String display, ConceptSetComponent vsi) {
try {
ValueSet vs = new ValueSet().setUrl(Utilities.makeUuidUrn());
vs.getCompose().addInclude(vsi);
return verifyCodeExternal(vs, new Coding().setSystem(system).setCode(code).setDisplay(display), true);
} catch (Exception e) {
return new ValidationResult(IssueSeverity.FATAL, "Error validating code \"" + code + "\" in system \"" + system + "\": " + e.getMessage());
}
}
Aggregations