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

Form 21-22a: Fill in questions 19a and 19b on generated PDF #19460

Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ def flatten_form_params
}.merge(flatten_veteran_params(form_params))
.merge(flatten_claimant_params(form_params))
end

def flatten_veteran_params(veteran_params)
super.merge(veteran_insurance_numbers: veteran_params.dig(:veteran, :insurance_numbers))
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ def flatten_form_params
representative_id: form_params[:representative][:id],
record_consent: form_params[:record_consent],
consent_limits: form_params[:consent_limits],
consent_address_change: form_params[:consent_address_change]
consent_address_change: form_params[:consent_address_change],
consent_inside_access: form_params[:consent_inside_access],
consent_outside_access: form_params[:consent_outside_access],
consent_team_members: form_params[:consent_team_members]
}.merge(flatten_veteran_params(form_params))
.merge(flatten_claimant_params(form_params))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ def params_permitted
[
:record_consent,
:consent_address_change,
:consent_inside_access,
:consent_outside_access,
{ consent_limits: [],
consent_team_members: [],
claimant: claimant_params_permitted,
representative: representative_params_permitted,
veteran: veteran_params_permitted }
Expand Down Expand Up @@ -53,9 +56,10 @@ def veteran_params_permitted
:service_branch_other,
:phone,
:email,
{ insurance_numbers: [],
{
name: name_params_permitted,
address: address_params_permitted }
address: address_params_permitted
}
]
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Form2122Base
veteran_phone
veteran_email
veteran_service_number
veteran_insurance_numbers
]

claimant_attrs = %i[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ class Form2122aData < RepresentationManagement::Form2122Base
VETERAN_SERVICE_BRANCHES = %w[ARMY NAVY AIR_FORCE MARINE_CORPS COAST_GUARD SPACE_FORCE NOAA
USPHS].freeze

consent_attrs = %i[
consent_inside_access
consent_outside_access
consent_team_members
]

veteran_attrs = %i[
veteran_service_branch
]

attr_accessor(*[veteran_attrs].flatten)
attr_accessor(*[veteran_attrs, consent_attrs].flatten)

validates :representative_id, presence: true

Expand Down
10 changes: 0 additions & 10 deletions modules/representation_management/app/swagger/v0/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,6 @@
"veteran": {
"type": "object",
"properties": {
"insurance_numbers": {
"type": "array",
"items": {
"type": "string"
},
"example": [
"123456789",
"987654321"
]
},
"name": {
"type": "object",
"properties": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ def format_phone_number(phone_number)
"#{phone_number[0..2]}-#{phone_number[3..5]}-#{phone_number[6..9]}"
end

# Removes non-digit characters from a phone number.
#
# @param phone_number [String] The phone number to be unformatted.
# @return [String] The unformatted phone number.
def unformat_phone_number(phone_number)
phone_number&.gsub(/\D/, '')
end

#
# Fill in pdf form fields based on data provided, then combine all
# the pages into a final pdf. We create an inner tempfile to fill
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ def veteran_identification(data)
"#{PAGE1_KEY}.DOByear[0]": data.veteran_date_of_birth.split('-').first,
# Veteran Service Number
"#{PAGE1_KEY}.VeteransServiceNumber_If_Applicable[0]": \
data.veteran_service_number,
# Veteran Insurance Number
"#{PAGE1_KEY}.InsuranceNumber_s[0]": data.veteran_insurance_numbers.join(', ')
data.veteran_service_number
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,25 +177,38 @@ def representative_contact_details(data)
"#{PAGE2_KEY}.MailingAddress_ZIPOrPostalCode_FirstFiveNumbers[2]": data.representative.zip_code,
"#{PAGE2_KEY}.MailingAddress_ZIPOrPostalCode_LastFourNumbers[2]": data.representative.zip_suffix,
# Representative Phone Number
"#{PAGE2_KEY}.Telephone_Number_Area_Code[2]": data.representative_phone[0..2],
"#{PAGE2_KEY}.Telephone_Middle_Three_Numbers[1]": data.representative_phone[3..5],
"#{PAGE2_KEY}.Telephone_Last_Four_Numbers[2]": data.representative_phone[6..9],
"#{PAGE2_KEY}.Telephone_Number_Area_Code[2]": unformat_phone_number(data.representative_phone)[0..2],
"#{PAGE2_KEY}.Telephone_Middle_Three_Numbers[1]": unformat_phone_number(data.representative_phone)[3..5],
"#{PAGE2_KEY}.Telephone_Last_Four_Numbers[2]": unformat_phone_number(data.representative_phone)[6..9],
# Representative Email
"#{PAGE2_KEY}.E_Mail_Address_Of_Individual_Appointed_As_Claimants_Representative_Optional[0]": \
data.representative.email
}
end

# rubocop:disable Metrics/LineLength
# Disabled due to two extremely long keys.
def appointment_options(data)
{
# Record Consent
"#{PAGE2_KEY}.AuthorizationForRepAccessToRecords[0]": data.record_consent == true ? 1 : 0,
# Consent Limits
"#{PAGE2_KEY}.RelationshipToVeteran[1]": limitations_of_consent_text(data.consent_limits),
"#{PAGE2_KEY}.RelationshipToVeteran[1]": limitations_of_consent_text(data.consent_limits,
data.record_consent),
# Consent Address Change
"#{PAGE2_KEY}.AuthorizationForRepActClaimantsBehalf[0]": data.consent_address_change == true ? 1 : 0
"#{PAGE2_KEY}.AuthorizationForRepActClaimantsBehalf[0]": data.consent_address_change == true ? 1 : 0,
# 19a Consent Inside Access
"#{PAGE2_KEY}.Checkbox_I_Authorize_VA_To_Disclose_All_My_Records_Other_Than_As_Provided_In_Items_20_And_21[0]": data.consent_inside_access == true ? 1 : 0,
# 19a text box - This is commented for now because we're not gathering this data on the frontend but I
# didn't want to lose the key.
# "#{PAGE2_KEY}.Provide_The_Name_Of_The_Firm_Or_Organization_Here[0]": data.consent_team_members.to_sentence,
# 19b Consent Outside Access
"#{PAGE2_KEY}.Checkbox_I_Authorize_VA_To_Disclose_All_My_Records_Other_Than_As_Provided_In_Items_20_And_21[1]": data.consent_outside_access == true ? 1 : 0,
# 19b text box
"#{PAGE2_KEY}.Provide_The_Names_Of_The_Individuals_Here[0]": data.consent_team_members.to_sentence
}
end
# rubocop:enable Metrics/LineLength

def header_options(data)
{
Expand Down Expand Up @@ -236,15 +249,16 @@ def representative_type_checkbox(representative_type)
representative_type_map[representative_type]
end

def limitations_of_consent_text(consent_limits)
def limitations_of_consent_text(consent_limits, record_consent)
return '' unless record_consent

limitations = {
'ALCOHOLISM' => 'Alcoholism and alcohol abuse records',
'DRUG_ABUSE' => 'Drug abuse records',
'HIV' => 'HIV records',
'SICKLE_CELL' => 'Sickle cell anemia records'
}
consent_text = consent_limits.filter_map { |limit| limitations[limit] }.to_sentence
consent_text.presence || "No, they can't access any of these types of records."
consent_limits.filter_map { |limit| limitations[limit] }.to_sentence
end

def normalize_country_code_to_alpha2(country_code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"service_branch": "ARMY",
"phone": "5555555555",
"email": "[email protected]",
"insurance_numbers": [],
"name": {
"first": "John",
"middle": "M",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"service_number": "123456789",
"phone": "5555555555",
"email": "[email protected]",
"insurance_numbers": [],
"name": {
"first": "John",
"middle": "M",
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
{
"record_consent": true,
"consent_address_change": true,
"consent_limits": [],
"consent_limits": [
"ALCOHOLISM",
"DRUG_ABUSE"
],
"consent_inside_access": true,
"consent_outside_access": true,
"consent_team_members": [
"Jane M Representative",
"John M Representative",
"Jane M Doe",
"John M Doe",
"Bobbie M Law",
"Bob M Law",
"Alice M Aster",
"Arthur M Aster"
],
"veteran": {
"ssn": "123456789",
"va_file_number": "123456789",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
{
"record_consent": true,
"consent_address_change": true,
"consent_limits": [],
"consent_limits": [
"ALCOHOLISM",
"DRUG_ABUSE"
],
"consent_inside_access": true,
"consent_outside_access": true,
"consent_team_members": [
"Jane M Representative",
"John M Representative",
"Jane M Doe",
"John M Doe",
"Bobbie M Law",
"Bob M Law",
"Alice M Aster",
"Arthur M Aster"
],
"claimant": {
"date_of_birth": "1980-12-31",
"relationship": "Spouse",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
veteran_va_file_number: '123456789',
veteran_date_of_birth: '1980-12-31',
veteran_service_number: '123456789',
veteran_insurance_numbers: [],
veteran_address_line1: '123 Fake Veteran St',
veteran_address_line2: '',
veteran_city: 'Portland',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
state_code: 'OR',
country_code_iso3: 'USA',
zip_code: '12345',
phone: '5555555555',
phone: '555-555-5555', # We're adding dashes here to make sure they aren't present in the pdf output.
email: '[email protected]',
individual_type: 'attorney')
end
Expand Down Expand Up @@ -54,8 +54,24 @@
representative_id: representative.id,

record_consent: true,
consent_limits: [],
consent_address_change: true
consent_limits: %w[
ALCOHOLISM
DRUG_ABUSE
],
consent_address_change: true,
consent_inside_access: true,
consent_outside_access: true,
consent_team_members: [
'Jane M Representative',
'John M Representative',
'Jane M Doe',
'John M Doe',
'Bobbie M Law',
'Bob M Law',
'Alice M Aster',
'Arthur M Aster'
]

}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
service_branch: 'ARMY',
phone: '5555555555',
email: '[email protected]',
insurance_numbers: [],
name: {
first: 'John',
middle: 'Middle', # This is a middle name as submitted by the frontend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,21 @@
let(:params) do
{
pdf_generator2122a: {
record_consent: '',
consent_address_change: '',
record_consent: true,
consent_address_change: true,
consent_limits: [],
consent_inside_access: true,
consent_outside_access: true,
consent_team_members: [
'Jane M Representative',
'John M Representative',
'Jane M Doe',
'John M Doe',
'Bobbie M Law',
'Bob M Law',
'Alice M Aster',
'Arthur M Aster'
],
claimant: {
date_of_birth: '1980-12-31',
relationship: 'Spouse',
Expand Down Expand Up @@ -51,7 +63,6 @@
service_number: '123456789',
phone: '5555555555',
email: '[email protected]',
insurance_numbers: [],
name: {
first: 'John',
middle: 'M',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def self.veteran
service_branch: 'ARMY',
phone: '5555555555',
email: '[email protected]',
insurance_numbers: [],
name:,
address:
}
Expand Down Expand Up @@ -109,11 +108,6 @@ def self.veteran_parameter
{
type: :object,
properties: {
insurance_numbers: {
type: :array,
items: { type: :string },
example: %w[123456789 987654321]
},
name: name_parameters,
address: address_parameters,
ssn: { type: :string, example: '123456789' },
Expand Down
Loading