feature/IO-3182-Phone-Number-Consent - Checkpoint
This commit is contained in:
@@ -238,6 +238,75 @@ const extractRepairFacilityData = (rq) => {
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Extracts loss information from the XML request.
|
||||
* @param rq
|
||||
* @returns {{loss_dt: (*|null), reported_dt: (*|null), loss_type_code: (*|null), loss_type_desc: (*|null)}}
|
||||
*/
|
||||
const extractLossInfo = (rq) => {
|
||||
const loss = rq.ClaimInfo?.LossInfo?.Facts || {};
|
||||
const custom = rq.ClaimInfo?.CustomElement || {};
|
||||
return {
|
||||
loss_date: loss.LossDateTime || null,
|
||||
loss_type: custom.LossTypeCode || null,
|
||||
loss_desc: custom.LossTypeDesc || null
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Extracts insurance data from the XML request.
|
||||
* @param rq
|
||||
* @returns {{insd_ln: (*|null), insd_fn: (string|null), insd_title: (*|null), insd_co_nm: (*|string|null), insd_addr1: (*|null), insd_addr2: (*|null), insd_city: (*|null), insd_st: (*|null), insd_zip: (*|null), insd_ctry: (*|null), insd_ph1, insd_ph1x, insd_ph2, insd_ph2x, insd_fax, insd_faxx, insd_ea}}
|
||||
*/
|
||||
const extractInsuranceData = (rq) => {
|
||||
const insuredParty = rq.AdminInfo?.Insured?.Party || {};
|
||||
const insuredPerson = insuredParty.PersonInfo || {};
|
||||
const insuredComms = Array.isArray(insuredParty.ContactInfo?.Communications)
|
||||
? insuredParty.ContactInfo.Communications
|
||||
: [insuredParty.ContactInfo?.Communications || {}];
|
||||
const insuredAddress = insuredPerson.Communications?.Address || {};
|
||||
|
||||
const insurerParty = rq.AdminInfo?.InsuranceCompany?.Party || {};
|
||||
|
||||
let insd_ph1, insd_ph1x, insd_ph2, insd_ph2x, insd_fax, insd_faxx, insd_ea;
|
||||
|
||||
for (const c of insuredComms) {
|
||||
if (c.CommQualifier === "CP") {
|
||||
insd_ph1 = c.CommPhone;
|
||||
insd_ph1x = c.CommPhoneExt;
|
||||
}
|
||||
if (c.CommQualifier === "WP") {
|
||||
insd_ph2 = c.CommPhone;
|
||||
insd_ph2x = c.CommPhoneExt;
|
||||
}
|
||||
if (c.CommQualifier === "FX") {
|
||||
insd_fax = c.CommPhone;
|
||||
insd_faxx = c.CommPhoneExt;
|
||||
}
|
||||
if (c.CommQualifier === "EM") insd_ea = c.CommEmail;
|
||||
}
|
||||
|
||||
return {
|
||||
insd_ln: insuredPerson.PersonName?.LastName || null,
|
||||
insd_fn: insuredPerson.PersonName?.FirstName || null,
|
||||
insd_title: insuredPerson.PersonName?.Title || null,
|
||||
insd_co_nm: insurerParty.OrgInfo?.CompanyName || insuredParty.OrgInfo?.CompanyName || null,
|
||||
insd_addr1: insuredAddress.Address1 || null,
|
||||
insd_addr2: insuredAddress.Address2 || null,
|
||||
insd_city: insuredAddress.City || null,
|
||||
insd_st: insuredAddress.StateProvince || null,
|
||||
insd_zip: insuredAddress.PostalCode || null,
|
||||
insd_ctry: insuredAddress.Country || null,
|
||||
insd_ph1,
|
||||
insd_ph1x,
|
||||
insd_ph2,
|
||||
insd_ph2x,
|
||||
insd_fax,
|
||||
insd_faxx,
|
||||
insd_ea
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Extracts vehicle data from the XML request.
|
||||
* @param {object} rq - The VehicleDamageEstimateAddRq object.
|
||||
@@ -246,7 +315,8 @@ const extractRepairFacilityData = (rq) => {
|
||||
*/
|
||||
const extractVehicleData = (rq, shopId) => {
|
||||
const desc = rq.VehicleInfo?.VehicleDesc || {};
|
||||
|
||||
const exterior = rq.VehicleInfo?.Paint?.Exterior || {};
|
||||
const interior = rq.VehicleInfo?.Paint?.Interior || {};
|
||||
return {
|
||||
shopid: shopId,
|
||||
v_vin: rq.VehicleInfo?.VINInfo?.VIN?.VINNum || null,
|
||||
@@ -255,12 +325,25 @@ const extractVehicleData = (rq, shopId) => {
|
||||
v_model_yr: desc.ModelYear || null,
|
||||
v_make_desc: desc.MakeDesc || null,
|
||||
v_model_desc: desc.ModelName || null,
|
||||
v_color: rq.VehicleInfo?.Paint?.Exterior?.ColorName || null,
|
||||
v_color: exterior.Color?.ColorName || null,
|
||||
v_bstyle: desc.BodyStyle || null,
|
||||
v_engine: desc.EngineDesc || null,
|
||||
v_options: desc.SubModelDesc || null,
|
||||
v_type: desc.FuelType || null,
|
||||
v_cond: rq.VehicleInfo?.Condition?.DrivableInd
|
||||
v_cond: rq.VehicleInfo?.Condition?.DrivableInd,
|
||||
v_trimcode: desc.TrimCode || null,
|
||||
v_tone: exterior.Tone || null,
|
||||
v_stage: exterior.RefinishStage || rq.VehicleInfo?.Paint?.RefinishStage || null,
|
||||
v_prod_dt: desc.ProductionDate || null,
|
||||
v_paint_codes: Array.isArray(exterior.PaintCodeInfo)
|
||||
? exterior.PaintCodeInfo.map((p) => p.PaintCode).join(",")
|
||||
: exterior.PaintCode || null,
|
||||
v_mldgcode: desc.MldgCode || null,
|
||||
v_makecode: desc.MakeCode || null,
|
||||
trim_color: interior.ColorName || desc.TrimColor || null,
|
||||
db_v_code: desc.DatabaseCode || null,
|
||||
v_model_num: desc.ModelNum || null,
|
||||
v_odo: desc.OdometerInfo?.OdometerReading || null
|
||||
};
|
||||
};
|
||||
|
||||
@@ -395,7 +478,9 @@ const partsManagementVehicleDamageEstimateAddRq = async (req, res) => {
|
||||
const adjusterData = extractAdjusterData(rq);
|
||||
const repairFacilityData = extractRepairFacilityData(rq);
|
||||
const vehicleData = extractVehicleData(rq, shopId);
|
||||
const lossInfo = extractLossInfo(rq);
|
||||
const joblinesData = extractJobLines(rq);
|
||||
const insuranceData = extractInsuranceData(rq);
|
||||
|
||||
// Find or create relationships
|
||||
const ownerid = await insertOwner(ownerData, logger);
|
||||
@@ -424,10 +509,12 @@ const partsManagementVehicleDamageEstimateAddRq = async (req, res) => {
|
||||
asgn_date,
|
||||
scheduled_in,
|
||||
scheduled_completion,
|
||||
...insuranceData, // Inline insurance data
|
||||
...lossInfo, // Inline loss information
|
||||
...ownerData, // Inline owner data
|
||||
...estimatorData,
|
||||
...adjusterData,
|
||||
...repairFacilityData,
|
||||
...estimatorData, // Inline estimator data
|
||||
...adjusterData, // Inline adjuster data
|
||||
...repairFacilityData, // Inline repair facility data
|
||||
// Inline vehicle data
|
||||
v_vin: vehicleData.v_vin,
|
||||
v_model_yr: vehicleData.v_model_yr,
|
||||
|
||||
Reference in New Issue
Block a user