track hint about code validation

This commit is contained in:
Grahame Grieve 2022-11-10 05:16:10 +11:00
parent b7a882114d
commit 21b0577249
4 changed files with 26 additions and 2 deletions

View File

@ -609,6 +609,26 @@ public class ToolingExtensions {
resource.getExtension().add(new Extension(uri).setValue(new StringType(value)));
}
public static void setUriExtension(DomainResource resource, String uri, String value) {
if (Utilities.noString(value))
return;
Extension ext = getExtension(resource, uri);
if (ext != null)
ext.setValue(new UriType(value));
else
resource.getExtension().add(new Extension(uri).setValue(new UriType(value)));
}
public static void setUriExtension(Element resource, String uri, String value) {
if (Utilities.noString(value))
return;
Extension ext = getExtension(resource, uri);
if (ext != null)
ext.setValue(new UriType(value));
else
resource.getExtension().add(new Extension(uri).setValue(new UriType(value)));
}
public static void setCodeExtension(DomainResource resource, String uri, String value) {
if (Utilities.noString(value))
return;

View File

@ -794,5 +794,5 @@ SD_TYPE_NOT_LOCAL = The type {0} is not legal because it is not defined in the F
SD_TYPE_NOT_LOGICAL = The type {0} can only be defined if the kind is 'logical' not {1}
SD_CONSTRAINED_TYPE_NO_MATCH = The type {0} must be the same as the type in the base structure {1} that is being constrained
SD_SPECIALIZED_TYPE_MATCHES = The type {0} must not be the same as the type in the base structure {1} that is being specialised
SD_CONSTRAINED_KIND_NO_MATCH = The kind {0} must be the same as the kind {1} in the base structure {2}
SD_CONSTRAINED_KIND_NO_MATCH = The kind {0} must be the same as the kind {1} in the base structure {3} (base type = {2})
SD_PATH_TYPE_MISMATCH = The path {1} must start with the type of the structure {0}

View File

@ -32,6 +32,7 @@ import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.VersionUtilities;
import org.hl7.fhir.utilities.i18n.I18nConstants;
import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity;
import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType;
import org.hl7.fhir.utilities.validation.ValidationMessage.Source;
import org.hl7.fhir.utilities.validation.ValidationOptions;
@ -564,6 +565,8 @@ public class QuestionnaireValidator extends BaseValidator {
ok = txRule(errors, res.getTxLink(), IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, I18nConstants.QUESTIONNAIRE_QR_ITEM_BADOPTION, c.getSystem(), c.getCode()) && ok;
} else if (res.getSeverity() != null) {
super.addValidationMessage(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), res.getMessage(), res.getSeverity(), Source.TerminologyEngine, null);
} else if (res.getMessage() != null) {
super.addValidationMessage(errors, IssueType.INFORMATIONAL, value.line(), value.col(), stack.getLiteralPath(), res.getMessage(), res.getSeverity() == null ? IssueSeverity.INFORMATION : res.getSeverity(), Source.TerminologyEngine, null);
}
} catch (Exception e) {
warning(errors, IssueType.CODEINVALID, value.line(), value.col(), stack.getLiteralPath(), false, I18nConstants.QUESTIONNAIRE_QR_ITEM_CODING, e.getMessage());

View File

@ -78,7 +78,8 @@ public class StructureDefinitionValidator extends BaseValidator {
StructureDefinition base = context.fetchResource(StructureDefinition.class, sd.getBaseDefinition());
if (warning(errors, IssueType.NOTFOUND, stack.getLiteralPath(), base != null, I18nConstants.UNABLE_TO_FIND_BASE__FOR_, sd.getBaseDefinition(), "StructureDefinition, so can't check the differential")) {
if (rule(errors, IssueType.NOTFOUND, stack.getLiteralPath(), sd.hasDerivation(), I18nConstants.SD_MUST_HAVE_DERIVATION, sd.getUrl())) {
rule(errors, IssueType.NOTFOUND, stack.getLiteralPath(), base.getAbstract() || sd.hasKind() && sd.getKind() == base.getKind(), I18nConstants.SD_CONSTRAINED_KIND_NO_MATCH, sd.getKind().toCode(), base.getKind().toCode(), base.getType());
boolean bok = base.getAbstract() || sd.hasKind() && sd.getKind() == base.getKind();
rule(errors, IssueType.NOTFOUND, stack.getLiteralPath(), bok, I18nConstants.SD_CONSTRAINED_KIND_NO_MATCH, sd.getKind().toCode(), base.getKind().toCode(), base.getType(), base.getUrl());
if (sd.getDerivation() == TypeDerivationRule.CONSTRAINT) {
rule(errors, IssueType.NOTFOUND, stack.getLiteralPath(), sd.hasType() && sd.getType().equals(base.getType()), I18nConstants.SD_CONSTRAINED_TYPE_NO_MATCH, sd.getType(), base.getType());
List<ValidationMessage> msgs = new ArrayList<>();