Skip to content

Commit

Permalink
Merge branch 'master' into mm/1411-updates-notification-to-save-templ…
Browse files Browse the repository at this point in the history
…ate-id
  • Loading branch information
MarchandMD authored Dec 4, 2024
2 parents e2e0e49 + fd06ac0 commit 0f5c952
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require 'bgs_service/vnp_ptcpnt_addrs_service'
require 'bgs_service/vnp_ptcpnt_phone_service'
require 'bgs_service/vnp_ptcpnt_service'
require 'concurrent-ruby'

module ClaimsApi
module PowerOfAttorneyRequestService
Expand All @@ -27,24 +28,57 @@ def initialize(veteran_participant_id, form_data, claimant_participant_id = nil,

def call
@vnp_proc_id = create_vnp_proc[:vnp_proc_id]
create_vnp_form
@veteran_vnp_ptcpnt_id = create_vnp_ptcpnt(@veteran_participant_id)[:vnp_ptcpnt_id]

# Parallelize create_vnp_form and create_vnp_ptcpnt
form_promise = Concurrent::Promise.execute do
create_vnp_form
end

ptcpnt_promise = Concurrent::Promise.execute do
create_vnp_ptcpnt(@veteran_participant_id)
end

# Wait for both promises and store the participant ID
form_promise.value!
@veteran_vnp_ptcpnt_id = ptcpnt_promise.value![:vnp_ptcpnt_id]

create_vonapp_data(@form_data[:veteran], @veteran_vnp_ptcpnt_id)

if @has_claimant
@claimant_vnp_ptcpnt_id = create_vnp_ptcpnt(@claimant_participant_id)[:vnp_ptcpnt_id]
create_vonapp_data(@form_data[:claimant], @claimant_vnp_ptcpnt_id)
end

create_veteran_representative
end

private

def create_vonapp_data(person, vnp_ptcpnt_id)
create_vnp_person(person, vnp_ptcpnt_id)
create_vnp_mailing_address(person[:address], vnp_ptcpnt_id)
create_vnp_email_address(person[:email], vnp_ptcpnt_id) if person[:email]
promises = []

promises << Concurrent::Promise.execute do
create_vnp_person(person, vnp_ptcpnt_id)
end

promises << Concurrent::Promise.execute do
create_vnp_mailing_address(person[:address], vnp_ptcpnt_id)
end

if person[:email]
promises << Concurrent::Promise.execute do
create_vnp_email_address(person[:email], vnp_ptcpnt_id)
end
end

create_vnp_phone(person[:phone][:areaCode], person[:phone][:phoneNumber], vnp_ptcpnt_id) if person[:phone]
if person[:phone]
promises << Concurrent::Promise.execute do
create_vnp_phone(person[:phone][:areaCode], person[:phone][:phoneNumber], vnp_ptcpnt_id)
end
end

# Wait for all promises to complete and raise any errors that occurred
promises.each(&:value!)
end

def create_vnp_proc
Expand All @@ -65,23 +99,21 @@ def create_vnp_form
end

def create_vnp_ptcpnt(participant_id)
ClaimsApi::VnpPtcpntService
.new(external_uid: @veteran_participant_id, external_key: @veteran_participant_id)
.vnp_ptcpnt_create(
{
vnp_proc_id: @vnp_proc_id,
vnp_ptcpnt_id: nil,
fraud_ind: nil,
legacy_poa_cd: nil,
misc_vendor_ind: nil,
ptcpnt_short_nm: nil,
ptcpnt_type_nm: PTCPNT_TYPE,
tax_idfctn_nbr: nil,
tin_waiver_reason_type_cd: nil,
ptcpnt_fk_ptcpnt_id: nil,
corp_ptcpnt_id: participant_id
}.merge(bgs_jrn_fields)
)
vnp_ptcpnt_service.vnp_ptcpnt_create(
{
vnp_proc_id: @vnp_proc_id,
vnp_ptcpnt_id: nil,
fraud_ind: nil,
legacy_poa_cd: nil,
misc_vendor_ind: nil,
ptcpnt_short_nm: nil,
ptcpnt_type_nm: PTCPNT_TYPE,
tax_idfctn_nbr: nil,
tin_waiver_reason_type_cd: nil,
ptcpnt_fk_ptcpnt_id: nil,
corp_ptcpnt_id: participant_id
}.merge(bgs_jrn_fields)
)
end

def create_vnp_person(person, vnp_ptcpnt_id)
Expand All @@ -102,8 +134,7 @@ def create_vnp_person(person, vnp_ptcpnt_id)

# rubocop: disable Metrics/MethodLength
def create_vnp_mailing_address(address, vnp_ptcpnt_id)
ClaimsApi::VnpPtcpntAddrsService
.new(external_uid: @veteran_participant_id, external_key: @veteran_participant_id)
vnp_ptcpnt_addrs_service
.vnp_ptcpnt_addrs_create(
{
vnp_ptcpnt_addrs_id: nil,
Expand Down Expand Up @@ -148,8 +179,7 @@ def create_vnp_mailing_address(address, vnp_ptcpnt_id)

# rubocop: disable Metrics/MethodLength
def create_vnp_email_address(email, vnp_ptcpnt_id)
ClaimsApi::VnpPtcpntAddrsService
.new(external_uid: @veteran_participant_id, external_key: @veteran_participant_id)
vnp_ptcpnt_addrs_service
.vnp_ptcpnt_addrs_create(
{
vnp_ptcpnt_addrs_id: nil,
Expand Down Expand Up @@ -248,6 +278,16 @@ def create_veteran_representative
# rubocop: enable Metrics/MethodLength
# rubocop: enable Naming/VariableNumber

def vnp_ptcpnt_service
@vnp_ptcpnt_service ||= ClaimsApi::VnpPtcpntService
.new(external_uid: @veteran_participant_id, external_key: @veteran_participant_id)
end

def vnp_ptcpnt_addrs_service
@vnp_ptcpnt_addrs_service ||= ClaimsApi::VnpPtcpntAddrsService
.new(external_uid: @veteran_participant_id, external_key: @veteran_participant_id)
end

def bgs_jrn_fields
{
jrn_dt: Time.current.iso8601,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ def get_non_obsolete_requests
end

def set_to_obsolete(request)
ClaimsApi::ManageRepresentativeService
.new(external_uid: @veteran_participant_id, external_key: @veteran_participant_id)
.update_poa_request(representative: request[:representative], proc_id: request[:proc_id])
manage_representative_service.update_poa_request(representative: request[:representative],
proc_id: request[:proc_id])
end

def manage_representative_service
@manage_representative_service ||= ClaimsApi::ManageRepresentativeService
.new(external_uid: @veteran_participant_id,
external_key: @veteran_participant_id)
end
end
end
Expand Down
20 changes: 10 additions & 10 deletions modules/claims_api/app/swagger/claims_api/v2/dev/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4394,7 +4394,7 @@
"202 without a transactionId": {
"value": {
"data": {
"id": "2dd4c099-b700-471b-b4a5-578b55234a2f",
"id": "2fb15206-dc89-46cd-85fc-18db26b2a50b",
"type": "forms/526",
"attributes": {
"claimId": "600442191",
Expand Down Expand Up @@ -4625,7 +4625,7 @@
"202 with a transactionId": {
"value": {
"data": {
"id": "8088708b-f0a2-43d3-8bca-6432c8b24b89",
"id": "b35ec564-4bc1-46b9-ba31-a1a0836b8e9e",
"type": "forms/526",
"attributes": {
"claimId": "600442191",
Expand Down Expand Up @@ -9838,7 +9838,7 @@
"application/json": {
"example": {
"data": {
"id": "cd3552a2-7300-4902-81a9-0814b4f65127",
"id": "40281859-0f83-4820-bdac-f2d0e5d6626a",
"type": "forms/526",
"attributes": {
"claimProcessType": "STANDARD_CLAIM_PROCESS",
Expand Down Expand Up @@ -14477,7 +14477,7 @@
"application/json": {
"example": {
"data": {
"id": "89beb6db-e4ed-43e9-baa8-a3157a1788a7",
"id": "22662bb8-70a1-46c7-a162-c3d2a7544c33",
"type": "individual",
"attributes": {
"code": "067",
Expand Down Expand Up @@ -14967,7 +14967,7 @@
"description": "Email address of the claimant.",
"type": "string",
"pattern": "^(?!.*\\s).+@.+\\..+|^$",
"maxLength": 61,
"maxLength": 30,
"example": "[email protected]"
},
"relationship": {
Expand Down Expand Up @@ -15251,7 +15251,7 @@
"application/json": {
"example": {
"data": {
"id": "005a7686-e6a3-4644-b9c0-b7894a53d65e",
"id": "bf6dcb7c-3231-4fde-934b-a7da4d062032",
"type": "organization",
"attributes": {
"code": "083",
Expand Down Expand Up @@ -15738,7 +15738,7 @@
"description": "Email address of the claimant.",
"type": "string",
"pattern": "^(?!.*\\s).+@.+\\..+|^$",
"maxLength": 61,
"maxLength": 30,
"example": "[email protected]"
},
"relationship": {
Expand Down Expand Up @@ -16416,7 +16416,7 @@
"description": "Email address of the claimant.",
"type": "string",
"pattern": "^(?!.*\\s).+@.+\\..+|^$",
"maxLength": 61,
"maxLength": 30,
"example": "[email protected]"
},
"relationship": {
Expand Down Expand Up @@ -17099,7 +17099,7 @@
"description": "Email address of the claimant.",
"type": "string",
"pattern": "^(?!.*\\s).+@.+\\..+|^$",
"maxLength": 61,
"maxLength": 30,
"example": "[email protected]"
},
"relationship": {
Expand Down Expand Up @@ -17251,7 +17251,7 @@
"application/json": {
"example": {
"data": {
"id": "2c6ffced-a984-4521-8a2c-72de8d057362",
"id": "0f7ac3e1-5ff2-4d8b-9464-fa55c06b5de5",
"type": "claimsApiPowerOfAttorneys",
"attributes": {
"dateRequestAccepted": "2024-12-04",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3685,7 +3685,7 @@
"202 without a transactionId": {
"value": {
"data": {
"id": "75a03f81-51ea-4a94-a4df-06abe167840c",
"id": "f6cc643c-ae2d-4e3f-a985-eff72b9c0e13",
"type": "forms/526",
"attributes": {
"claimId": "600442191",
Expand Down Expand Up @@ -3916,7 +3916,7 @@
"202 with a transactionId": {
"value": {
"data": {
"id": "1c8aefef-b0a4-4d8c-a953-ab3b83e8240a",
"id": "300dab5e-21d3-4723-8eb2-e422eddd1af9",
"type": "forms/526",
"attributes": {
"claimId": "600442191",
Expand Down Expand Up @@ -9129,7 +9129,7 @@
"application/json": {
"example": {
"data": {
"id": "4a7e2be4-579e-4fe2-a919-33961dc4ca31",
"id": "d85f57bf-4394-4f62-9dbd-5dcfbb9e79a4",
"type": "forms/526",
"attributes": {
"claimProcessType": "STANDARD_CLAIM_PROCESS",
Expand Down Expand Up @@ -13768,7 +13768,7 @@
"application/json": {
"example": {
"data": {
"id": "c35771ee-4ada-4139-9f20-e3b1f3a6ae04",
"id": "962e299d-695c-48ba-9414-f85a00be7f95",
"type": "individual",
"attributes": {
"code": "067",
Expand Down Expand Up @@ -14258,7 +14258,7 @@
"description": "Email address of the claimant.",
"type": "string",
"pattern": "^(?!.*\\s).+@.+\\..+|^$",
"maxLength": 61,
"maxLength": 30,
"example": "[email protected]"
},
"relationship": {
Expand Down Expand Up @@ -14542,7 +14542,7 @@
"application/json": {
"example": {
"data": {
"id": "c7cfb021-7b7b-4a91-b2cf-024934a8ac20",
"id": "bd7eb43f-d007-4161-a548-7c068c7ebc8e",
"type": "organization",
"attributes": {
"code": "083",
Expand Down Expand Up @@ -15029,7 +15029,7 @@
"description": "Email address of the claimant.",
"type": "string",
"pattern": "^(?!.*\\s).+@.+\\..+|^$",
"maxLength": 61,
"maxLength": 30,
"example": "[email protected]"
},
"relationship": {
Expand Down Expand Up @@ -15707,7 +15707,7 @@
"description": "Email address of the claimant.",
"type": "string",
"pattern": "^(?!.*\\s).+@.+\\..+|^$",
"maxLength": 61,
"maxLength": 30,
"example": "[email protected]"
},
"relationship": {
Expand Down Expand Up @@ -16390,7 +16390,7 @@
"description": "Email address of the claimant.",
"type": "string",
"pattern": "^(?!.*\\s).+@.+\\..+|^$",
"maxLength": 61,
"maxLength": 30,
"example": "[email protected]"
},
"relationship": {
Expand Down Expand Up @@ -16542,7 +16542,7 @@
"application/json": {
"example": {
"data": {
"id": "34a8cdf8-94f2-4d46-947b-622130582b45",
"id": "a2fb31f5-c7b8-474f-8187-0e3fba309b9b",
"type": "claimsApiPowerOfAttorneys",
"attributes": {
"dateRequestAccepted": "2024-12-04",
Expand Down
2 changes: 1 addition & 1 deletion modules/claims_api/config/schemas/v2/2122.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
"description": "Email address of the claimant.",
"type": "string",
"pattern": "^(?!.*\\s).+@.+\\..+|^$",
"maxLength": 61,
"maxLength": 30,
"example": "[email protected]"
},
"relationship": {
Expand Down
2 changes: 1 addition & 1 deletion modules/claims_api/config/schemas/v2/2122a.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
"description": "Email address of the claimant.",
"type": "string",
"pattern": "^(?!.*\\s).+@.+\\..+|^$",
"maxLength": 61,
"maxLength": 30,
"example": "[email protected]"
},
"relationship": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def page1_options(data)
# Item 12
"#{base_form}.TelephoneNumber_IncludeAreaCode[1]": "#{data.dig('claimant', 'phone', 'areaCode')} #{data.dig('claimant', 'phone', 'phoneNumber')}",
# Item 13
"#{base_form}.EmailAddress_Optional[1]": data.dig('claimant', 'email'),
"#{base_form}.EmailAddress_Optional[1]": data.dig('claimant', 'email')&.downcase,
# Item 14
"#{base_form}.RelationshipToVeteran[0]": data.dig('claimant', 'relationship'),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def page1_options(data)
# Item 12
"#{base_form}.TelephoneNumber_IncludeAreaCode[0]": "#{data.dig('claimant', 'phone', 'areaCode')} #{data.dig('claimant', 'phone', 'phoneNumber')}",
# Item 13
"#{base_form}.Claimants_EmailAddress_Optional[0]": data.dig('claimant', 'email'),
"#{base_form}.Claimants_EmailAddress_Optional[0]": data.dig('claimant', 'email')&.downcase,
# Item 14
"#{base_form}.Relationship_To_Veteran[0]": data.dig('claimant', 'relationship'),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
firstName: 'Lillian',
middleInitial: 'A',
lastName: 'Disney',
email: 'lillian@disney.com',
email: 'LILLian@disney.com',
relationship: 'Spouse',
address: {
addressLine1: '2688 S Camino Real',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
firstName: 'Lillian',
middleInitial: 'A',
lastName: 'Disney',
email: 'lillian@disney.com',
email: 'LILLIAN@disney.com',
relationship: 'Spouse',
address: {
addressLine1: '2688 S Camino Real',
Expand Down

0 comments on commit 0f5c952

Please sign in to comment.