Skip to content

Commit

Permalink
Sample PDF, Spec updates, PDF JSON, Upload/PDF Stamper logic
Browse files Browse the repository at this point in the history
  • Loading branch information
balexandr committed Jan 23, 2024
1 parent 5bf9392 commit 85eb028
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ class UploadsController < ApplicationController
'26-4555' => 'vba_26_4555',
'10-10D' => 'vha_10_10d',
'40-0247' => 'vba_40_0247',
'20-10206' => 'vba_20_10206'
}.freeze
'20-10206' => 'vba_20_10206',
'10-7959A' => 'vha_10_7959a'
}.freeze

def submit
Datadog::Tracing.active_trace&.set_tag('form_id', params[:form_number])
Expand Down
46 changes: 46 additions & 0 deletions modules/simple_forms_api/app/form_mappings/vha_10_7959a.json.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"form1[0].#subform[0].Phone-ptnt[0]": "<%= form.data.dig('veteran', 'phone_number') %>",
"form1[0].#subform[0].ZIPCode-ptnt[0]": "<%= form.data.dig('veteran', 'address', 'postal_code') %>",
"form1[0].#subform[0].State-ptnt[0]": "<%= form.data.dig('veteran', 'address', 'state') %>",
"form1[0].#subform[0].City-ptnt[0]": "<%= form.data.dig('veteran', 'address', 'city') %>",
"form1[0].#subform[0].Date-Ptnt[0]": "<%= form.data.dig('veteran', 'date_of_birth') %>",
"form1[0].#subform[0].CheckIfNew[0]": "<%= form.data.dig('veteran', 'is_new_address') %>",
"form1[0].#subform[0].StreetAddrss-ptnt[0]": "<%= form.data.dig('veteran', 'address', 'street') %>",
"form1[0].#subform[0].SSN-ptnt[0]": "<%= form.data.dig('veteran', 'ssn_or_tin') %>",
"form1[0].#subform[0].MiddleInit-ptnt[0]": "<%= form.data.dig('veteran', 'full_name', 'middle') %>",
"form1[0].#subform[0].FirstNme-ptnt[0]": "<%= form.data.dig('veteran', 'full_name', 'first') %>",
"form1[0].#subform[0].LastNme-ptnt[0]": "<%= form.data.dig('veteran', 'full_name', 'last') %>",

"form1[0].#subform[0].#area[2].WorkRelatedTreat[0]": "",
"form1[0].#subform[0].#area[2]": "",
"form1[0].#subform[0].#area[0].OutsdWrkAccdnt[0]": "",
"form1[0].#subform[0].#area[0]": "",
"form1[0].#subform[0].PtntCverage[0]": "",
"form1[0].#subform[0].NameOHI-1[0]": "<%= form.data.dig('ohi_info', 'insurances')[0]&.dig('name') %>",
"form1[0].#subform[0].OHIPolicyNmbr-1[0]": "<%= form.data.dig('ohi_info', 'insurances')[0]&.dig('policy_number') %>",
"form1[0].#subform[0].Phone-OHI-1[0]": "<%= form.data.dig('ohi_info', 'insurances')[0]&.dig('phone_number') %>",
"form1[0].#subform[0].NameOHI-2[0]": "<%= form.data.dig('ohi_info', 'insurances')[1]&.dig('name') %>",
"form1[0].#subform[0].OHIPolicyNmbr-2[0]": "<%= form.data.dig('ohi_info', 'insurances')[1]&.dig('policy_number') %>",
"form1[0].#subform[0].Phone-OHI-2[0]": "<%= form.data.dig('ohi_info', 'insurances')[1]&.dig('phone_number') %>",
"form1[0].#subform[0].#area[1].RadioButtonList[0]": "",
"form1[0].#subform[0].#area[1].RadioButtonList[1]": "",
"form1[0].#subform[0].#area[1].RadioButtonList[2]": "",
"form1[0].#subform[0].#area[1].RadioButtonList[3]": "",
"form1[0].#subform[0].#area[1].SpecifyOtherPrimaryHealthInsurance[0]": "<%= form.data.dig('ohi_info', 'coverage_type_other') %>",

"form1[0].#subform[0].LastNme-spnsr[0]": "<%= form.data.dig('sponsor', 'full_name', 'last') %>",
"form1[0].#subform[0].FirstNme-spnsr[0]": "<%= form.data.dig('sponsor', 'full_name', 'first') %>",
"form1[0].#subform[0].MiddleInit-spnsr[0]": "<%= form.data.dig('sponsor', 'full_name', 'middle') %>",

"form1[0].#subform[0].SignatureTelephoneNumber[0]": "<%= form.data.dig('claimant', 'phone_number') %>",
"form1[0].#subform[0].SignatureZipCode[0]": "<%= form.data.dig('claimant', 'address', 'postal_code') %>",
"form1[0].#subform[0].SignatureState[0]": "<%= form.data.dig('claimant', 'address', 'state') %>",
"form1[0].#subform[0].SignatureCity[0]": "<%= form.data.dig('claimant', 'address', 'city') %>",
"form1[0].#subform[0].SignatureStreetAddress[0]": "<%= form.data.dig('claimant', 'address', 'street') %>",
"form1[0].#subform[0].SignatureField1[0]": "<%= form.data.dig('claimant', 'signature') %>",
"form1[0].#subform[0].SignatureMiddleInitial[0]": "<%= form.data.dig('claimant', 'full_name', 'middle') %>",
"form1[0].#subform[0].SignatureFirstName[0]": "<%= form.data.dig('claimant', 'full_name', 'first') %>",
"form1[0].#subform[0].SignatureLastName[0]": "<%= form.data.dig('claimant', 'full_name', 'last') %>",
"form1[0].#subform[0].relationshipToApplicant[0]": "<%= form.data.dig('claimant', 'relationship_to_patient') %>",
"form1[0].#subform[0].SignatureDateOfBirth2[0]": "<%= form.data.dig('claimant', 'date_of_birth') %>"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module SimpleFormsApi
class VHA107959a
include Virtus.model(nullify_blank: true)

attribute :data

def initialize(data)
@data = data
end

def metadata
{
'veteranFirstName' => @data.dig('veteran', 'full_name', 'first'),
'veteranLastName' => @data.dig('veteran', 'full_name', 'last'),
'fileNumber' => @data.dig('veteran', 'va_file_number').presence || @data.dig('veteran', 'ssn'),
'zipCode' => @data.dig('veteran', 'address', 'postal_code'),
'source' => 'VA Platform Digital Forms',
'docType' => @data['form_number'],
'businessLine' => 'CMP'
}
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

module SimpleFormsApi
class PdfStamper
FORM_REQUIRES_STAMP = %w[26-4555 21-4142 21-10210 21-0845 21P-0847 21-0966 21-0972].freeze
FORM_REQUIRES_STAMP = %w[26-4555 21-4142 21-10210 21-0845 21P-0847 21-0966 21-0972 10-7959A].freeze
SUBMISSION_TEXT = 'Signed electronically and submitted via VA.gov at '

def self.stamp_pdf(stamped_template_path, form)
Expand All @@ -20,6 +20,30 @@ def self.stamp_pdf(stamped_template_path, form)
stamp(desired_stamps, stamped_template_path, text_only: false)
end

def self.stamp107959a(stamped_template_path, form)
stp = stamped_template_path # Shortened to not exceed below line length
stamp107959a_resubmission(stp, [341, 461], 'X') if form.data.dig('veteran', 'is_new_address')
stamp107959a_resubmission(stp, [235, 377], 'X') if form.data.dig('ohi_info', 'is_treatment_work_injury')
stamp107959a_resubmission(stp, [267, 377], 'X') unless form.data.dig('ohi_info', 'is_treatment_work_injury')
stamp107959a_resubmission(stp, [525, 377], 'X') if form.data.dig('ohi_info', 'is_treatement_non_work_injury')
stamp107959a_resubmission(stp, [556, 377], 'X') unless form.data.dig('ohi_info', 'is_treatement_non_work_injury')
stamp107959a_resubmission(stp, [38, 341.5], 'X') if form.data.dig('ohi_info', 'is_patient_covered')
stamp107959a_resubmission(stp, [313, 341.5], 'X') unless form.data.dig('ohi_info', 'is_patient_covered')
stamp107959a_resubmission(stp, [53, 327], 'o', 10) if form.data.dig('ohi_info', 'coverage_type') == 'employer'
stamp107959a_resubmission(stp, [186.5, 327], 'o', 10) if form.data.dig('ohi_info', 'coverage_type') == 'private'
stamp107959a_resubmission(stp, [283, 327], 'o', 10) if form.data.dig('ohi_info', 'coverage_type') == 'medicare'
stamp107959a_resubmission(stp, [394, 327], 'o', 10) if form.data.dig('ohi_info', 'coverage_type') == 'other'
end

def self.stamp107959a_resubmission(stamped_template_path, coordinates, text, font_size = 12)
page_configuration = [
{ type: :text, position: coordinates },
{ type: :new_page }
]

multistamp(stamped_template_path, text, page_configuration, font_size)
end

def self.stamp264555(stamped_template_path, form)
desired_stamps = []
desired_stamps.append([73, 390, 'X']) unless form.data['previous_sah_application']['has_previous_sah_application']
Expand Down
66 changes: 66 additions & 0 deletions modules/simple_forms_api/spec/fixtures/form_json/vha_10_7959a.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"form_number": "10-7959A",
"veteran": {
"date_of_birth": "1987-02-02",
"address": {
"country": "USA",
"street": "1 First Ln",
"city": "Place",
"state": "AL",
"postal_code": "12345"
},
"full_name": {
"first": "Veteran",
"middle": "B",
"last": "Surname"
},
"ssn_or_tin": "222554444",
"va_claim_number": "123456789",
"phone_number": "9876543213",
"is_new_address": true
},
"sponsor": {
"full_name": {
"first": "Sponsor",
"middle": "P",
"last": "Sponsor_Surname"
}
},
"ohi_info": {
"is_treatment_work_injury": false,
"is_treatement_non_work_injury": true,
"is_patient_covered": true,
"coverage_type": "other",
"coverage_type_other": "",
"insurances": [
{
"name": "OHI LLC",
"policy_number": "7777",
"phone_number": "215-345-2424"
},
{
"name": "OHI ORG",
"policy_number": "9999",
"phone_number": "668-123-4567"
}
]
},
"claimant": {
"date_of_birth": "1986-03-03",
"full_name": {
"first": "Claimant",
"middle": "L",
"last": "Claimant_Surname"
},
"address": {
"country": "USA",
"street": "2 Second Ln",
"city": "Place Two",
"state": "PA",
"postal_code": "54321"
},
"phone_number": "2153555555",
"relationship_to_patient": "Mother",
"signature": "Claimant Signature"
}
}
2 changes: 2 additions & 0 deletions modules/simple_forms_api/spec/requests/v1/uploads_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def self.test_submit_request(test_payload)
end
end

test_submit_request 'vha_10_7959a.json'
test_submit_request 'vha_10_10d.json'
test_submit_request 'vba_26_4555.json'
test_submit_request 'vba_21_4142.json'
Expand Down Expand Up @@ -73,6 +74,7 @@ def self.test_saves_form_submission_attempt(test_payload)
test_saves_form_submission_attempt 'vba_40_0247.json'
test_saves_form_submission_attempt 'vba_21_0966.json'
test_saves_form_submission_attempt 'vba_20_10206.json'
test_saves_form_submission_attempt 'vha_10_7959a.json'

describe 'request with intent to file unauthenticated' do
let(:expiration_date) { Time.zone.now }
Expand Down
2 changes: 2 additions & 0 deletions modules/simple_forms_api/spec/services/pdf_filler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def self.test_pdf_fill(form_number, test_payload = form_number)
test_pdf_fill 'vba_21_0966', 'vba_21_0966-min'
test_pdf_fill 'vba_40_0247'
test_pdf_fill 'vba_40_0247', 'vba_40_0247-min'
test_pdf_fill 'vha_10_7959a'

def self.test_json_valid(mapping_file)
it 'validates json is parseable' do
Expand All @@ -52,4 +53,5 @@ def self.test_json_valid(mapping_file)
test_json_valid 'vba_21_0972.json.erb'
test_json_valid 'vba_21_0966.json.erb'
test_json_valid 'vba_40_0247.json.erb'
test_json_valid 'vha_10_7959a.json.erb'
end
Binary file not shown.

0 comments on commit 85eb028

Please sign in to comment.