Add details for better error messages on bad code system urls
This commit is contained in:
parent
0287248a48
commit
bec72616e0
|
@ -598,3 +598,5 @@ BUNDLE_RULE_UNKNOWN = Bundle Rule refers to invalid resource {0}
|
|||
BUNDLE_RULE_INVALID_INDEX = Bundle Rules index is invalid ({0})
|
||||
BUNDLE_RULE_PROFILE_UNKNOWN = Bundle Rules profile {1} is unknown for {0}
|
||||
UNABLE_TO_CHECK_IF_THE_PROVIDED_CODES_ARE_IN_THE_VALUE_SET_ = Unable to determine whether the provided codes are in the value set {0} because the value set or code system is not known to the validator
|
||||
TERMINOLOGY_TX_SYSTEM_WRONG_HTML = The code system reference {0} is wrong - the code system reference cannot be to an HTML page. This may be the correct reference: {1}
|
||||
TERMINOLOGY_TX_SYSTEM_WRONG_BUILD = The code system reference {0} is wrong - the code system reference cannot be a reference to build.fhir.org. This may be the correct reference: {1}
|
||||
|
|
|
@ -770,13 +770,19 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
else
|
||||
return txRule(errors, s.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, s == null, I18nConstants.TERMINOLOGY_PASSTHROUGH_TX_MESSAGE, s.getMessage(), system, code);
|
||||
return true;
|
||||
} else if (system.startsWith("http://hl7.org/fhir")) {
|
||||
} else if (system.startsWith("http://build.fhir.org") || system.startsWith("https://build.fhir.org")) {
|
||||
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_SYSTEM_WRONG_BUILD, system, suggestSystemForBuild(system));
|
||||
return false;
|
||||
} else if (system.startsWith("http://hl7.org/fhir") || system.startsWith("https://hl7.org/fhir") || system.startsWith("http://www.hl7.org/fhir") || system.startsWith("https://www.hl7.org/fhir")) {
|
||||
if (Utilities.existsInList(system, "http://hl7.org/fhir/sid/icd-10", "http://hl7.org/fhir/sid/cvx", "http://hl7.org/fhir/sid/icd-10", "http://hl7.org/fhir/sid/icd-10-cm",
|
||||
"http://hl7.org/fhir/sid/icd-9-cm", "http://hl7.org/fhir/sid/icd-9", "http://hl7.org/fhir/sid/ndc", "http://hl7.org/fhir/sid/srt"))
|
||||
"http://hl7.org/fhir/sid/icd-9-cm", "http://hl7.org/fhir/sid/icd-9", "http://hl7.org/fhir/sid/ndc", "http://hl7.org/fhir/sid/srt")) {
|
||||
return true; // else don't check these (for now)
|
||||
else if (system.startsWith("http://hl7.org/fhir/test"))
|
||||
} else if (system.startsWith("http://hl7.org/fhir/test")) {
|
||||
return true; // we don't validate these
|
||||
else {
|
||||
} else if (system.endsWith(".html")) {
|
||||
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_SYSTEM_WRONG_HTML, system, suggestSystemForPage(system));
|
||||
return false;
|
||||
} else {
|
||||
CodeSystem cs = getCodeSystem(system);
|
||||
if (rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, cs != null, I18nConstants.TERMINOLOGY_TX_SYSTEM_UNKNOWN, system)) {
|
||||
ConceptDefinitionComponent def = getCodeDefinition(cs, code);
|
||||
|
@ -813,6 +819,59 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
}
|
||||
}
|
||||
|
||||
private Object suggestSystemForPage(String system) {
|
||||
if (system.contains("/codesystem-")) {
|
||||
String s = system.substring(system.indexOf("/codesystem-")+12);
|
||||
String url = "http://hl7.org/fhir/"+s.replace(".html", "");
|
||||
if (context.fetchCodeSystem(url) != null) {
|
||||
return url;
|
||||
} else {
|
||||
return "{unable to determine intended url}";
|
||||
}
|
||||
}
|
||||
if (system.contains("/valueset-")) {
|
||||
String s = system.substring(system.indexOf("/valueset-")+8);
|
||||
String url = "http://hl7.org/fhir/"+s.replace(".html", "");
|
||||
if (context.fetchCodeSystem(url) != null) {
|
||||
return url;
|
||||
} else {
|
||||
return "{unable to determine intended url}";
|
||||
}
|
||||
}
|
||||
return "{unable to determine intended url}";
|
||||
}
|
||||
|
||||
private Object suggestSystemForBuild(String system) {
|
||||
if (system.contains("/codesystem-")) {
|
||||
String s = system.substring(system.indexOf("/codesystem-")+12);
|
||||
String url = "http://hl7.org/fhir/"+s.replace(".html", "");
|
||||
if (context.fetchCodeSystem(url) != null) {
|
||||
return url;
|
||||
} else {
|
||||
return "{unable to determine intended url}";
|
||||
}
|
||||
}
|
||||
if (system.contains("/valueset-")) {
|
||||
String s = system.substring(system.indexOf("/valueset-")+8);
|
||||
String url = "http://hl7.org/fhir/"+s.replace(".html", "");
|
||||
if (context.fetchCodeSystem(url) != null) {
|
||||
return url;
|
||||
} else {
|
||||
return "{unable to determine intended url}";
|
||||
}
|
||||
}
|
||||
system = system.replace("https://", "http://");
|
||||
if (system.length() < 22) {
|
||||
return "{unable to determine intended url}";
|
||||
}
|
||||
system = "http://hl7.org/fhir/"+system.substring(22).replace(".html", "");
|
||||
if (context.fetchCodeSystem(system) != null) {
|
||||
return system;
|
||||
} else {
|
||||
return "{unable to determine intended url}";
|
||||
}
|
||||
}
|
||||
|
||||
private boolean startsWithButIsNot(String system, String... uri) {
|
||||
for (String s : uri)
|
||||
if (!system.equals(s) && system.startsWith(s))
|
||||
|
|
|
@ -130,7 +130,7 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
|
|||
version = VersionUtilities.getMajMin(version);
|
||||
if (!ve.containsKey(version)) {
|
||||
if (version.startsWith("5.0"))
|
||||
ve.put(version, new ValidationEngine("hl7.fhir.r5.core#4.4.0", DEF_TX, txLog, FhirPublication.R5, true, "4.4.0"));
|
||||
ve.put(version, new ValidationEngine("hl7.fhir.r5.core#4.5.0", DEF_TX, txLog, FhirPublication.R5, true, "4.5.0"));
|
||||
else if (version.startsWith("3.0"))
|
||||
ve.put(version, new ValidationEngine("hl7.fhir.r3.core#3.0.2", DEF_TX, txLog, FhirPublication.STU3, true, "3.0.2"));
|
||||
else if (version.startsWith("4.0"))
|
||||
|
|
Loading…
Reference in New Issue