From 05db71f995b00abd1d2dae112cf70b8d0c273290 Mon Sep 17 00:00:00 2001 From: Daniel Naab Date: Wed, 28 Feb 2024 21:54:01 -0600 Subject: [PATCH] Add PDF field mapping for the AL form, to map the PDFLib fields to the extracted data --- packages/documents/src/pdf/mock-api.ts | 33 +++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/documents/src/pdf/mock-api.ts b/packages/documents/src/pdf/mock-api.ts index c4c64459..319b8391 100644 --- a/packages/documents/src/pdf/mock-api.ts +++ b/packages/documents/src/pdf/mock-api.ts @@ -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', @@ -179,6 +180,36 @@ const getElementInputs = (element: ExtractedElement): FormElement[] => { .filter((item): item is NonNullable => item !== null); }; +const PdfFieldMap: Record = { + 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 { return parseElements(obj.elements);