validate example URLs in value sets correctly

This commit is contained in:
Grahame Grieve 2023-03-22 23:06:33 +11:00
parent 05a367b088
commit 74a69de992
4 changed files with 28 additions and 12 deletions

View File

@ -957,6 +957,15 @@ public class Utilities {
return false;
}
public static boolean containsInList(String value, String... array) {
if (value == null)
return false;
for (String s : array)
if (value.contains(s))
return true;
return false;
}
public static boolean existsInList(String value, String... array) {
if (value == null)
return false;
@ -1991,7 +2000,7 @@ public class Utilities {
public static String tail(String url) {
int i = url.length()-1;
while (i >= 0 && isTokenChar(url.charAt(i))) {
while (i >= 0 && (isTokenChar(url.charAt(i)) || isDigit(url.charAt(i))) ) {
i--;
}
if (i < 0) {

View File

@ -558,6 +558,8 @@ SEARCHPARAMETER_EXP_WRONG = The expression ''{2}'' is not compatible with the ex
VALUESET_NO_SYSTEM_WARNING = No System specified, so Concepts and Filters can't be checked
VALUESET_INCLUDE_INVALID_CONCEPT_CODE = The code {1} is not valid in the system {0}
VALUESET_INCLUDE_INVALID_CONCEPT_CODE_VER = The code {2} is not valid in the system {0} version {1}
VALUESET_EXAMPLE_SYSTEM_HINT = Example System ''{0}'' specified, so Concepts and Filters can''t be checked
VALUESET_EXAMPLE_SYSTEM_ERROR = Example System ''{0}'' specified, which is illegal. Concepts and Filters can''t be checked
VALUESET_UNC_SYSTEM_WARNING = Unknown System ''{0}'' specified, so Concepts and Filters can''t be checked (Details: {1})
VALUESET_UNC_SYSTEM_WARNING_VER = Unknown System/Version ''{0}'' specified, so Concepts and Filters can''t be checked (Details: {1})
Extension_PROF_Type = The Profile ''{0}'' definition allows for the type {1} but found type {2}
@ -855,7 +857,7 @@ SM_NO_LIST_RULE_ID_NEEDED = A list ruleId should not be provided since this is a
SM_LIST_RULE_ID_ONLY_WHEN_SHARE = A ruleId should only be provided when the rule mode is ''share''
SM_RULE_SOURCE_UNASSIGNED = The source statement doesn''t assign a variable to the source - check that this is what is intended
SM_TARGET_PATH_MULTIPLE_MATCHES = The target path {0}.{1} refers to the path {2} which is could be a reference to multiple elements ({3}). No further checking can be performed
SM_SOURCE_TYPE_INVALID = The type {0} is not valid in this source context {1}. The possible types are [{2}]
SM_SOURCE_TYPE_INVALID = The type {0} is not valid in the source context {1}. The possible types are [{2}]
SM_TARGET_TRANSFORM_PARAM_COUNT_RANGE = Transform {0} takes {1}-{2} parameter(s) but {3} were found
SM_TARGET_TRANSFORM_PARAM_COUNT_SINGLE = Transform {0} takes {1} parameter(s) but {2} were found
SM_TARGET_TRANSFORM_NOT_CHECKED = Transform {0} not checked dyet

View File

@ -155,6 +155,7 @@ public class BaseValidator implements IValidationContextResourceLoader {
protected List<ValidationMessage> messagesToRemove = new ArrayList<>();
private ValidationLevel level = ValidationLevel.HINTS;
protected Coding jurisdiction;
protected boolean allowExamples;
public BaseValidator(IWorkerContext context, XVerExtensionManager xverManager) {
super();
@ -1231,4 +1232,17 @@ public class BaseValidator implements IValidationContextResourceLoader {
String url = cr.getChildValue("url");
return url != null && url.contains("hl7");
}
public boolean isAllowExamples() {
return this.allowExamples;
}
public void setAllowExamples(boolean value) {
this.allowExamples = value;
}
protected boolean isExampleUrl(String url) {
return Utilities.containsInList(url, "example.org", "acme.com", "acme.org");
}
}

View File

@ -471,7 +471,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
private IValidationProfileUsageTracker tracker;
private ValidatorHostServices validatorServices;
private boolean assumeValidRestReferences;
private boolean allowExamples;
private boolean securityChecks;
private ProfileUtilities profileUtilities;
private boolean crumbTrails;
@ -586,14 +585,6 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
this.assumeValidRestReferences = value;
}
public boolean isAllowExamples() {
return this.allowExamples;
}
public void setAllowExamples(boolean value) {
this.allowExamples = value;
}
public boolean isAllowComments() {
return allowComments;
}
@ -5043,7 +5034,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} else if (element.getType().equals("StructureMap")) {
return new StructureMapValidator(context, timeTracker, fpe, xverManager,profileUtilities, jurisdiction).validateStructureMap(errors, element, stack);
} else if (element.getType().equals("ValueSet")) {
return new ValueSetValidator(context, timeTracker, this, xverManager, jurisdiction).validateValueSet(errors, element, stack);
return new ValueSetValidator(context, timeTracker, this, xverManager, jurisdiction, allowExamples).validateValueSet(errors, element, stack);
} else {
return true;
}