From 2dd956c50b8a33fb07856771890ddf35091e6a4d Mon Sep 17 00:00:00 2001 From: Emily Michaud <59289146+emichaud998@users.noreply.github.com> Date: Fri, 27 Oct 2023 13:33:09 -0400 Subject: [PATCH] Update new _lastUpdated tests so class name follows naming convention for _lastUpdated tests that already exist, add spec tests for all of the new optional _lastUpdated tests --- .../organization_lastupdated_search_test.rb | 2 +- .../patient_lastupdated_search_test.rb | 2 +- .../practitioner_lastupdated_search_test.rb | 2 +- .../related_person_lastupdated_search_test.rb | 2 +- .../carin_search_test_last_updated.rb | 392 ++++++++++++++---- spec/fixtures/c4bb_organization_example.json | 56 +++ spec/fixtures/c4bb_practitioner_example.json | 44 ++ .../fixtures/c4bb_related_person_example.json | 54 +++ 8 files changed, 467 insertions(+), 87 deletions(-) create mode 100644 spec/fixtures/c4bb_organization_example.json create mode 100644 spec/fixtures/c4bb_practitioner_example.json create mode 100644 spec/fixtures/c4bb_related_person_example.json 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

Contacts

-Telecom
*ph: 555-555-5511(WORK)
" + }, + "identifier": [ + { + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "NPI", + "display": "National Provider Identifier" + } + ], + "text": "National Provider Identifier" + }, + "system": "http://hl7.org/fhir/sid/us-npi", + "value": "0099887766" + } + ], + "active": true, + "name": "ABC Ambulance Services", + "address": [ + { + "line": [ + "Attn: ABC Ambulance Services" + ], + "city": "Pittsburgh", + "state": "PA", + "postalCode": "15222", + "country": "USA" + } + ], + "contact": [ + { + "telecom": [ + { + "system": "phone", + "value": "555-555-5511", + "use": "work" + } + ] + } + ] +} \ No newline at end of file diff --git a/spec/fixtures/c4bb_practitioner_example.json b/spec/fixtures/c4bb_practitioner_example.json new file mode 100644 index 00000000..64e48b63 --- /dev/null +++ b/spec/fixtures/c4bb_practitioner_example.json @@ -0,0 +1,44 @@ +{ + "resourceType": "Practitioner", + "id": "Practitioner1", + "meta": { + "versionId": "1", + "lastUpdated": "2022-09-17T20:32:28.890+00:00", + "source": "#Y5mT8EmnotqMSybZ", + "profile": [ + "http://hl7.org/fhir/us/carin-bb/StructureDefinition/C4BB-Practitioner|2.0.0" + ] + }, + "text": { + "status": "generated", + "div": "

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

" + }, + "identifier": [ + { + "type": { + "coding": [ + { + "system": "http://terminology.hl7.org/CodeSystem/v2-0203", + "code": "NPI", + "display": "National Provider Identifier" + } + ], + "text": "National Provider Identifier" + }, + "system": "http://hl7.org/fhir/sid/us-npi", + "value": "6667778880" + } + ], + "active": true, + "name": [ + { + "family": "Smith", + "given": [ + "John" + ], + "prefix": [ + "Dr." + ] + } + ] +} \ No newline at end of file diff --git a/spec/fixtures/c4bb_related_person_example.json b/spec/fixtures/c4bb_related_person_example.json new file mode 100644 index 00000000..59ba9b87 --- /dev/null +++ b/spec/fixtures/c4bb_related_person_example.json @@ -0,0 +1,54 @@ +{ + "resourceType" : "RelatedPerson", + "id" : "RelatedPerson1", + "meta" : { + "lastUpdated" : "2020-05-04T03:02:01-04:00", + "profile" : [ + "http://hl7.org/fhir/us/carin-bb/StructureDefinition/C4BB-RelatedPerson|2.0.0" + ] + }, + "text" : { + "status" : "generated", + "div" : "

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

" + }, + "active" : true, + "patient" : { + "reference" : "Patient/Patient1" + }, + "relationship" : [ + { + "coding" : [ + { + "system" : "http://terminology.hl7.org/CodeSystem/v3-RoleCode", + "code" : "MTH" + } + ] + } + ], + "name" : [ + { + "family" : "Example1", + "given" : [ + "Mary" + ] + } + ], + "telecom" : [ + { + "system" : "phone", + "value" : "(301)666-1212", + "rank" : 2 + } + ], + "address" : [ + { + "type" : "physical", + "line" : [ + "123 Main Street" + ], + "city" : "Pittsburgh", + "state" : "PA", + "postalCode" : "12519" + } + ] +} \ No newline at end of file