Skip to content

Commit

Permalink
31050 Demographics integeration (#8200)
Browse files Browse the repository at this point in the history
- Hiding feature behind a flipper
- Parse demographics data using the appointment data serializer
- Approved results return demographics data when feature is on
- Fix rubocop warnings
  • Loading branch information
dillo authored Oct 19, 2021
1 parent 773080d commit 35889a6
Show file tree
Hide file tree
Showing 6 changed files with 179 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,44 @@ class AppointmentDataSerializer
set_type :appointment_data

attribute :payload do |object|
approved_values =
appointments =
object.payload.dig(:appointments).map do |appt|
appt.except!(:patientDFN, :stationNo)
end

{ appointments: approved_values }
if Flipper.enabled?(:check_in_experience_demographics_page_enabled)
raw_demographics = object.payload.dig(:demographics)
demographics = {
mailingAddress: {
street1: raw_demographics.dig(:mailingAddress, :street1),
street2: raw_demographics.dig(:mailingAddress, :street2),
street3: raw_demographics.dig(:mailingAddress, :street3),
city: raw_demographics.dig(:mailingAddress, :city),
county: raw_demographics.dig(:mailingAddress, :county),
state: raw_demographics.dig(:mailingAddress, :state),
zip: raw_demographics.dig(:mailingAddress, :zip),
country: raw_demographics.dig(:mailingAddress, :country)
},
homeAddress: {
street1: raw_demographics.dig(:homeAddress, :street1),
street2: raw_demographics.dig(:homeAddress, :street2),
street3: raw_demographics.dig(:homeAddress, :street3),
city: raw_demographics.dig(:homeAddress, :city),
county: raw_demographics.dig(:homeAddress, :county),
state: raw_demographics.dig(:homeAddress, :state),
zip: raw_demographics.dig(:homeAddress, :zip),
country: raw_demographics.dig(:homeAddress, :country)
},
homePhone: raw_demographics[:homePhone],
mobilePhone: raw_demographics[:mobilePhone],
workPhone: raw_demographics[:workPhone],
emailAddress: raw_demographics[:emailAddress]
}

{ demographics: demographics, appointments: appointments }
else
{ appointments: appointments }
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
allow(Rails).to receive(:cache).and_return(memory_store)
allow(Flipper).to receive(:enabled?)
.with('check_in_experience_multiple_appointment_support').and_return(true)
allow(Flipper).to receive(:enabled?)
.with(:check_in_experience_demographics_page_enabled).and_return(true)

Rails.cache.clear
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,42 @@
RSpec.describe CheckIn::V2::AppointmentDataSerializer do
subject { described_class }

before do
allow(Flipper).to receive(:enabled?)
.with(:check_in_experience_demographics_page_enabled).and_return(true)
end

let(:appointment_data) do
{
id: 'd602d9eb-9a31-484f-9637-13ab0b507e0d',
scope: 'read.full',
payload: {
demographics: {
mailingAddress: {
street1: '123 Turtle Trail',
street2: '',
street3: '',
city: 'Treetopper',
county: 'SAN BERNARDINO',
state: 'Tennessee',
zip: '101010',
country: 'USA'
},
homeAddress: {
street1: '445 Fine Finch Fairway',
street2: 'Apt 201',
street3: '',
city: 'Fairfence',
county: 'FOO',
state: 'Florida',
zip: '445545',
country: 'USA'
},
homePhone: '5552223333',
mobilePhone: '5553334444',
workPhone: '5554445555',
emailAddress: 'kermit.frog@sesameenterprises.us'
},
appointments: [
{
appointmentIEN: '1',
Expand Down Expand Up @@ -56,6 +87,32 @@
type: :appointment_data,
attributes: {
payload: {
demographics: {
mailingAddress: {
street1: '123 Turtle Trail',
street2: '',
street3: '',
city: 'Treetopper',
county: 'SAN BERNARDINO',
state: 'Tennessee',
zip: '101010',
country: 'USA'
},
homeAddress: {
street1: '445 Fine Finch Fairway',
street2: 'Apt 201',
street3: '',
city: 'Fairfence',
county: 'FOO',
state: 'Florida',
zip: '445545',
country: 'USA'
},
homePhone: '5552223333',
mobilePhone: '5553334444',
workPhone: '5554445555',
emailAddress: 'kermit.frog@sesameenterprises.us'
},
appointments: [
{
appointmentIEN: '1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,32 @@
id: 'd602d9eb-9a31-484f-9637-13ab0b507e0d',
scope: 'read.full',
payload: {
demographics: {
mailingAddress: {
street1: '123 Turtle Trail',
street2: '',
street3: '',
city: 'Treetopper',
county: 'SAN BERNARDINO',
state: 'Tennessee',
zip: '101010',
country: 'USA'
},
homeAddress: {
street1: '445 Fine Finch Fairway',
street2: 'Apt 201',
street3: '',
city: 'Fairfence',
county: 'FOO',
state: 'Florida',
zip: '445545',
country: 'USA'
},
homePhone: '5552223333',
mobilePhone: '5553334444',
workPhone: '5554445555',
emailAddress: 'kermit.frog@sesameenterprises.us'
},
appointments: [
{
appointmentIEN: '1',
Expand Down
8 changes: 5 additions & 3 deletions modules/check_in/spec/services/v2/lorota/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,26 @@
end

describe '#get' do
let(:conn) { double('Faraday::Connection') }
let(:req) { Faraday::Request.new }

it 'connection is called with get' do
allow_any_instance_of(Faraday::Connection).to receive(:get).with(anything).and_return(anything)

expect_any_instance_of(Faraday::Connection).to receive(:get)
.with('/dev/data/d602d9eb-9a31-484f-9637-13ab0b507e0d').once
.with('/dev/data/d602d9eb-9a31-484f-9637-13ab0b507e0d').once.and_yield(req)

subject.build.get('/dev/data/d602d9eb-9a31-484f-9637-13ab0b507e0d')
end
end

describe '#post' do
let(:req) { Faraday::Request.new }

it 'connection is called with post' do
allow_any_instance_of(Faraday::Connection).to receive(:post).with(anything).and_return(anything)

expect_any_instance_of(Faraday::Connection).to receive(:post)
.with('/dev/token').once
.with('/dev/token').once.and_yield(req)

subject.build.post('/dev/token', {})
end
Expand Down
57 changes: 55 additions & 2 deletions modules/check_in/spec/services/v2/lorota/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
let(:memory_store) { ActiveSupport::Cache.lookup_store(:memory_store) }

before do
allow(Flipper).to receive(:enabled?).with(:check_in_experience_demographics_page_enabled).and_return(true)
allow(Rails).to receive(:cache).and_return(memory_store)

Rails.cache.clear
Expand Down Expand Up @@ -53,6 +54,32 @@
id: 'd602d9eb-9a31-484f-9637-13ab0b507e0d',
scope: 'read.full',
payload: {
demographics: {
mailingAddress: {
street1: '123 Turtle Trail',
street2: '',
street3: '',
city: 'Treetopper',
county: 'SAN BERNARDINO',
state: 'Tennessee',
zip: '101010',
country: 'USA'
},
homeAddress: {
street1: '445 Fine Finch Fairway',
street2: 'Apt 201',
street3: '',
city: 'Fairfence',
county: 'FOO',
state: 'Florida',
zip: '445545',
country: 'USA'
},
homePhone: '5552223333',
mobilePhone: '5553334444',
workPhone: '5554445555',
emailAddress: 'kermit.frog@sesameenterprises.us'
},
appointments: [
{
appointmentIEN: '1',
Expand Down Expand Up @@ -92,8 +119,33 @@
end
let(:approved_response) do
{
id: 'd602d9eb-9a31-484f-9637-13ab0b507e0d',
payload: {
demographics: {
mailingAddress: {
street1: '123 Turtle Trail',
street2: '',
street3: '',
city: 'Treetopper',
county: 'SAN BERNARDINO',
state: 'Tennessee',
zip: '101010',
country: 'USA'
},
homeAddress: {
street1: '445 Fine Finch Fairway',
street2: 'Apt 201',
street3: '',
city: 'Fairfence',
county: 'FOO',
state: 'Florida',
zip: '445545',
country: 'USA'
},
homePhone: '5552223333',
mobilePhone: '5553334444',
workPhone: '5554445555',
emailAddress: 'kermit.frog@sesameenterprises.us'
},
appointments: [
{
'appointmentIEN' => '1',
Expand Down Expand Up @@ -124,7 +176,8 @@
'timeCheckedIn' => 'time the user checked already'
}
]
}
},
id: 'd602d9eb-9a31-484f-9637-13ab0b507e0d'
}
end

Expand Down

0 comments on commit 35889a6

Please sign in to comment.