Change warnings about invalid codes to hints in retired value sets

This commit is contained in:
Grahame Grieve 2020-09-25 15:00:10 +10:00
parent 4979a03140
commit 28e7a19125
2 changed files with 22 additions and 7 deletions

View File

@ -529,6 +529,21 @@ public class BaseValidator {
return thePass; return thePass;
} }
/**
* Test a rule and add a {@link IssueSeverity#WARNING} validation message if the validation fails
*
* @param thePass
* Set this parameter to <code>false</code> if the validation does not pass
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/
protected boolean warningOrHint(List<ValidationMessage> errors, IssueType type, String path, boolean thePass, boolean warning, String msg, Object... theMessageArguments) {
if (!thePass) {
String message = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, type, -1, -1, path, message, warning ? IssueSeverity.WARNING : IssueSeverity.INFORMATION, null);
}
return thePass;
}
/** /**
* Test a rule and add a {@link IssueSeverity#WARNING} validation message if the validation fails * Test a rule and add a {@link IssueSeverity#WARNING} validation message if the validation fails
* *

View File

@ -56,28 +56,28 @@ public class ValueSetValidator extends BaseValidator {
List<Element> composes = vs.getChildrenByName("compose"); List<Element> composes = vs.getChildrenByName("compose");
int cc = 0; int cc = 0;
for (Element compose : composes) { for (Element compose : composes) {
validateValueSetCompose(errors, compose, stack.push(compose, cc, null, null), vs.getNamedChildValue("url")); validateValueSetCompose(errors, compose, stack.push(compose, cc, null, null), vs.getNamedChildValue("url"), "retired".equals(vs.getNamedChildValue("url")));
cc++; cc++;
} }
} }
} }
private void validateValueSetCompose(List<ValidationMessage> errors, Element compose, NodeStack stack, String vsid) { private void validateValueSetCompose(List<ValidationMessage> errors, Element compose, NodeStack stack, String vsid, boolean retired) {
List<Element> includes = compose.getChildrenByName("include"); List<Element> includes = compose.getChildrenByName("include");
int ci = 0; int ci = 0;
for (Element include : includes) { for (Element include : includes) {
validateValueSetInclude(errors, include, stack.push(include, ci, null, null), vsid); validateValueSetInclude(errors, include, stack.push(include, ci, null, null), vsid, retired);
ci++; ci++;
} }
List<Element> excludes = compose.getChildrenByName("exclude"); List<Element> excludes = compose.getChildrenByName("exclude");
int ce = 0; int ce = 0;
for (Element exclude : excludes) { for (Element exclude : excludes) {
validateValueSetInclude(errors, exclude, stack.push(exclude, ce, null, null), vsid); validateValueSetInclude(errors, exclude, stack.push(exclude, ce, null, null), vsid, retired);
ce++; ce++;
} }
} }
private void validateValueSetInclude(List<ValidationMessage> errors, Element include, NodeStack stack, String vsid) { private void validateValueSetInclude(List<ValidationMessage> errors, Element include, NodeStack stack, String vsid, boolean retired) {
String system = include.getChildValue("system"); String system = include.getChildValue("system");
String version = include.getChildValue("version"); String version = include.getChildValue("version");
List<Element> valuesets = include.getChildrenByName("valueSet"); List<Element> valuesets = include.getChildrenByName("valueSet");
@ -125,9 +125,9 @@ public class ValueSetValidator extends BaseValidator {
} }
for (VSCodingValidationRequest cv : batch) { for (VSCodingValidationRequest cv : batch) {
if (version == null) { if (version == null) {
warning(errors, IssueType.BUSINESSRULE, cv.getStack().getLiteralPath(), cv.getResult().isOk(), I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE, system, cv.getCoding().getCode()); warningOrHint(errors, IssueType.BUSINESSRULE, cv.getStack().getLiteralPath(), cv.getResult().isOk(), !retired, I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE, system, cv.getCoding().getCode());
} else { } else {
warning(errors, IssueType.BUSINESSRULE, cv.getStack().getLiteralPath(), cv.getResult().isOk(), I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE_VER, system, version, cv.getCoding().getCode()); warningOrHint(errors, IssueType.BUSINESSRULE, cv.getStack().getLiteralPath(), cv.getResult().isOk(), !retired, I18nConstants.VALUESET_INCLUDE_INVALID_CONCEPT_CODE_VER, system, version, cv.getCoding().getCode());
} }
} }
} }