Skip to content

Commit

Permalink
Merge branch 'master' into 97-add_endpoint_for_avg_number_of_days
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatos312 authored Apr 12, 2024
2 parents b6d120e + c81ef53 commit 00922f7
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 5 deletions.
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
4 changes: 3 additions & 1 deletion lib/pdf_fill/forms/va21p530v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,9 @@ def merge_fields(_options = {})

expand_cemetery_location

# special case: the UI only has a 'yes' checkbox, so the PDF 'noTransportation' checkbox can never be true.
@form_data['hasTransportation'] = @form_data['transportation'] == true ? 'YES' : nil

# special case: these fields were built as checkboxes instead of radios, so usual radio logic can't be used.
burial_expense_responsibility = @form_data['burialExpenseResponsibility']
@form_data['hasBurialExpenseResponsibility'] = burial_expense_responsibility ? 'On' : nil
Expand Down Expand Up @@ -759,7 +762,6 @@ def merge_fields(_options = {})
govtContributions
previouslyReceivedAllowance
allowanceStatementOfTruth
transportation
].each do |attr|
expand_checkbox_in_place(@form_data, attr)
end
Expand Down
5 changes: 2 additions & 3 deletions spec/fixtures/pdf_fill/21P-530V2/merge_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"signatureDate":"2024-03-21",
"veteranSocialSecurityNumber2":{"first":"987", "second":"65", "third":"4322"},
"veteranSocialSecurityNumber3":{"first":"987", "second":"65", "third":"4322"},
"hasTransportation":"YES",
"hasBurialExpenseResponsibility":"On",
"noBurialExpenseResponsibility":null,
"hasPlotExpenseResponsibility":"On",
Expand All @@ -93,7 +94,5 @@
"hasPreviouslyReceivedAllowance":"YES",
"noPreviouslyReceivedAllowance":null,
"hasAllowanceStatementOfTruth":null,
"noAllowanceStatementOfTruth":null,
"hasTransportation":"YES",
"noTransportation":null
"noAllowanceStatementOfTruth":null
}
13 changes: 13 additions & 0 deletions spec/lib/pdf_fill/forms/va21p530v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,18 @@ def class_form_data
get_fixture('pdf_fill/21P-530V2/merge_fields').to_json
)
end

it 'leaves benefit selections blank on pdf if unselected', run_at: '2024-03-21 00:00:00 EDT' do
unselected_benefits_data = get_fixture('pdf_fill/21P-530V2/kitchen_sink').except(
'burialAllowance', 'plotAllowance', 'transportation'
)
expected_merge_data = get_fixture('pdf_fill/21P-530V2/merge_fields').except(
'burialAllowance', 'plotAllowance', 'transportation'
)
expected_merge_data['hasTransportation'] = nil
expect(described_class.new(unselected_benefits_data).merge_fields.to_json).to eq(
expected_merge_data.to_json
)
end
end
end
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 00922f7

Please sign in to comment.