Module: DaVinciPlanNetTestKit::ReadTest
- Included in:
- DaVinciPlanNetV110::EndpointReadTest, DaVinciPlanNetV110::HealthcareServiceReadTest, DaVinciPlanNetV110::InsurancePlanReadTest, DaVinciPlanNetV110::LocationReadTest, DaVinciPlanNetV110::NetworkReadTest, DaVinciPlanNetV110::OrgAffilReadTest, DaVinciPlanNetV110::OrganizationReadTest, DaVinciPlanNetV110::PractitionerReadTest, DaVinciPlanNetV110::PractitionerRoleReadTest
- Defined in:
- lib/davinci_plan_net_test_kit/read_test.rb
Instance Method Summary collapse
- #all_scratch_resources ⇒ Object
- #bad_resource_id_message(expected_id) ⇒ Object
- #no_resources_skip_message ⇒ Object
- #perform_read_test(resources, reply_handler = nil) ⇒ Object
- #read_and_validate(resource_to_read) ⇒ Object
- #readable_resources(resources) ⇒ Object
- #resource_class ⇒ Object
- #resource_id(resource) ⇒ Object
Instance Method Details
#all_scratch_resources ⇒ Object
3 4 5 |
# File 'lib/davinci_plan_net_test_kit/read_test.rb', line 3 def all_scratch_resources scratch_resources[:all] ||= [] end |
#bad_resource_id_message(expected_id) ⇒ Object
54 55 56 |
# File 'lib/davinci_plan_net_test_kit/read_test.rb', line 54 def (expected_id) "Expected resource to have id: `#{expected_id.inspect}`, but found `#{resource.id.inspect}`" end |
#no_resources_skip_message ⇒ Object
49 50 51 52 |
# File 'lib/davinci_plan_net_test_kit/read_test.rb', line 49 def "No #{resource_type} resources appear to be available. " \ "Please use #{resource_type}s with more information." end |
#perform_read_test(resources, reply_handler = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/davinci_plan_net_test_kit/read_test.rb', line 7 def perform_read_test(resources, reply_handler = nil) skip_if resources.blank?, resources_to_read = readable_resources(resources) assert resources_to_read.present?, "No #{resource_type} id found." if config.[:read_all_resources] resources_to_read.each do |resource| read_and_validate(resource) end else read_and_validate(resources_to_read.first) end end |
#read_and_validate(resource_to_read) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/davinci_plan_net_test_kit/read_test.rb', line 31 def 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) if resource_to_read.is_a? FHIR::Reference all_scratch_resources << resource end end |
#readable_resources(resources) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/davinci_plan_net_test_kit/read_test.rb', line 23 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
58 59 60 |
# File 'lib/davinci_plan_net_test_kit/read_test.rb', line 58 def resource_class FHIR.const_get(resource_type) end |
#resource_id(resource) ⇒ Object
45 46 47 |
# File 'lib/davinci_plan_net_test_kit/read_test.rb', line 45 def resource_id(resource) resource.is_a?(FHIR::Reference) ? resource.reference.split('/').last : resource.id end |