use of org.hl7.fhir.r5.context.IWorkerContext.ValidationResult 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());
}
}
use of org.hl7.fhir.r5.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) {
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;
}
use of org.hl7.fhir.r5.context.IWorkerContext.ValidationResult 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;
}
use of org.hl7.fhir.r5.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;
}
use of org.hl7.fhir.r5.context.IWorkerContext.ValidationResult 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