Search in sources :

Example 6 with ValueSetComposeComponent

use of org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent 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 7 with ValueSetComposeComponent

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

the class ValueSet method setProperty.

@Override
public void setProperty(String name, Base value) throws FHIRException {
    if (name.equals("url"))
        // UriType
        this.url = castToUri(value);
    else if (name.equals("identifier"))
        // Identifier
        this.identifier = castToIdentifier(value);
    else if (name.equals("version"))
        // StringType
        this.version = castToString(value);
    else if (name.equals("name"))
        // StringType
        this.name = castToString(value);
    else if (name.equals("status"))
        // Enumeration<ConformanceResourceStatus>
        this.status = new ConformanceResourceStatusEnumFactory().fromType(value);
    else if (name.equals("experimental"))
        // BooleanType
        this.experimental = castToBoolean(value);
    else if (name.equals("publisher"))
        // StringType
        this.publisher = castToString(value);
    else if (name.equals("contact"))
        this.getContact().add((ValueSetContactComponent) value);
    else if (name.equals("date"))
        // DateTimeType
        this.date = castToDateTime(value);
    else if (name.equals("lockedDate"))
        // DateType
        this.lockedDate = castToDate(value);
    else if (name.equals("description"))
        // StringType
        this.description = castToString(value);
    else if (name.equals("useContext"))
        this.getUseContext().add(castToCodeableConcept(value));
    else if (name.equals("immutable"))
        // BooleanType
        this.immutable = castToBoolean(value);
    else if (name.equals("requirements"))
        // StringType
        this.requirements = castToString(value);
    else if (name.equals("copyright"))
        // StringType
        this.copyright = castToString(value);
    else if (name.equals("extensible"))
        // BooleanType
        this.extensible = castToBoolean(value);
    else if (name.equals("compose"))
        // ValueSetComposeComponent
        this.compose = (ValueSetComposeComponent) value;
    else if (name.equals("expansion"))
        // ValueSetExpansionComponent
        this.expansion = (ValueSetExpansionComponent) value;
    else
        super.setProperty(name, value);
}
Also used : ConformanceResourceStatusEnumFactory(org.hl7.fhir.dstu2016may.model.Enumerations.ConformanceResourceStatusEnumFactory)

Example 8 with ValueSetComposeComponent

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

the class BaseWorkerContext method expandVS.

@Override
public ValueSetExpansionComponent expandVS(ConceptSetComponent inc, boolean heirachical) throws TerminologyServiceException {
    ValueSet vs = new ValueSet();
    vs.setCompose(new ValueSetComposeComponent());
    vs.getCompose().getInclude().add(inc);
    ValueSetExpansionOutcome vse = expandVS(vs, true, heirachical);
    ValueSet valueset = vse.getValueset();
    if (valueset == null) {
        throw new TerminologyServiceException("Error Expanding ValueSet: " + vse.getError());
    }
    return valueset.getExpansion();
}
Also used : ValueSetExpansionOutcome(org.hl7.fhir.dstu3.terminologies.ValueSetExpander.ValueSetExpansionOutcome) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) NoTerminologyServiceException(org.hl7.fhir.exceptions.NoTerminologyServiceException) ValueSet(org.hl7.fhir.dstu3.model.ValueSet) ValueSetComposeComponent(org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent)

Example 9 with ValueSetComposeComponent

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

the class BaseWorkerContext method expandVS.

@Override
public ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical) throws TerminologyServiceException {
    ValueSet vs = new ValueSet();
    vs.setStatus(PublicationStatus.ACTIVE);
    vs.setCompose(new ValueSetComposeComponent());
    vs.getCompose().getInclude().add(inc);
    CacheToken cacheToken = txCache.generateExpandToken(vs, hierarchical);
    ValueSetExpansionOutcome res;
    res = txCache.getExpansion(cacheToken);
    if (res != null) {
        return res;
    }
    Parameters p = expParameters.copy();
    p.setParameter("includeDefinition", false);
    p.setParameter("excludeNested", !hierarchical);
    boolean cached = addDependentResources(p, vs);
    if (cached) {
        p.addParameter().setName("cache-id").setValue(new StringType(cacheId));
    }
    for (ConceptSetComponent incl : vs.getCompose().getInclude()) {
        codeSystemsUsed.add(incl.getSystem());
    }
    for (ConceptSetComponent incl : vs.getCompose().getExclude()) {
        codeSystemsUsed.add(incl.getSystem());
    }
    if (noTerminologyServer) {
        return new ValueSetExpansionOutcome(formatMessage(I18nConstants.ERROR_EXPANDING_VALUESET_RUNNING_WITHOUT_TERMINOLOGY_SERVICES), TerminologyServiceErrorClass.NOSERVICE);
    }
    Map<String, String> params = new HashMap<String, String>();
    params.put("_limit", Integer.toString(expandCodesLimit));
    params.put("_incomplete", "true");
    tlog("$expand on " + txCache.summary(vs));
    try {
        ValueSet result = txClient.expandValueset(vs, p, params);
        res = new ValueSetExpansionOutcome(result).setTxLink(txLog.getLastId());
    } catch (Exception e) {
        res = new ValueSetExpansionOutcome(e.getMessage() == null ? e.getClass().getName() : e.getMessage(), TerminologyServiceErrorClass.UNKNOWN);
        if (txLog != null) {
            res.setTxLink(txLog.getLastId());
        }
    }
    txCache.cacheExpansion(cacheToken, res, TerminologyCache.PERMANENT);
    return res;
}
Also used : ConceptSetComponent(org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent) Parameters(org.hl7.fhir.r4b.model.Parameters) StringType(org.hl7.fhir.r4b.model.StringType) HashMap(java.util.HashMap) CacheToken(org.hl7.fhir.r4b.context.TerminologyCache.CacheToken) ValueSetExpansionOutcome(org.hl7.fhir.r4b.terminologies.ValueSetExpander.ValueSetExpansionOutcome) ValueSet(org.hl7.fhir.r4b.model.ValueSet) ValueSetComposeComponent(org.hl7.fhir.r4b.model.ValueSet.ValueSetComposeComponent) TerminologyServiceException(org.hl7.fhir.exceptions.TerminologyServiceException) FileNotFoundException(java.io.FileNotFoundException) NoTerminologyServiceException(org.hl7.fhir.exceptions.NoTerminologyServiceException) DefinitionException(org.hl7.fhir.exceptions.DefinitionException) IOException(java.io.IOException) FHIRException(org.hl7.fhir.exceptions.FHIRException)

Example 10 with ValueSetComposeComponent

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

the class ValueSetExpanderSimple method handleCompose.

private void handleCompose(ValueSetComposeComponent compose, ValueSetExpansionComponent exp, Parameters expParams, String ctxt, List<Extension> extensions, ValueSet valueSet) throws ETooCostly, FileNotFoundException, IOException, FHIRException {
    compose.checkNoModifiers("ValueSet.compose", "expanding");
    // Exclude comes first because we build up a map of things to exclude
    for (ConceptSetComponent inc : compose.getExclude()) excludeCodes(inc, exp.getParameter(), ctxt);
    canBeHeirarchy = !expParams.getParameterBool("excludeNested") && excludeKeys.isEmpty() && excludeSystems.isEmpty();
    includeAbstract = !expParams.getParameterBool("excludeNotForUI");
    boolean first = true;
    for (ConceptSetComponent inc : compose.getInclude()) {
        if (first == true)
            first = false;
        else
            canBeHeirarchy = false;
        includeCodes(inc, exp, expParams, canBeHeirarchy, compose.hasInactive() && !compose.getInactive(), extensions, valueSet);
    }
}
Also used : ConceptSetComponent(org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent)

Aggregations

ConceptSetComponent (org.hl7.fhir.r4.model.ValueSet.ConceptSetComponent)9 ArrayList (java.util.ArrayList)8 ValueSetComposeComponent (org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent)8 ValueSetComposeComponent (org.hl7.fhir.r4.model.ValueSet.ValueSetComposeComponent)7 ValueSetComposeComponent (org.hl7.fhir.dstu3.model.ValueSet.ValueSetComposeComponent)6 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)6 CodeType (org.hl7.fhir.r5.model.CodeType)6 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)5 HashMap (java.util.HashMap)4 ConceptReferenceComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptReferenceComponent)4 ConceptSetComponent (org.hl7.fhir.dstu3.model.ValueSet.ConceptSetComponent)4 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)4 ConceptReferenceComponent (org.hl7.fhir.r4.model.ValueSet.ConceptReferenceComponent)4 ConceptSetComponent (org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent)4 FileNotFoundException (java.io.FileNotFoundException)3 IOException (java.io.IOException)3 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)3 FHIRException (org.hl7.fhir.exceptions.FHIRException)3 NoTerminologyServiceException (org.hl7.fhir.exceptions.NoTerminologyServiceException)3 ConceptSetComponent (org.hl7.fhir.r4b.model.ValueSet.ConceptSetComponent)3