Skip to content

Commit

Permalink
Add PDF field mapping for the AL form, to map the PDFLib fields to th…
Browse files Browse the repository at this point in the history
…e extracted data
  • Loading branch information
danielnaab committed Feb 29, 2024
1 parent 45fab67 commit 05db71f
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion packages/documents/src/pdf/mock-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export const parseAlabamaNameChangeForm = (): ParsedPdf => {
const fieldsetElements: FormElementId[] = [];
for (const input of element.inputs) {
if (input.input_type === 'Tx') {
const id = input.input_params.output_id.toLowerCase();
const id = PdfFieldMap[input.input_params.output_id];
console.log(input.input_params.output_id.toLowerCase(), id);
fieldsetElements.push(id);
parsedPdf.elements[id] = {
type: 'input',
Expand Down Expand Up @@ -179,6 +180,36 @@ const getElementInputs = (element: ExtractedElement): FormElement[] => {
.filter((item): item is NonNullable<FormElement> => item !== null);
};

const PdfFieldMap: Record<string, string> = {
County_Name1: 'users1_address_county',
Current_First_Name1: 'users1_name_first',
Current_Middle_Name1: 'users1_name_middle',
Current_Last_Name1: 'users1_name_last',
Current_First_Name2: 'users1_name_first__2',
Current_Middle_Name2: 'users1_name_middle__2',
Current_Last_Name2: 'users1_name_last__2',
Street_Address: 'users1_address_line_one',
City: 'users1_address_city',
State: 'users1_address_state',
Zip: 'users1_address_zip',
Home_Phone: 'users1_phone',
Work_Phone: 'work_phone',
DOB: 'users1_birthdate',
Birth_First_Name: 'user1_preferred_name_first',
Birth_Middle_Name: 'user1_preferred_name_middle',
Birth_Last_Name: 'user1_preferred_name_last',
County_Name2: 'user1_address_county__2',
PhotoID: 'photo_id',
'DL#': 'driver_license_number',
'ID#': 'non_driver_id_number',
Why_change_name1: 'reasons_for_change', // pdf-lib combines the three input lines into a single input
Why_change_name2: 'reasons_for_change',
Why_change_name3: 'reasons_for_change',
New_First_Name: 'users1_previous_names1_first',
New_Middle_Name: 'users1_previous_names1_middle',
New_Last_Name: 'users1_previous_names1_last',
};

/*
function parseJson(obj: ExtractedJsonType): Array<any> {
return parseElements(obj.elements);
Expand Down

0 comments on commit 05db71f

Please sign in to comment.