Merge pull request #146 from hapifhir/ja_20200302_use_validationoptions

Use ValidationOptions instead of TerminologyServiceOptions
This commit is contained in:
Grahame Grieve 2020-03-03 08:41:15 +11:00 committed by GitHub
commit c923cba4e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 33 additions and 29 deletions

View File

@ -45,17 +45,21 @@ import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
import org.hl7.fhir.r4.terminologies.ValueSetExpanderSimple;
import org.hl7.fhir.r4.utils.ToolingExtensions;
import org.hl7.fhir.utilities.OIDUtils;
import org.hl7.fhir.utilities.TerminologyServiceOptions;
import org.hl7.fhir.utilities.TranslationServices;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.utilities.validation.ValidationOptions;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.*;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public abstract class BaseWorkerContext implements IWorkerContext {
@ -438,25 +442,25 @@ public abstract class BaseWorkerContext implements IWorkerContext {
// --- validate code -------------------------------------------------------------------------------
@Override
public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display) {
public ValidationResult validateCode(ValidationOptions options, String system, String code, String display) {
Coding c = new Coding(system, code, display);
return validateCode(options, c, null);
}
@Override
public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display, ValueSet vs) {
public ValidationResult validateCode(ValidationOptions options, String system, String code, String display, ValueSet vs) {
Coding c = new Coding(system, code, display);
return validateCode(options, c, vs);
}
@Override
public ValidationResult validateCode(TerminologyServiceOptions options, String code, ValueSet vs) {
public ValidationResult validateCode(ValidationOptions options, String code, ValueSet vs) {
Coding c = new Coding(null, code, null);
return doValidateCode(options, c, vs, true);
}
@Override
public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display, ConceptSetComponent vsi) {
public ValidationResult validateCode(ValidationOptions options, String system, String code, String display, ConceptSetComponent vsi) {
Coding c = new Coding(system, code, display);
ValueSet vs = new ValueSet();
vs.setUrl(Utilities.makeUuidUrn());
@ -465,11 +469,11 @@ public abstract class BaseWorkerContext implements IWorkerContext {
}
@Override
public ValidationResult validateCode(TerminologyServiceOptions options, Coding code, ValueSet vs) {
public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs) {
return doValidateCode(options, code, vs, false);
}
public ValidationResult doValidateCode(TerminologyServiceOptions options, Coding code, ValueSet vs, boolean implySystem) {
public ValidationResult doValidateCode(ValidationOptions options, Coding code, ValueSet vs, boolean implySystem) {
CacheToken cacheToken = txCache != null ? txCache.generateValidationToken(options, code, vs) : null;
ValidationResult res = null;
if (txCache != null)
@ -511,7 +515,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
return res;
}
private void setTerminologyOptions(TerminologyServiceOptions options, Parameters pIn) {
private void setTerminologyOptions(ValidationOptions options, Parameters pIn) {
if (options != null) {
if (!Utilities.noString(options.getLanguage()))
pIn.addParameter("displayLanguage", options.getLanguage());
@ -519,7 +523,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
}
@Override
public ValidationResult validateCode(TerminologyServiceOptions options, CodeableConcept code, ValueSet vs) {
public ValidationResult validateCode(ValidationOptions options, CodeableConcept code, ValueSet vs) {
CacheToken cacheToken = txCache.generateValidationToken(options, code, vs);
ValidationResult res = txCache.getValidation(cacheToken);
if (res != null)

View File

@ -51,6 +51,7 @@ import org.hl7.fhir.r4.utils.IResourceValidator;
import org.hl7.fhir.utilities.TerminologyServiceOptions;
import org.hl7.fhir.utilities.TranslationServices;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.utilities.validation.ValidationOptions;
/**
@ -376,7 +377,7 @@ public interface IWorkerContext {
* @param display
* @return
*/
public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display);
public ValidationResult validateCode(ValidationOptions options, String system, String code, String display);
/**
* Validation of a code - consult the terminology service
@ -392,10 +393,10 @@ public interface IWorkerContext {
* @param display
* @return
*/
public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display, ValueSet vs);
public ValidationResult validateCode(TerminologyServiceOptions options, String code, ValueSet vs);
public ValidationResult validateCode(TerminologyServiceOptions options, Coding code, ValueSet vs);
public ValidationResult validateCode(TerminologyServiceOptions options, CodeableConcept code, ValueSet vs);
public ValidationResult validateCode(ValidationOptions options, String system, String code, String display, ValueSet vs);
public ValidationResult validateCode(ValidationOptions options, String code, ValueSet vs);
public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs);
public ValidationResult validateCode(ValidationOptions options, CodeableConcept code, ValueSet vs);
/**
* Validation of a code - consult the terminology service
@ -411,7 +412,7 @@ public interface IWorkerContext {
* @param display
* @return
*/
public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display, ConceptSetComponent vsi);
public ValidationResult validateCode(ValidationOptions options, String system, String code, String display, ConceptSetComponent vsi);
/**
* returns the recommended tla for the type

View File

@ -46,7 +46,6 @@ import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.r4.terminologies.ValueSetExpander.TerminologyServiceErrorClass;
import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.TerminologyServiceOptions;
import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
@ -55,6 +54,7 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonNull;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import org.hl7.fhir.utilities.validation.ValidationOptions;
/**
* This implements a two level cache.
@ -112,7 +112,7 @@ public class TerminologyCache {
load();
}
public CacheToken generateValidationToken(TerminologyServiceOptions options, Coding code, ValueSet vs) {
public CacheToken generateValidationToken(ValidationOptions options, Coding code, ValueSet vs) {
CacheToken ct = new CacheToken();
if (code.hasSystem())
ct.name = getNameForSystem(code.getSystem());
@ -130,7 +130,7 @@ public class TerminologyCache {
return ct;
}
public CacheToken generateValidationToken(TerminologyServiceOptions options, CodeableConcept code, ValueSet vs) {
public CacheToken generateValidationToken(ValidationOptions options, CodeableConcept code, ValueSet vs) {
CacheToken ct = new CacheToken();
for (Coding c : code.getCoding()) {
if (c.hasSystem())

View File

@ -30,8 +30,8 @@ import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent;
import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent;
import org.hl7.fhir.r4.model.ValueSet.*;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.TerminologyServiceOptions;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.utilities.validation.ValidationOptions;
import java.util.ArrayList;
import java.util.HashMap;
@ -43,9 +43,9 @@ public class ValueSetCheckerSimple implements ValueSetChecker {
private ValueSet valueset;
private IWorkerContext context;
private Map<String, ValueSetCheckerSimple> inner = new HashMap<>();
private TerminologyServiceOptions options;
private ValidationOptions options;
public ValueSetCheckerSimple(TerminologyServiceOptions options, ValueSet source, IWorkerContext context) {
public ValueSetCheckerSimple(ValidationOptions options, ValueSet source, IWorkerContext context) {
this.valueset = source;
this.context = context;
this.options = options;

View File

@ -83,7 +83,6 @@ import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple;
import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.r5.utils.client.ToolingClientLogger;
import org.hl7.fhir.utilities.OIDUtils;
import org.hl7.fhir.utilities.TerminologyServiceOptions;
import org.hl7.fhir.utilities.TranslationServices;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities;

View File

@ -51,7 +51,6 @@ import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorCla
import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
import org.hl7.fhir.r5.utils.INarrativeGenerator;
import org.hl7.fhir.r5.utils.IResourceValidator;
import org.hl7.fhir.utilities.TerminologyServiceOptions;
import org.hl7.fhir.utilities.TranslationServices;
import org.hl7.fhir.utilities.validation.ValidationOptions;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;

View File

@ -45,7 +45,6 @@ import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent;
import org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent;
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
import org.hl7.fhir.utilities.TerminologyServiceOptions;
import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.validation.ValidationOptions;
import org.hl7.fhir.utilities.validation.ValidationOptions.ValueSetMode;

View File

@ -171,7 +171,8 @@ public class BaseValidator {
*/
protected boolean hint(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg) {
if (!thePass) {
addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.INFORMATION);
String message = formatMessage(msg);
addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION);
}
return thePass;
}

View File

@ -2018,7 +2018,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
long t = System.nanoTime();
ValidationResult vr = null;
if (binding.getStrength() != BindingStrength.EXAMPLE) {
vr = context.validateCode(new ValidationOptions(stack.workingLang), value, vs);
ValidationOptions options = new ValidationOptions(stack.workingLang).guessSystem();
vr = context.validateCode(options, value, vs);
}
txTime = txTime + (System.nanoTime() - t);
if (vr != null && !vr.isOk()) {