Change validator so that it marks value properties in primitive data types as illegal

This commit is contained in:
Grahame Grieve 2024-02-28 12:22:33 +11:00
parent f22316d55f
commit da56e4296b
7 changed files with 40 additions and 245 deletions

View File

@ -18,6 +18,7 @@
* Fix where validator was ignoring minimum cardinality for XML attributes (especially in CDA)
* Improved ConceptMap validation
* Updated IG versions used for -cda and -ccda CLI validation options.
* Change validator so that it marks value properties in primitive data types as illegal
## Other code changes
@ -32,3 +33,8 @@
* Fix wrong URLs rendering Profiles and Questionnaires
* Fix bug using wrong version constant for R3
* Updates for R5 StructureMap syntax
* Support for case sensitive Code system tests
* Add TurtleGeneratorTests for R5
* Introduce new validator cliContext option disableDefaultResourceFetcher (#1526)
* Render contained resources when rendering Patient resources
* Fix bug in FML Parser

View File

@ -1059,6 +1059,7 @@ public class I18nConstants {
public static final String VALUESET_INCLUDE_CSVER_MULTI_FOUND = "VALUESET_INCLUDE_CSVER_MULTI_FOUND";
public static final String UNABLE_TO_INFER_CODESYSTEM = "UNABLE_TO_INFER_CODESYSTEM";
public static final String CODE_CASE_DIFFERENCE = "CODE_CASE_DIFFERENCE";
public static final String ILLEGAL_PROPERTY = "ILLEGAL_PROPERTY";
}

View File

@ -1117,3 +1117,4 @@ VALUESET_INCLUDE_CS_MULTI_FOUND = Multiple matching contained code systems found
VALUESET_INCLUDE_CSVER_MULTI_FOUND = Multiple matching contained code systems found for system ''{0}'' version ''{1}''
CODE_CASE_DIFFERENCE = The code ''{0}'' differs from the correct code ''{1}'' by case. Although the code system ''{2}'' is case insensitive, implementers are strongly encouraged to use the correct case anyway
SCT_NO_MRCM = Not validated against the Machine Readable Concept Model (MRCM)
ILLEGAL_PROPERTY = The property ''{0}'' is invalid

View File

@ -2627,6 +2627,12 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
private boolean checkPrimitive(ValidationContext valContext, List<ValidationMessage> errors, String path, String type, ElementDefinition context, Element e, StructureDefinition profile, NodeStack node, NodeStack parentNode, Element resource) throws FHIRException {
boolean ok = true;
// sanity check. The only children allowed are id and extension, but value might slip through in some circumstances.
for (Element child : e.getChildren()) {
ok = rule(errors, "2024-02-28", IssueType.INVALID, child.line(), child.col(), path, !"value".equals(child.getName()), I18nConstants.ILLEGAL_PROPERTY, "value") && ok;
}
if (isBlank(e.primitiveValue())) {
if (e.primitiveValue() == null)
ok = rule(errors, NO_RULE_DATE, IssueType.INVALID, e.line(), e.col(), path, e.hasChildren(), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_PRIMITIVE_VALUEEXT) && ok;
@ -6116,7 +6122,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
}
childDefinitions = getActualTypeChildren(valContext, element, actualType);
} else if (definition.getType().size() > 1) {
// this only happens when the profile constrains the abstract children but leaves th choice open.
// this only happens when the profile constrains the abstract children but leaves the choice open.
if (actualType == null) {
vi.setValid(false);
return false; // there'll be an error elsewhere in this case, and we're going to stop.

View File

@ -1,4 +1,4 @@
package org.hl7.fhir.r5.test;
package org.hl7.fhir.validation.tests;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;

View File

@ -20,7 +20,7 @@
<properties>
<guava_version>32.0.1-jre</guava_version>
<hapi_fhir_version>6.4.1</hapi_fhir_version>
<validator_test_case_version>1.4.29-SNAPSHOT</validator_test_case_version>
<validator_test_case_version>1.5.0-SNAPSHOT</validator_test_case_version>
<jackson_version>2.16.0</jackson_version>
<junit_jupiter_version>5.9.2</junit_jupiter_version>
<junit_platform_launcher_version>1.8.2</junit_platform_launcher_version>