Merge branch 'master' of https://github.com/hapifhir/org.hl7.fhir.core
This commit is contained in:
commit
690f983177
|
@ -45,17 +45,21 @@ import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||||
import org.hl7.fhir.r4.terminologies.ValueSetExpanderSimple;
|
import org.hl7.fhir.r4.terminologies.ValueSetExpanderSimple;
|
||||||
import org.hl7.fhir.r4.utils.ToolingExtensions;
|
import org.hl7.fhir.r4.utils.ToolingExtensions;
|
||||||
import org.hl7.fhir.utilities.OIDUtils;
|
import org.hl7.fhir.utilities.OIDUtils;
|
||||||
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
|
||||||
import org.hl7.fhir.utilities.TranslationServices;
|
import org.hl7.fhir.utilities.TranslationServices;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
|
||||||
|
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
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 {
|
public abstract class BaseWorkerContext implements IWorkerContext {
|
||||||
|
|
||||||
|
@ -438,25 +442,25 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
||||||
// --- validate code -------------------------------------------------------------------------------
|
// --- validate code -------------------------------------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@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);
|
Coding c = new Coding(system, code, display);
|
||||||
return validateCode(options, c, null);
|
return validateCode(options, c, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
Coding c = new Coding(system, code, display);
|
||||||
return validateCode(options, c, vs);
|
return validateCode(options, c, vs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
Coding c = new Coding(null, code, null);
|
||||||
return doValidateCode(options, c, vs, true);
|
return doValidateCode(options, c, vs, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
Coding c = new Coding(system, code, display);
|
||||||
ValueSet vs = new ValueSet();
|
ValueSet vs = new ValueSet();
|
||||||
vs.setUrl(Utilities.makeUuidUrn());
|
vs.setUrl(Utilities.makeUuidUrn());
|
||||||
|
@ -465,11 +469,11 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
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;
|
CacheToken cacheToken = txCache != null ? txCache.generateValidationToken(options, code, vs) : null;
|
||||||
ValidationResult res = null;
|
ValidationResult res = null;
|
||||||
if (txCache != null)
|
if (txCache != null)
|
||||||
|
@ -511,7 +515,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setTerminologyOptions(TerminologyServiceOptions options, Parameters pIn) {
|
private void setTerminologyOptions(ValidationOptions options, Parameters pIn) {
|
||||||
if (options != null) {
|
if (options != null) {
|
||||||
if (!Utilities.noString(options.getLanguage()))
|
if (!Utilities.noString(options.getLanguage()))
|
||||||
pIn.addParameter("displayLanguage", options.getLanguage());
|
pIn.addParameter("displayLanguage", options.getLanguage());
|
||||||
|
@ -519,7 +523,7 @@ public abstract class BaseWorkerContext implements IWorkerContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
CacheToken cacheToken = txCache.generateValidationToken(options, code, vs);
|
||||||
ValidationResult res = txCache.getValidation(cacheToken);
|
ValidationResult res = txCache.getValidation(cacheToken);
|
||||||
if (res != null)
|
if (res != null)
|
||||||
|
|
|
@ -51,6 +51,7 @@ import org.hl7.fhir.r4.utils.IResourceValidator;
|
||||||
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
||||||
import org.hl7.fhir.utilities.TranslationServices;
|
import org.hl7.fhir.utilities.TranslationServices;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||||
|
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -376,7 +377,7 @@ public interface IWorkerContext {
|
||||||
* @param display
|
* @param display
|
||||||
* @return
|
* @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
|
* Validation of a code - consult the terminology service
|
||||||
|
@ -392,10 +393,10 @@ public interface IWorkerContext {
|
||||||
* @param display
|
* @param display
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
public ValidationResult validateCode(TerminologyServiceOptions options, String code, ValueSet vs);
|
public ValidationResult validateCode(ValidationOptions options, String code, ValueSet vs);
|
||||||
public ValidationResult validateCode(TerminologyServiceOptions options, Coding code, ValueSet vs);
|
public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs);
|
||||||
public ValidationResult validateCode(TerminologyServiceOptions options, CodeableConcept code, ValueSet vs);
|
public ValidationResult validateCode(ValidationOptions options, CodeableConcept code, ValueSet vs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validation of a code - consult the terminology service
|
* Validation of a code - consult the terminology service
|
||||||
|
@ -411,7 +412,7 @@ public interface IWorkerContext {
|
||||||
* @param display
|
* @param display
|
||||||
* @return
|
* @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
|
* returns the recommended tla for the type
|
||||||
|
|
|
@ -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.TerminologyServiceErrorClass;
|
||||||
import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||||
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
|
||||||
import org.hl7.fhir.utilities.TextFile;
|
import org.hl7.fhir.utilities.TextFile;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
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.JsonNull;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.google.gson.JsonPrimitive;
|
||||||
|
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This implements a two level cache.
|
* This implements a two level cache.
|
||||||
|
@ -112,7 +112,7 @@ public class TerminologyCache {
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CacheToken generateValidationToken(TerminologyServiceOptions options, Coding code, ValueSet vs) {
|
public CacheToken generateValidationToken(ValidationOptions options, Coding code, ValueSet vs) {
|
||||||
CacheToken ct = new CacheToken();
|
CacheToken ct = new CacheToken();
|
||||||
if (code.hasSystem())
|
if (code.hasSystem())
|
||||||
ct.name = getNameForSystem(code.getSystem());
|
ct.name = getNameForSystem(code.getSystem());
|
||||||
|
@ -130,7 +130,7 @@ public class TerminologyCache {
|
||||||
return ct;
|
return ct;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CacheToken generateValidationToken(TerminologyServiceOptions options, CodeableConcept code, ValueSet vs) {
|
public CacheToken generateValidationToken(ValidationOptions options, CodeableConcept code, ValueSet vs) {
|
||||||
CacheToken ct = new CacheToken();
|
CacheToken ct = new CacheToken();
|
||||||
for (Coding c : code.getCoding()) {
|
for (Coding c : code.getCoding()) {
|
||||||
if (c.hasSystem())
|
if (c.hasSystem())
|
||||||
|
|
|
@ -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.CodeSystem.ConceptDefinitionDesignationComponent;
|
||||||
import org.hl7.fhir.r4.model.ValueSet.*;
|
import org.hl7.fhir.r4.model.ValueSet.*;
|
||||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
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.ValidationMessage.IssueSeverity;
|
||||||
|
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -43,9 +43,9 @@ public class ValueSetCheckerSimple implements ValueSetChecker {
|
||||||
private ValueSet valueset;
|
private ValueSet valueset;
|
||||||
private IWorkerContext context;
|
private IWorkerContext context;
|
||||||
private Map<String, ValueSetCheckerSimple> inner = new HashMap<>();
|
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.valueset = source;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
|
@ -83,7 +83,6 @@ import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple;
|
||||||
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
||||||
import org.hl7.fhir.r5.utils.client.ToolingClientLogger;
|
import org.hl7.fhir.r5.utils.client.ToolingClientLogger;
|
||||||
import org.hl7.fhir.utilities.OIDUtils;
|
import org.hl7.fhir.utilities.OIDUtils;
|
||||||
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
|
||||||
import org.hl7.fhir.utilities.TranslationServices;
|
import org.hl7.fhir.utilities.TranslationServices;
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
import org.hl7.fhir.utilities.VersionUtilities;
|
import org.hl7.fhir.utilities.VersionUtilities;
|
||||||
|
|
|
@ -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.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||||
import org.hl7.fhir.r5.utils.INarrativeGenerator;
|
import org.hl7.fhir.r5.utils.INarrativeGenerator;
|
||||||
import org.hl7.fhir.r5.utils.IResourceValidator;
|
import org.hl7.fhir.r5.utils.IResourceValidator;
|
||||||
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
|
||||||
import org.hl7.fhir.utilities.TranslationServices;
|
import org.hl7.fhir.utilities.TranslationServices;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
|
||||||
|
|
|
@ -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.ConceptSetFilterComponent;
|
||||||
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
|
import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent;
|
||||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||||
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
|
||||||
import org.hl7.fhir.utilities.Utilities;
|
import org.hl7.fhir.utilities.Utilities;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationOptions.ValueSetMode;
|
import org.hl7.fhir.utilities.validation.ValidationOptions.ValueSetMode;
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class OIDUtils {
|
||||||
if (r.equals("2.16.840.1.113883.6.103"))
|
if (r.equals("2.16.840.1.113883.6.103"))
|
||||||
return "http://hl7.org/fhir/sid/icd-9"; //todo: confirm this
|
return "http://hl7.org/fhir/sid/icd-9"; //todo: confirm this
|
||||||
if (r.equals("2.16.840.1.113883.6.73"))
|
if (r.equals("2.16.840.1.113883.6.73"))
|
||||||
return "http://hl7.org/fhir/sid/atc";
|
return "http://www.whocc.no/atc";
|
||||||
if (r.equals("2.16.840.1.113883.3.26.1.1"))
|
if (r.equals("2.16.840.1.113883.3.26.1.1"))
|
||||||
return "http://ncimeta.nci.nih.gov";
|
return "http://ncimeta.nci.nih.gov";
|
||||||
if (r.equals("2.16.840.1.113883.3.26.1.1.1"))
|
if (r.equals("2.16.840.1.113883.3.26.1.1.1"))
|
||||||
|
|
|
@ -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) {
|
protected boolean hint(List<ValidationMessage> errors, IssueType type, int line, int col, String path, boolean thePass, String msg) {
|
||||||
if (!thePass) {
|
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;
|
return thePass;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2018,7 +2018,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
long t = System.nanoTime();
|
long t = System.nanoTime();
|
||||||
ValidationResult vr = null;
|
ValidationResult vr = null;
|
||||||
if (binding.getStrength() != BindingStrength.EXAMPLE) {
|
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);
|
txTime = txTime + (System.nanoTime() - t);
|
||||||
if (vr != null && !vr.isOk()) {
|
if (vr != null && !vr.isOk()) {
|
||||||
|
|
Loading…
Reference in New Issue