More refactoring + renaming

This commit is contained in:
dotasek 2024-12-02 19:24:49 -05:00
parent 8d27b6f592
commit 7cbef50f6b
2 changed files with 106 additions and 112 deletions

View File

@ -69,7 +69,6 @@ import org.hl7.fhir.r5.utils.UserDataNames;
import org.hl7.fhir.r5.utils.XVerExtensionManager; import org.hl7.fhir.r5.utils.XVerExtensionManager;
import org.hl7.fhir.r5.utils.XVerExtensionManager.XVerExtensionStatus; import org.hl7.fhir.r5.utils.XVerExtensionManager.XVerExtensionStatus;
import org.hl7.fhir.r5.utils.validation.IMessagingServices; import org.hl7.fhir.r5.utils.validation.IMessagingServices;
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor; import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor;
import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher; import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher;
import org.hl7.fhir.r5.utils.validation.ValidatorSession; import org.hl7.fhir.r5.utils.validation.ValidatorSession;
@ -281,7 +280,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
protected String urlRegex; protected String urlRegex;
private boolean suppressMsg(String path, String theMessage) { protected boolean isSuppressedValidationMessage(String path, String theMessage) {
if (policyAdvisor == null) { if (policyAdvisor == null) {
return false; return false;
} else { } else {
@ -290,7 +289,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean fail(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean fail(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingErrors() && !suppressMsg(path, theMessage)) { if (!thePass && doingErrors() && !isSuppressedValidationMessage(path, theMessage)) {
String msg = context.formatMessage(theMessage, theMessageArguments); String msg = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, line, col, path, msg, IssueSeverity.FATAL, theMessage); addValidationMessage(errors, ruleDate, type, line, col, path, msg, IssueSeverity.FATAL, theMessage);
} }
@ -310,7 +309,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean hint(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg) { protected boolean hint(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg) {
if (!thePass && doingHints() && !suppressMsg(path, msg)) { if (!thePass && doingHints() && !isSuppressedValidationMessage(path, msg)) {
String message = context.formatMessage(msg); String message = context.formatMessage(msg);
addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.INFORMATION, msg); addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.INFORMATION, msg);
} }
@ -325,7 +324,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean hintInv(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, String invId) { protected boolean hintInv(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, String invId) {
if (!thePass && doingHints() && !suppressMsg(path, invId)) { if (!thePass && doingHints() && !isSuppressedValidationMessage(path, invId)) {
String message = context.formatMessage(msg); String message = context.formatMessage(msg);
addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.INFORMATION, msg).setInvId(invId); addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.INFORMATION, msg).setInvId(invId);
} }
@ -364,7 +363,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean hint(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean hint(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingHints() && !suppressMsg(path, theMessage)) { if (!thePass && doingHints() && !isSuppressedValidationMessage(path, theMessage)) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.INFORMATION, theMessage); addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.INFORMATION, theMessage);
} }
@ -372,7 +371,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean hintPlural(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, int num, String theMessage, Object... theMessageArguments) { protected boolean hintPlural(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, int num, String theMessage, Object... theMessageArguments) {
if (!thePass && doingHints() && !suppressMsg(path, theMessage)) { if (!thePass && doingHints() && !isSuppressedValidationMessage(path, theMessage)) {
String message = context.formatMessagePlural(num, theMessage, theMessageArguments); String message = context.formatMessagePlural(num, theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.INFORMATION, theMessage); addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.INFORMATION, theMessage);
} }
@ -385,7 +384,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean txHint(List<ValidationMessage> errors, String ruleDate, String txLink, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean txHint(List<ValidationMessage> errors, String ruleDate, String txLink, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingHints() && !suppressMsg(path, theMessage)) { if (!thePass && doingHints() && !isSuppressedValidationMessage(path, theMessage)) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.INFORMATION, Source.TerminologyEngine, theMessage).setTxLink(txLink); addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.INFORMATION, Source.TerminologyEngine, theMessage).setTxLink(txLink);
} }
@ -400,7 +399,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean hint(List<ValidationMessage> errors, String ruleDate, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean hint(List<ValidationMessage> errors, String ruleDate, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingHints() && !suppressMsg(CommaSeparatedStringBuilder.join(".", pathParts), theMessage)) { if (!thePass && doingHints() && !isSuppressedValidationMessage(CommaSeparatedStringBuilder.join(".", pathParts), theMessage)) {
String path = toPath(pathParts); String path = toPath(pathParts);
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.INFORMATION, theMessage); addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.INFORMATION, theMessage);
@ -416,7 +415,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean hint(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean hint(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingHints() && !suppressMsg(path, theMessage)) { if (!thePass && doingHints() && !isSuppressedValidationMessage(path, theMessage)) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.INFORMATION, null); addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.INFORMATION, null);
} }
@ -431,7 +430,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean rule(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean rule(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingErrors() && !suppressMsg(path, theMessage)) { if (!thePass && doingErrors() && !isSuppressedValidationMessage(path, theMessage)) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.ERROR, theMessage); addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.ERROR, theMessage);
} }
@ -439,7 +438,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean ruleInv(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String theMessage, String invId, Object... theMessageArguments) { protected boolean ruleInv(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String theMessage, String invId, Object... theMessageArguments) {
if (!thePass && doingErrors() && !suppressMsg(path, theMessage)) { if (!thePass && doingErrors() && !isSuppressedValidationMessage(path, theMessage)) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.ERROR, invId).setInvId(invId); addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.ERROR, invId).setInvId(invId);
} }
@ -447,7 +446,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean rule(List<ValidationMessage> errors, String ruleDate, IssueType type, NodeStack stack, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean rule(List<ValidationMessage> errors, String ruleDate, IssueType type, NodeStack stack, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingErrors() && !suppressMsg(stack.getLiteralPath(), theMessage)) { if (!thePass && doingErrors() && !isSuppressedValidationMessage(stack.getLiteralPath(), theMessage)) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, stack.line(), stack.col(), stack.getLiteralPath(), message, IssueSeverity.ERROR, theMessage); addValidationMessage(errors, ruleDate, type, stack.line(), stack.col(), stack.getLiteralPath(), message, IssueSeverity.ERROR, theMessage);
} }
@ -459,7 +458,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean rulePlural(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, int num, String theMessage, Object... theMessageArguments) { protected boolean rulePlural(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, int num, String theMessage, Object... theMessageArguments) {
if (!thePass && doingErrors() && !suppressMsg(path, theMessage)) { if (!thePass && doingErrors() && !isSuppressedValidationMessage(path, theMessage)) {
String message = context.formatMessagePlural(num, theMessage, theMessageArguments); String message = context.formatMessagePlural(num, theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.ERROR, theMessage); addValidationMessage(errors, ruleDate, type, line, col, path, message, IssueSeverity.ERROR, theMessage);
} }
@ -467,7 +466,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean txRule(List<ValidationMessage> errors, String ruleDate, String txLink, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean txRule(List<ValidationMessage> errors, String ruleDate, String txLink, IssueType type, int line, int col, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingErrors() && !suppressMsg(path, theMessage)) { if (!thePass && doingErrors() && !isSuppressedValidationMessage(path, theMessage)) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
ValidationMessage vm = new ValidationMessage(Source.TerminologyEngine, type, line, col, path, message, IssueSeverity.ERROR).setMessageId(idForMessage(theMessage, message)); ValidationMessage vm = new ValidationMessage(Source.TerminologyEngine, type, line, col, path, message, IssueSeverity.ERROR).setMessageId(idForMessage(theMessage, message));
vm.setRuleDate(ruleDate); vm.setRuleDate(ruleDate);
@ -505,7 +504,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean rule(List<ValidationMessage> errors, String ruleDate, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean rule(List<ValidationMessage> errors, String ruleDate, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingErrors() && !suppressMsg(CommaSeparatedStringBuilder.join(".", pathParts), theMessage)) { if (!thePass && doingErrors() && !isSuppressedValidationMessage(CommaSeparatedStringBuilder.join(".", pathParts), theMessage)) {
String path = toPath(pathParts); String path = toPath(pathParts);
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.ERROR, theMessage); addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.ERROR, theMessage);
@ -523,7 +522,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
protected boolean rule(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean rule(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingErrors() && !suppressMsg(path, theMessage)) { if (!thePass && doingErrors() && !isSuppressedValidationMessage(path, theMessage)) {
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.ERROR, theMessage); addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.ERROR, theMessage);
} }
@ -531,7 +530,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean rulePlural(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, int num, String theMessage, Object... theMessageArguments) { protected boolean rulePlural(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, int num, String theMessage, Object... theMessageArguments) {
if (!thePass && doingErrors() && !suppressMsg(path, theMessage)) { if (!thePass && doingErrors() && !isSuppressedValidationMessage(path, theMessage)) {
String message = context.formatMessagePlural(num, theMessage, theMessageArguments); String message = context.formatMessagePlural(num, theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.ERROR, theMessage); addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.ERROR, theMessage);
} }
@ -597,7 +596,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean warning(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) { protected boolean warning(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(path, msg)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(path, msg)) {
String nmsg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
IssueSeverity severity = IssueSeverity.WARNING; IssueSeverity severity = IssueSeverity.WARNING;
addValidationMessage(errors, ruleDate, type, line, col, path, nmsg, severity, msg); addValidationMessage(errors, ruleDate, type, line, col, path, nmsg, severity, msg);
@ -607,7 +606,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean warning(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, String id, boolean thePass, String msg, Object... theMessageArguments) { protected boolean warning(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, String id, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(path, msg)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(path, msg)) {
String nmsg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
IssueSeverity severity = IssueSeverity.WARNING; IssueSeverity severity = IssueSeverity.WARNING;
addValidationMessage(errors, ruleDate, type, line, col, path, nmsg, severity, id); addValidationMessage(errors, ruleDate, type, line, col, path, nmsg, severity, id);
@ -617,7 +616,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean warningInv(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, String invId, Object... theMessageArguments) { protected boolean warningInv(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, String invId, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(path, invId)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(path, invId)) {
String nmsg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
IssueSeverity severity = IssueSeverity.WARNING; IssueSeverity severity = IssueSeverity.WARNING;
String id = idForMessage(msg, nmsg); String id = idForMessage(msg, nmsg);
@ -636,7 +635,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean warningPlural(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, int num, String msg, Object... theMessageArguments) { protected boolean warningPlural(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, int num, String msg, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(path, msg)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(path, msg)) {
String nmsg = context.formatMessagePlural(num, msg, theMessageArguments); String nmsg = context.formatMessagePlural(num, msg, theMessageArguments);
IssueSeverity severity = IssueSeverity.WARNING; IssueSeverity severity = IssueSeverity.WARNING;
addValidationMessage(errors, ruleDate, type, line, col, path, nmsg, severity, msg); addValidationMessage(errors, ruleDate, type, line, col, path, nmsg, severity, msg);
@ -678,7 +677,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean txWarning(List<ValidationMessage> errors, String ruleDate, String txLink, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) { protected boolean txWarning(List<ValidationMessage> errors, String ruleDate, String txLink, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(path, msg)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(path, msg)) {
String nmsg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
ValidationMessage vmsg = new ValidationMessage(Source.TerminologyEngine, type, line, col, path, nmsg, IssueSeverity.WARNING).setTxLink(txLink).setMessageId(idForMessage(msg, nmsg)); ValidationMessage vmsg = new ValidationMessage(Source.TerminologyEngine, type, line, col, path, nmsg, IssueSeverity.WARNING).setTxLink(txLink).setMessageId(idForMessage(msg, nmsg));
vmsg.setRuleDate(ruleDate); vmsg.setRuleDate(ruleDate);
@ -691,30 +690,23 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
/** /**
* 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
*
* @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) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected ValidationMessage txIssue(List<ValidationMessage> errors, String ruleDate, String txLink, int line, int col, String path, OperationOutcomeIssueComponent issue) { protected ValidationMessage buildValidationMessage(String txLink, int line, int col, String path, OperationOutcomeIssueComponent issue) {
if (issue.hasLocation() && issue.getExpressionOrLocation().get(0).getValue().contains(".")) { if (issue.hasLocation() && issue.getExpressionOrLocation().get(0).getValue().contains(".")) {
path = path + dropHead(issue.getExpressionOrLocation().get(0).getValue()); path = path + dropHead(issue.getExpressionOrLocation().get(0).getValue());
} }
IssueType code = IssueType.fromCode(issue.getCode().toCode()); IssueType code = IssueType.fromCode(issue.getCode().toCode());
IssueSeverity severity = IssueSeverity.fromCode(issue.getSeverity().toCode()); IssueSeverity severity = IssueSeverity.fromCode(issue.getSeverity().toCode());
ValidationMessage vmsg = new ValidationMessage(Source.TerminologyEngine, code, line, col, path, issue.getDetails().getText(), severity).setTxLink(txLink); ValidationMessage validationMessage = new ValidationMessage(Source.TerminologyEngine, code, line, col, path, issue.getDetails().getText(), severity).setTxLink(txLink);
if (issue.getExtensionString(ToolingExtensions.EXT_ISSUE_SERVER) != null) { if (issue.getExtensionString(ToolingExtensions.EXT_ISSUE_SERVER) != null) {
vmsg.setServer(issue.getExtensionString(ToolingExtensions.EXT_ISSUE_SERVER).replace("local.fhir.org", "tx-dev.fhir.org")); validationMessage.setServer(issue.getExtensionString(ToolingExtensions.EXT_ISSUE_SERVER).replace("local.fhir.org", "tx-dev.fhir.org"));
} }
if (issue.getExtensionString(ToolingExtensions.EXT_ISSUE_MSG_ID) != null) { if (issue.getExtensionString(ToolingExtensions.EXT_ISSUE_MSG_ID) != null) {
vmsg.setMessageId(issue.getExtensionString(ToolingExtensions.EXT_ISSUE_MSG_ID)); validationMessage.setMessageId(issue.getExtensionString(ToolingExtensions.EXT_ISSUE_MSG_ID));
} }
return validationMessage;
if (!suppressMsg(path, vmsg.getMessageId())) {
errors.add(vmsg);
}
return vmsg;
} }
private String dropHead(String value) { private String dropHead(String value) {
@ -729,7 +721,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean txWarningForLaterRemoval(Object location, List<ValidationMessage> errors, String ruleDate, String txLink, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) { protected boolean txWarningForLaterRemoval(Object location, List<ValidationMessage> errors, String ruleDate, String txLink, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(path, msg)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(path, msg)) {
String nmsg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
ValidationMessage vmsg = new ValidationMessage(Source.TerminologyEngine, type, line, col, path, nmsg, IssueSeverity.WARNING).setTxLink(txLink).setMessageId(msg); ValidationMessage vmsg = new ValidationMessage(Source.TerminologyEngine, type, line, col, path, nmsg, IssueSeverity.WARNING).setTxLink(txLink).setMessageId(msg);
vmsg.setRuleDate(ruleDate); vmsg.setRuleDate(ruleDate);
@ -758,7 +750,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean warningOrError(boolean isError, List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) { protected boolean warningOrError(boolean isError, List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass && !suppressMsg(path, msg)) { if (!thePass && !isSuppressedValidationMessage(path, msg)) {
String nmsg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
IssueSeverity lvl = isError ? IssueSeverity.ERROR : IssueSeverity.WARNING; IssueSeverity lvl = isError ? IssueSeverity.ERROR : IssueSeverity.WARNING;
if (doingLevel(lvl)) { if (doingLevel(lvl)) {
@ -774,7 +766,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
} }
protected boolean hintOrError(boolean isError, List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) { protected boolean hintOrError(boolean isError, List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass && !suppressMsg(path, msg)) { if (!thePass && !isSuppressedValidationMessage(path, msg)) {
String nmsg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
IssueSeverity lvl = isError ? IssueSeverity.ERROR : IssueSeverity.INFORMATION; IssueSeverity lvl = isError ? IssueSeverity.ERROR : IssueSeverity.INFORMATION;
if (doingLevel(lvl)) { if (doingLevel(lvl)) {
@ -793,7 +785,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean warning(List<ValidationMessage> errors, String ruleDate, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean warning(List<ValidationMessage> errors, String ruleDate, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(CommaSeparatedStringBuilder.join(".", pathParts), theMessage)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(CommaSeparatedStringBuilder.join(".", pathParts), theMessage)) {
String path = toPath(pathParts); String path = toPath(pathParts);
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.WARNING, theMessage); addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.WARNING, theMessage);
@ -809,7 +801,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean warning(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String msg, Object... theMessageArguments) { protected boolean warning(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(path, msg)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(path, msg)) {
String message = context.formatMessage(msg, theMessageArguments); String message = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.WARNING, null); addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.WARNING, null);
} }
@ -824,7 +816,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @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, String ruleDate, IssueType type, String path, boolean thePass, boolean warning, String msg, Object... theMessageArguments) { protected boolean warningOrHint(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, boolean warning, String msg, Object... theMessageArguments) {
if (!thePass && !suppressMsg(path, msg)) { if (!thePass && !isSuppressedValidationMessage(path, msg)) {
String message = context.formatMessage(msg, theMessageArguments); String message = context.formatMessage(msg, theMessageArguments);
IssueSeverity lvl = warning ? IssueSeverity.WARNING : IssueSeverity.INFORMATION; IssueSeverity lvl = warning ? IssueSeverity.WARNING : IssueSeverity.INFORMATION;
if (doingLevel(lvl)) { if (doingLevel(lvl)) {
@ -842,7 +834,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean warningHtml(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String msg, String html) { protected boolean warningHtml(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String msg, String html) {
if (!thePass && doingWarnings() && !suppressMsg(path, msg)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(path, msg)) {
addValidationMessage(errors, ruleDate, type, path, msg, html, IssueSeverity.WARNING, null); addValidationMessage(errors, ruleDate, type, path, msg, html, IssueSeverity.WARNING, null);
} }
return thePass; return thePass;
@ -856,7 +848,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean warningHtml(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String msg, String html, Object... theMessageArguments) { protected boolean warningHtml(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String msg, String html, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(path, msg)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(path, msg)) {
String nmsg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, ruleDate, type, path, nmsg, html, IssueSeverity.WARNING, msg); addValidationMessage(errors, ruleDate, type, path, nmsg, html, IssueSeverity.WARNING, msg);
} }
@ -872,7 +864,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean suppressedwarning(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) { protected boolean suppressedwarning(List<ValidationMessage> errors, String ruleDate, IssueType type, int line, int col, String path, boolean thePass, String msg, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(path, msg)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(path, msg)) {
String nmsg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, ruleDate, type, line, col, path, nmsg, IssueSeverity.INFORMATION, msg); addValidationMessage(errors, ruleDate, type, line, col, path, nmsg, IssueSeverity.INFORMATION, msg);
} }
@ -888,7 +880,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean suppressedwarning(List<ValidationMessage> errors, String ruleDate, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) { protected boolean suppressedwarning(List<ValidationMessage> errors, String ruleDate, IssueType type, List<String> pathParts, boolean thePass, String theMessage, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(CommaSeparatedStringBuilder.join(".", pathParts), theMessage)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(CommaSeparatedStringBuilder.join(".", pathParts), theMessage)) {
String path = toPath(pathParts); String path = toPath(pathParts);
String message = context.formatMessage(theMessage, theMessageArguments); String message = context.formatMessage(theMessage, theMessageArguments);
addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.INFORMATION, theMessage); addValidationMessage(errors, ruleDate, type, -1, -1, path, message, IssueSeverity.INFORMATION, theMessage);
@ -943,7 +935,7 @@ public class BaseValidator implements IValidationContextResourceLoader, IMessagi
* @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation) * @return Returns <code>thePass</code> (in other words, returns <code>true</code> if the rule did not fail validation)
*/ */
protected boolean suppressedwarning(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String msg, String html, Object... theMessageArguments) { protected boolean suppressedwarning(List<ValidationMessage> errors, String ruleDate, IssueType type, String path, boolean thePass, String msg, String html, Object... theMessageArguments) {
if (!thePass && doingWarnings() && !suppressMsg(path, msg)) { if (!thePass && doingWarnings() && !isSuppressedValidationMessage(path, msg)) {
String nmsg = context.formatMessage(msg, theMessageArguments); String nmsg = context.formatMessage(msg, theMessageArguments);
addValidationMessage(errors, ruleDate, type, path, nmsg, html, IssueSeverity.INFORMATION, msg); addValidationMessage(errors, ruleDate, type, path, nmsg, html, IssueSeverity.INFORMATION, msg);
} }

View File

@ -1118,7 +1118,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
timeTracker.tx(t, "vc "+system+"#"+code+" '"+display+"'"); timeTracker.tx(t, "vc "+system+"#"+code+" '"+display+"'");
if (s == null) if (s == null)
return true; return true;
ok = processTxIssues(errors, s, element, path, false, null, null) & ok; ok = calculateSeverityForIssuesAndUpdateErrors(errors, s, element, path, false, null, null) & ok;
if (s.isOk()) { if (s.isOk()) {
if (s.getMessage() != null && !s.messageIsInIssues()) { if (s.getMessage() != null && !s.messageIsInIssues()) {
@ -1375,7 +1375,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
if (cc.hasCoding()) { if (cc.hasCoding()) {
long t = System.nanoTime(); long t = System.nanoTime();
ValidationResult vr = checkCodeOnServer(stack, null, cc); ValidationResult vr = checkCodeOnServer(stack, null, cc);
bh.see(processTxIssues(errors, vr, element, path, false, null, null)); bh.see(calculateSeverityForIssuesAndUpdateErrors(errors, vr, element, path, false, null, null));
timeTracker.tx(t, "vc " + cc.toString()); timeTracker.tx(t, "vc " + cc.toString());
} }
} catch (CheckCodeOnServerException e) { } catch (CheckCodeOnServerException e) {
@ -1620,7 +1620,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} else { } else {
checked.set(true); checked.set(true);
ValidationResult vr = checkCodeOnServer(stack, valueset, cc); ValidationResult vr = checkCodeOnServer(stack, valueset, cc);
bh.see(processTxIssues(errors, vr, element, path, false, vsRef, strength)); bh.see(calculateSeverityForIssuesAndUpdateErrors(errors, vr, element, path, false, vsRef, strength));
if (!vr.isOk()) { if (!vr.isOk()) {
bindingsOk = false; bindingsOk = false;
if (vr.getErrorClass() != null && vr.getErrorClass() == TerminologyServiceErrorClass.NOSERVICE) { if (vr.getErrorClass() != null && vr.getErrorClass() == TerminologyServiceErrorClass.NOSERVICE) {
@ -1715,80 +1715,82 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
// } // }
// } // }
private boolean processTxIssues(List<ValidationMessage> errors, ValidationResult vr, Element element, String path, boolean ignoreCantInfer, String vsurl, BindingStrength bs) { private boolean calculateSeverityForIssuesAndUpdateErrors(List<ValidationMessage> errors, ValidationResult validationResult, Element element, String path, boolean ignoreCantInfer, String vsurl, BindingStrength bindingStrength) {
boolean ok = true; boolean noErrorsFound = true;
if (vr != null) { if (validationResult != null) {
for (OperationOutcomeIssueComponent iss : vr.getIssues()) { for (OperationOutcomeIssueComponent issue : validationResult.getIssues()) {
Optional<OperationOutcomeIssueComponent> processedTxIssue = processTxIssue(iss, ignoreCantInfer, bs); if (!isIgnoredTxIssueType(issue, ignoreCantInfer)) {
if (processedTxIssue.isPresent()) { OperationOutcomeIssueComponent issueWithCalculatedSeverity = getTxIssueWithCalculatedSeverity(issue, ignoreCantInfer, bindingStrength);
var vmsg = txIssue(errors, null, vr.getTxLink(), element.line(), element.col(), path, processedTxIssue.get()); var validationMessage = buildValidationMessage(validationResult.getTxLink(), element.line(), element.col(), path, issueWithCalculatedSeverity);
if (vmsg.isError()) { if (!isSuppressedValidationMessage(path, validationMessage.getMessageId())) {
ok = false; errors.add(validationMessage);
if (validationMessage.isError()) {
noErrorsFound = false;
}
} }
} }
} }
} }
return ok; return noErrorsFound;
} }
private Optional<OperationOutcomeIssueComponent> processTxIssue(OperationOutcomeIssueComponent iss, boolean ignoreCantInfer, BindingStrength bs) { private boolean isIgnoredTxIssueType(OperationOutcomeIssueComponent issueComponent, boolean ignoreCantInfer) {
if (iss.getDetails().hasCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "not-in-vs")) if (issueComponent.getDetails().hasCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "not-in-vs")) {
{ return true;
return Optional.empty();
} }
if (iss.getDetails().hasCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "this-code-not-in-vs")) if (issueComponent.getDetails().hasCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "this-code-not-in-vs")) {
{ return true;
return Optional.empty();
} }
if (ignoreCantInfer || iss.getDetails().hasCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "cannot-infer")) if (ignoreCantInfer || issueComponent.getDetails().hasCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "cannot-infer")) {
{ return true;
return Optional.empty();
} }
return false;
}
OperationOutcomeIssueComponent i = iss.copy(); private OperationOutcomeIssueComponent getTxIssueWithCalculatedSeverity(OperationOutcomeIssueComponent issueComponent, boolean ignoreCantInfer, BindingStrength bindingStrength) {
if (i.getDetails().hasCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "not-found")) { OperationOutcomeIssueComponent outIssueComponent = issueComponent.copy();
String msg = iss.getDetails().getText(); if (outIssueComponent.getDetails().hasCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "not-found")) {
boolean isHL7 = msg == null ? false : msg.contains("http://hl7.org/fhir") || msg.contains("http://terminology.hl7.org"); String text = issueComponent.getDetails().getText();
org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity notFoundLevel = null; boolean isHL7 = text == null ? false : text.contains("http://hl7.org/fhir") || text.contains("http://terminology.hl7.org");
String notFoundNote = null; org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity notFoundLevel = null;
if (bs == null) { String notFoundNote = null;
notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING; if (bindingStrength == null) {
notFoundNote = null; // "binding=null"; notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING;
} else if (bs == BindingStrength.REQUIRED && isHL7) { notFoundNote = null; // "binding=null";
notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.ERROR; } else if (bindingStrength == BindingStrength.REQUIRED && isHL7) {
notFoundNote = "error because this is a required binding to an HL7 code system"; notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.ERROR;
} else if (bs == BindingStrength.REQUIRED && unknownCodeSystemsCauseErrors) { notFoundNote = "error because this is a required binding to an HL7 code system";
notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.ERROR; } else if (bindingStrength == BindingStrength.REQUIRED && unknownCodeSystemsCauseErrors) {
notFoundNote = "error because this is a required binding"; notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.ERROR;
} else if (bs == BindingStrength.REQUIRED) { notFoundNote = "error because this is a required binding";
notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING; } else if (bindingStrength == BindingStrength.REQUIRED) {
notFoundNote = null; // "binding=required"; notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING;
} else if (bs == BindingStrength.EXTENSIBLE) { notFoundNote = null; // "binding=required";
notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING; } else if (bindingStrength == BindingStrength.EXTENSIBLE) {
notFoundNote = null; // "binding=extensible"; notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING;
} else { notFoundNote = null; // "binding=extensible";
notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING; } else {
notFoundNote = null; // "binding="+bs.toCode(); notFoundLevel = org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING;
} notFoundNote = null; // "binding="+bs.toCode();
if (notFoundLevel != null && i.getSeverity().isHigherThan(notFoundLevel)) { // && (vsurl != null && i.getDetails().getText().contains(vsurl))) { }
i.setSeverity(notFoundLevel); if (notFoundLevel != null && outIssueComponent.getSeverity().isHigherThan(notFoundLevel)) { // && (vsurl != null && i.getDetails().getText().contains(vsurl))) {
if (notFoundNote != null) { outIssueComponent.setSeverity(notFoundLevel);
i.getDetails().setText(i.getDetails().getText()+" ("+notFoundNote+")"); if (notFoundNote != null) {
} outIssueComponent.getDetails().setText(outIssueComponent.getDetails().getText() + " (" + notFoundNote + ")");
} }
} }
if (baseOptions.isDisplayWarningMode() && i.getSeverity() == org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.ERROR && i.getDetails().hasCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "invalid-display")) { }
i.setSeverity(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING); if (outIssueComponent.getDetails().hasCoding("http://hl7.org/fhir/tools/CodeSystem/tx-issue-type", "invalid-display") && baseOptions.isDisplayWarningMode() && outIssueComponent.getSeverity() == org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.ERROR) {
} outIssueComponent.setSeverity(org.hl7.fhir.r5.model.OperationOutcome.IssueSeverity.WARNING);
return Optional.of(i); }
return outIssueComponent;
} }
public boolean checkBindings(List<ValidationMessage> errors, String path, Element element, NodeStack stack, ValueSet valueset, Coding nextCoding) { public boolean checkBindings(List<ValidationMessage> errors, String path, Element element, NodeStack stack, ValueSet valueset, Coding nextCoding) {
boolean ok = true; boolean ok = true;
if (isNotBlank(nextCoding.getCode()) && isNotBlank(nextCoding.getSystem()) && context.supportsSystem(nextCoding.getSystem(), baseOptions.getFhirVersion())) { if (isNotBlank(nextCoding.getCode()) && isNotBlank(nextCoding.getSystem()) && context.supportsSystem(nextCoding.getSystem(), baseOptions.getFhirVersion())) {
ValidationResult vr = checkCodeOnServer(stack, valueset, nextCoding); ValidationResult vr = checkCodeOnServer(stack, valueset, nextCoding);
ok = processTxIssues(errors, vr, element, path, false, null, null) && ok; ok = calculateSeverityForIssuesAndUpdateErrors(errors, vr, element, path, false, null, null) && ok;
if (vr.getSeverity() != null && !vr.messageIsInIssues()) { if (vr.getSeverity() != null && !vr.messageIsInIssues()) {
if (vr.getSeverity() == IssueSeverity.INFORMATION) { if (vr.getSeverity() == IssueSeverity.INFORMATION) {
@ -1919,7 +1921,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
if (strength == BindingStrength.REQUIRED) { if (strength == BindingStrength.REQUIRED) {
removeTrackedMessagesForLocation(errors, element, path); removeTrackedMessagesForLocation(errors, element, path);
} }
ok = processTxIssues(errors, vr, element, path, false, vsRef, strength) && ok; ok = calculateSeverityForIssuesAndUpdateErrors(errors, vr, element, path, false, vsRef, strength) && ok;
timeTracker.tx(t, "vc "+system+"#"+code+" '"+display+"'"); timeTracker.tx(t, "vc "+system+"#"+code+" '"+display+"'");
if (vr != null && !vr.isOk()) { if (vr != null && !vr.isOk()) {
if (vr.IsNoService()) if (vr.IsNoService())
@ -2064,7 +2066,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
try { try {
long t = System.nanoTime(); long t = System.nanoTime();
ValidationResult vr = checkCodeOnServer(stack, valueset, cc); ValidationResult vr = checkCodeOnServer(stack, valueset, cc);
ok = processTxIssues(errors, vr, element, path, false, maxVSUrl, null) && ok; ok = calculateSeverityForIssuesAndUpdateErrors(errors, vr, element, path, false, maxVSUrl, null) && ok;
timeTracker.tx(t, "vc "+cc.toString()); timeTracker.tx(t, "vc "+cc.toString());
if (!vr.isOk()) { if (!vr.isOk()) {
if (vr.getErrorClass() != null && vr.getErrorClass().isInfrastructure()) if (vr.getErrorClass() != null && vr.getErrorClass().isInfrastructure())
@ -2103,7 +2105,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
try { try {
long t = System.nanoTime(); long t = System.nanoTime();
ValidationResult vr = checkCodeOnServer(stack, valueset, c); ValidationResult vr = checkCodeOnServer(stack, valueset, c);
ok = processTxIssues(errors, vr, element, path, false, maxVSUrl, null) && ok; ok = calculateSeverityForIssuesAndUpdateErrors(errors, vr, element, path, false, maxVSUrl, null) && ok;
timeTracker.tx(t, "vc "+c.getSystem()+"#"+c.getCode()+" '"+c.getDisplay()+"'"); timeTracker.tx(t, "vc "+c.getSystem()+"#"+c.getCode()+" '"+c.getDisplay()+"'");
if (!vr.isOk()) { if (!vr.isOk()) {
@ -2134,7 +2136,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
try { try {
long t = System.nanoTime(); long t = System.nanoTime();
ValidationResult vr = checkCodeOnServer(stack, valueset, value, baseOptions); ValidationResult vr = checkCodeOnServer(stack, valueset, value, baseOptions);
ok = processTxIssues(errors, vr, element, path, false, maxVSUrl, null) && ok; ok = calculateSeverityForIssuesAndUpdateErrors(errors, vr, element, path, false, maxVSUrl, null) && ok;
timeTracker.tx(t, "vc "+value); timeTracker.tx(t, "vc "+value);
if (!vr.isOk()) { if (!vr.isOk()) {
if (vr.getErrorClass() != null && vr.getErrorClass().isInfrastructure()) if (vr.getErrorClass() != null && vr.getErrorClass().isInfrastructure())
@ -2269,7 +2271,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
checked.set(true); checked.set(true);
vr = checkCodeOnServer(stack, valueset, c); vr = checkCodeOnServer(stack, valueset, c);
} }
ok = processTxIssues(errors, vr, element, path, strength == BindingStrength.EXTENSIBLE, vsRef, strength) && ok; ok = calculateSeverityForIssuesAndUpdateErrors(errors, vr, element, path, strength == BindingStrength.EXTENSIBLE, vsRef, strength) && ok;
timeTracker.tx(t, "vc "+c.getSystem()+"#"+c.getCode()+" '"+c.getDisplay()+"'"); timeTracker.tx(t, "vc "+c.getSystem()+"#"+c.getCode()+" '"+c.getDisplay()+"'");
if (strength == BindingStrength.REQUIRED) { if (strength == BindingStrength.REQUIRED) {
@ -3744,7 +3746,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} }
vr = checkCodeOnServer(stack, vs, value, options); vr = checkCodeOnServer(stack, vs, value, options);
} }
ok = processTxIssues(errors, vr, element, path, binding.getStrength() != BindingStrength.REQUIRED, binding.getValueSet(), binding.getStrength()) && ok; ok = calculateSeverityForIssuesAndUpdateErrors(errors, vr, element, path, binding.getStrength() != BindingStrength.REQUIRED, binding.getValueSet(), binding.getStrength()) && ok;
timeTracker.tx(t, "vc "+value+""); timeTracker.tx(t, "vc "+value+"");
if (binding.getStrength() == BindingStrength.REQUIRED) { if (binding.getStrength() == BindingStrength.REQUIRED) {