pick up missing hints and warnings on terminology fields
This commit is contained in:
parent
7166d55153
commit
4a85513acb
|
@ -1298,8 +1298,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (vr.getMessage() != null) {
|
} else if (vr.getMessage() != null) {
|
||||||
|
if (vr.getSeverity() == IssueSeverity.INFORMATION) {
|
||||||
|
txHint(errors, "2023-07-03", vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, vr.getMessage());
|
||||||
|
} else {
|
||||||
res = false;
|
res = false;
|
||||||
txWarning(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, vr.getMessage());
|
txWarning(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, vr.getMessage());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (binding.getStrength() == BindingStrength.EXTENSIBLE) {
|
if (binding.getStrength() == BindingStrength.EXTENSIBLE) {
|
||||||
removeTrackedMessagesForLocation(errors, element, path);
|
removeTrackedMessagesForLocation(errors, element, path);
|
||||||
|
@ -1426,7 +1430,11 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
} else if (vr.getMessage() != null) {
|
} else if (vr.getMessage() != null) {
|
||||||
res = false;
|
res = false;
|
||||||
|
if (vr.getSeverity() == IssueSeverity.INFORMATION) {
|
||||||
|
txHint(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, vr.getMessage());
|
||||||
|
} else {
|
||||||
txWarning(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, vr.getMessage());
|
txWarning(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, vr.getMessage());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
res = false;
|
res = false;
|
||||||
}
|
}
|
||||||
|
@ -1533,6 +1541,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
txHint(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_NOVALID_6, describeReference(binding.getValueSet(), valueset), (vr.getMessage() != null ? " (error message = " + vr.getMessage() + ")" : ""), system+"#"+code);
|
txHint(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_NOVALID_6, describeReference(binding.getValueSet(), valueset), (vr.getMessage() != null ? " (error message = " + vr.getMessage() + ")" : ""), system+"#"+code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (vr != null && vr.getMessage() != null){
|
||||||
|
if (vr.getSeverity() == IssueSeverity.INFORMATION) {
|
||||||
|
txHint(errors, "2023-07-04", vr.getTxLink(), IssueType.INFORMATIONAL, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_HINT, code, vr.getMessage());
|
||||||
|
} else {
|
||||||
|
txWarning(errors, "2023-07-04", vr.getTxLink(), IssueType.INFORMATIONAL, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_WARNING, code, vr.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (STACK_TRACE) e.printStackTrace();
|
if (STACK_TRACE) e.printStackTrace();
|
||||||
|
@ -1813,8 +1827,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (vr != null && vr.getMessage() != null) {
|
} else if (vr != null && vr.getMessage() != null) {
|
||||||
|
if (vr.getSeverity() == IssueSeverity.INFORMATION) {
|
||||||
|
txHint(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, vr.getMessage());
|
||||||
|
} else {
|
||||||
txWarning(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, vr.getMessage());
|
txWarning(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, vr.getMessage());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (STACK_TRACE) e.printStackTrace();
|
if (STACK_TRACE) e.printStackTrace();
|
||||||
warning(errors, NO_RULE_DATE, IssueType.CODEINVALID, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_ERROR_CODING1, e.getMessage());
|
warning(errors, NO_RULE_DATE, IssueType.CODEINVALID, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_ERROR_CODING1, e.getMessage());
|
||||||
|
@ -1908,7 +1926,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
// two questions
|
// two questions
|
||||||
// 1. can this extension be used here?
|
// 1. can this extension be used here?
|
||||||
checkExtensionContext(errors, resource, container, ex, containerStack, hostContext, isModifier);
|
checkExtensionContext(hostContext.getAppContext(), errors, resource, container, ex, containerStack, hostContext, isModifier);
|
||||||
|
|
||||||
if (isModifier)
|
if (isModifier)
|
||||||
rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, element.line(), element.col(), path + "[url='" + url + "']", ex.getSnapshot().getElement().get(0).getIsModifier(), I18nConstants.EXTENSION_EXT_MODIFIER_Y, url);
|
rule(errors, NO_RULE_DATE, IssueType.STRUCTURE, element.line(), element.col(), path + "[url='" + url + "']", ex.getSnapshot().getElement().get(0).getIsModifier(), I18nConstants.EXTENSION_EXT_MODIFIER_Y, url);
|
||||||
|
@ -1979,7 +1997,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkExtensionContext(List<ValidationMessage> errors, Element resource, Element container, StructureDefinition definition, NodeStack stack, ValidatorHostContext hostContext, boolean modifier) {
|
private boolean checkExtensionContext(Object appContext, List<ValidationMessage> errors, Element resource, Element container, StructureDefinition definition, NodeStack stack, ValidatorHostContext hostContext, boolean modifier) {
|
||||||
String extUrl = definition.getUrl();
|
String extUrl = definition.getUrl();
|
||||||
boolean ok = false;
|
boolean ok = false;
|
||||||
CommaSeparatedStringBuilder contexts = new CommaSeparatedStringBuilder();
|
CommaSeparatedStringBuilder contexts = new CommaSeparatedStringBuilder();
|
||||||
|
@ -2002,11 +2020,17 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
if (ctxt.getType() == ExtensionContextType.ELEMENT) {
|
if (ctxt.getType() == ExtensionContextType.ELEMENT) {
|
||||||
String en = ctxt.getExpression();
|
String en = ctxt.getExpression();
|
||||||
contexts.append("e:" + en);
|
contexts.append("e:" + en);
|
||||||
|
String pu = null;
|
||||||
|
if (en.contains("#")) {
|
||||||
|
pu = en.substring(0, en.indexOf("#"));
|
||||||
|
en = en.substring(en.indexOf("#")+1);
|
||||||
|
}
|
||||||
if (Utilities.existsInList(en, "Element", "Any")) {
|
if (Utilities.existsInList(en, "Element", "Any")) {
|
||||||
ok = true;
|
ok = true;
|
||||||
} else if (en.equals("Resource") && container.isResource()) {
|
} else if (en.equals("Resource") && container.isResource()) {
|
||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
|
if (checkConformsToProfile(appContext, errors, resource, container, stack, extUrl, ctxt.getExpression(), pu)) {
|
||||||
for (String p : plist) {
|
for (String p : plist) {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
break;
|
break;
|
||||||
|
@ -2034,6 +2058,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (ctxt.getType() == ExtensionContextType.EXTENSION) {
|
} else if (ctxt.getType() == ExtensionContextType.EXTENSION) {
|
||||||
contexts.append("x:" + ctxt.getExpression());
|
contexts.append("x:" + ctxt.getExpression());
|
||||||
String ext = null;
|
String ext = null;
|
||||||
|
@ -2088,6 +2113,36 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkConformsToProfile(Object appContext, List<ValidationMessage> errors, Element resource, Element container, NodeStack stack, String extUrl, String expression, String pu) {
|
||||||
|
if (pu == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (pu.equals("http://hl7.org/fhir/StructureDefinition/"+resource.fhirType())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
StructureDefinition sd = context.fetchResource(StructureDefinition.class, pu);
|
||||||
|
if (!rule(errors, "2023-07-03", IssueType.UNKNOWN, container.line(), container.col(), stack.getLiteralPath(), sd != null,I18nConstants.EXTENSION_CONTEXT_UNABLE_TO_FIND_PROFILE, extUrl, expression)) {
|
||||||
|
return false;
|
||||||
|
} else if (sd.getType().equals(resource.fhirType())) {
|
||||||
|
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||||
|
ValidationMode mode = new ValidationMode(ValidationReason.Expression, ProfileSource.FromExpression);
|
||||||
|
validateResource(new ValidatorHostContext(appContext, resource), valerrors, resource, resource, sd, IdStatus.OPTIONAL, new NodeStack(context, null, resource, validationLanguage), null, mode);
|
||||||
|
boolean ok = true;
|
||||||
|
List<ValidationMessage> record = new ArrayList<>();
|
||||||
|
for (ValidationMessage v : valerrors) {
|
||||||
|
ok = ok && !v.getLevel().isError();
|
||||||
|
if (v.getLevel().isError() || v.isSlicingHint()) {
|
||||||
|
record.add(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
} else {
|
||||||
|
warning(errors, "2023-07-03", IssueType.UNKNOWN, container.line(), container.col(), stack.getLiteralPath(), false,
|
||||||
|
I18nConstants.EXTENSION_CONTEXT_UNABLE_TO_CHECK_PROFILE, extUrl, expression, pu);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<StructureDefinitionContextComponent> fixContexts(String extUrl, List<StructureDefinitionContextComponent> list) {
|
private List<StructureDefinitionContextComponent> fixContexts(String extUrl, List<StructureDefinitionContextComponent> list) {
|
||||||
List<StructureDefinitionContextComponent> res = new ArrayList<>();
|
List<StructureDefinitionContextComponent> res = new ArrayList<>();
|
||||||
for (StructureDefinitionContextComponent ctxt : list) {
|
for (StructureDefinitionContextComponent ctxt : list) {
|
||||||
|
@ -3053,6 +3108,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
txHint(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_NOVALID_18, value, describeReference(binding.getValueSet(), vs), getErrorMessage(vr.getMessage()));
|
txHint(errors, NO_RULE_DATE, vr.getTxLink(), IssueType.CODEINVALID, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_NOVALID_18, value, describeReference(binding.getValueSet(), vs), getErrorMessage(vr.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (vr != null && vr.getMessage() != null){
|
||||||
|
if (vr.getSeverity() == IssueSeverity.INFORMATION) {
|
||||||
|
txHint(errors, "2023-07-04", vr.getTxLink(), IssueType.INFORMATIONAL, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_HINT, value, vr.getMessage());
|
||||||
|
} else {
|
||||||
|
txWarning(errors, "2023-07-04", vr.getTxLink(), IssueType.INFORMATIONAL, element.line(), element.col(), path, false, I18nConstants.TERMINOLOGY_TX_WARNING, value, vr.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue