Module: USCoreTestKit::PractitionerAddressTest
- Includes:
- MustSupportTest, ReferenceResolutionTest, SearchTest
- Defined in:
- lib/us_core_test_kit/practitioner_address_test.rb
Constant Summary collapse
- MUST_SUPPORT_ELEMENTS =
[ { path: 'address' }, { path: 'address.line' }, { path: 'address.city' }, { path: 'address.state' }, { path: 'address.postalCode' }, { path: 'address.country' } ].freeze
Constants included from FHIRResourceNavigation
FHIRResourceNavigation::DAR_EXTENSION_URL, FHIRResourceNavigation::PRIMITIVE_DATA_TYPES
Instance Method Summary collapse
- #get_practitioner_ids(references) ⇒ Object
- #resource_type ⇒ Object
- #scratch_resources ⇒ Object
- #verify_practitioner_address ⇒ Object
Methods included from MustSupportTest
#all_scratch_resources, #exclude_uscdi_only_test?, #find_missing_elements, #find_slice, #find_slice_by_values, #handle_must_support_choices, #is_any_choice_supported?, #missing_element_string, #missing_elements, #missing_extensions, #missing_must_support_strings, #missing_slices, #must_support_elements, #must_support_extensions, #must_support_slices, #perform_must_support_test
Methods included from FHIRResourceNavigation
#find_a_value_at, #find_slice_via_discriminator, #get_next_value, #get_primitive_type_value, #resolve_path, #verify_slice_by_values
Methods included from ReferenceResolutionTest
#is_reference_resolved?, #must_support_references, #must_support_references_with_target_profile, #no_resources_skip_message, #perform_reference_resolution_test, #record_resolved_reference, #resolve_reference, #resolved_references, #resource_is_valid_with_target_profile?, #unresolved_references, #unresolved_references_strings, #validate_reference_resolution
Methods included from SearchTest
#all_comparator_searches_tested?, #all_provenance_revinclude_search_params, #all_scratch_resources, #all_search_params, #all_search_params_present?, #all_search_variants_tested?, #any_valid_search_params?, #array_of_codes, #cant_resolve_next_bundle_message, #check_resource_against_params, #check_search_response, #date_comparator_value, #default_search_values, #element_has_valid_value?, #empty_search_params_message, #fetch_all_bundled_resources, #filter_conditions, #filter_devices, #fixed_value_search_param_name, #fixed_value_search_param_values, #fixed_value_search_params, #initial_search_variant_test_records, #is_reference_match?, #no_resources_skip_message, #patient_id_list, #patient_id_param?, #patient_search?, #perform_comparator_searches, #perform_multiple_or_search_test, #perform_post_search, #perform_reference_with_type_search, #perform_search, #perform_search_with_status, #perform_search_with_system, #references_to_save, #required_comparators, #resource_matches_param?, #run_provenance_revinclude_search_test, #run_search_test, #save_delayed_references, #save_resource_reference, #scratch_resources_for_patient, #search_and_check_response, #search_param_paths, #search_param_value, #search_params_tag, #search_params_with_values, #search_variant_test_records, #status_search_param_name, #status_search_values, #tags, #test_medication_inclusion, #unable_to_resolve_params_message, #unescape_search_value
Methods included from ResourceSearchParamChecker
#element_has_valid_value?, #resource_matches_param?, #search_param_paths
Methods included from DateSearchValidation
#fhir_date_comparer, #get_fhir_datetime_range, #get_fhir_period_range, #is_date?, #validate_date_search, #validate_datetime_search, #validate_period_search
Instance Method Details
#get_practitioner_ids(references) ⇒ Object
81 82 83 |
# File 'lib/us_core_test_kit/practitioner_address_test.rb', line 81 def get_practitioner_ids(references) references.map { |reference| reference.reference&.split('/')&.last }.compact.uniq end |
#resource_type ⇒ Object
18 19 20 |
# File 'lib/us_core_test_kit/practitioner_address_test.rb', line 18 def resource_type 'Practitioner' end |
#scratch_resources ⇒ Object
22 23 24 |
# File 'lib/us_core_test_kit/practitioner_address_test.rb', line 22 def scratch_resources scratch[:practitioner_resource] ||= {} end |
#verify_practitioner_address ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/us_core_test_kit/practitioner_address_test.rb', line 26 def verify_practitioner_address references = scratch.dig(:references, 'Practitioner') assert references.any?, 'No Pracitioner references found.' @missing_elements = MUST_SUPPORT_ELEMENTS practitioners = [] references.each do |reference| resolved_resource = resolve_reference(reference) if resolved_resource.nil? || resolved_resource.resourceType != resource_type || resolved_resource.id != reference.reference_id next end practitioners << resolved_resource some_missing_elements = find_missing_elements([resolved_resource], MUST_SUPPORT_ELEMENTS) @missing_elements &= some_missing_elements break if @missing_elements.empty? end missing_elements_string = @missing_elements.map { |element| missing_element_string(element) } support_practitioner_role = false if @missing_elements.any? resource_type = 'PractitionerRole' support_practitioner_role = practitioners.any? do |practitioner| search_params = { practitioner: practitioner.id } search_and_check_response(search_params, resource_type) practitioner_roles = fetch_all_bundled_resources(resource_type:) .select { |resource| resource.resourceType == resource_type } next false if practitioner_roles.empty? next true if config.[:skip_practitioner_role_validation] target_profile_with_version = "http://hl7.org/fhir/us/core/StructureDefinition/us-core-practitionerrole|#{.profile_version}" practitioner_roles.any? { |pr| resource_is_valid_with_target_profile?(pr, target_profile_with_version) } end end = "Could not find US Core PractitionerRole Profile resources and " \ "these MustSupport elements #{missing_elements_string.join(', ')} " \ "in US Core Practitioner Profile resources. " \ "Please use patients with more information." assert (support_practitioner_role || @missing_elements.blank?), end |