IO-3423 Use INSD if CLMD and OWNR Blank
This commit is contained in:
@@ -355,63 +355,77 @@ export function ReplaceOwnerInfoWithClaimant<
|
||||
| "clmt_ph1"
|
||||
| "clmt_ph2"
|
||||
| "clmt_ea"
|
||||
| "insd_ln"
|
||||
| "insd_fn"
|
||||
| "insd_title"
|
||||
| "insd_co_nm"
|
||||
| "insd_addr1"
|
||||
| "insd_addr2"
|
||||
| "insd_city"
|
||||
| "insd_st"
|
||||
| "insd_zip"
|
||||
| "insd_ctry"
|
||||
| "insd_ph1"
|
||||
| "insd_ph2"
|
||||
| "insd_ea"
|
||||
| "owner"
|
||||
>
|
||||
>,
|
||||
>(jobObject: T): T {
|
||||
// In some scenarios, the owner information is missing. So we use the claimant instead.
|
||||
// We pull the claimant info for this, but we don't store it in our system, so it needs to be deleted regardless.
|
||||
if (
|
||||
_.isEmpty(jobObject.ownr_ln) &&
|
||||
_.isEmpty(jobObject.ownr_fn) &&
|
||||
_.isEmpty(jobObject.ownr_co_nm)
|
||||
) {
|
||||
jobObject.ownr_ln = jobObject.clmt_ln;
|
||||
jobObject.ownr_fn = jobObject.clmt_fn;
|
||||
jobObject.ownr_title = jobObject.clmt_title;
|
||||
jobObject.ownr_co_nm = jobObject.clmt_co_nm;
|
||||
jobObject.ownr_addr1 = jobObject.clmt_addr1;
|
||||
jobObject.ownr_addr2 = jobObject.clmt_addr2;
|
||||
jobObject.ownr_city = jobObject.clmt_city;
|
||||
jobObject.ownr_st = jobObject.clmt_st;
|
||||
jobObject.ownr_zip = jobObject.clmt_zip;
|
||||
jobObject.ownr_ctry = jobObject.clmt_ctry;
|
||||
jobObject.ownr_ph1 = jobObject.clmt_ph1;
|
||||
jobObject.ownr_ph2 = jobObject.clmt_ph2;
|
||||
jobObject.ownr_ea = jobObject.clmt_ea;
|
||||
// Promote claimant data first if owner identity is entirely missing; otherwise fallback to insured data.
|
||||
const identityKeys = ["ln", "fn", "co_nm"] as const; // keys used to determine presence
|
||||
const copyKeys = [
|
||||
"ln",
|
||||
"fn",
|
||||
"title",
|
||||
"co_nm",
|
||||
"addr1",
|
||||
"addr2",
|
||||
"city",
|
||||
"st",
|
||||
"zip",
|
||||
"ctry",
|
||||
"ph1",
|
||||
"ph2",
|
||||
"ea",
|
||||
] as const; // full set of fields to copy/delete
|
||||
|
||||
// Ensure the owner and owner.data fields exist before assigning values
|
||||
if (jobObject.owner?.data) {
|
||||
jobObject.owner.data.ownr_ln = jobObject.clmt_ln;
|
||||
jobObject.owner.data.ownr_fn = jobObject.clmt_fn;
|
||||
jobObject.owner.data.ownr_title = jobObject.clmt_title;
|
||||
jobObject.owner.data.ownr_co_nm = jobObject.clmt_co_nm;
|
||||
jobObject.owner.data.ownr_addr1 = jobObject.clmt_addr1;
|
||||
jobObject.owner.data.ownr_addr2 = jobObject.clmt_addr2;
|
||||
jobObject.owner.data.ownr_city = jobObject.clmt_city;
|
||||
jobObject.owner.data.ownr_st = jobObject.clmt_st;
|
||||
jobObject.owner.data.ownr_zip = jobObject.clmt_zip;
|
||||
jobObject.owner.data.ownr_ctry = jobObject.clmt_ctry;
|
||||
jobObject.owner.data.ownr_ph1 = jobObject.clmt_ph1;
|
||||
jobObject.owner.data.ownr_ph2 = jobObject.clmt_ph2;
|
||||
jobObject.owner.data.ownr_ea = jobObject.clmt_ea;
|
||||
}
|
||||
const ownerMissing = identityKeys.every((k) =>
|
||||
_.isEmpty((jobObject as any)[`ownr_${k}`]),
|
||||
);
|
||||
const claimantHasAll = identityKeys.every(
|
||||
(k) => !_.isEmpty((jobObject as any)[`clmt_${k}`]),
|
||||
);
|
||||
const claimantMissing = identityKeys.every((k) =>
|
||||
_.isEmpty((jobObject as any)[`clmt_${k}`]),
|
||||
);
|
||||
|
||||
const { owner } = jobObject as any; // destructure for optional nested updates
|
||||
|
||||
// Copy helper inline (no extra function as requested)
|
||||
const promote = (sourcePrefix: "clmt" | "insd"): void => {
|
||||
copyKeys.forEach((suffix) => {
|
||||
(jobObject as any)[`ownr_${suffix}`] = (jobObject as any)[
|
||||
`${sourcePrefix}_${suffix}`
|
||||
];
|
||||
if (owner?.data) {
|
||||
owner.data[`ownr_${suffix}`] = (jobObject as any)[
|
||||
`${sourcePrefix}_${suffix}`
|
||||
];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (ownerMissing && claimantHasAll) {
|
||||
promote("clmt");
|
||||
} else if (ownerMissing && claimantMissing) {
|
||||
promote("insd");
|
||||
}
|
||||
|
||||
// Delete the claimant info as it's not needed.
|
||||
delete jobObject.clmt_ln;
|
||||
delete jobObject.clmt_fn;
|
||||
delete jobObject.clmt_title;
|
||||
delete jobObject.clmt_co_nm;
|
||||
delete jobObject.clmt_addr1;
|
||||
delete jobObject.clmt_addr2;
|
||||
delete jobObject.clmt_city;
|
||||
delete jobObject.clmt_st;
|
||||
delete jobObject.clmt_zip;
|
||||
delete jobObject.clmt_ctry;
|
||||
delete jobObject.clmt_ph1;
|
||||
delete jobObject.clmt_ph2;
|
||||
delete jobObject.clmt_ea;
|
||||
copyKeys.forEach((suffix) => delete (jobObject as any)[`clmt_${suffix}`]);
|
||||
// Delete the insured info as it's not needed.
|
||||
copyKeys.forEach((suffix) => delete (jobObject as any)[`insd_${suffix}`]);
|
||||
|
||||
return jobObject;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user