Skip to content

Commit

Permalink
[Automated] Merged master into target k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
va-vsp-bot committed Apr 23, 2024
2 parents e248699 + 373a339 commit f9c74e6
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 0 deletions.
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module CheckIn
module Facilities
class FacilitiesDataSerializer
include JSONAPI::Serializer

set_id(&:id)

attribute :name, :type, :classification, :timezone, :phone, :physicalAddress
end
end
end
@@ -0,0 +1,144 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.describe CheckIn::Facilities::FacilitiesDataSerializer do
subject { described_class }

let(:facilities_data) do
{
id: '442',
facilitiesApiId: 'vha_442',
vistaSite: '442',
vastParent: '442',
type: 'va_health_facility',
name: 'Cheyenne VA Medical Center',
classification: 'VA Medical Center (VAMC)',
timezone: {
timeZoneId: 'America/Denver'
},
lat: 41.148026,
long: -104.786255,
website: 'https://www.va.gov/cheyenne-health-care/locations/cheyenne-va-medical-center/',
phone: {
main: '307-778-7550',
fax: '307-778-7381',
pharmacy: '866-420-6337',
afterHours: '307-778-7550',
patientAdvocate: '307-778-7550 x7573',
mentalHealthClinic: '307-778-7349',
enrollmentCoordinator: '307-778-7550 x7579'
},
mailingAddress: {
type: 'postal',
line: [nil, nil, nil]
},
physicalAddress: {
type: 'physical',
line: ['2360 East Pershing Boulevard', nil, nil],
city: 'Cheyenne',
state: 'WY',
postalCode: '82001-5356'
},
mobile: false,
healthService: %w[Audiology Cardiology CaregiverSupport Covid19Vaccine DentalServices Dermatology EmergencyCare
Gastroenterology Gynecology MentalHealthCare Nutrition Ophthalmology Optometry Orthopedics
Podiatry PrimaryCare Urology WomensHealth],
operatingStatus: {
code: 'NORMAL'
},
visn: '19'
}
end

describe '#serializable_hash' do
context 'when all the necessary fields exist' do
let(:serialized_hash_response) do
{
data: {
id: '442',
type: :facilities_data,
attributes: {
type: 'va_health_facility',
name: 'Cheyenne VA Medical Center',
classification: 'VA Medical Center (VAMC)',
timezone: {
timeZoneId: 'America/Denver'
},
phone: {
main: '307-778-7550',
fax: '307-778-7381',
pharmacy: '866-420-6337',
afterHours: '307-778-7550',
patientAdvocate: '307-778-7550 x7573',
mentalHealthClinic: '307-778-7349',
enrollmentCoordinator: '307-778-7550 x7579'
},
physicalAddress: {
type: 'physical',
line: ['2360 East Pershing Boulevard', nil, nil],
city: 'Cheyenne',
state: 'WY',
postalCode: '82001-5356'
}
}
}
}
end

it 'returns a serialized hash' do
facilities_struct = OpenStruct.new(facilities_data)
facilities_serializer = CheckIn::Facilities::FacilitiesDataSerializer.new(facilities_struct)

expect(facilities_serializer.serializable_hash).to eq(serialized_hash_response)
end
end

context 'when name does not exist' do
let(:facilities_data_without_name) do
facilities_data.except!(:name)
facilities_data
end

let(:serialized_hash_response) do
{
data: {
id: '442',
type: :facilities_data,
attributes: {
name: nil,
type: 'va_health_facility',
classification: 'VA Medical Center (VAMC)',
timezone: {
timeZoneId: 'America/Denver'
},
phone: {
main: '307-778-7550',
fax: '307-778-7381',
pharmacy: '866-420-6337',
afterHours: '307-778-7550',
patientAdvocate: '307-778-7550 x7573',
mentalHealthClinic: '307-778-7349',
enrollmentCoordinator: '307-778-7550 x7579'
},
physicalAddress: {
type: 'physical',
line: ['2360 East Pershing Boulevard', nil, nil],
city: 'Cheyenne',
state: 'WY',
postalCode: '82001-5356'
}
}
}
}
end

it 'returns a serialized hash with nil in name field' do
facilities_struct = OpenStruct.new(facilities_data_without_name)
facilities_serializer = CheckIn::Facilities::FacilitiesDataSerializer.new(facilities_struct)

expect(facilities_serializer.serializable_hash).to eq(serialized_hash_response)
end
end
end
end

0 comments on commit f9c74e6

Please sign in to comment.