Class: Inferno::DSL::FHIREvaluation::Rules::AllProfilesHaveExamples
- Inherits:
-
Inferno::DSL::FHIREvaluation::Rule
- Object
- Inferno::DSL::FHIREvaluation::Rule
- Inferno::DSL::FHIREvaluation::Rules::AllProfilesHaveExamples
- Includes:
- ProfileConformanceHelper
- Defined in:
- lib/inferno/dsl/fhir_evaluation/rules/all_profiles_have_examples.rb
Constant Summary
Constants included from ProfileConformanceHelper
ProfileConformanceHelper::DEFAULT_OPTIONS
Instance Attribute Summary collapse
-
#all_resources ⇒ Object
Returns the value of attribute all_resources.
-
#context ⇒ Object
Returns the value of attribute context.
-
#unused_profile_urls ⇒ Object
Returns the value of attribute unused_profile_urls.
Instance Method Summary collapse
Methods included from ProfileConformanceHelper
#conforms_to_profile?, #declares_meta_profile?, #validates_profile?
Instance Attribute Details
#all_resources ⇒ Object
Returns the value of attribute all_resources.
8 9 10 |
# File 'lib/inferno/dsl/fhir_evaluation/rules/all_profiles_have_examples.rb', line 8 def all_resources @all_resources end |
#context ⇒ Object
Returns the value of attribute context.
8 9 10 |
# File 'lib/inferno/dsl/fhir_evaluation/rules/all_profiles_have_examples.rb', line 8 def context @context end |
#unused_profile_urls ⇒ Object
Returns the value of attribute unused_profile_urls.
8 9 10 |
# File 'lib/inferno/dsl/fhir_evaluation/rules/all_profiles_have_examples.rb', line 8 def unused_profile_urls @unused_profile_urls end |
Instance Method Details
#check(context) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/inferno/dsl/fhir_evaluation/rules/all_profiles_have_examples.rb', line 10 def check(context) @context = context @unused_profile_urls = [] @all_resources = [] = context.config.data['Rule']['AllProfilesHaveExamples']['ConformanceOptions']. context.data.map { |entry| extract_resources(entry) } all_resources.uniq! context.ig.profiles.each do |profile| profile_used = all_resources.any? do |resource| conforms_to_profile?(resource, profile, , context.validator) end unused_profile_urls << profile.url unless profile_used end unused_profile_urls.uniq! if unused_profile_urls.any? = "Found profiles without examples: \n\t #{unused_profile_urls.join(', ')}" result = EvaluationResult.new(, rule: self) else = 'All profiles have example instances.' result = EvaluationResult.new(, severity: 'success', rule: self) end context.add_result result end |
#extract_resources(resource) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/inferno/dsl/fhir_evaluation/rules/all_profiles_have_examples.rb', line 39 def extract_resources(resource) all_resources << resource return unless resource.resourceType == 'Bundle' resource.entry.map { |entry| extract_resources(entry.resource) }.flatten end |