From 446a1c3875aabe4a615c603381bcb87ca65ba6e6 Mon Sep 17 00:00:00 2001 From: kanchanasuriya Date: Tue, 9 Apr 2024 09:27:52 -0700 Subject: [PATCH 1/3] 71787 CIE VAOS Appointment Serializer --- .../vaos/vaos_appointment_data_serializer.rb | 19 + .../vaos_appointment_data_serializer_spec.rb | 517 ++++++++++++++++++ 2 files changed, 536 insertions(+) create mode 100644 modules/check_in/app/serializers/check_in/vaos/vaos_appointment_data_serializer.rb create mode 100644 modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb diff --git a/modules/check_in/app/serializers/check_in/vaos/vaos_appointment_data_serializer.rb b/modules/check_in/app/serializers/check_in/vaos/vaos_appointment_data_serializer.rb new file mode 100644 index 00000000000..9a524002c2a --- /dev/null +++ b/modules/check_in/app/serializers/check_in/vaos/vaos_appointment_data_serializer.rb @@ -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 diff --git a/modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb b/modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb new file mode 100644 index 00000000000..1c9c4bd6772 --- /dev/null +++ b/modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb @@ -0,0 +1,517 @@ +# 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', + serviceTypes: [ + { + coding: [ + { + system: 'http://veteran.apps.va.gov/terminologies/fhir/CodeSystem/vats-service-type', + code: 'amputation' + } + ] + } + ], + serviceCategory: [ + { + coding: [ + { + system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_1', + code: 'REGULAR', + display: 'REGULAR' + } + ], + text: 'REGULAR' + } + ], + patientIcn: '1013125218V696863', + locationId: '983GC', + clinic: '1081', + start: '2023-11-06T16:00:00Z', + end: '2023-11-06T16:30:00Z', + minutesDuration: 30, + slot: { + id: '3230323331313036313630303A323032333131303631363330', + 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 + } + }, + { + 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', + serviceTypes: [ + { + coding: [ + { + system: 'http://veteran.apps.va.gov/terminologies/fhir/CodeSystem/vats-service-type', + code: 'amputation' + } + ] + } + ], + serviceCategory: [ + { + coding: [ + { + system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_1', + code: 'REGULAR', + display: 'REGULAR' + } + ], + text: 'REGULAR' + } + ], + patientIcn: '1013125218V696863', + locationId: '983GC', + clinic: '1081', + start: '2023-11-13T16:00:00Z', + end: '2023-11-13T16:30:00Z', + minutesDuration: 30, + slot: { + id: '3230323331313133313630303A323032333131313331363330', + start: '2023-11-13T16:00:00Z', + end: '2023-11-13T16:30:00Z' + }, + created: '2023-08-02T00:00:00Z', + cancellable: true, + extension: { + ccLocation: { + address: {} + }, + vistaStatus: [ + 'FUTURE' + ], + preCheckinAllowed: true, + eCheckinAllowed: true + } + }, + { + id: '180767', + identifier: [ + { + system: 'Appointment/', + value: '413938333130383737' + }, + { + system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', + value: '983:10877' + } + ], + kind: 'clinic', + status: 'booked', + serviceType: 'amputation', + serviceTypes: [ + { + coding: [ + { + system: 'http://veteran.apps.va.gov/terminologies/fhir/CodeSystem/vats-service-type', + code: 'amputation' + } + ] + } + ], + serviceCategory: [ + { + coding: [ + { + system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_1', + code: 'REGULAR', + display: 'REGULAR' + } + ], + text: 'REGULAR' + } + ], + patientIcn: '1013125218V696863', + locationId: '983GC', + clinic: '1081', + start: '2023-11-20T16:00:00Z', + end: '2023-11-20T16:30:00Z', + minutesDuration: 30, + slot: { + id: '3230323331313230313630303A323032333131323031363330', + start: '2023-11-20T16:00:00Z', + end: '2023-11-20T16:30:00Z' + }, + created: '2023-08-02T00:00:00Z', + cancellable: true, + extension: { + ccLocation: { + address: {} + }, + vistaStatus: [ + 'FUTURE' + ], + preCheckinAllowed: true, + eCheckinAllowed: true + } + }, + { + id: '180768', + identifier: [ + { + system: 'Appointment/', + value: '413938333130383738' + }, + { + system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', + value: '983:10878' + } + ], + kind: 'clinic', + status: 'booked', + serviceType: 'amputation', + serviceTypes: [ + { + coding: [ + { + system: 'http://veteran.apps.va.gov/terminologies/fhir/CodeSystem/vats-service-type', + code: 'amputation' + } + ] + } + ], + serviceCategory: [ + { + coding: [ + { + system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_1', + code: 'REGULAR', + display: 'REGULAR' + } + ], + text: 'REGULAR' + } + ], + patientIcn: '1013125218V696863', + locationId: '983GC', + clinic: '1081', + start: '2023-11-27T16:00:00Z', + end: '2023-11-27T16:30:00Z', + minutesDuration: 30, + slot: { + id: '3230323331313237313630303A323032333131323731363330', + start: '2023-11-27T16:00:00Z', + end: '2023-11-27T16:30:00Z' + }, + 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(:appointment3) do + { + id: '180767', + identifier: [ + { + system: 'Appointment/', + value: '413938333130383737' + }, + { + system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', + value: '983:10877' + } + ], + kind: 'clinic', + status: 'booked', + serviceType: 'amputation', + locationId: '983GC', + clinic: '1081', + start: '2023-11-20T16:00:00Z', + end: '2023-11-20T16:30:00Z', + extension: { + ccLocation: { + address: {} + }, + vistaStatus: [ + 'FUTURE' + ], + preCheckinAllowed: true, + eCheckinAllowed: true + } + } + end + let(:appointment4) do + { + id: '180768', + identifier: [ + { + system: 'Appointment/', + value: '413938333130383738' + }, + { + system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', + value: '983:10878' + } + ], + kind: 'clinic', + status: 'booked', + serviceType: 'amputation', + locationId: '983GC', + clinic: '1081', + start: '2023-11-27T16:00:00Z', + end: '2023-11-27T16: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, appointment3, appointment4 + ] + } + } + } + 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', + serviceTypes: [ + { + coding: [ + { + system: 'http://veteran.apps.va.gov/terminologies/fhir/CodeSystem/vats-service-type', + code: 'amputation' + } + ] + } + ], + serviceCategory: [ + { + coding: [ + { + system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_1', + code: 'REGULAR', + display: 'REGULAR' + } + ], + text: 'REGULAR' + } + ], + patientIcn: '1013125218V696863', + locationId: '983GC', + clinic: '1081', + start: '2023-11-06T16:00:00Z', + end: '2023-11-06T16:30:00Z', + minutesDuration: 30, + slot: { + id: '3230323331313036313630303A323032333131303631363330', + 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 From 5dce8b900f28e197040c733e1cdbc161e57319da Mon Sep 17 00:00:00 2001 From: kanchanasuriya Date: Thu, 11 Apr 2024 12:01:55 -0700 Subject: [PATCH 2/3] Reducing LOC --- .../vaos_appointment_data_serializer_spec.rb | 95 +------------------ 1 file changed, 1 insertion(+), 94 deletions(-) diff --git a/modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb b/modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb index 1c9c4bd6772..ea417fbc245 100644 --- a/modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb +++ b/modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb @@ -190,67 +190,6 @@ preCheckinAllowed: true, eCheckinAllowed: true } - }, - { - id: '180768', - identifier: [ - { - system: 'Appointment/', - value: '413938333130383738' - }, - { - system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', - value: '983:10878' - } - ], - kind: 'clinic', - status: 'booked', - serviceType: 'amputation', - serviceTypes: [ - { - coding: [ - { - system: 'http://veteran.apps.va.gov/terminologies/fhir/CodeSystem/vats-service-type', - code: 'amputation' - } - ] - } - ], - serviceCategory: [ - { - coding: [ - { - system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_1', - code: 'REGULAR', - display: 'REGULAR' - } - ], - text: 'REGULAR' - } - ], - patientIcn: '1013125218V696863', - locationId: '983GC', - clinic: '1081', - start: '2023-11-27T16:00:00Z', - end: '2023-11-27T16:30:00Z', - minutesDuration: 30, - slot: { - id: '3230323331313237313630303A323032333131323731363330', - start: '2023-11-27T16:00:00Z', - end: '2023-11-27T16:30:00Z' - }, - created: '2023-08-02T00:00:00Z', - cancellable: true, - extension: { - ccLocation: { - address: {} - }, - vistaStatus: [ - 'FUTURE' - ], - preCheckinAllowed: true, - eCheckinAllowed: true - } } ] } @@ -353,38 +292,6 @@ } } end - let(:appointment4) do - { - id: '180768', - identifier: [ - { - system: 'Appointment/', - value: '413938333130383738' - }, - { - system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', - value: '983:10878' - } - ], - kind: 'clinic', - status: 'booked', - serviceType: 'amputation', - locationId: '983GC', - clinic: '1081', - start: '2023-11-27T16:00:00Z', - end: '2023-11-27T16:30:00Z', - extension: { - ccLocation: { - address: {} - }, - vistaStatus: [ - 'FUTURE' - ], - preCheckinAllowed: true, - eCheckinAllowed: true - } - } - end let(:serialized_hash_response) do { @@ -396,7 +303,7 @@ { appointments: [ - appointment1, appointment2, appointment3, appointment4 + appointment1, appointment2, appointment3 ] } } From 7188cf136752ce032fda19bbc83be684116a1d3a Mon Sep 17 00:00:00 2001 From: kanchanasuriya Date: Tue, 16 Apr 2024 10:49:13 -0700 Subject: [PATCH 3/3] Removing unwanted test data --- .../vaos_appointment_data_serializer_spec.rb | 177 +----------------- 1 file changed, 1 insertion(+), 176 deletions(-) diff --git a/modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb b/modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb index ea417fbc245..c96be214efb 100644 --- a/modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb +++ b/modules/check_in/spec/serializers/vaos/vaos_appointment_data_serializer_spec.rb @@ -23,39 +23,12 @@ kind: 'clinic', status: 'booked', serviceType: 'amputation', - serviceTypes: [ - { - coding: [ - { - system: 'http://veteran.apps.va.gov/terminologies/fhir/CodeSystem/vats-service-type', - code: 'amputation' - } - ] - } - ], - serviceCategory: [ - { - coding: [ - { - system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_1', - code: 'REGULAR', - display: 'REGULAR' - } - ], - text: 'REGULAR' - } - ], patientIcn: '1013125218V696863', locationId: '983GC', clinic: '1081', start: '2023-11-06T16:00:00Z', end: '2023-11-06T16:30:00Z', minutesDuration: 30, - slot: { - id: '3230323331313036313630303A323032333131303631363330', - start: '2023-11-06T16:00:00Z', - end: '2023-11-06T16:30:00Z' - }, created: '2023-08-02T00:00:00Z', cancellable: true, extension: { @@ -84,100 +57,12 @@ kind: 'clinic', status: 'booked', serviceType: 'amputation', - serviceTypes: [ - { - coding: [ - { - system: 'http://veteran.apps.va.gov/terminologies/fhir/CodeSystem/vats-service-type', - code: 'amputation' - } - ] - } - ], - serviceCategory: [ - { - coding: [ - { - system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_1', - code: 'REGULAR', - display: 'REGULAR' - } - ], - text: 'REGULAR' - } - ], patientIcn: '1013125218V696863', locationId: '983GC', clinic: '1081', start: '2023-11-13T16:00:00Z', end: '2023-11-13T16:30:00Z', minutesDuration: 30, - slot: { - id: '3230323331313133313630303A323032333131313331363330', - start: '2023-11-13T16:00:00Z', - end: '2023-11-13T16:30:00Z' - }, - created: '2023-08-02T00:00:00Z', - cancellable: true, - extension: { - ccLocation: { - address: {} - }, - vistaStatus: [ - 'FUTURE' - ], - preCheckinAllowed: true, - eCheckinAllowed: true - } - }, - { - id: '180767', - identifier: [ - { - system: 'Appointment/', - value: '413938333130383737' - }, - { - system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', - value: '983:10877' - } - ], - kind: 'clinic', - status: 'booked', - serviceType: 'amputation', - serviceTypes: [ - { - coding: [ - { - system: 'http://veteran.apps.va.gov/terminologies/fhir/CodeSystem/vats-service-type', - code: 'amputation' - } - ] - } - ], - serviceCategory: [ - { - coding: [ - { - system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_1', - code: 'REGULAR', - display: 'REGULAR' - } - ], - text: 'REGULAR' - } - ], - patientIcn: '1013125218V696863', - locationId: '983GC', - clinic: '1081', - start: '2023-11-20T16:00:00Z', - end: '2023-11-20T16:30:00Z', - minutesDuration: 30, - slot: { - id: '3230323331313230313630303A323032333131323031363330', - start: '2023-11-20T16:00:00Z', - end: '2023-11-20T16:30:00Z' - }, created: '2023-08-02T00:00:00Z', cancellable: true, extension: { @@ -260,38 +145,6 @@ } } end - let(:appointment3) do - { - id: '180767', - identifier: [ - { - system: 'Appointment/', - value: '413938333130383737' - }, - { - system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_84', - value: '983:10877' - } - ], - kind: 'clinic', - status: 'booked', - serviceType: 'amputation', - locationId: '983GC', - clinic: '1081', - start: '2023-11-20T16:00:00Z', - end: '2023-11-20T16:30:00Z', - extension: { - ccLocation: { - address: {} - }, - vistaStatus: [ - 'FUTURE' - ], - preCheckinAllowed: true, - eCheckinAllowed: true - } - } - end let(:serialized_hash_response) do { @@ -303,7 +156,7 @@ { appointments: [ - appointment1, appointment2, appointment3 + appointment1, appointment2 ] } } @@ -326,39 +179,11 @@ kind: 'clinic', status: 'booked', serviceType: 'amputation', - serviceTypes: [ - { - coding: [ - { - system: 'http://veteran.apps.va.gov/terminologies/fhir/CodeSystem/vats-service-type', - code: 'amputation' - } - ] - } - ], - serviceCategory: [ - { - coding: [ - { - system: 'http://www.va.gov/Terminology/VistADefinedTerms/409_1', - code: 'REGULAR', - display: 'REGULAR' - } - ], - text: 'REGULAR' - } - ], patientIcn: '1013125218V696863', locationId: '983GC', clinic: '1081', start: '2023-11-06T16:00:00Z', end: '2023-11-06T16:30:00Z', - minutesDuration: 30, - slot: { - id: '3230323331313036313630303A323032333131303631363330', - start: '2023-11-06T16:00:00Z', - end: '2023-11-06T16:30:00Z' - }, created: '2023-08-02T00:00:00Z', cancellable: true, extension: {