Module: Inferno::DSL::FHIREvaluation::ProfileConformanceHelper
- Included in:
- Rules::AllMustSupportsPresent
- Defined in:
- lib/inferno/dsl/fhir_evaluation/profile_conformance_helper.rb
Overview
This module is used to decide whether a resource instantiates a given profile. Aligning resources to profiles is necessary when evaluating the comprehensiveness of the resources with respect to those profiles, unfortunately it’s impossible to programmatically determine intent. (i.e, is this resource supposed to instantiate this profile?) This module offers some approaches to make that determination.
Constant Summary collapse
- DEFAULT_OPTIONS =
{ considerMetaProfile: true, considerValidationResults: false, considerOnlyResourceType: false }.freeze
Instance Method Summary collapse
-
#conforms_to_profile?(resource, profile, options = DEFAULT_OPTIONS, validator = nil) {|resource| ... } ⇒ Boolean
Check whether the given resource conforms to the given profile, using the given options to select which approaches are considered.
-
#declares_meta_profile?(resource, profile) ⇒ Boolean
Check if the given resource claims conformance to the profile, versioned or unversioned, based on resource.meta.profile.
Instance Method Details
#conforms_to_profile?(resource, profile, options = DEFAULT_OPTIONS, validator = nil) {|resource| ... } ⇒ Boolean
Check whether the given resource conforms to the given profile, using the given options to select which approaches are considered. Current options: - If the resource is the right resourceType - If the resource claims conformance in resource.meta.profile - If the resource validates against the profile using the FHIR validator (NOT YET IMPLEMENTED) - If the resource meets other criteria defined in the block. As an example, the block may look for the presence of certain codes, such as LOINC “8867-4” in an Observation category code suggests that the resource intended to conform to a “Heart Rate” profile
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/inferno/dsl/fhir_evaluation/profile_conformance_helper.rb', line 32 def conforms_to_profile?(resource, profile, = DEFAULT_OPTIONS, validator = nil) # rubocop:disable Metrics/CyclomaticComplexity return false if resource.resourceType != profile.type return true if [:considerOnlyResourceType] return true if [:considerMetaProfile] && (resource, profile) return true if [:considerValidationResults] && validates_profile?(resource, profile, validator) return true if block_given? && yield(resource) false end |
#declares_meta_profile?(resource, profile) ⇒ Boolean
Check if the given resource claims conformance to the profile, versioned or unversioned, based on resource.meta.profile.
50 51 52 53 54 55 56 |
# File 'lib/inferno/dsl/fhir_evaluation/profile_conformance_helper.rb', line 50 def (resource, profile) declared_profiles = resource&.&.profile || [] profile_url = profile.url versioned_url = "#{profile_url}|#{profile.version}" declared_profiles.include?(profile_url) || declared_profiles.include?(versioned_url) end |