Search in sources :

Example 6 with ValidationResult

use of org.hl7.fhir.r4b.context.IWorkerContext.ValidationResult in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method handleByCache.

private ValidationResult handleByCache(ValueSet vs, CodeableConcept concept, boolean tryCache) {
    String cacheId = cacheId(concept);
    Map<String, ValidationResult> cache = validationCache.get(vs.getUrl());
    if (cache == null) {
        cache = new HashMap<String, IWorkerContext.ValidationResult>();
        validationCache.put(vs.getUrl(), cache);
    }
    if (cache.containsKey(cacheId))
        return cache.get(cacheId);
    if (validationCache.containsKey(vs.getUrl()) && validationCache.get(vs.getUrl()).containsKey(cacheId))
        return validationCache.get(vs.getUrl()).get(cacheId);
    if (!tryCache)
        return null;
    if (!cacheValidation)
        return null;
    if (failed.contains(vs.getUrl()))
        return null;
    ValueSetExpansionOutcome vse = expandVS(vs, true);
    if (vse.getValueset() == null || notcomplete(vse.getValueset())) {
        failed.add(vs.getUrl());
        return null;
    }
    ValidationResult res = validateCode(concept, vse.getValueset());
    cache.put(cacheId, res);
    return res;
}
Also used : ValueSetExpansionOutcome(org.hl7.fhir.dstu2016may.terminologies.ValueSetExpander.ValueSetExpansionOutcome)

Example 7 with ValidationResult

use of org.hl7.fhir.r4b.context.IWorkerContext.ValidationResult in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method handleByCache.

private ValidationResult handleByCache(ValueSet vs, Coding coding, boolean tryCache) {
    String cacheId = cacheId(coding);
    Map<String, ValidationResult> cache = validationCache.get(vs.getUrl());
    if (cache == null) {
        cache = new HashMap<String, IWorkerContext.ValidationResult>();
        validationCache.put(vs.getUrl(), cache);
    }
    if (cache.containsKey(cacheId))
        return cache.get(cacheId);
    if (!tryCache)
        return null;
    if (!cacheValidation)
        return null;
    if (failed.contains(vs.getUrl()))
        return null;
    ValueSetExpansionOutcome vse = expandVS(vs, true);
    if (vse.getValueset() == null || notcomplete(vse.getValueset())) {
        failed.add(vs.getUrl());
        return null;
    }
    ValidationResult res = validateCode(coding, vse.getValueset());
    cache.put(cacheId, res);
    return res;
}
Also used : ValueSetExpansionOutcome(org.hl7.fhir.dstu2016may.terminologies.ValueSetExpander.ValueSetExpansionOutcome)

Example 8 with ValidationResult

use of org.hl7.fhir.r4b.context.IWorkerContext.ValidationResult in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method verifyCodeExternal.

private ValidationResult verifyCodeExternal(ValueSet vs, CodeableConcept cc, boolean tryCache) throws Exception {
    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, false);
    Map<String, ValidationResult> cache = validationCache.get(vs.getUrl());
    cache.put(cacheId(cc), res);
    return res;
}
Also used : Parameters(org.hl7.fhir.dstu3.model.Parameters)

Example 9 with ValidationResult

use of org.hl7.fhir.r4b.context.IWorkerContext.ValidationResult in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method handleByCache.

private ValidationResult handleByCache(ValueSet vs, CodeableConcept concept, boolean tryCache) {
    String cacheId = cacheId(concept);
    Map<String, ValidationResult> cache = validationCache.get(vs.getUrl());
    if (cache == null) {
        cache = new HashMap<String, IWorkerContext.ValidationResult>();
        validationCache.put(vs.getUrl(), cache);
    }
    if (cache.containsKey(cacheId)) {
        return cache.get(cacheId);
    }
    if (validationCache.containsKey(vs.getUrl()) && validationCache.get(vs.getUrl()).containsKey(cacheId)) {
        return validationCache.get(vs.getUrl()).get(cacheId);
    }
    if (!tryCache) {
        return null;
    }
    if (!cacheValidation) {
        return null;
    }
    if (failed.contains(vs.getUrl())) {
        return null;
    }
    ValueSetExpansionOutcome vse = expandVS(vs, true, false);
    if (vse.getValueset() == null || notcomplete(vse.getValueset())) {
        failed.add(vs.getUrl());
        return null;
    }
    ValidationResult res = validateCode(concept, vse.getValueset());
    cache.put(cacheId, res);
    return res;
}
Also used : ValueSetExpansionOutcome(org.hl7.fhir.dstu3.terminologies.ValueSetExpander.ValueSetExpansionOutcome)

Example 10 with ValidationResult

use of org.hl7.fhir.r4b.context.IWorkerContext.ValidationResult in project org.hl7.fhir.core by hapifhir.

the class BaseWorkerContext method handleByCache.

private ValidationResult handleByCache(ValueSet vs, Coding coding, boolean tryCache) {
    String cacheId = cacheId(coding);
    Map<String, ValidationResult> cache = validationCache.get(vs.getUrl());
    if (cache == null) {
        cache = new HashMap<String, IWorkerContext.ValidationResult>();
        validationCache.put(vs.getUrl(), cache);
    }
    if (cache.containsKey(cacheId)) {
        return cache.get(cacheId);
    }
    if (!tryCache) {
        return null;
    }
    if (!cacheValidation) {
        return null;
    }
    if (failed.contains(vs.getUrl())) {
        return null;
    }
    ValueSetExpansionOutcome vse = expandVS(vs, true, false);
    if (vse.getValueset() == null || notcomplete(vse.getValueset())) {
        failed.add(vs.getUrl());
        return null;
    }
    ValidationResult res = validateCode(coding, vse.getValueset());
    cache.put(cacheId, res);
    return res;
}
Also used : ValueSetExpansionOutcome(org.hl7.fhir.dstu3.terminologies.ValueSetExpander.ValueSetExpansionOutcome)

Aggregations

FHIRException (org.hl7.fhir.exceptions.FHIRException)32 IOException (java.io.IOException)22 ValidationResult (org.hl7.fhir.r5.context.IWorkerContext.ValidationResult)20 TerminologyServiceException (org.hl7.fhir.exceptions.TerminologyServiceException)17 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)15 FileNotFoundException (java.io.FileNotFoundException)14 ValidationResult (ca.uhn.fhir.validation.ValidationResult)12 CodeSystem (org.hl7.fhir.r5.model.CodeSystem)12 ConceptDefinitionComponent (org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent)11 ValueSet (org.hl7.fhir.r5.model.ValueSet)11 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)11 NoTerminologyServiceException (org.hl7.fhir.exceptions.NoTerminologyServiceException)10 ValidationResult (org.hl7.fhir.r4b.context.IWorkerContext.ValidationResult)10 ArrayList (java.util.ArrayList)9 Coding (org.hl7.fhir.r5.model.Coding)9 NotImplementedException (org.apache.commons.lang3.NotImplementedException)7 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)7 ValidationResult (org.hl7.fhir.r4.context.IWorkerContext.ValidationResult)7 ConceptDefinitionComponent (org.hl7.fhir.r4b.model.CodeSystem.ConceptDefinitionComponent)7 FHIRLexerException (org.hl7.fhir.r5.utils.FHIRLexer.FHIRLexerException)7