get control over caching for terminology testing
This commit is contained in:
parent
fafd0a8a37
commit
d60b9009b2
|
@ -322,6 +322,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
locator = other.locator;
|
||||
userAgent = other.userAgent;
|
||||
tcc.copy(other.tcc);
|
||||
cachingAllowed = other.cachingAllowed;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1050,9 +1051,9 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
codeSystemsUsed.add(code.getSystem());
|
||||
}
|
||||
|
||||
final CacheToken cacheToken = txCache != null ? txCache.generateValidationToken(options, code, vs, expParameters) : null;
|
||||
final CacheToken cacheToken = cachingAllowed && txCache != null ? txCache.generateValidationToken(options, code, vs, expParameters) : null;
|
||||
ValidationResult res = null;
|
||||
if (txCache != null) {
|
||||
if (cachingAllowed && txCache != null) {
|
||||
res = txCache.getValidation(cacheToken);
|
||||
}
|
||||
if (res != null) {
|
||||
|
@ -1072,7 +1073,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
vsc.setThrowToServer(options.isUseServer() && tcc.getClient() != null);
|
||||
if (!ValueSetUtilities.isServerSide(code.getSystem())) {
|
||||
res = vsc.validateCode(path, code);
|
||||
if (txCache != null) {
|
||||
if (txCache != null && cachingAllowed) {
|
||||
txCache.cacheValidation(cacheToken, res, TerminologyCache.TRANSIENT);
|
||||
}
|
||||
return res;
|
||||
|
@ -1107,8 +1108,8 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
if (noTerminologyServer) {
|
||||
return new ValidationResult(IssueSeverity.ERROR,formatMessage(I18nConstants.ERROR_VALIDATING_CODE_RUNNING_WITHOUT_TERMINOLOGY_SERVICES), TerminologyServiceErrorClass.NOSERVICE, issues);
|
||||
}
|
||||
String csumm = txCache != null ? txCache.summary(code) : null;
|
||||
if (txCache != null) {
|
||||
String csumm =cachingAllowed && txCache != null ? txCache.summary(code) : null;
|
||||
if (cachingAllowed && txCache != null) {
|
||||
txLog("$validate "+csumm+" for "+ txCache.summary(vs));
|
||||
} else {
|
||||
txLog("$validate "+csumm+" before cache exists");
|
||||
|
@ -1123,7 +1124,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
res.setDiagnostics("Local Error: "+localError.trim()+". Server Error: "+res.getMessage());
|
||||
}
|
||||
updateUnsupportedCodeSystems(res, code, codeKey);
|
||||
if (txCache != null) { // we never cache unsupported code systems - we always keep trying (but only once per run)
|
||||
if (cachingAllowed && txCache != null) { // we never cache unsupported code systems - we always keep trying (but only once per run)
|
||||
txCache.cacheValidation(cacheToken, res, TerminologyCache.PERMANENT);
|
||||
}
|
||||
return res;
|
||||
|
@ -1204,9 +1205,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
@Override
|
||||
public ValidationResult validateCode(ValidationOptions options, CodeableConcept code, ValueSet vs) {
|
||||
CacheToken cacheToken = txCache.generateValidationToken(options, code, vs, expParameters);
|
||||
ValidationResult res = txCache.getValidation(cacheToken);
|
||||
if (res != null) {
|
||||
return res;
|
||||
ValidationResult res = null;
|
||||
if (cachingAllowed) {
|
||||
res = txCache.getValidation(cacheToken);
|
||||
if (res != null) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
for (Coding c : code.getCoding()) {
|
||||
if (c.hasSystem()) {
|
||||
|
@ -1222,7 +1226,9 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
vsc.setUnknownSystems(unknownSystems);
|
||||
vsc.setThrowToServer(options.isUseServer() && tcc.getClient() != null);
|
||||
res = vsc.validateCode("CodeableConcept", code);
|
||||
txCache.cacheValidation(cacheToken, res, TerminologyCache.TRANSIENT);
|
||||
if (cachingAllowed) {
|
||||
txCache.cacheValidation(cacheToken, res, TerminologyCache.TRANSIENT);
|
||||
}
|
||||
return res;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -1247,7 +1253,9 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
} catch (Exception e) {
|
||||
res = new ValidationResult(IssueSeverity.ERROR, e.getMessage() == null ? e.getClass().getName() : e.getMessage(), null).setTxLink(txLog == null ? null : txLog.getLastId());
|
||||
}
|
||||
txCache.cacheValidation(cacheToken, res, TerminologyCache.PERMANENT);
|
||||
if (cachingAllowed) {
|
||||
txCache.cacheValidation(cacheToken, res, TerminologyCache.PERMANENT);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1919,6 +1927,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
|
||||
protected IWorkerContextManager.IPackageLoadingTracker packageTracker;
|
||||
private boolean forPublication;
|
||||
private boolean cachingAllowed = true;
|
||||
|
||||
@Override
|
||||
public Resource fetchResourceById(String type, String uri) {
|
||||
|
@ -2478,4 +2487,12 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
forPublication = value;
|
||||
}
|
||||
|
||||
public boolean isCachingAllowed() {
|
||||
return cachingAllowed;
|
||||
}
|
||||
|
||||
public void setCachingAllowed(boolean cachingAllowed) {
|
||||
this.cachingAllowed = cachingAllowed;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.hl7.fhir.exceptions.PathEngineException;
|
|||
import org.hl7.fhir.r5.conformance.profile.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.context.ContextUtilities;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Element;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
|
||||
|
@ -245,6 +246,13 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||
} else {
|
||||
val.setBaseOptions(val.getBaseOptions().withVersionFlexible(false));
|
||||
}
|
||||
if (content.has("no-tx")) {
|
||||
boolean notx = "true".equals(content.get("no-tx").getAsString());
|
||||
((SimpleWorkerContext) val.getContext()).setCanRunWithoutTerminology(notx);
|
||||
((SimpleWorkerContext) val.getContext()).setNoTerminologyServer(notx);
|
||||
((SimpleWorkerContext) val.getContext()).setCachingAllowed(!notx);
|
||||
|
||||
}
|
||||
if (content.has("packages")) {
|
||||
for (JsonElement e : content.getAsJsonArray("packages")) {
|
||||
String n = e.getAsString();
|
||||
|
|
|
@ -1152,3 +1152,19 @@ v: {
|
|||
"version" : "http://snomed.info/sct/900000000000207008/version/20230131"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
{"code" : {
|
||||
"code" : "kg"
|
||||
}, "url": "http://fhir.de/ValueSet/VitalSignDE_Body_Weigth_UCUM", "version": "0.9.13", "langs":"[en]", "useServer":"true", "useClient":"true", "guessSystem":"true", "valueSetMode":"ALL_CHECKS", "displayWarningMode":"false", "versionFlexible":"false", "profile": {
|
||||
"resourceType" : "Parameters",
|
||||
"parameter" : [{
|
||||
"name" : "profile-url",
|
||||
"valueString" : "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"
|
||||
}]
|
||||
}}####
|
||||
v: {
|
||||
"display" : "kilogram",
|
||||
"code" : "kg",
|
||||
"system" : "http://unitsofmeasure.org",
|
||||
"version" : "2.0.1"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
|
|
|
@ -3462,3 +3462,20 @@ v: {
|
|||
"version" : "2.74"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
{"code" : {
|
||||
"system" : "http://loinc.org",
|
||||
"code" : "29463-7"
|
||||
}, "url": "http://fhir.de/ValueSet/VitalSignDE_Body_Weight_Loinc--0", "version": "0.9.13", "langs":"[en]", "useServer":"true", "useClient":"false", "guessSystem":"false", "valueSetMode":"CHECK_MEMERSHIP_ONLY", "displayWarningMode":"false", "versionFlexible":"false", "profile": {
|
||||
"resourceType" : "Parameters",
|
||||
"parameter" : [{
|
||||
"name" : "profile-url",
|
||||
"valueString" : "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"
|
||||
}]
|
||||
}}####
|
||||
v: {
|
||||
"display" : "Body weight",
|
||||
"code" : "29463-7",
|
||||
"system" : "http://loinc.org",
|
||||
"version" : "2.74"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
|
|
|
@ -2188,3 +2188,36 @@ v: {
|
|||
"version" : "http://snomed.info/sct/900000000000207008/version/20210731"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
{"code" : {
|
||||
"system" : "http://snomed.info/sct",
|
||||
"code" : "27113001"
|
||||
}, "url": "https://fhir.kbv.de/ValueSet/KBV_VS_Base_Body_Weight_Snomed--0", "version": "1.2.1", "langs":"[en]", "useServer":"true", "useClient":"false", "guessSystem":"false", "valueSetMode":"CHECK_MEMERSHIP_ONLY", "displayWarningMode":"false", "versionFlexible":"false", "profile": {
|
||||
"resourceType" : "Parameters",
|
||||
"parameter" : [{
|
||||
"name" : "profile-url",
|
||||
"valueString" : "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"
|
||||
}]
|
||||
}}####
|
||||
v: {
|
||||
"display" : "Body weight (observable entity)",
|
||||
"code" : "27113001",
|
||||
"system" : "http://snomed.info/sct",
|
||||
"version" : "http://snomed.info/sct/900000000000207008/version/20210731"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
{"code" : {
|
||||
"system" : "http://snomed.info/sct",
|
||||
"code" : "27113001"
|
||||
}, "url": "https://fhir.kbv.de/ValueSet/KBV_VS_Base_Body_Weight_Snomed--1", "version": "1.2.1", "langs":"[en]", "useServer":"true", "useClient":"false", "guessSystem":"false", "valueSetMode":"CHECK_MEMERSHIP_ONLY", "displayWarningMode":"false", "versionFlexible":"false", "profile": {
|
||||
"resourceType" : "Parameters",
|
||||
"parameter" : [{
|
||||
"name" : "profile-url",
|
||||
"valueString" : "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"
|
||||
}]
|
||||
}}####
|
||||
v: {
|
||||
"severity" : "error",
|
||||
"error" : "The provided code http://snomed.info/sct#27113001 is not in the value set 'https://fhir.kbv.de/ValueSet/KBV_VS_Base_Body_Weight_Snomed--1|1.2.1' (from Tx-Server)",
|
||||
"class" : "UNKNOWN"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
|
|
|
@ -436,3 +436,20 @@ v: {
|
|||
"class" : "UNKNOWN"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
{"code" : {
|
||||
"system" : "http://unitsofmeasure.org",
|
||||
"code" : "kg"
|
||||
}, "url": "http://fhir.de/ValueSet/UcumVitalsCommonDE--0", "version": "0.9.13", "langs":"[en]", "useServer":"true", "useClient":"false", "guessSystem":"false", "valueSetMode":"CHECK_MEMERSHIP_ONLY", "displayWarningMode":"false", "versionFlexible":"false", "profile": {
|
||||
"resourceType" : "Parameters",
|
||||
"parameter" : [{
|
||||
"name" : "profile-url",
|
||||
"valueString" : "http://hl7.org/fhir/ExpansionProfile/dc8fd4bc-091a-424a-8a3b-6198ef146891"
|
||||
}]
|
||||
}}####
|
||||
v: {
|
||||
"display" : "kilogram",
|
||||
"code" : "kg",
|
||||
"system" : "http://unitsofmeasure.org",
|
||||
"version" : "2.0.1"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue