more work on versioned API
This commit is contained in:
parent
f2dc77272b
commit
9f8eeed5f6
|
@ -4,7 +4,7 @@ import org.hl7.fhir.utilities.FhirPublication;
|
|||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||
|
||||
public class CacheTestUtils {
|
||||
public static final ValidationOptions validationOptions = new ValidationOptions(FhirPublication.R4).withGuessSystem()
|
||||
public static final ValidationOptions validationOptions = new ValidationOptions(FhirPublication.R4, null).withGuessSystem()
|
||||
.withVersionFlexible(false);
|
||||
|
||||
}
|
||||
|
|
|
@ -767,11 +767,11 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
|
||||
|
||||
public boolean supportsSystem(String system, FhirPublication fhirVersion) throws TerminologyServiceException {
|
||||
return supportsSystem(system);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsSystem(String system) throws TerminologyServiceException {
|
||||
// return supportsSystem(system);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean supportsSystem(String system) throws TerminologyServiceException {
|
||||
synchronized (lock) {
|
||||
if (codeSystems.has(system) && codeSystems.get(system).getContent() != CodeSystemContentMode.NOTPRESENT) {
|
||||
return true;
|
||||
|
@ -945,7 +945,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
List<String> allErrors = new ArrayList<>();
|
||||
|
||||
// ok, first we try to expand locally
|
||||
ValueSetExpander vse = constructValueSetExpanderSimple();
|
||||
ValueSetExpander vse = constructValueSetExpanderSimple(new ValidationOptions(vs.getFHIRPublicationVersion()));
|
||||
res = null;
|
||||
try {
|
||||
res = vse.expand(vs, p);
|
||||
|
@ -1357,16 +1357,16 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
return res;
|
||||
}
|
||||
|
||||
protected ValueSetExpander constructValueSetExpanderSimple() {
|
||||
return new ValueSetExpander(this, new TerminologyOperationContext(this));
|
||||
protected ValueSetExpander constructValueSetExpanderSimple(ValidationOptions options) {
|
||||
return new ValueSetExpander(this, new TerminologyOperationContext(this, options));
|
||||
}
|
||||
|
||||
protected ValueSetValidator constructValueSetCheckerSimple( ValidationOptions options, ValueSet vs, ValidationContextCarrier ctxt) {
|
||||
return new ValueSetValidator(this, new TerminologyOperationContext(this), options, vs, ctxt, expParameters, tcc.getTxcaps());
|
||||
protected ValueSetValidator constructValueSetCheckerSimple(ValidationOptions options, ValueSet vs, ValidationContextCarrier ctxt) {
|
||||
return new ValueSetValidator(this, new TerminologyOperationContext(this, options), options, vs, ctxt, expParameters, tcc.getTxcaps());
|
||||
}
|
||||
|
||||
protected ValueSetValidator constructValueSetCheckerSimple( ValidationOptions options, ValueSet vs) {
|
||||
return new ValueSetValidator(this, new TerminologyOperationContext(this), options, vs, expParameters, tcc.getTxcaps());
|
||||
return new ValueSetValidator(this, new TerminologyOperationContext(this, options), options, vs, expParameters, tcc.getTxcaps());
|
||||
}
|
||||
|
||||
protected Parameters constructParameters(ValueSet vs, boolean hierarchical) {
|
||||
|
|
|
@ -129,6 +129,7 @@ import org.hl7.fhir.utilities.Utilities;
|
|||
import org.hl7.fhir.utilities.i18n.AcceptLanguageHeader;
|
||||
import org.hl7.fhir.utilities.i18n.AcceptLanguageHeader.LanguagePreference;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||
|
||||
public class ValueSetExpander extends ValueSetProcessBase {
|
||||
|
||||
|
@ -540,7 +541,7 @@ public class ValueSetExpander extends ValueSetProcessBase {
|
|||
// importValueSet(imp.getValue(), params, expParams);
|
||||
|
||||
CodeSystem cs = context.fetchSupplementedCodeSystem(exc.getSystem());
|
||||
if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(exc.getSystem())) {
|
||||
if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(exc.getSystem(), opContext.getOptions().getFhirVersion())) {
|
||||
ValueSetExpansionOutcome vse = context.expandVS(exc, false, false);
|
||||
ValueSet valueset = vse.getValueset();
|
||||
if (valueset == null)
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.hl7.fhir.r5.context.IWorkerContext;
|
|||
import org.hl7.fhir.r5.model.OperationOutcome.IssueType;
|
||||
import org.hl7.fhir.r5.terminologies.utilities.TerminologyOperationContext.TerminologyServiceProtectionException;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
@ -40,11 +41,13 @@ public class TerminologyOperationContext {
|
|||
private List<String> contexts = new ArrayList<>();
|
||||
private IWorkerContext worker;
|
||||
private boolean original;
|
||||
private ValidationOptions options;
|
||||
|
||||
public TerminologyOperationContext(IWorkerContext worker) {
|
||||
public TerminologyOperationContext(IWorkerContext worker, ValidationOptions options) {
|
||||
super();
|
||||
this.worker = worker;
|
||||
this.original = true;
|
||||
this.options = options;
|
||||
|
||||
if (EXPANSION_DEAD_TIME_SECS == 0 || debugging) {
|
||||
deadTime = 0;
|
||||
|
@ -53,12 +56,13 @@ public class TerminologyOperationContext {
|
|||
}
|
||||
}
|
||||
|
||||
private TerminologyOperationContext() {
|
||||
private TerminologyOperationContext(ValidationOptions options) {
|
||||
super();
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public TerminologyOperationContext copy() {
|
||||
TerminologyOperationContext ret = new TerminologyOperationContext();
|
||||
TerminologyOperationContext ret = new TerminologyOperationContext(this.options);
|
||||
ret.worker = worker;
|
||||
ret.contexts.addAll(contexts);
|
||||
ret.deadTime = deadTime;
|
||||
|
@ -82,5 +86,9 @@ public class TerminologyOperationContext {
|
|||
return original;
|
||||
}
|
||||
|
||||
public ValidationOptions getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -346,7 +346,7 @@ public class SimpleWorkerContextTests {
|
|||
Mockito.doReturn(expectedExpansionResult).when(valueSetExpanderSimple).expand(eq(vs),
|
||||
argThat(new ParametersMatcher(pInWithDependentResources)));
|
||||
|
||||
Mockito.doReturn(valueSetExpanderSimple).when(context).constructValueSetExpanderSimple();
|
||||
Mockito.doReturn(valueSetExpanderSimple).when(context).constructValueSetExpanderSimple(null);
|
||||
|
||||
ValueSetExpansionOutcome actualExpansionResult = context.expandVS(vs, true, true, true, pIn);
|
||||
|
||||
|
@ -373,7 +373,7 @@ public class SimpleWorkerContextTests {
|
|||
Mockito.doReturn(expectedExpansionResult).when(valueSetExpanderSimple).expand(eq(vs),
|
||||
argThat(new ParametersMatcher(pInWithDependentResources)));
|
||||
|
||||
Mockito.doReturn(valueSetExpanderSimple).when(context).constructValueSetExpanderSimple();
|
||||
Mockito.doReturn(valueSetExpanderSimple).when(context).constructValueSetExpanderSimple(null);
|
||||
|
||||
Mockito.doReturn(expectedValueSet).when(terminologyClient).expandValueset(eq(vs), argThat(new ParametersMatcher(pInWithDependentResources)), eq(params));
|
||||
|
||||
|
|
|
@ -1120,7 +1120,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
// public API
|
||||
private boolean checkCode(List<ValidationMessage> errors, Element element, String path, String code, String system, String version, String display, boolean checkDisplay, NodeStack stack) throws TerminologyServiceException {
|
||||
long t = System.nanoTime();
|
||||
boolean ss = context.supportsSystem(system);
|
||||
boolean ss = context.supportsSystem(system, baseOptions.getFhirVersion());
|
||||
timeTracker.tx(t, "ss "+system);
|
||||
if (ss) {
|
||||
t = System.nanoTime();
|
||||
|
@ -1382,7 +1382,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
boolean atLeastOneSystemIsSupported = false;
|
||||
for (Coding nextCoding : cc.getCoding()) {
|
||||
String nextSystem = nextCoding.getSystem();
|
||||
if (isNotBlank(nextSystem) && context.supportsSystem(nextSystem)) {
|
||||
if (isNotBlank(nextSystem) && context.supportsSystem(nextSystem, baseOptions.getFhirVersion())) {
|
||||
atLeastOneSystemIsSupported = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1474,7 +1474,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
|
||||
public boolean checkBindings(List<ValidationMessage> errors, String path, Element element, NodeStack stack, ValueSet valueset, Coding nextCoding) {
|
||||
boolean ok = true;
|
||||
if (isNotBlank(nextCoding.getCode()) && isNotBlank(nextCoding.getSystem()) && context.supportsSystem(nextCoding.getSystem())) {
|
||||
if (isNotBlank(nextCoding.getCode()) && isNotBlank(nextCoding.getSystem()) && context.supportsSystem(nextCoding.getSystem(), baseOptions.getFhirVersion())) {
|
||||
ValidationResult vr = checkCodeOnServer(stack, valueset, nextCoding, false);
|
||||
if (vr != null && vr.isOk()) {
|
||||
for (OperationOutcomeIssueComponent iss : vr.getIssues()) {
|
||||
|
@ -1535,7 +1535,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
boolean atLeastOneSystemIsSupported = false;
|
||||
for (Coding nextCoding : cc.getCoding()) {
|
||||
String nextSystem = nextCoding.getSystem();
|
||||
if (isNotBlank(nextSystem) && context.supportsSystem(nextSystem)) {
|
||||
if (isNotBlank(nextSystem) && context.supportsSystem(nextSystem, baseOptions.getFhirVersion())) {
|
||||
atLeastOneSystemIsSupported = true;
|
||||
break;
|
||||
}
|
||||
|
@ -1596,7 +1596,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
String nextCode = nextCoding.getCode();
|
||||
String nextSystem = nextCoding.getSystem();
|
||||
String nextVersion = nextCoding.getVersion();
|
||||
if (isNotBlank(nextCode) && isNotBlank(nextSystem) && context.supportsSystem(nextSystem)) {
|
||||
if (isNotBlank(nextCode) && isNotBlank(nextSystem) && context.supportsSystem(nextSystem, baseOptions.getFhirVersion())) {
|
||||
ValidationResult vr = checkCodeOnServer(stack, nextCode, nextSystem, nextVersion, null, false);
|
||||
if (vr != null && vr.isOk()) {
|
||||
for (OperationOutcomeIssueComponent iss : vr.getIssues()) {
|
||||
|
|
|
@ -69,7 +69,7 @@ public class CodeSystemValidator extends BaseValidator {
|
|||
} // todo... try getting the value set the other way...
|
||||
|
||||
if (supp != null) {
|
||||
if (context.supportsSystem(supp)) {
|
||||
if (context.supportsSystem(supp, options.getFhirVersion())) {
|
||||
List<Element> concepts = cs.getChildrenByName("concept");
|
||||
int ce = 0;
|
||||
for (Element concept : concepts) {
|
||||
|
|
Loading…
Reference in New Issue