#357: fix bug looking for contained resources inside bundles

This commit is contained in:
Grahame Grieve 2021-12-17 14:38:21 +11:00
parent 47dd580868
commit e4d3047138
3 changed files with 20 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Validator:
* check StructureDefinition derivation consistency
* fix bug looking for contained resources inside bundles
Other code changes:
* Add support for new FHIR releases

View File

@ -10036,6 +10036,7 @@ The primary difference between a medication statement and a medication administr
* R4B - manually added
*/
_4_1_0,
_4_3_0_SNAPSHOT1,
_4_3_0_CIBUILD,
NULL;
public static FHIRVersion fromCode(String codeString) throws FHIRException {
@ -10089,6 +10090,8 @@ The primary difference between a medication statement and a medication administr
return _4_0_1;
if ("4.1.0".equals(codeString))
return _4_1_0;
if ("4.3.0-snapshot1".equals(codeString))
return _4_3_0_SNAPSHOT1;
if ("4.3.0-cibuild".equals(codeString))
return _4_3_0_CIBUILD;
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
@ -10123,6 +10126,7 @@ The primary difference between a medication statement and a medication administr
case _4_0_0: return "4.0.0";
case _4_0_1: return "4.0.1";
case _4_1_0: return "4.1.0";
case _4_3_0_SNAPSHOT1: return "4.3.0-snapshot1";
case _4_3_0_CIBUILD: return "4.3.0-cibuild";
case NULL: return null;
@ -10155,6 +10159,7 @@ The primary difference between a medication statement and a medication administr
case _4_0_0: return "http://hl7.org/fhir/FHIR-version";
case _4_0_1: return "http://hl7.org/fhir/FHIR-version";
case _4_1_0: return "http://hl7.org/fhir/FHIR-version";
case _4_3_0_SNAPSHOT1: return "http://hl7.org/fhir/FHIR-version";
case _4_3_0_CIBUILD: return "http://hl7.org/fhir/FHIR-version";
case NULL: return null;
default: return "?";
@ -10186,6 +10191,7 @@ The primary difference between a medication statement and a medication administr
case _4_0_0: return "FHIR Release 4 (Normative + STU).";
case _4_0_1: return "FHIR Release 4 Technical Correction #1.";
case _4_1_0: return "FHIR Release 4B Ballot #1";
case _4_3_0_SNAPSHOT1: return "FHIR Release 4B Snapshot #1";
case _4_3_0_CIBUILD: return "FHIR Release 4B CI-Builld";
case NULL: return null;
default: return "?";
@ -10217,6 +10223,7 @@ The primary difference between a medication statement and a medication administr
case _4_0_0: return "4.0.0";
case _4_0_1: return "4.0.1";
case _4_1_0: return "4.1.0";
case _4_3_0_SNAPSHOT1: return "4.3.0-snapshot";
case _4_3_0_CIBUILD: return "4.3.0-cibuild";
case NULL: return null;
default: return "?";
@ -10283,6 +10290,8 @@ The primary difference between a medication statement and a medication administr
return FHIRVersion._4_0_1;
if ("4.1.0".equals(codeString))
return FHIRVersion._4_1_0;
if ("4.3.0-snapshot1".equals(codeString))
return FHIRVersion._4_3_0_SNAPSHOT1;
if ("4.3.0-cibuild".equals(codeString))
return FHIRVersion._4_3_0_CIBUILD;
throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'");
@ -10343,6 +10352,8 @@ The primary difference between a medication statement and a medication administr
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_0_1);
if ("4.1.0".equals(codeString))
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_1_0);
if ("4.3.0-snapshot1".equals(codeString))
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_3_0_SNAPSHOT1);
if ("4.3.0-cibuild".equals(codeString))
return new Enumeration<FHIRVersion>(this, FHIRVersion._4_3_0_CIBUILD);
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
@ -10396,6 +10407,8 @@ The primary difference between a medication statement and a medication administr
return "4.0.1";
if (code == FHIRVersion._4_1_0)
return "4.1.0";
if (code == FHIRVersion._4_3_0_SNAPSHOT1)
return "4.3.0-snapshot1";
if (code == FHIRVersion._4_3_0_CIBUILD)
return "4.3.0-cibuild";
return "?";

View File

@ -304,8 +304,10 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
}
} else if (item instanceof Element) {
Element e = (Element) item;
if (e.getSpecial() != null) {
if (e.getSpecial() == SpecialElement.CONTAINED) {
self.validateResource(new ValidatorHostContext(ctxt.getAppContext(), e, ctxt.getRootResource()), valerrors, e, e, sd, IdStatus.OPTIONAL, new NodeStack(context, null, e, validationLanguage));
} else if (e.getSpecial() != null) {
self.validateResource(new ValidatorHostContext(ctxt.getAppContext(), e), valerrors, e, e, sd, IdStatus.OPTIONAL, new NodeStack(context, null, e, validationLanguage));
} else {
self.validateResource(new ValidatorHostContext(ctxt.getAppContext(), e), valerrors, e, e, sd, IdStatus.OPTIONAL, new NodeStack(context, null, e, validationLanguage));
}
@ -1312,7 +1314,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
String system = c.getSystem();
String display = c.getDisplay();
String version = c.getVersion();
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, isCodeSystemReferenceValid(system), I18nConstants.TERMINOLOGY_TX_SYSTEM_RELATIVE);
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, system == null || isCodeSystemReferenceValid(system), I18nConstants.TERMINOLOGY_TX_SYSTEM_RELATIVE);
if (system != null && code != null && !noTerminologyChecks) {
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, !isValueSet(system), I18nConstants.TERMINOLOGY_TX_SYSTEM_VALUESET2, system);
@ -1568,7 +1570,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
private void checkCodedElement(List<ValidationMessage> errors, String path, Element element, StructureDefinition profile, ElementDefinition theElementCntext, boolean inCodeableConcept, boolean checkDisplay, NodeStack stack,
String theCode, String theSystem, String theVersion, String theDisplay) {
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, isCodeSystemReferenceValid(theSystem), I18nConstants.TERMINOLOGY_TX_SYSTEM_RELATIVE);
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, theSystem == null || isCodeSystemReferenceValid(theSystem), I18nConstants.TERMINOLOGY_TX_SYSTEM_RELATIVE);
warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, Utilities.noString(theCode) || !Utilities.noString(theSystem), I18nConstants.TERMINOLOGY_TX_SYSTEM_NO_CODE);
if (theSystem != null && theCode != null && !noTerminologyChecks) {
@ -2023,7 +2025,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
private void checkIdentifier(List<ValidationMessage> errors, String path, Element element, ElementDefinition context) {
String system = element.getNamedChildValue("system");
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, isIdentifierSystemReferenceValid(system), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_IDENTIFIER_SYSTEM);
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, system == null || isIdentifierSystemReferenceValid(system), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_IDENTIFIER_SYSTEM);
if ("urn:ietf:rfc:3986".equals(system)) {
String value = element.getNamedChildValue("value");
rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, isAbsolute(value), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_IDENTIFIER_IETF_SYSTEM_VALUE);