use of org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent in project kindling by HL7.
the class MarkDownPreProcessor method presentExpansion.
private static String presentExpansion(List<ValueSetExpansionContainsComponent> contains, BuildWorkerContext workerContext) {
StringBuilder b = new StringBuilder();
for (ValueSetExpansionContainsComponent cc : contains) {
b.append(" - **");
b.append(cc.getCode());
b.append("** (\"");
b.append(cc.getDisplay());
b.append("\"): ");
ConceptDefinitionComponent definition = workerContext.getCodeDefinition(cc.getSystem(), cc.getCode());
b.append(definition.getDefinition());
b.append("\r\n");
}
return b.toString();
}
use of org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent in project kindling by HL7.
the class XSDGenerator method generateEnum.
private void generateEnum(String en) throws IOException {
if (allenums.contains(en))
return;
allenums.add(en);
write(" <xs:simpleType name=\"" + en + "-list\">\r\n");
write(" <xs:restriction base=\"code-primitive\">\r\n");
ValueSet vs = enums.get(en);
vs.setUserData(ToolResourceUtilities.NAME_VS_USE_MARKER, true);
ValueSet ex = workerContext.expandVS(vs, true, false).getValueset();
for (ValueSetExpansionContainsComponent cc : ex.getExpansion().getContains()) {
genIncludedCode(cc);
}
write(" </xs:restriction>\r\n");
write(" </xs:simpleType>\r\n");
write(" <xs:complexType name=\"" + en + "\">\r\n");
write(" <xs:annotation>\r\n");
write(" <xs:documentation xml:lang=\"en\">" + Utilities.escapeXml(enumDefs.get(en)) + "</xs:documentation>\r\n");
write(" <xs:documentation xml:lang=\"en\">If the element is present, it must have either a @value, an @id, or extensions</xs:documentation>\r\n");
write(" </xs:annotation>\r\n");
write(" <xs:complexContent>\r\n");
write(" <xs:extension base=\"Element\">\r\n");
write(" <xs:attribute name=\"value\" type=\"" + en + "-list\" use=\"optional\"/>\r\n");
write(" </xs:extension>\r\n");
write(" </xs:complexContent>\r\n");
write(" </xs:complexType>\r\n");
}
use of org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class SpecDifferenceEvaluator method compareBindings.
private boolean compareBindings(JsonObject element, ElementDefinitionBindingComponent rev, ElementDefinitionBindingComponent orig) {
boolean res = false;
if (rev.getStrength() != orig.getStrength()) {
element.addProperty("binding-strength-changed", true);
res = true;
}
if (!Base.compareDeep(rev.getValueSet(), orig.getValueSet(), false)) {
element.addProperty("binding-valueset-changed", true);
res = true;
}
if (!maxValueSetsMatch(rev, orig)) {
element.addProperty("max-valueset-changed", true);
res = true;
}
if (rev.getStrength() == BindingStrength.REQUIRED && orig.getStrength() == BindingStrength.REQUIRED) {
JsonArray oa = new JsonArray();
JsonArray ra = new JsonArray();
ValueSet vrev = getValueSet(rev.getValueSet(), revision.getExpansions());
ValueSet vorig = getValueSet(rev.getValueSet(), original.getExpansions());
if (vrev != null && vorig != null) {
for (ValueSetExpansionContainsComponent cc : vorig.getExpansion().getContains()) {
if (!hasCode(vrev, cc))
oa.add(new JsonPrimitive(cc.getCode()));
}
for (ValueSetExpansionContainsComponent cc : vrev.getExpansion().getContains()) {
if (!hasCode(vorig, cc))
ra.add(new JsonPrimitive(cc.getCode()));
}
}
if (oa.size() > 0 || ra.size() > 0) {
element.addProperty("binding-codes-changed", true);
res = true;
}
if (oa.size() > 0)
element.add("removed-codes", oa);
if (ra.size() > 0)
element.add("added-codes", ra);
}
return res;
}
use of org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method expand.
@Override
public ValueSetExpansionOutcome expand(ValueSet source) {
try {
focus = source.copy();
focus.setExpansion(new ValueSet.ValueSetExpansionComponent());
focus.getExpansion().setTimestampElement(DateTimeType.now());
focus.getExpansion().setIdentifier(Factory.createUUID());
handleDefine(source, focus.getExpansion().getParameter());
if (source.hasCompose())
handleCompose(source.getCompose(), focus.getExpansion().getParameter());
for (ValueSetExpansionContainsComponent c : codes) {
if (map.containsKey(key(c))) {
focus.getExpansion().getContains().add(c);
}
}
return new ValueSetExpansionOutcome(focus, null);
} catch (Exception e) {
// that might fail too, but it might not, later.
return new ValueSetExpansionOutcome(new ValueSetCheckerSimple(source, factory, context), e.getMessage());
}
}
use of org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent in project org.hl7.fhir.core by hapifhir.
the class ValueSetExpanderSimple method importValueSet.
private void importValueSet(String value, List<ValueSetExpansionParameterComponent> params) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException {
if (value == null)
throw new TerminologyServiceException("unable to find value set with no identity");
ValueSet vs = context.fetchResource(ValueSet.class, value);
if (vs == null)
throw new TerminologyServiceException("Unable to find imported value set " + value);
ValueSetExpansionOutcome vso = factory.getExpander().expand(vs);
if (vso.getService() != null)
throw new TerminologyServiceException("Unable to expand imported value set " + value);
if (vs.hasVersion())
if (!existsInParams(params, "version", new UriType(vs.getUrl() + "?version=" + vs.getVersion())))
params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(vs.getUrl() + "?version=" + vs.getVersion())));
for (ValueSetExpansionParameterComponent p : vso.getValueset().getExpansion().getParameter()) {
if (!existsInParams(params, p.getName(), p.getValue()))
params.add(p);
}
for (ValueSetExpansionContainsComponent c : vso.getValueset().getExpansion().getContains()) {
addCode(c.getSystem(), c.getCode(), c.getDisplay());
}
}
Aggregations