-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
71787 CIE VAOS Appointment Serializer #16304
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
446a1c3
71787 CIE VAOS Appointment Serializer
5dce8b9
Reducing LOC
a60dfe0
Merge branch 'master' into 71787_CIE_VAOS_Appointment_Serializer
kanchanasuriya 2ab467c
Merge branch 'master' into 71787_CIE_VAOS_Appointment_Serializer
kanchanasuriya de407bb
Merge branch 'master' into 71787_CIE_VAOS_Appointment_Serializer
kanchanasuriya 7188cf1
Removing unwanted test data
8599186
Merge branch 'master' into 71787_CIE_VAOS_Appointment_Serializer
kanchanasuriya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
modules/check_in/app/serializers/check_in/vaos/vaos_appointment_data_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckIn | ||
module VAOS | ||
class VAOSAppointmentDataSerializer | ||
include JSONAPI::Serializer | ||
|
||
keys_to_serialize = %i[id identifier kind status serviceType locationId clinic start end extension] | ||
|
||
set_id(&:id) | ||
|
||
attribute :appointments do |object| | ||
object.data.map do |data| | ||
data.select { |key| keys_to_serialize.include?(key) } | ||
end | ||
end | ||
end | ||
end | ||
end |
249 changes: 249 additions & 0 deletions
249
modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,249 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe CheckIn::VAOS::VAOSAppointmentDataSerializer do | ||
subject { described_class } | ||
|
||
let(:vaos_appointment_data) do | ||
{ | ||
data: [ | ||
{ | ||
id: '180765', | ||
identifier: [ | ||
{ | ||
system: 'Appointment/', | ||
value: '413938333130383735' | ||
}, | ||
{ | ||
system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', | ||
value: '983:10875' | ||
} | ||
], | ||
kind: 'clinic', | ||
status: 'booked', | ||
serviceType: 'amputation', | ||
patientIcn: '1013125218V696863', | ||
locationId: '983GC', | ||
clinic: '1081', | ||
start: '2023-11-06T16:00:00Z', | ||
end: '2023-11-06T16:30:00Z', | ||
minutesDuration: 30, | ||
created: '2023-08-02T00:00:00Z', | ||
cancellable: true, | ||
extension: { | ||
ccLocation: { | ||
address: {} | ||
}, | ||
vistaStatus: [ | ||
'NO ACTION TAKEN' | ||
], | ||
preCheckinAllowed: true, | ||
eCheckinAllowed: true | ||
} | ||
}, | ||
{ | ||
id: '180766', | ||
identifier: [ | ||
{ | ||
system: 'Appointment/', | ||
value: '413938333130383736' | ||
}, | ||
{ | ||
system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', | ||
value: '983:10876' | ||
} | ||
], | ||
kind: 'clinic', | ||
status: 'booked', | ||
serviceType: 'amputation', | ||
patientIcn: '1013125218V696863', | ||
locationId: '983GC', | ||
clinic: '1081', | ||
start: '2023-11-13T16:00:00Z', | ||
end: '2023-11-13T16:30:00Z', | ||
minutesDuration: 30, | ||
created: '2023-08-02T00:00:00Z', | ||
cancellable: true, | ||
extension: { | ||
ccLocation: { | ||
address: {} | ||
}, | ||
vistaStatus: [ | ||
'FUTURE' | ||
], | ||
preCheckinAllowed: true, | ||
eCheckinAllowed: true | ||
} | ||
} | ||
] | ||
} | ||
end | ||
|
||
context 'For valid vaos appointment data' do | ||
let(:appointment1) do | ||
{ | ||
id: '180765', | ||
identifier: [ | ||
{ | ||
system: 'Appointment/', | ||
value: '413938333130383735' | ||
}, | ||
{ | ||
system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', | ||
value: '983:10875' | ||
} | ||
], | ||
kind: 'clinic', | ||
status: 'booked', | ||
serviceType: 'amputation', | ||
locationId: '983GC', | ||
clinic: '1081', | ||
start: '2023-11-06T16:00:00Z', | ||
end: '2023-11-06T16:30:00Z', | ||
extension: { | ||
ccLocation: { | ||
address: {} | ||
}, | ||
vistaStatus: [ | ||
'NO ACTION TAKEN' | ||
], | ||
preCheckinAllowed: true, | ||
eCheckinAllowed: true | ||
} | ||
} | ||
end | ||
let(:appointment2) do | ||
{ | ||
id: '180766', | ||
identifier: [ | ||
{ | ||
system: 'Appointment/', | ||
value: '413938333130383736' | ||
}, | ||
{ | ||
system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', | ||
value: '983:10876' | ||
} | ||
], | ||
kind: 'clinic', | ||
status: 'booked', | ||
serviceType: 'amputation', | ||
locationId: '983GC', | ||
clinic: '1081', | ||
start: '2023-11-13T16:00:00Z', | ||
end: '2023-11-13T16:30:00Z', | ||
extension: { | ||
ccLocation: { | ||
address: {} | ||
}, | ||
vistaStatus: [ | ||
'FUTURE' | ||
], | ||
preCheckinAllowed: true, | ||
eCheckinAllowed: true | ||
} | ||
} | ||
end | ||
|
||
let(:serialized_hash_response) do | ||
{ | ||
data: | ||
{ | ||
id: nil, | ||
type: :vaos_appointment_data, | ||
attributes: | ||
{ | ||
appointments: | ||
[ | ||
appointment1, appointment2 | ||
] | ||
} | ||
} | ||
} | ||
end | ||
|
||
it 'returns a serialized hash' do | ||
appt_struct = OpenStruct.new(vaos_appointment_data) | ||
appt_serializer = subject.new(appt_struct) | ||
expect(appt_serializer.serializable_hash).to eq(serialized_hash_response) | ||
end | ||
end | ||
|
||
context 'Missing serialization key' do | ||
let(:vaos_appointment_data_without_identifier) do | ||
{ | ||
data: [ | ||
{ | ||
id: '180765', | ||
kind: 'clinic', | ||
status: 'booked', | ||
serviceType: 'amputation', | ||
patientIcn: '1013125218V696863', | ||
locationId: '983GC', | ||
clinic: '1081', | ||
start: '2023-11-06T16:00:00Z', | ||
end: '2023-11-06T16:30:00Z', | ||
created: '2023-08-02T00:00:00Z', | ||
cancellable: true, | ||
extension: { | ||
ccLocation: { | ||
address: {} | ||
}, | ||
vistaStatus: [ | ||
'NO ACTION TAKEN' | ||
], | ||
preCheckinAllowed: true, | ||
eCheckinAllowed: true | ||
} | ||
} | ||
] | ||
} | ||
end | ||
|
||
let(:appointment_without_identifier) do | ||
{ | ||
id: '180765', | ||
kind: 'clinic', | ||
status: 'booked', | ||
serviceType: 'amputation', | ||
locationId: '983GC', | ||
clinic: '1081', | ||
start: '2023-11-06T16:00:00Z', | ||
end: '2023-11-06T16:30:00Z', | ||
extension: { | ||
ccLocation: { | ||
address: {} | ||
}, | ||
vistaStatus: [ | ||
'NO ACTION TAKEN' | ||
], | ||
preCheckinAllowed: true, | ||
eCheckinAllowed: true | ||
} | ||
} | ||
end | ||
let(:serialized_hash_response) do | ||
{ | ||
data: | ||
{ | ||
id: nil, | ||
type: :vaos_appointment_data, | ||
attributes: | ||
{ | ||
appointments: | ||
[ | ||
appointment_without_identifier | ||
] | ||
} | ||
} | ||
} | ||
end | ||
|
||
it 'identifier not present' do | ||
appt_struct = OpenStruct.new(vaos_appointment_data_without_identifier) | ||
appt_serializer = subject.new(appt_struct) | ||
expect(appt_serializer.serializable_hash).to eq(serialized_hash_response) | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need to put the whole payload here to test the serializer, or can we trim it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought of having the real sample data received from VAOS service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's almost 300 lines of the payload, that are IMHO unnecessary. I would suggest trimming it and keeping the parts that are really needed to test the serializer and trimming the rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trimmed test data further to reduce the line of code in 7188cf.