Search in sources :

Example 96 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method verifyCodeExternal.

private ValidationResult verifyCodeExternal(ValueSet vs, CodeableConcept cc, boolean tryCache) {
    ValidationResult res = handleByCache(vs, cc, tryCache);
    if (res != null)
        return res;
    Parameters pin = new Parameters();
    pin.addParameter().setName("codeableConcept").setValue(cc);
    pin.addParameter().setName("valueSet").setResource(vs);
    res = serverValidateCode(pin);
    Map<String, ValidationResult> cache = validationCache.get(vs.getUrl());
    cache.put(cacheId(cc), res);
    return res;
}
Also used : Parameters(org.hl7.fhir.dstu2.model.Parameters)

Example 97 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet 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();
}
Also used : ValueSetExpansionOutcome(org.hl7.fhir.dstu2.terminologies.ValueSetExpander.ValueSetExpansionOutcome) ValueSet(org.hl7.fhir.dstu2.model.ValueSet) ValueSetComposeComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetComposeComponent)

Example 98 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method verifyCodeExternal.

private ValidationResult verifyCodeExternal(ValueSet vs, Coding coding, boolean tryCache) {
    ValidationResult res = handleByCache(vs, coding, tryCache);
    if (res != null)
        return res;
    Parameters pin = new Parameters();
    pin.addParameter().setName("coding").setValue(coding);
    pin.addParameter().setName("valueSet").setResource(vs);
    res = serverValidateCode(pin);
    Map<String, ValidationResult> cache = validationCache.get(vs.getUrl());
    cache.put(cacheId(coding), res);
    return res;
}
Also used : Parameters(org.hl7.fhir.dstu2.model.Parameters)

Example 99 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet in project org.hl7.fhir.core by hapifhir.

the class ValueSetExpanderSimple method includeCodes.

private void includeCodes(ConceptSetComponent inc, List<ValueSetExpansionParameterComponent> params) throws TerminologyServiceException, ETooCostly {
    if (context.supportsSystem(inc.getSystem())) {
        addCodes(context.expandVS(inc), params);
        return;
    }
    ValueSet cs = context.fetchCodeSystem(inc.getSystem());
    if (cs == null)
        throw new TerminologyServiceException("unable to find code system " + inc.getSystem().toString());
    if (cs.hasVersion())
        if (!existsInParams(params, "version", new UriType(cs.getUrl() + "?version=" + cs.getVersion())))
            params.add(new ValueSetExpansionParameterComponent().setName("version").setValue(new UriType(cs.getUrl() + "?version=" + cs.getVersion())));
    if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) {
        // special case - add all the code system
        for (ConceptDefinitionComponent def : cs.getCodeSystem().getConcept()) {
            addCodeAndDescendents(inc.getSystem(), def);
        }
    }
    for (ConceptReferenceComponent c : inc.getConcept()) {
        addCode(inc.getSystem(), c.getCode(), Utilities.noString(c.getDisplay()) ? getCodeDisplay(cs, c.getCode()) : c.getDisplay());
    }
    if (inc.getFilter().size() > 1)
        // need to and them, and this isn't done yet. But this shouldn't arise in non loinc and snomed value sets
        throw new TerminologyServiceException("Multiple filters not handled yet");
    if (inc.getFilter().size() == 1) {
        ConceptSetFilterComponent fc = inc.getFilter().get(0);
        if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.ISA) {
            // special: all non-abstract codes in the target code system under the value
            ConceptDefinitionComponent def = getConceptForCode(cs.getCodeSystem().getConcept(), fc.getValue());
            if (def == null)
                throw new TerminologyServiceException("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'");
            addCodeAndDescendents(inc.getSystem(), def);
        } else
            throw new NotImplementedException("not done yet");
    }
}
Also used : ConceptSetFilterComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptSetFilterComponent) ConceptDefinitionComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptDefinitionComponent) ValueSetExpansionParameterComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionParameterComponent) NotImplementedException(org.apache.commons.lang3.NotImplementedException) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) ValueSet(org.hl7.fhir.dstu2.model.ValueSet) ConceptReferenceComponent(org.hl7.fhir.dstu2.model.ValueSet.ConceptReferenceComponent) UriType(org.hl7.fhir.dstu2.model.UriType)

Example 100 with ValueSet

use of org.hl7.fhir.r4.model.ValueSet 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());
    }
}
Also used : ValueSetExpansionContainsComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionContainsComponent) ValueSetExpansionComponent(org.hl7.fhir.dstu2.model.ValueSet.ValueSetExpansionComponent) ValueSet(org.hl7.fhir.dstu2.model.ValueSet) NotImplementedException(org.apache.commons.lang3.NotImplementedException) IOException(java.io.IOException) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

ValueSet (org.hl7.fhir.r5.model.ValueSet)159 ValueSet (org.hl7.fhir.r4.model.ValueSet)116 Test (org.junit.jupiter.api.Test)115 ArrayList (java.util.ArrayList)101 FHIRException (org.hl7.fhir.exceptions.FHIRException)100 IOException (java.io.IOException)97 ValueSet (org.hl7.fhir.dstu3.model.ValueSet)59 ValueSet (org.hl7.fhir.r4b.model.ValueSet)59 FileNotFoundException (java.io.FileNotFoundException)58 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)56 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)46 HashMap (java.util.HashMap)45 Test (org.junit.Test)45 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)43 File (java.io.File)36 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)36 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)31 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)29 RestIntegrationTest (org.opencds.cqf.ruler.test.RestIntegrationTest)29 FileInputStream (java.io.FileInputStream)27