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 authored Apr 12, 2024
2 parents 6a1cc4d + 84381a1 commit 343a2d8
Show file tree
Hide file tree
Showing 4 changed files with 203 additions and 1 deletion.
29 changes: 28 additions & 1 deletion app/controllers/v0/health_care_applications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'hca/service'
require 'bgs/service'
require 'pdf_fill/filler'
require 'lighthouse/facilities/v1/client'

module V0
class HealthCareApplicationsController < ApplicationController
Expand All @@ -11,7 +12,7 @@ class HealthCareApplicationsController < ApplicationController
service_tag 'healthcare-application'
FORM_ID = '1010ez'

skip_before_action(:authenticate, only: %i[create show enrollment_status healthcheck download_pdf])
skip_before_action(:authenticate, only: %i[create show enrollment_status healthcheck download_pdf facilities])

before_action :record_submission_attempt, only: :create
before_action :load_user, only: %i[create enrollment_status]
Expand Down Expand Up @@ -76,12 +77,38 @@ def download_pdf
send_data file_contents, filename: file_name_for_pdf, type: 'application/pdf', disposition: 'attachment'
end

def facilities
render(json: lighthouse_facilities_service.get_facilities(lighthouse_facilities_params))
end

private

def health_care_application
@health_care_application ||= HealthCareApplication.new(params.permit(:form))
end

def lighthouse_facilities_service
@lighthouse_facilities_service ||= Lighthouse::Facilities::V1::Client.new
end

def lighthouse_facilities_params
params.permit(
:zip,
:state,
:lat,
:long,
:radius,
:bbox,
:visn,
:type,
:services,
:mobile,
:page,
:per_page,
facilityIds: []
)
end

def file_name_for_pdf
veteran_name = health_care_application.parsed_form.try(:[], 'veteranFullName')
first_name = veteran_name.try(:[], 'first') || 'First'
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
get(:healthcheck)
get(:enrollment_status)
get(:rating_info)
get(:facilities)
post(:download_pdf)
end
end
Expand Down
45 changes: 45 additions & 0 deletions spec/requests/health_care_applications_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,51 @@
end
end

describe 'GET facilities' do
it 'responds with facilities data' do
VCR.use_cassette('lighthouse/facilities/v1/200_facilities_facility_ids', match_requests_on: %i[method uri]) do
get(facilities_v0_health_care_applications_path(facilityIds: %w[vha_757 vha_358]))
end
expect(response).to have_http_status(:ok)
expect(response.parsed_body[0]).to eq({ 'access' => nil,
'active_status' => nil,
'address' => {
'mailing' => { 'zip' => '66713', 'city' => 'Leavenworth',
'state' => 'KS', 'address1' => '150 Muncie Rd' },
'physical' => { 'zip' => '66713', 'city' => 'Baxter Springs',
'state' => 'KS',
'address1' => 'Baxter Springs City Cemetery' }
},
'classification' => 'Soldiers Lot',
'detailed_services' => nil,
'distance' => nil,
'facility_type' => 'va_cemetery',
'facility_type_prefix' => 'nca',
'feedback' => nil,
'hours' =>
{ 'monday' => 'Sunrise - Sundown',
'tuesday' => 'Sunrise - Sundown',
'wednesday' => 'Sunrise - Sundown',
'thursday' => 'Sunrise - Sundown',
'friday' => 'Sunrise - Sundown',
'saturday' => 'Sunrise - Sundown',
'sunday' => 'Sunrise - Sundown' },
'id' => 'nca_042',
'lat' => 37.0320575,
'long' => -94.7706605,
'mobile' => nil,
'name' => "Baxter Springs City Soldiers' Lot",
'operating_status' => { 'code' => 'NORMAL' },
'operational_hours_special_instructions' => nil,
'phone' => { 'fax' => '9137584136', 'main' => '9137584105' },
'services' => nil,
'type' => 'va_facilities',
'unique_id' => '042',
'visn' => nil,
'website' => 'https://www.cem.va.gov/cems/lots/BaxterSprings.asp' })
end
end

describe 'POST create' do
subject do
post(v0_health_care_applications_path,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 343a2d8

Please sign in to comment.