Skip to content
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

[10-10EZ] Boilerplate to generate filled out 10-10EZ pdf #20784

Merged
merged 4 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/health_care_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ def send_failure_email?
async_submission_failed? && email.present?
end

def form_id
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is expected by PdfFill::Filler since it is generally expecting a saved_claim model, but our hca model has the same parsed_form object as the saved_claim model so it appears to work fine.

self.class::FORM_ID
end

def submit_sync
@parsed_form = HCA::OverridesParser.new(parsed_form).override

Expand Down
2 changes: 2 additions & 0 deletions lib/pdf_fill/filler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'pdf_fill/forms/va210781v2'
require 'pdf_fill/forms/va218940'
require 'pdf_fill/forms/va1010cg'
require 'pdf_fill/forms/va1010ez'
require 'pdf_fill/forms/va686c674'
require 'pdf_fill/forms/va281900'
require 'pdf_fill/forms/va288832'
Expand Down Expand Up @@ -52,6 +53,7 @@ def register_form(form_id, form_class)
'21-0781V2' => PdfFill::Forms::Va210781v2,
'21-8940' => PdfFill::Forms::Va218940,
'10-10CG' => PdfFill::Forms::Va1010cg,
'10-10EZ' => PdfFill::Forms::Va1010ez,
'686C-674' => PdfFill::Forms::Va686c674,
'28-1900' => PdfFill::Forms::Va281900,
'28-8832' => PdfFill::Forms::Va288832,
Expand Down
Binary file added lib/pdf_fill/forms/pdfs/10-10EZ.pdf
Binary file not shown.
29 changes: 29 additions & 0 deletions lib/pdf_fill/forms/va1010ez.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

require 'pdf_fill/forms/form_base'

module PdfFill
module Forms
class Va1010ez < FormBase
FORM_ID = HealthCareApplication::FORM_ID

KEY = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be updated to include all fields in future PRs, but for now we wanted to just get the basic generation/filling functionality out there. This work is not exposed externally anywhere either.

'veteranFullName' => {
key: 'F[0].P4[0].LastFirstMiddle[0]'
}
}.freeze

def merge_fields(_options = {})
merge_full_name
@form_data
end

private

def merge_full_name
@form_data['veteranFullName'] =
combine_full_name(@form_data['veteranFullName'])
end
end
end
end
112 changes: 112 additions & 0 deletions spec/fixtures/pdf_fill/10-10EZ/merge_fields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"isMedicaidEligible": true,
"spouseAddress": {
"street": "12345 Elm St",
"city": "Houston",
"postalCode": "77388",
"country": "USA",
"state": "TX"
},
"spousePhone": "2122122121",
"cohabitedLastYear": true,
"sameAddress": false,
"medicarePartAEffectiveDate": "2000-01-01",
"medicareClaimNumber": "0123456",
"isEnrolledMedicarePartA": true,
"isCoveredByHealthInsurance": true,
"providers": [
{
"insuranceName": "Aetna",
"insurancePolicyHolderName": "Indiana Jones",
"insurancePolicyNumber": "32345111",
"insuranceGroupCode": "1233444"
}
],
"deductibleMedicalExpenses": 0,
"deductibleFuneralExpenses": 0,
"deductibleEducationExpenses": 0,
"spouseGrossIncome": 20,
"spouseNetIncome": 21,
"spouseOtherIncome": 22,
"veteranGrossIncome": 60000,
"veteranNetIncome": 0,
"veteranOtherIncome": 0,
"spouseFullName": {
"first": "Jane",
"middle": "marie",
"last": "Jones"
},
"spouseDateOfBirth": "1977-01-01",
"dateOfMarriage": "2000-01-01",
"maritalStatus": "Married",
"purpleHeartRecipient": true,
"isFormerPow": true,
"postNov111998Combat": true,
"disabledInLineOfDuty": true,
"swAsiaCombat": true,
"vietnamService": true,
"exposedToRadiation": true,
"radiumTreatments": true,
"campLejeune": true,
"discloseFinancialInformation": true,
"lastServiceBranch": "air force",
"lastEntryDate": "1998-01-01",
"lastDischargeDate": "2004-01-01",
"dischargeType": "honorable",
"vaCompensationType": "lowDisability",
"isAmericanIndianOrAlaskanNative": true,
"isAsian": true,
"isBlackOrAfricanAmerican": true,
"isSpanishHispanicLatino": true,
"isNativeHawaiianOrOtherPacificIslander": true,
"isWhite": true,
"hasDemographicNoAnswer": true,
"isEssentialAcaCoverage": true,
"vaMedicalFacility": "520GA",
"wantsInitialVaContact": true,
"email": "[email protected]",
"homePhone": "3462636183",
"mobilePhone": "3462636184",
"veteranAddress": {
"street": "321 Elm St",
"city": "Houston",
"postalCode": "77388",
"country": "USA",
"state": "TX"
},
"gender": "M",
"mothersMaidenName": "Test",
"cityOfBirth": "Spring",
"stateOfBirth": "TX",
"veteranFullName": "Indiana Bill Jones II",
"veteranSocialSecurityNumber": "234221243",
"veteranDateOfBirth": "1980-01-01",
"privacyAgreementAccepted": true,
"dependents": [
{
"fullName": {
"first": "Bob",
"middle": "Joe",
"last": "Jones"
},
"dependentRelation": "Son",
"socialSecurityNumber": "343221234",
"dateOfBirth": "2000-02-01",
"becameDependent": "2000-02-01",
"attendedSchoolLastYear": true,
"dependentEducationExpenses": 0,
"disabledBefore18": false,
"cohabitedLastYear": true,
"grossIncome": 10,
"netIncome": 11,
"otherIncome": 12
}
],
"veteranHomeAddress": {
"street": "123 Elm St",
"city": "Houston",
"postalCode": "77388",
"country": "USA",
"state": "TX"
}
}
6 changes: 4 additions & 2 deletions spec/fixtures/pdf_fill/10-10EZ/simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@
"stateOfBirth": "TX",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was leftover from previous work to generate a 10-10EZ pdf. I updated it to test the full name functionality. In future PRs I will update the kitchent_sink and simple files to ensure they have the proper values for each, but for now I kept this since it had all of the required fields per the vets-json-schema for this form.

"veteranFullName": {
"first": "Indiana",
"last": "Jones"
"middle": "Bill",
"last": "Jones",
"suffix": "II"
},
"veteranSocialSecurityNumber": "234221243",
"veteranDateOfBirth": "1980-01-01",
Expand Down Expand Up @@ -112,4 +114,4 @@
"country": "USA",
"state": "TX"
}
}
}
Binary file modified spec/fixtures/pdf_fill/10-10EZ/unsigned/simple.pdf
Binary file not shown.
7 changes: 5 additions & 2 deletions spec/lib/pdf_fill/fill_form_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# - :input_data_fixture_dir (String): Directory path for input data fixtures. Default to "pdf_fill/#{form_id}".
# - :output_pdf_fixture_dir (String): Directory path for output PDF fixtures. Default to "pdf_fill/#{form_id}".
# - :fill_options (Hash): Options to be passed to the `fill_form` method. Default empty.
# - :test_data_types (Array): Array of form data to validate. Defaults to %w[simple kitchen_sink overflow]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this shared_example to allow for testing just some of the data types, while keeping it backwards compatible by setting the default if it is not supplied. Naming things is hard, so open to a different name here.

#
# Example Usage:
#
Expand All @@ -23,16 +24,18 @@
# use_vets_json_schema: true,
# input_data_fixture_dir: 'modules/pensions/spec/pdf_fill/fixtures',
# output_pdf_fixture_dir: 'modules/pensions/spec/pdf_fill/fixtures'
# test_data_types: %w[simple]
# }
RSpec.shared_examples 'a form filler' do |options|
form_id, factory = options.values_at(:form_id, :factory)
form_id, factory, test_data_types = options.values_at(:form_id, :factory, :test_data_types)
test_data_types ||= %w[simple kitchen_sink overflow]

describe PdfFill::Filler, type: :model do
context "form #{form_id}", run_at: '2017-07-25 00:00:00 -0400' do
let(:input_data_fixture_dir) { options[:input_data_fixture_dir] || "spec/fixtures/pdf_fill/#{form_id}" }
let(:output_pdf_fixture_dir) { options[:output_pdf_fixture_dir] || "spec/fixtures/pdf_fill/#{form_id}" }

%w[simple kitchen_sink overflow].each do |type|
test_data_types.each do |type|
context "with #{type} test data" do
let(:form_data) do
return get_fixture_absolute("#{input_data_fixture_dir}/#{type}") unless options[:use_vets_json_schema]
Expand Down
33 changes: 33 additions & 0 deletions spec/lib/pdf_fill/forms/va1010ez_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

require 'rails_helper'
require 'pdf_fill/forms/va1010ez'
require 'lib/pdf_fill/fill_form_examples'

describe PdfFill::Forms::Va1010ez do
include SchemaMatchers

let(:form_data) do
get_fixture('pdf_fill/10-10EZ/simple')
end

let(:form_class) do
described_class.new(form_data)
end

it_behaves_like 'a form filler', {
form_id: described_class::FORM_ID,
factory: :health_care_application,
input_data_fixture_dir: 'spec/fixtures/pdf_fill/10-10EZ',
output_pdf_fixture_dir: 'spec/fixtures/pdf_fill/10-10EZ/unsigned',
test_data_types: %w[simple]
}

describe '#merge_fields' do
it 'merges the right fields' do
expect(form_class.merge_fields.to_json).to eq(
get_fixture('pdf_fill/10-10EZ/merge_fields').to_json
)
end
end
end
6 changes: 6 additions & 0 deletions spec/models/health_care_application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -910,4 +910,10 @@ def self.expect_job_submission(job)
end
end
end

describe '#form_id' do
it 'has form_id from FORM_ID const' do
expect(health_care_application.form_id).to eq described_class::FORM_ID
end
end
end
Loading