// https://github.optum.com/paymentintegrity/artemis-ui/blob/e5c205e66b98f322897dddf9a3f2a74a1044a617/src/pages/investigation/subforms/investigation-results-form-converted.js#L168
// https://www.npmtrends.com/lodash.clonedeep-vs-clone-deep-vs-clone-vs-merge-deep-vs-rfdc
// https://www.npmjs.com/package/clone
// https://www.npmjs.com/package/lodash.clonedeep
const {
performance
} = require('perf_hooks');
const perf = (op, fn) => {
const t0 = performance.now();
const result = fn();
const ms = performance.now() - t0;
return {
meta: {
perf: {
message: `Execute ${op} in ${ms}ms`,
ms
}
},
data: result
};
};
const investigation = [
{
"memberPolicies": [
{
"rowId": 18599411,
"businessRowId": 30,
"memberDemographicRowId": 18599411,
"inventoryGroupRowId": 1085902,
"memberIdNumber": "KEN01376000908355338000",
"galaxyMemberSystemId": "123656591",
"fundingType": "F ",
"feedback": null,
"familyId": "00908355338",
"divisionCode": "KEN ",
"contractNumber": null,
"cirrusMemberId": null,
"alternateId": null,
"subscriberStateProvinceTerritoryRowId": 25,
"subscriberWorkPhone": null,
"subscriberMiddleName": null,
"subscriberLastName": "CHANG",
"subscriberId": "KEN01376000908355338000",
"subscriberHomePhone": "5734456568 ",
"subscriberGender": "M",
"subscriberFirstName": "CHENG-HSIUNG",
"subscriberDateOfBirth": "1945-08-07T00:00:00",
"spouseSignificantOtherId": null,
"spouseSignificantOtherGroupNumber": null,
"spouseSignificantOtherGroupName": null,
"spouseSignificantOtherEmployerPhone": null,
"retireeExpirationDate": null,
"retireeEffectiveDate": null,
"relationshipCode": null,
"memberStipulations": null,
"memberPolicyEffectiveStartDate": "2020-12-01T00:00:00",
"memberPolicyEffectiveEndDate": "2020-12-31T00:00:00",
"memberClaimSpend": 44653.65,
"medicalFinancialProduct": "01003",
"medicalLegalEntity": "01385",
"lineOfBusiness": "MCR ",
"isRetiree": false,
"groupCode": "KEN013760",
"productId": null,
"subGroupId": "KEN013760",
"subGroupName": "UNIVERSITY OF MISSOURI",
"accidental": false,
"commercialRxCoverage": false,
"hasDental": false,
"medicare": false,
"otherInsurance": false,
"studentPolicyCoordinates": false,
"memberDemographic": {
"rowId": 18599411,
"dateOfBirth": "1945-08-07T00:00:00",
"emailAddress": null,
"firstName": "CHENG-HSIUNG",
"middleName": null,
"lastName": "CHANG",
"gender": "M",
"lastFourOfSocialSecurityNumber": "1823",
"lastFourOfSubscriberSocialSecurityNumber": "1823",
"memberCellPhone": null,
"suffix": null,
"developerNotes": null,
"dateOfDeath": null,
"preferredContactMethod": null,
"logicalDelete": false
},
"cdbVerifications": [],
"cobras": [],
"cosmosMemberPolicyInvestigations": [],
"cspFacetsMemberPolicyInvestigations": [],
"hospices": [],
"investigationResults": [],
"memberFamilyDynamics": [
{
"memberPolicyRowId": 18599411,
"subscriberCustodialParent": false,
"subscriberBiologicalParent": false,
"responsibleParty": null,
"otherInsurancePolicyHolderCustodialParent": false,
"otherInsurancePolicyHolderBiologicalParent": false,
"jointPhysicalCustody": false,
"jointLegalCustody": false,
"familyDynamics": false,
"contactSuccessful": false,
"applicableCourtDecree": false
}
],
"otherPolicyAccidentalCoverages": [],
"otherPolicyCommercialCoverages": [],
"otherPolicyDentalCoverages": [],
"otherPolicyMedicareCoverages": [],
"otherPolicyMedicareEligibles": [
{
"rowId": 8,
"memberPolicyRowId": 18599411,
"startDate": "2021-02-16T06:11:13.447",
"endDate": "2022-02-16T06:11:13.447",
"enrollmentStartDate": "2021-02-16T06:11:13.447",
"enrollmentEndDate": "2022-02-16T06:11:13.447",
"partType": "A"
},
{
"rowId": 9,
"memberPolicyRowId": 18599411,
"startDate": "2021-02-16T06:11:16.5",
"endDate": "2022-02-16T06:11:16.5",
"enrollmentStartDate": "2021-02-16T06:11:16.5",
"enrollmentEndDate": "2022-02-16T06:11:16.5",
"partType": "A"
}
],
"otherPolicyMedicareEntitlements": [
{
"rowId": 14,
"memberPolicyRowId": 18599411,
"startDate": "2021-02-16T06:11:13.447",
"endDate": "2022-02-16T06:11:13.447",
"eligibilityType": "Age"
},
{
"rowId": 15,
"memberPolicyRowId": 18599411,
"startDate": "2021-02-16T06:11:16.5",
"endDate": "2022-02-16T06:11:16.5",
"eligibilityType": "Age"
}
],
"otherPolicyPharmacyCoverages": []
}
],
"inventories": [
{
"rowId": 27716599,
"inventoryStatusRowId": 100,
"businessRowId": 30,
"workflowRowId": 3783,
"importDate": "2020-12-19T14:10:09.037",
"wowuserRowId": 1002583,
"inventoryMultipleRowId": 1,
"assignedDate": "2021-01-04T12:47:02.803",
"pendedDate": "2021-05-06T07:59:24.803",
"completionDate": null,
"memberIdNumber": "KEN01376000908355338000",
"inventoryGroupRowId": 1085902,
"familyId": "00908355338",
"medicarePolicyNumber": null,
"otherInsurancePolicyNumber": null,
"pharmacyPolicy": null,
"otherInsurancePolicyHolder": null,
"otherInsuranceOtherEmployeeId": null,
"otherInsuranceMemberSystemId": null,
"coreSystemUpdateStatusRowId": 0,
"coreSystemWowuser": null,
"coreSystemCompletionDate": null,
"coreSystemPendDate": null,
"dentalCarrier": null,
"coreSystemUniqueIdentifier": null,
"authorizationNumber": null,
"dollarAmount": 1000,
"providerNumber": null,
"providerName": null,
"groupCode": "KEN013760",
"medicareAeffectiveDate": null,
"medicareAendDate": null,
"medicareBeffectiveDate": null,
"medicareBendDate": null,
"medicareDeffectiveDate": null,
"medicareDendDate": null,
"otherInsuranceCarrierCode": null,
"otherInsuranceCarrierName": null,
"otherInsurancePhone": null,
"pharmacyCarrierName": null,
"otherCarrierEffDate": null,
"otherCarrierEndDate": null,
"pharmacyEffectiveStartDate": null,
"pharmacyEffectiveEndDateAllNull": null,
"referenceNumber": null,
"claimNumber": "935203533555800",
"dentalCoverageEffectiveDate": null,
"dentalCoverageTerminationDate": null,
"dentalCoverageCoordinationOfBenefitEffectiveDate": null,
"dentalCoverageCoordinationOfBenefitEndDate": null,
"cobraTerminationDate": null,
"retireeEffectiveDate": null,
"retireeExpirationDate": null,
"externalNotes": "",
"internalNotes": "CLAIM ID: 935203533555800 BILLED AMOUNT: 379073.72",
"wowautomatedInvestigation": false,
"memberRowId": 18599411,
"courtOrdered": false,
"visionIndicator": false,
"behavioralHealthIndicator": false,
"autismIndicator": false,
"naiccode": null,
"otherInsuranceGroupNumber": null,
"autoWorkersCompensationCarrierName": null,
"type": null,
"dateOfAccident": null,
"diagnosis": null,
"accidentCarrierCode": null,
"jitClaimNumber": null,
"jitBilledCharges": null,
"inventoryGroupReviewRowId": null,
"inventorySourceID": 0,
"inventorySourceDescription": null,
"rpaWorkedStatus": null,
"businessRow": {
"rowId": 30,
"businessName": "United Healthcare",
"platformDelete": null,
"clientDelete": null,
"clientRowId": 4,
"platformRowId": 3,
"addDate": "2010-05-03T13:41:51.737",
"addBy": 237,
"changeDate": "2018-12-26T07:32:41.767",
"changeBy": 19,
"effectiveDate": "2010-05-03T13:41:51.737",
"logicalDelete": false,
"developerNotes": "Add Client * DataMod WI #27117",
"writeToMemberAuthority": false,
"jitageOutDuration": 5,
"segmentName": "United Healthcare Medicare Advantage",
"detailBusinessName": null,
"businessNameWithId": null
},
"workflowRow": {
"rowId": 3783,
"workflowName": "High Dollar UFE Claim ",
"workflowDescription": "Standard",
"workflowSourceId": 16,
"workflowSourceIddescription": "Algorithm Commercial Claims (P)",
"businessId": 30,
"businessName": "United Healthcare",
"statusId": 7,
"insuranceType": "OI ",
"insuranceSubType": 25,
"insuranceSubTypeService": 20,
"updatePotential": 0.008,
"turnAroundTimeRequired": false,
"monthlyVolumeEstimate": 50,
"issuesPerHour": 3.7,
"allowStartTime": "2015-02-03T05:00:00",
"allowEndTime": "2015-02-03T20:00:00",
"allowWeekday": true,
"allowWeekend": true,
"allowRPA": false,
"frequency": "Weekly ",
"peot1AllNull": null,
"peot2": null,
"peoi1AllNull": null,
"peoi2AllNull": null,
"peod1AllNull": null,
"peod2AllNull": null,
"workflowGroupingRowId": 3,
"addDate": "2015-02-03T16:17:41.293",
"addBy": 237,
"changeDate": "2021-05-13T06:31:30.69",
"changeBy": 999999,
"fileLoadedName": null,
"resubmissionException": "Y",
"resubmissionRule": 180,
"proactiveReactive": "P",
"newProductionIdsPerHour": null,
"effectiveDate": "2015-02-03T16:17:41.293",
"logicalDelete": false,
"developerNotes": "Data Mod for US364078 * *DataMod INC5850213 * *DataMod INC6188528 * *DataMod INC6570132 * *Incident INC8563287 * *Incident INC8563287 * *Incident INC8563287* *DataMod INC9279077* *DataMod INC15422284",
"isEmployeeImport": false,
"totalMedicalExpenses": 4504048.61,
"countOfCompletedRecords": 297,
"turnAroundTimeInDays": 30,
"priorityOutOfSync": false,
"agingOfId": null,
"cobprogram": 31,
"market": null,
"roleDelineation": true,
"isEmployeeProtected": false,
"newborn": false,
"outputRowId": 1,
"isMedicare": false,
"investigationGuideTypeRowId": -1,
"workflowPrioritization": null,
"knowledgeCategoryRowId": null,
"addByName": null,
"changeByName": null,
"workflowAnalytics": [],
"workflowStateProvinceTerritory": []
},
"wowUserRow": {
"rowId": 1002583,
"userName": "dchan5",
"wowuserAccessRowId": 0,
"employeeId": "001615853 ",
"firstName": "DANIEL",
"middleName": null,
"lastName": "CHAN",
"title": "Dev",
"emailAddress": "daniel.chan@optum.com",
"employeeManagerId": 0,
"phoneNumber": " ",
"extension": null,
"jackNumber": null,
"mailStopCode": null,
"assetTagNumber": null,
"scheduledStartTimeDelete": null,
"scheduledStopTimeDelete": null,
"projectHoursPerDay": 0,
"overTimeAllowed": true,
"numberOfPendsAllowed": 25,
"pendTurnaroundTime": 5,
"allowedPiecesOfWork": 1,
"currentlyAvailable": 1,
"reassignAllowed": "Y",
"maximumNoResolutionPerDay": 0,
"performanceStatus": null,
"userCobstartDate": null,
"effectiveDate": "2020-11-05T08:24:37.36",
"logicalDelete": false,
"developerNotes": null,
"lastActivityDate": null,
"scheduledStart": "1900-01-01T00:01:00",
"scheduledStop": "1900-01-01T23:59:00",
"wowuserPerformanceStatusRowId": null,
"investigationGuideExempt": false,
"justInTimeInvestigator": false,
"retroInvestigator": false,
"isRobotProcessAutomationUser": false
},
"fileAttachments": [],
"ecrsSubmissions": [],
"studentSurveyResults": [],
"cosmosMemberPolicyInvestigation": [],
"cspFacetsMemberPolicyInvestigation": [],
"inventoryAccessory": [
{
"rowId": 15603037,
"inventoryRowId": 27716599,
"workflowRowId": 3783,
"totalPriority": 186,
"highestPriorityOverride": false,
"highestPriorityOverrideDate": null,
"priorityOutOfSync": false,
"effectiveDate": "2020-12-19T14:10:09.083",
"logicalDelete": false,
"developerNotes": null,
"partitionIndex": null,
"maintenancePriority": 0,
"cobscorePriority": 0,
"jitpriority": null,
"mlscorePriority": 1
}
],
"inventoryGroupingCarrier": [],
"inventoryGroupingFamily": [
{
"rowId": 7480539,
"inventoryRowId": 27716599,
"groupingNumber": 4597449,
"effectiveDate": "2021-05-11T14:36:48.947",
"logicalDelete": null,
"developerNotes": null,
"familyId": "00908355338"
}
],
"investigationResult": [],
"investigationSourceSystemErrorTracking": [],
"investigationErrorTracking": [],
"phoneLog": [],
"outsourcedInvestigation": [],
"inventoryStatusDescription": null,
"inventoryMultipleDescription": null,
"businessDescription": null,
"wowUserDescription": null,
"coreSystemUpdateStatusDescription": null,
"coreSystemWowUserDescription": null
}
]
}
];
const pathify = obj => {
const result = {};
const dig = (obj, chain = '') => {
if (typeof obj !== 'object') {
return;
}
if (Array.isArray(obj)) {
dig(
obj[0],
chain ?
`${chain}[0]` :
''
);
}
const keys = Object.keys(obj);
for (let i = 0; i < keys.length; i++) {
const propertyName = keys[i];
const propertyValue = obj[propertyName];
const path = chain ?
`${chain}.${propertyName}` :
propertyName;
if (
typeof propertyValue !== 'object' ||
Array.isArray(propertyValue) === false
) {
result[propertyName] = path;
continue;
}
dig(propertyValue, path);
}
};
dig(obj);
return result;
};
const pathsResult = perf(
'pathify(investigation)',
() => pathify(investigation)
);
const paths = pathsResult.data;
const fields = Object.keys(paths);
const fieldCount = fields.length;
console.log(fieldCount);
console.log(pathsResult.meta.perf.message);
console.log(paths);
const propsIndex = 0;
const currentInvestigationResultsIndex = 0;
const getFieldName = field => `memberPolicies[${propsIndex}].investigationResults[${currentInvestigationResultsIndex}].${field}`;
const getFieldsStatically = () => {
for (let i = 0; i < fieldCount; i++) {
getFieldName(fields[i]);
}
};
const getFieldsStaticallyResults = perf(
'getFieldsStatically()',
() => getFieldsStatically()
);
console.log(getFieldsStaticallyResults.meta.perf.message);
const getFieldsDynamically = () => {
for (let i = 0; i < fieldCount; i++) {
paths[fields[i]];
}
};
const getFieldsDynamicallyResults = perf(
'getFieldsDynamically()',
() => getFieldsDynamically()
);
console.log(getFieldsDynamicallyResults.meta.perf.message);
console.log(
`Total time saved by pathify() perf is ${
(getFieldsStaticallyResults.meta.perf.ms -
getFieldsDynamicallyResults.meta.perf.ms)
}ms`
);
console.log(
`Total time saved by pathify() perf per call is ${
(getFieldsStaticallyResults.meta.perf.ms -
getFieldsDynamicallyResults.meta.perf.ms) / fieldCount
}ms`
);