diff --git a/lib/carin_for_blue_button_test_kit/generated/v2.0.0/organization/organization_lastupdated_search_test.rb b/lib/carin_for_blue_button_test_kit/generated/v2.0.0/organization/organization_lastupdated_search_test.rb index de80770a..ebc00c59 100644 --- a/lib/carin_for_blue_button_test_kit/generated/v2.0.0/organization/organization_lastupdated_search_test.rb +++ b/lib/carin_for_blue_button_test_kit/generated/v2.0.0/organization/organization_lastupdated_search_test.rb @@ -3,7 +3,7 @@ module CarinForBlueButtonTestKit module CARIN4BBV200 - class OrganizationLastUpdatedSearchTest < Inferno::Test + class OrganizationLastupdatedSearchTest < Inferno::Test include CarinForBlueButtonTestKit::CarinSearchTest title 'Server returns valid results for Organization search by _lastUpdated' diff --git a/lib/carin_for_blue_button_test_kit/generated/v2.0.0/patient/patient_lastupdated_search_test.rb b/lib/carin_for_blue_button_test_kit/generated/v2.0.0/patient/patient_lastupdated_search_test.rb index 9a2d52b4..385f0074 100644 --- a/lib/carin_for_blue_button_test_kit/generated/v2.0.0/patient/patient_lastupdated_search_test.rb +++ b/lib/carin_for_blue_button_test_kit/generated/v2.0.0/patient/patient_lastupdated_search_test.rb @@ -3,7 +3,7 @@ module CarinForBlueButtonTestKit module CARIN4BBV200 - class PatientLastUpdatedSearchTest < Inferno::Test + class PatientLastupdatedSearchTest < Inferno::Test include CarinForBlueButtonTestKit::CarinSearchTest title 'Server returns valid results for Patient search by _lastUpdated' diff --git a/lib/carin_for_blue_button_test_kit/generated/v2.0.0/practitioner/practitioner_lastupdated_search_test.rb b/lib/carin_for_blue_button_test_kit/generated/v2.0.0/practitioner/practitioner_lastupdated_search_test.rb index c54d45f4..8cc13c34 100644 --- a/lib/carin_for_blue_button_test_kit/generated/v2.0.0/practitioner/practitioner_lastupdated_search_test.rb +++ b/lib/carin_for_blue_button_test_kit/generated/v2.0.0/practitioner/practitioner_lastupdated_search_test.rb @@ -3,7 +3,7 @@ module CarinForBlueButtonTestKit module CARIN4BBV200 - class PractitionerLastUpdatedSearchTest < Inferno::Test + class PractitionerLastupdatedSearchTest < Inferno::Test include CarinForBlueButtonTestKit::CarinSearchTest title 'Server returns valid results for Practitioner search by _lastUpdated' diff --git a/lib/carin_for_blue_button_test_kit/generated/v2.0.0/related_person/related_person_lastupdated_search_test.rb b/lib/carin_for_blue_button_test_kit/generated/v2.0.0/related_person/related_person_lastupdated_search_test.rb index 010d68ae..4f127dd5 100644 --- a/lib/carin_for_blue_button_test_kit/generated/v2.0.0/related_person/related_person_lastupdated_search_test.rb +++ b/lib/carin_for_blue_button_test_kit/generated/v2.0.0/related_person/related_person_lastupdated_search_test.rb @@ -3,7 +3,7 @@ module CarinForBlueButtonTestKit module CARIN4BBV200 - class RelatedPersonLastUpdatedSearchTest < Inferno::Test + class RelatedPersonLastupdatedSearchTest < Inferno::Test include CarinForBlueButtonTestKit::CarinSearchTest title 'Server returns valid results for RelatedPerson search by _lastUpdated' diff --git a/spec/carin_for_blue_button/carin_search_test_last_updated.rb b/spec/carin_for_blue_button/carin_search_test_last_updated.rb index 22826cd9..bd2e6f8c 100644 --- a/spec/carin_for_blue_button/carin_search_test_last_updated.rb +++ b/spec/carin_for_blue_button/carin_search_test_last_updated.rb @@ -1,96 +1,92 @@ # frozen_string_literal: true RSpec.describe CarinForBlueButtonTestKit::CarinSearchTest do + let(:suite) { Inferno::Repositories::TestSuites.new.find('c4bb_v200') } + let(:session_data_repo) { Inferno::Repositories::SessionData.new } + let(:test_session) { repo_create(:test_session, test_suite_id: suite.id) } + let(:url) { 'http://example.com/fhir' } + let(:error_outcome) { FHIR::OperationOutcome.new(issue: [{ severity: 'error' }]) } + + def run(runnable, inputs = {}) + test_run_params = { test_session_id: test_session.id }.merge(runnable.reference_hash) + test_run = Inferno::Repositories::TestRuns.new.create(test_run_params) + inputs.each do |name, value| + session_data_repo.save( + test_session_id: test_session.id, + name:, + value:, + type: runnable.config.input_type(name) + ) + end + Inferno::TestRunner.new(test_session:, test_run:).run(runnable) + end + + def setup_mock_test(coverage_test, coverage_resource) + allow_any_instance_of(coverage_test).to receive(:scratch_resources).and_return( + { + all: [coverage_resource] + } + ) + end + + describe 'carin Coverage search optional _lastUpdated' do + let(:coverage_last_updated_search_test) do + Class.new(CarinForBlueButtonTestKit::CARIN4BBV200::CoverageLastupdatedSearchTest) do + fhir_client { url :url } + input :url + end + end + let(:coverage_json_string) do File.read(File.join(__dir__, '..', 'fixtures', 'c4bb_coverage_example.json')) end - let(:eob_json_string) do - File.read(File.join(__dir__, '..', 'fixtures', 'c4bb_eob_inpatient_example.json')) - end - - let(:suite) { Inferno::Repositories::TestSuites.new.find('c4bb_v200') } - let(:session_data_repo) { Inferno::Repositories::SessionData.new } - let(:test_session) { repo_create(:test_session, test_suite_id: suite.id) } - let(:url) { 'http://example.com/fhir' } - let(:error_outcome) { FHIR::OperationOutcome.new(issue: [{ severity: 'error' }]) } - - def run(runnable, inputs = {}) - test_run_params = { test_session_id: test_session.id }.merge(runnable.reference_hash) - test_run = Inferno::Repositories::TestRuns.new.create(test_run_params) - inputs.each do |name, value| - session_data_repo.save( - test_session_id: test_session.id, - name:, - value:, - type: runnable.config.input_type(name) - ) - end - Inferno::TestRunner.new(test_session:, test_run:).run(runnable) - end - - def setup_mock_test(coverage_test, coverage_resource) - allow_any_instance_of(coverage_test).to receive(:scratch_resources).and_return( - { - all: [coverage_resource] - } - ) - end - - describe 'carin coverage search optional _lastUpdated' do - let(:coverage_last_updated_search_test) do - Class.new(CarinForBlueButtonTestKit::CARIN4BBV200::CoverageLastupdatedSearchTest) do - fhir_client { url :url } - input :url - end - end - - let(:coverage) { FHIR.from_contents(coverage_json_string) } - let(:last_updated) { '2022-09-17' } - let(:bundle) do - FHIR::Bundle.new(entry: [{ resource: coverage }]) - end - - before do - Inferno::Repositories::Tests.new.insert(coverage_last_updated_search_test) - setup_mock_test(coverage_last_updated_search_test, coverage) - end - - it 'passes if _lastUpdated is passed in and 200 is received' do - stub_request(:get, "#{url}/Coverage?_lastUpdated=#{last_updated}") - .to_return(status: 200, body: bundle.to_json) - - result = run( - coverage_last_updated_search_test, - c4bb_v200_coverage__lastUpdated_search_test_param: last_updated, - url: - ) - expect(result.result).to eq('pass') - end + let(:coverage) { FHIR.from_contents(coverage_json_string) } + let(:last_updated) { '2022-09-17' } + let(:bundle) do + FHIR::Bundle.new(entry: [{ resource: coverage }]) + end - it 'skips if _lastUpdated is passed in and 400 is received' do - stub_request(:get, "#{url}/Coverage?_lastUpdated=#{last_updated}") - .to_return(status: 400, body: error_outcome.to_json) - result = run( - coverage_last_updated_search_test, - c4bb_v200_coverage__lastUpdated_search_test_param: last_updated, - url: - ) - expect(result.result).to eq('skip') - expect(result.result_message).to eq('_lastUpdated search query was unsuccessful and did not respond with a 200 status') - end + before do + Inferno::Repositories::Tests.new.insert(coverage_last_updated_search_test) + setup_mock_test(coverage_last_updated_search_test, coverage) + end - it 'skips if _lastUpdated is not passed in' do - result = run( - coverage_last_updated_search_test, - url: - ) - expect(result.result).to eq('skip') - expect(result.result_message).to eq('_lastUpdated optional and not provided') - end + it 'passes if _lastUpdated is passed in and 200 is received' do + stub_request(:get, "#{url}/Coverage?_lastUpdated=#{last_updated}") + .to_return(status: 200, body: bundle.to_json) + + result = run( + coverage_last_updated_search_test, + c4bb_v200_coverage__lastUpdated_search_test_param: last_updated, + url: + ) + expect(result.result).to eq('pass') + end + + it 'skips if _lastUpdated is passed in and 400 is received' do + stub_request(:get, "#{url}/Coverage?_lastUpdated=#{last_updated}") + .to_return(status: 400, body: error_outcome.to_json) + result = run( + coverage_last_updated_search_test, + c4bb_v200_coverage__lastUpdated_search_test_param: last_updated, + url: + ) + expect(result.result).to eq('skip') + expect(result.result_message).to eq('_lastUpdated search query was unsuccessful and did not respond with a 200 status') + end + + it 'skips if _lastUpdated is not passed in' do + result = run( + coverage_last_updated_search_test, + url: + ) + expect(result.result).to eq('skip') + expect(result.result_message).to eq('_lastUpdated optional and not provided') + end end - describe 'carin eob search required _lastUpdated' do + describe 'carin ExplanationOfBenefit search required _lastUpdated' do let(:eob_last_updated_search_test) do Class.new(CarinForBlueButtonTestKit::CARIN4BBV200::ExplanationOfBenefitLastupdatedSearchTest) do fhir_client { url :url } @@ -98,6 +94,10 @@ def setup_mock_test(coverage_test, coverage_resource) end end + let(:eob_json_string) do + File.read(File.join(__dir__, '..', 'fixtures', 'c4bb_eob_inpatient_example.json')) + end + let(:eob) { FHIR.from_contents(eob_json_string) } let(:last_updated) { '2020-04-28' } let(:bundle) do @@ -145,7 +145,233 @@ def setup_mock_test(coverage_test, coverage_resource) expect(result.result).to eq('fail') expect(result.result_message).to eq('Unexpected response status: expected 200, but received 400') end -end + end + + describe 'carin Patient search optional _lastUpdated' do + let(:patient_last_updated_search_test) do + Class.new(CarinForBlueButtonTestKit::CARIN4BBV200::PatientLastupdatedSearchTest) do + fhir_client { url :url } + input :url + end + end + let(:patient_json_string) do + File.read(File.join(__dir__, '..', 'fixtures', 'c4bb_patient_example.json')) + end + + let(:patient) { FHIR.from_contents(patient_json_string) } + let(:last_updated) { '2020-07-07' } + let(:bundle) do + FHIR::Bundle.new(entry: [{ resource: patient }]) + end + before do + Inferno::Repositories::Tests.new.insert(patient_last_updated_search_test) + setup_mock_test(patient_last_updated_search_test, patient) + end + + it 'passes if _lastUpdated is passed in and 200 is received' do + stub_request(:get, "#{url}/Patient?_lastUpdated=#{last_updated}") + .to_return(status: 200, body: bundle.to_json) + + result = run( + patient_last_updated_search_test, + c4bb_v200_patient__lastUpdated_search_test_param: last_updated, + url: + ) + expect(result.result).to eq('pass') + end + + it 'skips if _lastUpdated is passed in and 400 is received' do + stub_request(:get, "#{url}/Patient?_lastUpdated=#{last_updated}") + .to_return(status: 400, body: error_outcome.to_json) + result = run( + patient_last_updated_search_test, + c4bb_v200_patient__lastUpdated_search_test_param: last_updated, + url: + ) + expect(result.result).to eq('skip') + expect(result.result_message).to eq('_lastUpdated search query was unsuccessful and did not respond with a 200 status') + end + + it 'skips if _lastUpdated is not passed in' do + result = run( + patient_last_updated_search_test, + url: + ) + expect(result.result).to eq('skip') + expect(result.result_message).to eq('_lastUpdated optional and not provided') + end + end + + describe 'carin Organization search optional _lastUpdated' do + let(:organization_last_updated_search_test) do + Class.new(CarinForBlueButtonTestKit::CARIN4BBV200::OrganizationLastupdatedSearchTest) do + fhir_client { url :url } + input :url + end + end + + let(:organization_json_string) do + File.read(File.join(__dir__, '..', 'fixtures', 'c4bb_organization_example.json')) + end + + let(:organization) { FHIR.from_contents(organization_json_string) } + let(:last_updated) { '2022-09-17' } + let(:bundle) do + FHIR::Bundle.new(entry: [{ resource: organization }]) + end + + before do + Inferno::Repositories::Tests.new.insert(organization_last_updated_search_test) + setup_mock_test(organization_last_updated_search_test, organization) + end + + it 'passes if _lastUpdated is passed in and 200 is received' do + stub_request(:get, "#{url}/Organization?_lastUpdated=#{last_updated}") + .to_return(status: 200, body: bundle.to_json) + + result = run( + organization_last_updated_search_test, + c4bb_v200_organization__lastUpdated_search_test_param: last_updated, + url: + ) + expect(result.result).to eq('pass') + end + + it 'skips if _lastUpdated is passed in and 400 is received' do + stub_request(:get, "#{url}/Organization?_lastUpdated=#{last_updated}") + .to_return(status: 400, body: error_outcome.to_json) + result = run( + organization_last_updated_search_test, + c4bb_v200_organization__lastUpdated_search_test_param: last_updated, + url: + ) + expect(result.result).to eq('skip') + expect(result.result_message).to eq('_lastUpdated search query was unsuccessful and did not respond with a 200 status') + end + + it 'skips if _lastUpdated is not passed in' do + result = run( + organization_last_updated_search_test, + url: + ) + expect(result.result).to eq('skip') + expect(result.result_message).to eq('_lastUpdated optional and not provided') + end + end + + describe 'carin Practitioner search optional _lastUpdated' do + let(:practitioner_last_updated_search_test) do + Class.new(CarinForBlueButtonTestKit::CARIN4BBV200::PractitionerLastupdatedSearchTest) do + fhir_client { url :url } + input :url + end + end + + let(:practitioner_json_string) do + File.read(File.join(__dir__, '..', 'fixtures', 'c4bb_practitioner_example.json')) + end + + let(:practitioner) { FHIR.from_contents(practitioner_json_string) } + let(:last_updated) { '2022-09-17' } + let(:bundle) do + FHIR::Bundle.new(entry: [{ resource: practitioner }]) + end + + before do + Inferno::Repositories::Tests.new.insert(practitioner_last_updated_search_test) + setup_mock_test(practitioner_last_updated_search_test, practitioner) + end + + it 'passes if _lastUpdated is passed in and 200 is received' do + stub_request(:get, "#{url}/Practitioner?_lastUpdated=#{last_updated}") + .to_return(status: 200, body: bundle.to_json) + + result = run( + practitioner_last_updated_search_test, + c4bb_v200_practitioner__lastUpdated_search_test_param: last_updated, + url: + ) + expect(result.result).to eq('pass') + end + + it 'skips if _lastUpdated is passed in and 400 is received' do + stub_request(:get, "#{url}/Practitioner?_lastUpdated=#{last_updated}") + .to_return(status: 400, body: error_outcome.to_json) + result = run( + practitioner_last_updated_search_test, + c4bb_v200_practitioner__lastUpdated_search_test_param: last_updated, + url: + ) + expect(result.result).to eq('skip') + expect(result.result_message).to eq('_lastUpdated search query was unsuccessful and did not respond with a 200 status') + end + + it 'skips if _lastUpdated is not passed in' do + result = run( + practitioner_last_updated_search_test, + url: + ) + expect(result.result).to eq('skip') + expect(result.result_message).to eq('_lastUpdated optional and not provided') + end + end + + describe 'carin RelatedPerson search optional _lastUpdated' do + let(:related_person_last_updated_search_test) do + Class.new(CarinForBlueButtonTestKit::CARIN4BBV200::RelatedPersonLastupdatedSearchTest) do + fhir_client { url :url } + input :url + end + end + + let(:related_person_json_string) do + File.read(File.join(__dir__, '..', 'fixtures', 'c4bb_related_person_example.json')) + end + + let(:related_person) { FHIR.from_contents(related_person_json_string) } + let(:last_updated) { '2020-05-04' } + let(:bundle) do + FHIR::Bundle.new(entry: [{ resource: related_person }]) + end + + before do + Inferno::Repositories::Tests.new.insert(related_person_last_updated_search_test) + setup_mock_test(related_person_last_updated_search_test, related_person) + end + + it 'passes if _lastUpdated is passed in and 200 is received' do + stub_request(:get, "#{url}/RelatedPerson?_lastUpdated=#{last_updated}") + .to_return(status: 200, body: bundle.to_json) + + result = run( + related_person_last_updated_search_test, + c4bb_v200_related_person__lastUpdated_search_test_param: last_updated, + url: + ) + expect(result.result).to eq('pass') + end + + it 'skips if _lastUpdated is passed in and 400 is received' do + stub_request(:get, "#{url}/RelatedPerson?_lastUpdated=#{last_updated}") + .to_return(status: 400, body: error_outcome.to_json) + result = run( + related_person_last_updated_search_test, + c4bb_v200_related_person__lastUpdated_search_test_param: last_updated, + url: + ) + expect(result.result).to eq('skip') + expect(result.result_message).to eq('_lastUpdated search query was unsuccessful and did not respond with a 200 status') + end + + it 'skips if _lastUpdated is not passed in' do + result = run( + related_person_last_updated_search_test, + url: + ) + expect(result.result).to eq('skip') + expect(result.result_message).to eq('_lastUpdated optional and not provided') + end + end end \ No newline at end of file diff --git a/spec/fixtures/c4bb_organization_example.json b/spec/fixtures/c4bb_organization_example.json new file mode 100644 index 00000000..6a130b35 --- /dev/null +++ b/spec/fixtures/c4bb_organization_example.json @@ -0,0 +1,56 @@ +{ + "resourceType": "Organization", + "id": "ProviderTransportationOrganization1", + "meta": { + "versionId": "1", + "lastUpdated": "2022-09-17T20:32:22.159+00:00", + "source": "#yGJc0mfor4UJSplm", + "profile": [ + "http://hl7.org/fhir/us/carin-bb/StructureDefinition/C4BB-Organization|2.0.0" + ] + }, + "text": { + "status": "generated", + "div": "
Generated Narrative: Organization
Resource Organization "ProviderTransportationOrganization1" Updated "2020-05-04 03:02:01-0400"
Profile: C4BB Organization (version 2.0.0)
identifier: National Provider Identifier: 0099887766
active: true
name: ABC Ambulance Services
address: Attn: ABC Ambulance Services Pittsburgh PA 15222 USA
- | Telecom |
* | ph: 555-555-5511(WORK) |
Generated Narrative: Practitioner
Resource Practitioner "Practitioner1" Updated "2020-05-04 03:02:01-0400"
Profile: C4BB Practitioner (version 2.0.0)
identifier: National Provider Identifier: 6667778880
active: true
name: John Smith
Generated Narrative: RelatedPerson
Resource RelatedPerson "RelatedPerson1" Updated "2020-05-04 03:02:01-0400"
Profile: C4BB RelatedPerson (version 2.0.0)
active: true
patient: Patient/Patient1 " EXAMPLE1"
relationship: mother (RoleCode#MTH)
name: Mary Example1
telecom: ph: (301)666-1212
address: 123 Main Street Pittsburgh PA 12519