From 4004d51f7fe7eb116fdeaaf75b639fb2aac12abf Mon Sep 17 00:00:00 2001 From: 624883 Date: Tue, 3 Sep 2024 12:54:28 -0400 Subject: [PATCH] MBMS-73637 re-organized preneed meta data --- .../models/simple_forms_api/vba_40_10007.rb | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/modules/simple_forms_api/app/models/simple_forms_api/vba_40_10007.rb b/modules/simple_forms_api/app/models/simple_forms_api/vba_40_10007.rb index 9c0a7c77982..f4d0f5323f5 100644 --- a/modules/simple_forms_api/app/models/simple_forms_api/vba_40_10007.rb +++ b/modules/simple_forms_api/app/models/simple_forms_api/vba_40_10007.rb @@ -13,11 +13,41 @@ def initialize(data) @data = data end + def veteran_or_claimant_first_name(form_data) + relationship = form_data.dig('application', 'claimant', 'relationship_to_vet') + + if relationship != '1' && relationship != 'veteran' + form_data.dig('application', 'veteran', 'current_name', 'first') + else + form_data.dig('application', 'claimant', 'name', 'first') + end + end + + def veteran_or_claimant_last_name(form_data) + relationship = form_data.dig('application', 'claimant', 'relationship_to_vet') + + if relationship != '1' && relationship != 'veteran' + form_data.dig('application', 'veteran', 'current_name', 'last') + else + form_data.dig('application', 'claimant', 'name', 'last') + endq + end + + def veteran_or_claimant_file_number(form_data) + relationship = form_data.dig('application', 'claimant', 'relationship_to_vet') + + if relationship != '1' && relationship != 'veteran' + form_data.dig('application', 'veteran', 'ssn') || '' + else + form_data.dig('application', 'claimant', 'ssn') || '' + end + end + def metadata { - 'veteranFirstName' => @data.dig('application', 'claimant', 'name', 'first'), - 'veteranLastName' => @data.dig('application', 'claimant', 'name', 'last'), - 'fileNumber' => @data.dig('application', 'claimant', 'ssn')&.gsub('-', ''), + 'veteranFirstName' => veteran_or_claimant_first_name(@data), + 'veteranLastName' => veteran_or_claimant_last_name(@data), + 'fileNumber' => veteran_or_claimant_file_number(@data)&.gsub('-', ''), 'zipCode' => @data.dig('application', 'claimant', 'address', 'postal_code'), 'source' => 'VA Platform Digital Forms', 'docType' => @data['form_number'],