fix for R2B validation of resource ids, and problems validating codes

This commit is contained in:
Grahame Grieve 2021-04-02 06:24:43 +11:00
parent 91e31e813f
commit 11f66836ed
6 changed files with 25 additions and 4 deletions

View File

@ -73,6 +73,19 @@
<optional>true</optional>
</dependency>
<!-- HTTP Client -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.0</version>
<optional>true</optional>
</dependency>
<!-- JUnit Jupiter -->
<dependency>
<groupId>org.junit.jupiter</groupId>

View File

@ -177,7 +177,9 @@ public class StructureDefinition14_50 {
if (src.hasDifferential()) {
if (src.hasDifferential())
tgt.setDifferential(convertStructureDefinitionDifferentialComponent(src.getDifferential()));
tgt.getDifferential().getElementFirstRep().getType().clear();
if (!tgt.getDifferential().getElementFirstRep().getPath().contains(".")) {
tgt.getDifferential().getElementFirstRep().getType().clear();
}
}
if (tgt.getDerivation() == TypeDerivationRule.SPECIALIZATION) {
for (ElementDefinition ed : tgt.getSnapshot().getElement()) {

View File

@ -149,7 +149,11 @@ public class ValueSetCheckerSimple implements ValueSetChecker {
if (cs == null) {
warningMessage = "Unable to resolve system "+system;
if (!inExpansion) {
throw new FHIRException(warningMessage);
if (valueset.hasExpansion()) {
return new ValidationResult(IssueSeverity.ERROR, context.formatMessage(I18nConstants.CODESYSTEM_CS_UNK_EXPANSION, valueset.getUrl(), code.getCode().toString(), code.getSystem()));
} else {
throw new FHIRException(warningMessage);
}
}
}
if (cs != null && cs.hasSupplements()) {

View File

@ -53,6 +53,7 @@ public class I18nConstants {
public static final String CODESYSTEM_CS_NO_SUPPLEMENT = "CODESYSTEM_CS_NO_SUPPLEMENT";
public static final String CODESYSTEM_CS_SUPP_CANT_CHECK = "CODESYSTEM_CS_SUPP_CANT_CHECK";
public static final String CODESYSTEM_CS_SUPP_INVALID_CODE = "CODESYSTEM_CS_SUPP_INVALID_CODE";
public static final String CODESYSTEM_CS_UNK_EXPANSION = "CODESYSTEM_CS_UNK_EXPANSION";
public static final String CODE_FOUND_IN_EXPANSION_HOWEVER_ = "Code_found_in_expansion_however_";
public static final String CODING_HAS_NO_SYSTEM__CANNOT_VALIDATE = "Coding_has_no_system__cannot_validate";
public static final String CONTAINED_RESOURCE_DOES_NOT_APPEAR_TO_BE_A_FHIR_RESOURCE_UNKNOWN_NAME_ = "Contained_resource_does_not_appear_to_be_a_FHIR_resource_unknown_name_";

View File

@ -641,3 +641,4 @@ CODESYSTEM_CS_SUPP_CANT_CHECK = CodeSystem {0} cannot be found, so can't check i
CODESYSTEM_CS_SUPP_INVALID_CODE = The code ''{1}'' is not declared in the base CodeSystem {0} so is not valid in the supplement
SD_VALUE_TYPE_IILEGAL = The element {0} has a {1} of type {2}, which is not in the list of allowed types ({3})
SD_NO_TYPES_OR_CONTENTREF = The element {0} has no assigned types, and no content reference
CODESYSTEM_CS_UNK_EXPANSION = The code provided ({2}) is not in the value set {0}, and a code is required from this value set. The system {1} is unknown.

View File

@ -2002,7 +2002,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
}
if (type.equals(ID)) {
// work around an old issue with ElementDefinition.id
if (!context.getPath().equals("ElementDefinition.id") && !VersionUtilities.versionsCompatible("1.4", this.context.getVersion())) {
if (!context.getPath().equals("ElementDefinition.id") || VersionUtilities.versionsCompatible("1.4", this.context.getVersion())) {
rule(errors, IssueType.INVALID, e.line(), e.col(), path, FormatUtilities.isValidId(e.primitiveValue()), I18nConstants.TYPE_SPECIFIC_CHECKS_DT_ID_VALID, e.primitiveValue());
}
}
@ -4327,7 +4327,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
}
if (ei.definition != null) {
if (debug) {
System.out.println(Utilities.padLeft("", ' ', stack.depth())+ "Check "+ei.getPath()+" against defn "+ei.definition.getId());
System.out.println(Utilities.padLeft("", ' ', stack.depth())+ "Check "+ei.getPath()+" against defn "+ei.definition.getId()+" from "+profile.getUrl());
}
checkChildByDefinition(hostContext, errors, profile, definition, resource, element, actualType, stack, inCodeableConcept, checkDisplayInContext, ei, extensionUrl, ei.definition, false);
}