Module: AUCoreTestKit::ReadTest
- Included in:
- AUCoreV100::AllergyIntoleranceReadTest, AUCoreV100::BloodpressureReadTest, AUCoreV100::BodyheightReadTest, AUCoreV100::BodytempReadTest, AUCoreV100::BodyweightReadTest, AUCoreV100::ConditionReadTest, AUCoreV100::DiagnosticresultPathReadTest, AUCoreV100::DiagnosticresultReadTest, AUCoreV100::EncounterReadTest, AUCoreV100::HeartrateReadTest, AUCoreV100::ImmunizationReadTest, AUCoreV100::LocationReadTest, AUCoreV100::MedicationRequestReadTest, AUCoreV100::OrganizationReadTest, AUCoreV100::PatientReadTest, AUCoreV100::PractitionerReadTest, AUCoreV100::PractitionerRoleReadTest, AUCoreV100::ProcedureReadTest, AUCoreV100::ResprateReadTest, AUCoreV100::SmokingstatusReadTest, AUCoreV100::WaistcircumReadTest, AUCoreV110_PREVIEW::AllergyIntoleranceReadTest, AUCoreV110_PREVIEW::BloodpressureReadTest, AUCoreV110_PREVIEW::BodyheightReadTest, AUCoreV110_PREVIEW::BodytempReadTest, AUCoreV110_PREVIEW::BodyweightReadTest, AUCoreV110_PREVIEW::ConditionReadTest, AUCoreV110_PREVIEW::DiagnosticresultPathReadTest, AUCoreV110_PREVIEW::DiagnosticresultReadTest, AUCoreV110_PREVIEW::EncounterReadTest, AUCoreV110_PREVIEW::HeartrateReadTest, AUCoreV110_PREVIEW::ImmunizationReadTest, AUCoreV110_PREVIEW::LocationReadTest, AUCoreV110_PREVIEW::MedicationRequestReadTest, AUCoreV110_PREVIEW::MedicationStatementReadTest, AUCoreV110_PREVIEW::OrganizationReadTest, AUCoreV110_PREVIEW::PatientReadTest, AUCoreV110_PREVIEW::PractitionerReadTest, AUCoreV110_PREVIEW::PractitionerRoleReadTest, AUCoreV110_PREVIEW::ProcedureReadTest, AUCoreV110_PREVIEW::RelatedPersonReadTest, AUCoreV110_PREVIEW::ResprateReadTest, AUCoreV110_PREVIEW::SmokingstatusReadTest, AUCoreV110_PREVIEW::WaistcircumReadTest, AUCoreV200_DRAFT::AllergyIntoleranceReadTest, AUCoreV200_DRAFT::BloodpressureReadTest, AUCoreV200_DRAFT::BodyheightReadTest, AUCoreV200_DRAFT::BodytempReadTest, AUCoreV200_DRAFT::BodyweightReadTest, AUCoreV200_DRAFT::ConditionReadTest, AUCoreV200_DRAFT::DiagnosticresultPathReadTest, AUCoreV200_DRAFT::DiagnosticresultReadTest, AUCoreV200_DRAFT::EncounterReadTest, AUCoreV200_DRAFT::HealthcareServiceReadTest, AUCoreV200_DRAFT::HeartrateReadTest, AUCoreV200_DRAFT::ImmunizationReadTest, AUCoreV200_DRAFT::LocationReadTest, AUCoreV200_DRAFT::MedicationRequestReadTest, AUCoreV200_DRAFT::MedicationStatementReadTest, AUCoreV200_DRAFT::OrganizationReadTest, AUCoreV200_DRAFT::PatientReadTest, AUCoreV200_DRAFT::PractitionerReadTest, AUCoreV200_DRAFT::PractitionerRoleReadTest, AUCoreV200_DRAFT::ProcedureReadTest, AUCoreV200_DRAFT::RelatedPersonReadTest, AUCoreV200_DRAFT::ResprateReadTest, AUCoreV200_DRAFT::SmokingstatusReadTest, AUCoreV200_DRAFT::WaistcircumReadTest, SearchTest
- Defined in:
- lib/au_core_test_kit/read_test.rb
Instance Method Summary collapse
- #all_scratch_resources ⇒ Object
- #bad_resource_id_message(expected_id) ⇒ Object
- #basic_read_and_validate(resource_to_read) ⇒ Object
- #create_reference(resource_type, resource_id) ⇒ Object
- #fetch_resource_ids(resource_type) ⇒ Object
- #get_resources_to_read_from_arr_ids(resource_ids_arr, resource_type) ⇒ Object
- #no_resources_custom_skip_message ⇒ Object
- #no_resources_skip_message ⇒ Object
- #perform_read_test(resources, _reply_handler = nil) ⇒ Object
- #read_and_validate(resource_to_read) ⇒ Object
- #read_and_validate_as_first(resource_to_read, patient_id) ⇒ Object
- #read_and_validate_resourses_arr(resources_to_read) ⇒ Object
- #readable_resources(resources) ⇒ Object
- #resource_class ⇒ Object
- #resource_id(resource) ⇒ Object
- #resource_ids_str_to_arr(resource_ids_str) ⇒ Object
Instance Method Details
#all_scratch_resources ⇒ Object
5 6 7 |
# File 'lib/au_core_test_kit/read_test.rb', line 5 def all_scratch_resources scratch_resources[:all] ||= [] end |
#bad_resource_id_message(expected_id) ⇒ Object
111 112 113 |
# File 'lib/au_core_test_kit/read_test.rb', line 111 def (expected_id) "Expected resource to have id: `#{expected_id.inspect}`, but found `#{resource.id.inspect}`" end |
#basic_read_and_validate(resource_to_read) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/au_core_test_kit/read_test.rb', line 77 def basic_read_and_validate(resource_to_read) id = resource_id(resource_to_read) fhir_read resource_type, id assert_response_status(200) assert_resource_type(resource_type) assert resource.id.present? && resource.id == id, (id) nil unless resource_to_read.is_a? FHIR::Reference end |
#create_reference(resource_type, resource_id) ⇒ Object
62 63 64 65 66 67 |
# File 'lib/au_core_test_kit/read_test.rb', line 62 def create_reference(resource_type, resource_id) FHIR::Reference.new( reference: "#{resource_type}/#{resource_id}", type: resource_type ) end |
#fetch_resource_ids(resource_type) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/au_core_test_kit/read_test.rb', line 29 def fetch_resource_ids(resource_type) case resource_type when 'Location' location_ids when 'Organization' organization_ids when 'Practitioner' practitioner_ids when 'PractitionerRole' practitioner_role_ids when 'HealthcareService' healthcare_service_ids else '' end end |
#get_resources_to_read_from_arr_ids(resource_ids_arr, resource_type) ⇒ Object
56 57 58 59 60 |
# File 'lib/au_core_test_kit/read_test.rb', line 56 def get_resources_to_read_from_arr_ids(resource_ids_arr, resource_type) resource_ids_arr.map do |resource_id| create_reference(resource_type, resource_id) end end |
#no_resources_custom_skip_message ⇒ Object
115 116 117 |
# File 'lib/au_core_test_kit/read_test.rb', line 115 def "There are no resources of the type #{resource_type} from previous tests, and you didn't provide IDs to search." end |
#no_resources_skip_message ⇒ Object
106 107 108 109 |
# File 'lib/au_core_test_kit/read_test.rb', line 106 def "No #{resource_type} resources appear to be available. " \ 'Please use patients with more information.' end |
#perform_read_test(resources, _reply_handler = nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/au_core_test_kit/read_test.rb', line 9 def perform_read_test(resources, _reply_handler = nil) if resources.blank? resource_ids_str = fetch_resource_ids(resource_type) if resource_ids_str.blank? skip else resources_to_read = get_resources_to_read_from_arr_ids( resource_ids_str_to_arr(resource_ids_str), resource_type ) assert resources_to_read.present?, "No #{resource_type} id found." read_and_validate_resourses_arr(resources_to_read) end else resources_to_read = readable_resources(resources) assert resources_to_read.present?, "No #{resource_type} id found." read_and_validate_resourses_arr(resources_to_read) end end |
#read_and_validate(resource_to_read) ⇒ Object
89 90 91 92 93 |
# File 'lib/au_core_test_kit/read_test.rb', line 89 def read_and_validate(resource_to_read) basic_read_and_validate(resource_to_read) all_scratch_resources << resource end |
#read_and_validate_as_first(resource_to_read, patient_id) ⇒ Object
95 96 97 98 99 100 |
# File 'lib/au_core_test_kit/read_test.rb', line 95 def read_and_validate_as_first(resource_to_read, patient_id) basic_read_and_validate(resource_to_read) all_scratch_resources.concat([resource]).uniq! scratch_resources_for_patient(patient_id).concat([resource]).uniq! end |
#read_and_validate_resourses_arr(resources_to_read) ⇒ Object
50 51 52 53 54 |
# File 'lib/au_core_test_kit/read_test.rb', line 50 def read_and_validate_resourses_arr(resources_to_read) resources_to_read.each do |resource| read_and_validate(resource) end end |
#readable_resources(resources) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/au_core_test_kit/read_test.rb', line 69 def readable_resources(resources) resources .select { |resource| resource.is_a?(resource_class) || resource.is_a?(FHIR::Reference) } .select { |resource| (resource.is_a?(FHIR::Reference) ? resource.reference.split('/').last : resource.id).present? } .compact .uniq { |resource| resource.is_a?(FHIR::Reference) ? resource.reference.split('/').last : resource.id } end |
#resource_class ⇒ Object
119 120 121 |
# File 'lib/au_core_test_kit/read_test.rb', line 119 def resource_class FHIR.const_get(resource_type) end |
#resource_id(resource) ⇒ Object
102 103 104 |
# File 'lib/au_core_test_kit/read_test.rb', line 102 def resource_id(resource) resource.is_a?(FHIR::Reference) ? resource.reference.split('/').last : resource.id end |
#resource_ids_str_to_arr(resource_ids_str) ⇒ Object
46 47 48 |
# File 'lib/au_core_test_kit/read_test.rb', line 46 def resource_ids_str_to_arr(resource_ids_str) resource_ids_str.split(',').map(&:strip) end |