Fixes for display warnings

This commit is contained in:
Grahame Grieve 2023-05-13 21:47:25 -07:00
parent 37bf22f8e9
commit 6d2e3ee388
9 changed files with 59 additions and 6 deletions

View File

@ -477,6 +477,9 @@ public class ValueSetValidator {
res.getIssues().addAll(makeIssue(IssueSeverity.ERROR, IssueType.INVALID, path, msg));
}
}
if (res != null && res.getSeverity() == IssueSeverity.INFORMATION) {
res.setSeverity(IssueSeverity.ERROR); // back patching for display logic issue
}
return res;
}
@ -655,10 +658,18 @@ public class ValueSetValidator {
return new ValidationResult(IssueSeverity.WARNING, msg, code.getSystem(), cs.getVersion(), cc, getPreferredDisplay(cc, cs), makeIssue(IssueSeverity.WARNING, IssueType.INVALID, path+".display", msg));
} else {
String msg = context.formatMessagePlural(b.count(), I18nConstants.DISPLAY_NAME_FOR__SHOULD_BE_ONE_OF__INSTEAD_OF, code.getSystem(), code.getCode(), b.toString(), code.getDisplay(), options.langSummary());
return new ValidationResult(IssueSeverity.WARNING, msg, code.getSystem(), cs.getVersion(), cc, getPreferredDisplay(cc, cs), makeIssue(IssueSeverity.WARNING, IssueType.INVALID, path+".display", msg));
return new ValidationResult(dispWarningStatus(), msg, code.getSystem(), cs.getVersion(), cc, getPreferredDisplay(cc, cs), makeIssue(dispWarning(), IssueType.INVALID, path+".display", msg));
}
}
private IssueSeverity dispWarning() {
return options.isDisplayWarningMode() ? IssueSeverity.WARNING : IssueSeverity.ERROR;
}
private IssueSeverity dispWarningStatus() {
return options.isDisplayWarningMode() ? IssueSeverity.WARNING : IssueSeverity.INFORMATION; // information -> error later
}
private boolean isOkLanguage(String language) {
if (!options.hasLanguages()) {
return true;

View File

@ -16,6 +16,7 @@ public class ValidationOptions {
private boolean useClient = true;
private boolean guessSystem = false;
private ValueSetMode valueSetMode = ValueSetMode.ALL_CHECKS;
private boolean displayWarningMode = false;
private boolean vsAsUrl;
private boolean versionFlexible = true;
private boolean useValueSetDisplays;
@ -236,6 +237,15 @@ public class ValidationOptions {
return this;
}
public boolean isDisplayWarningMode() {
return displayWarningMode;
}
public ValidationOptions setDisplayWarningMode(boolean displayWarningMode) {
this.displayWarningMode = displayWarningMode;
return this;
}
public ValidationOptions copy() {
ValidationOptions n = new ValidationOptions();
n.languages.addAll(languages);
@ -246,13 +256,14 @@ public class ValidationOptions {
n.versionFlexible = versionFlexible;
n.valueSetMode = valueSetMode;
n.useValueSetDisplays = useValueSetDisplays;
n.displayWarningMode = displayWarningMode;
return n;
}
public String toJson() {
return "\"langs\":\""+languages.toString()+"\", \"useServer\":\""+Boolean.toString(useServer)+"\", \"useClient\":\""+Boolean.toString(useClient)+"\", "+
"\"guessSystem\":\""+Boolean.toString(guessSystem)+"\", \"valueSetMode\":\""+valueSetMode.toString()+"\", \"versionFlexible\":\""+Boolean.toString(versionFlexible)+"\"";
"\"guessSystem\":\""+Boolean.toString(guessSystem)+"\", \"valueSetMode\":\""+valueSetMode.toString()+"\", \"displayWarningMode\":\""+Boolean.toString(displayWarningMode)+"\", \"versionFlexible\":\""+Boolean.toString(versionFlexible)+"\"";
}
public String langSummary() {

View File

@ -180,6 +180,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IValidationP
@Getter @Setter private Map<String, byte[]> binaries = new HashMap<>();
@Getter @Setter private boolean doNative;
@Getter @Setter private boolean noInvariantChecks;
@Getter @Setter private boolean displayWarnings;
@Getter @Setter private boolean wantInvariantInMessage;
@Getter @Setter private boolean hintAboutNonMustSupport;
@Getter @Setter private boolean anyExtensionsAllowed = false;
@ -773,6 +774,7 @@ public class ValidationEngine implements IValidatorResourceFetcher, IValidationP
validator.setNoInvariantChecks(isNoInvariantChecks());
validator.setWantInvariantInMessage(isWantInvariantInMessage());
validator.setValidationLanguage(language);
validator.setDisplayWarnings(isDisplayWarnings());
if (language != null) {
validator.getContext().setValidationMessageLanguage(Locale.forLanguageTag(language));
}

View File

@ -45,6 +45,8 @@ public class CliContext {
private boolean noUnicodeBiDiControlChars = false;
@JsonProperty("noInvariants")
private boolean noInvariants = false;
@JsonProperty("displayWarnings")
private boolean displayWarnings = false;
@JsonProperty("wantInvariantsInMessages")
private boolean wantInvariantsInMessages = false;
@JsonProperty("doImplicitFHIRPathStringConversion")
@ -582,6 +584,16 @@ public class CliContext {
this.noInvariants = noInvariants;
}
@JsonProperty("displayWarnings")
public boolean isDisplayWarnings() {
return displayWarnings;
}
@JsonProperty("displayWarnings")
public void setDisplayWarnings(boolean displayWarnings) {
this.displayWarnings = displayWarnings;
}
@JsonProperty("wantInvariantsInMessages")
public boolean isWantInvariantsInMessages() {
return wantInvariantsInMessages;
@ -691,6 +703,7 @@ public class CliContext {
noExtensibleBindingMessages == that.noExtensibleBindingMessages &&
noUnicodeBiDiControlChars == that.noUnicodeBiDiControlChars &&
noInvariants == that.noInvariants &&
displayWarnings == that.displayWarnings &&
wantInvariantsInMessages == that.wantInvariantsInMessages &&
Objects.equals(extensions, that.extensions) &&
Objects.equals(map, that.map) &&
@ -727,7 +740,7 @@ public class CliContext {
@Override
public int hashCode() {
return Objects.hash(doNative, extensions, hintAboutNonMustSupport, recursive, doDebug, assumeValidRestReferences, canDoNative, noInternalCaching,
noExtensibleBindingMessages, noInvariants, wantInvariantsInMessages, map, output, outputSuffix, htmlOutput, txServer, sv, txLog, txCache, mapLog, lang, srcLang, tgtLang, fhirpath, snomedCT,
noExtensibleBindingMessages, noInvariants, displayWarnings, wantInvariantsInMessages, map, output, outputSuffix, htmlOutput, txServer, sv, txLog, txCache, mapLog, lang, srcLang, tgtLang, fhirpath, snomedCT,
targetVer, igs, questionnaireMode, level, profiles, sources, inputs, mode, locale, locations, crumbTrails, forPublication, showTimes, allowExampleUrls, outputStyle, jurisdiction, noUnicodeBiDiControlChars);
}
@ -745,6 +758,7 @@ public class CliContext {
", noExtensibleBindingMessages=" + noExtensibleBindingMessages +
", noUnicodeBiDiControlChars=" + noUnicodeBiDiControlChars +
", noInvariants=" + noInvariants +
", displayWarnings=" + displayWarnings +
", wantInvariantsInMessages=" + wantInvariantsInMessages +
", map='" + map + '\'' +
", output='" + output + '\'' +

View File

@ -448,6 +448,7 @@ public class ValidationService {
validationEngine.setNoExtensibleBindingMessages(cliContext.isNoExtensibleBindingMessages());
validationEngine.setNoUnicodeBiDiControlChars(cliContext.isNoUnicodeBiDiControlChars());
validationEngine.setNoInvariantChecks(cliContext.isNoInvariants());
validationEngine.setDisplayWarnings(cliContext.isDisplayWarnings());
validationEngine.setWantInvariantInMessage(cliContext.isWantInvariantsInMessages());
validationEngine.setSecurityChecks(cliContext.isSecurityChecks());
validationEngine.setCrumbTrails(cliContext.isCrumbTrails());

View File

@ -69,6 +69,7 @@ public class Params {
public static final String NO_EXTENSIBLE_BINDING_WARNINGS = "-no-extensible-binding-warnings";
public static final String NO_UNICODE_BIDI_CONTROL_CHARS = "-no_unicode_bidi_control_chars";
public static final String NO_INVARIANTS = "-no-invariants";
public static final String DISPLAY_WARNINGS = "-display-issues-are-warnings";
public static final String WANT_INVARIANTS_IN_MESSAGES = "-want-invariants-in-messages";
public static final String SECURITY_CHECKS = "-security-checks";
public static final String CRUMB_TRAIL = "-crumb-trails";
@ -243,6 +244,8 @@ public class Params {
cliContext.setNoUnicodeBiDiControlChars(true);
} else if (args[i].equals(NO_INVARIANTS)) {
cliContext.setNoInvariants(true);
} else if (args[i].equals(DISPLAY_WARNINGS)) {
cliContext.setDisplayWarnings(true);
} else if (args[i].equals(WANT_INVARIANTS_IN_MESSAGES)) {
cliContext.setWantInvariantsInMessages(true);
} else if (args[i].equals(HINT_ABOUT_NON_MUST_SUPPORT)) {

View File

@ -466,6 +466,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
private boolean noUnicodeBiDiControlChars;
private HtmlInMarkdownCheck htmlInMarkdownCheck;
private boolean allowComments;
private boolean displayWarnings;
private List<ImplementationGuide> igs = new ArrayList<>();
private List<String> extensionDomains = new ArrayList<String>();
@ -6534,5 +6535,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
this.forPublication = forPublication;
}
public boolean isDisplayWarnings() {
return baseOptions.isDisplayWarningMode();
}
public void setDisplayWarnings(boolean displayWarnings) {
baseOptions.setDisplayWarningMode(displayWarnings);
}
}

View File

@ -240,6 +240,9 @@ public class TerminologyServiceTests {
}
if (p.hasParameter("valueSetMode") && "CHECK_MEMBERSHIP_ONLY".equals(p.getParameterString("valueSetMode"))) {
options = options.withCheckValueSetOnly();
}
if (p.hasParameter("mode") && "lenient-display-validation".equals(p.getParameterString("mode"))) {
options = options.setDisplayWarningMode(true);
}
ValidationResult vm;
if (p.hasParameter("code")) {

View File

@ -19,7 +19,7 @@
<properties>
<hapi_fhir_version>6.4.1</hapi_fhir_version>
<validator_test_case_version>1.3.5</validator_test_case_version>
<validator_test_case_version>1.3.6-SNAPSHOT</validator_test_case_version>
<jackson_version>2.14.0</jackson_version>
<junit_jupiter_version>5.9.2</junit_jupiter_version>
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>