try again

This commit is contained in:
Grahame Grieve 2024-05-31 09:59:00 +10:00
parent 3dfbba0ec9
commit df711c0762
4 changed files with 107 additions and 7 deletions

View File

@ -35,7 +35,7 @@ import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
import org.hl7.fhir.r5.model.Coding;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.UsageContext;
import org.hl7.fhir.r5.utils.validation.constants.RuleImplementationLevel;
import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel;
import org.hl7.fhir.r5.utils.validation.constants.CheckDisplayOption;
import org.hl7.fhir.r5.utils.validation.constants.IdStatus;
import org.hl7.fhir.utilities.json.model.JsonObject;
@ -70,11 +70,8 @@ public interface IResourceValidator {
* whether the validator should enforce best practice guidelines
* as defined by various HL7 committees
*/
RuleImplementationLevel getBestPracticeWarningLevel();
IResourceValidator setBestPracticeWarningLevel(RuleImplementationLevel value);
RuleImplementationLevel getVitalSignsProfileCheckLevel();
IResourceValidator setVitalSignsProfileCheckLevel(RuleImplementationLevel value);
BestPracticeWarningLevel getBestPracticeWarningLevel();
IResourceValidator setBestPracticeWarningLevel(BestPracticeWarningLevel value);
IValidatorResourceFetcher getFetcher();
IResourceValidator setFetcher(IValidatorResourceFetcher value);

View File

@ -9,6 +9,8 @@ import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.utils.validation.constants.ContainedReferenceValidationPolicy;
import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy;
import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.validation.instance.BasePolicyAdvisorForMandatoryProfiles;
import org.hl7.fhir.r5.utils.validation.constants.CodedContentValidationPolicy;
import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor.ElementValidationAction;
import org.hl7.fhir.r5.utils.validation.constants.BindingKind;
@ -131,5 +133,41 @@ public interface IValidationPolicyAdvisor {
ValueSet valueSet,
List<String> systems);
/**
* This is called after a resource has been validated against the base structure,
* but before any profiles specified in .meta.profile or in the parameters are applied.
* This can be used to determine what additional profiles should be applied, for instance
* those derived from the http://hl7.org/fhir/tools/StructureDefinition/profile-mapping extension
*
* Note that the resource is an elementModel resource, not an IBaseResource. This is less convenient to
* read values from, but is the way the internals of the validator works (e.g. the version of the resource
* might be any version from R2-R6)
*
* The base implementation applies the mandatory vital signs to observations that have LOINC or SNOMED CT
* codes that indicate that they are vital signs. Note that these profiles are not optional; all resources
* are required to conform to them. For this reason, if you're providing your own policy advisor, you should
* keep a reference to the default one, or call BasePolicyAdvisorForMandatoryProfiles. You can choose not to,
* but if you do, you are allowing for resources that deviate from the FHIR specification (in a way that the
* community considers clinically unsafe, since it means that software (probably) will miss vital signs for
* patients).
*
* @param validator
* @param appContext What was originally provided from the app for it's context
* @param stackPath The current path for the stack. Note that the because of cross-references and FHIRPath conformsTo() statements, the stack can wind through the content unpredictably.
* @param definition the definition being validated against (might be useful: ElementDefinition.base.path, ElementDefinition.type, ElementDefinition.binding
* @param structure The structure definition that contains the element definition being validated against (may be from the base spec, may be from a profile)
* @param resource The actual resource (as an element model) so that the implementation can inspect the values in order to decide what profiles to apply
* @param valid true if the resource is so far considered valid
* @param messages all the validation messages. Implementations can inspect this, but the real purpose is to populate the messages with information messages explaining why profiles were (or weren't) applied
* @return
*/
List<StructureDefinition> getImpliedProfilesForInstance(IResourceValidator validator,
Object appContext,
String stackPath,
ElementDefinition definition,
StructureDefinition structure,
Element resource,
boolean valid,
List<ValidationMessage> messages);
}

View File

@ -1,6 +1,6 @@
package org.hl7.fhir.r5.utils.validation.constants;
public enum RuleImplementationLevel {
public enum BestPracticeWarningLevel {
Ignore,
Hint,
Warning,

View File

@ -0,0 +1,65 @@
package org.hl7.fhir.validation.instance;
import java.util.EnumSet;
import java.util.List;
import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.elementmodel.Element.SpecialElement;
import org.hl7.fhir.r5.model.ElementDefinition;
import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.ValueSet;
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor;
import org.hl7.fhir.r5.utils.validation.constants.BindingKind;
import org.hl7.fhir.r5.utils.validation.constants.ContainedReferenceValidationPolicy;
import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy;
import org.hl7.fhir.utilities.validation.ValidationMessage;
public class BasePolicyAdvisorForFullValidation implements IValidationPolicyAdvisor {
@Override
public ReferenceValidationPolicy policyForReference(IResourceValidator validator, Object appContext, String path,
String url) {
// TODO Auto-generated method stub
return null;
}
@Override
public ContainedReferenceValidationPolicy policyForContained(IResourceValidator validator, Object appContext,
StructureDefinition structure, ElementDefinition element, String containerType, String containerId,
SpecialElement containingResourceType, String path, String url) {
// TODO Auto-generated method stub
return null;
}
@Override
public EnumSet<ResourceValidationAction> policyForResource(IResourceValidator validator, Object appContext,
StructureDefinition type, String path) {
// TODO Auto-generated method stub
return null;
}
@Override
public EnumSet<ElementValidationAction> policyForElement(IResourceValidator validator, Object appContext,
StructureDefinition structure, ElementDefinition element, String path) {
// TODO Auto-generated method stub
return null;
}
@Override
public EnumSet<CodedContentValidationAction> policyForCodedContent(IResourceValidator validator, Object appContext,
String stackPath, ElementDefinition definition, StructureDefinition structure, BindingKind kind,
AdditionalBindingPurpose purpose, ValueSet valueSet, List<String> systems) {
// TODO Auto-generated method stub
return null;
}
@Override
public List<StructureDefinition> getImpliedProfilesForInstance(IResourceValidator validator, Object appContext,
String stackPath, ElementDefinition definition, StructureDefinition structure, Element resource, boolean valid,
List<ValidationMessage> messages) {
// TODO Auto-generated method stub
return null;
}
}