/** * Program: models_cin.js * @date 10/20/2022 * @author Stephan K Eisenbarth * Organization: VA CART * CIN: Sharon E. Davis * Description: JavaScript file containing the function calls for CIN */ //runTest(); // /** * @author Stephan K Eisenbarth * @date 10/12/2022 * Description: returns an array containing the covariate human readable names * @return varNameArr String array containing the covariate human readable names */ function getCINVariableNamesArr () { var varNameArr = ["Intercept", "Age", "Tobacco_Use", "Prior_PCI", "Prior_CABG", "Diabetes", "Ejection_fraction_lte40_percent", "Prior_MI", "Peripheral_vascular_disease", "CKD", "eGFR_lt60", "eGFR_lt45", "eGFR_lt30", "Hypertension", "Urgent", "Emergent", "Salvage", "Unstable_angina", "CHF_Any_Prior", "Anemia_HMG", "CVD", "Shock_CART", "STEMI", "NSTEMI", "MACD2021_cat[1.0 - 1.5)", "MACD2021_cat[1.5 - 2.0", "MACD2021_cat<0.5", "MACD2021_cat>=2.0"]; return varNameArr; } /** * @author Stephan K Eisenbarth * @date 10/11/2022 * Description: Processes the CIN form * @param parFormID String containing the CIN form's ID * @return outArr String array containing the values of successfully processing the CIN model */ function processForm_CIN (parFormID) { var outArr = null; var errMess = null; var errTitle = "CIN - "; // var x = document.getElementById ("ageFld"); var x = getElemInput (parFormID, "ageFld"); if (checkVal_Age (18, 91) == false) { errMess = errTitle + "Age invalid, must be between 18 and 91"; } else { // x = document.getElementById ("weightLbsFld"); x = getElemInput (parFormID, "weightLbsFld"); if (isDouble (x.value) == false) { errMess = errTitle + "Weight in pounds must be a number"; } else { // x = document.getElementById ("statusMenu"); x = getElemInput (parFormID, "statusMenu"); if (isEmpty (x.value) == true || x.value == "NULL") { errMess = errTitle + "PCI status drop-menu cannot be empty"; } else { // x = document.getElementById ("indicaMenu"); x = getElemInput (parFormID, "indicaMenu"); if (isEmpty (x.value) == true || x.value == "NULL") { errMess = errTitle + "Indications drop-menu cannot be empty"; } else { // x = document.getElementById ("HgBFld"); // x = getElemInput (parFormID, "HgBFld"); // if (isDouble (x.value) == false) { // errMess = errTitle + "Hemoglobin must be a number/decimal"; // } // else { // x = document.getElementById ("eGFRFld"); // x = getElemInput (parFormID, "eGFRFld"); // if (isDouble (x.value) == false) { // errMess = errTitle + "eGFR must be a number/decimal"; // } // else { // x = document.getElementById ("serumCreatinFld"); x = getElemInput (parFormID, "serumCreatinFld"); if (isDouble (x.value) == false) { errMess = errTitle + "Serum Creatinine must be a number in mg/dL"; } else { outArr = calcCIN (parFormID); } // } // } } } } } if (errMess != null) { alert (errMess); if (currModel != "cin_Area") { changeModel ("cinBtn"); } if (x != null) { getElementFromCurrModel(x.id).focus (); } } return outArr; } /** * @author Stephan K Eisenbarth * @date 10/11/2022 * Description: Calculates the associated CIN percentrage value based on the form's values * @param parFormID String containing the CIN form's ID */ function calcCIN (parFormID) { var resultsArr = null; var covarArr = [28]; // Array of the initial covariate values var index = 0; // int index used to track the current place within the covariate value array var ok = true; // Whether form was properly filled out covarArr [index ++] = 1 // Intercept value is always 1 covarArr [index ++] = getElemInput (parFormID, "ageFld").value; var tobacco = 0; if (getElemInput (parFormID, "TobaccoUse").checked) { tobacco = 1; } covarArr [index ++] = tobacco; var priorPCI = 0; if (getElemInput (parFormID, "PriorPCI").checked) { priorPCI = 1; } covarArr [index ++] = priorPCI; var PriorCABG = 0; if (getElemInput (parFormID, "PriorCABG").checked) { PriorCABG = 1; } covarArr [index ++] = PriorCABG; var diabetes = 0; if (getElemInput (parFormID, "Diabetes").checked) { diabetes = 1; } covarArr [index ++] = diabetes; var ejectFractLTE40 = 0; if (getElemInput (parFormID, "ejectFractLTE40").checked) { ejectFractLTE40 = 1; } covarArr [index ++] = ejectFractLTE40; var PriorMI = 0; if (getElemInput (parFormID, "PriorMI").checked) { PriorMI = 1; } covarArr [index ++] = PriorMI; var PVD = 0; if (getElemInput (parFormID, "PVD").checked) { PVD = 1; } covarArr [index ++] = PVD; var CKD = 0; if (getElemInput (parFormID, "CKD").checked) { CKD = 1; } covarArr [index ++] = CKD; var eGFRlt60 = 0; var eGFRlt45 = 0; var eGFRlt30 = 0; // var eGFRVal = getElemInput (parFormID, "eGFRFld").value; var serumCreatin = parseFloat(getElemInput (parFormID, "serumCreatinFld").value); var eGFRVal = get_eGFR (serumCreatin, getElemInput (parFormID, "sexMenu").value, getElemInput (parFormID, "ageFld").value); if (isDouble (eGFRVal) == true) { if (parseFloat (eGFRVal) < 30) { eGFRlt30 = 1; } else if (parseFloat (eGFRVal) < 45) { eGFRlt45 = 1 } else if (parseFloat (eGFRVal) < 60) { eGFRlt60 = 1; } } covarArr [index ++] = eGFRlt60; covarArr [index ++] = eGFRlt45; covarArr [index ++] = eGFRlt30; var HYP = 0; if (getElemInput (parFormID, "HYP").checked) { HYP = 1; } covarArr [index ++] = HYP; var URGENT = 0; if (getElemInput (parFormID, "statusMenu").value == "urgent") { URGENT = 1; } covarArr [index ++] = URGENT; var EMERG = 0; if (getElemInput (parFormID, "statusMenu").value == "emergent") { EMERG = 1; } covarArr [index ++] = EMERG; var SALV = 0; if (getElemInput (parFormID, "statusMenu").value == "salvage") { SALV = 1; } covarArr [index ++] = SALV; var UNSTABLE = 0; if (getElemInput (parFormID, "indicaMenu").value == "Unstable Angina") { UNSTABLE = 1; } covarArr [index ++] = UNSTABLE; var chf = 0; if (getElemInput (parFormID, "CHF").checked) { chf = 1; } covarArr [index ++] = chf; // ?????????????? NEED TO KNOW HOW SHARON CLASSIFIES THE Anemia_HMG ?????????????? var HMG = 0; if (getElemInput (parFormID, "ISANEMIC").checked) { HMG = 1; } covarArr [index ++] = HMG; var CVD = 0; if (getElemInput (parFormID, "PriorStroke").checked) { CVD = 1; } covarArr [index ++] = CVD; var Shock_CART = 0; if (getElemInput (parFormID, "CGS").checked) { Shock_CART = 1; } covarArr [index ++] = Shock_CART; var STEMI = 0; if (getElemInput (parFormID, "indicaMenu").value == "STEMI") { STEMI = 1; } covarArr [index ++] = STEMI; var NSTEMI = 0; if (getElemInput (parFormID, "indicaMenu").value == "NSTEMI") { NSTEMI = 1; } covarArr [index ++] = NSTEMI; var weightKG = parseFloat(getElemInput (parFormID, "weightLbsFld").value)*0.453592; var MACD = getMACD2021 (weightKG, serumCreatin); var MACD2 = 0; var MACD15_2 = 0; var MACD1_15 = 0; var MACDlt5 = 0; // This will always be 0 as we are not going to report on MACD < 0.5 /* if (MACD >= 2.0) { MACD2 = 1; } else if (MACD >= 1.5 || MACD <= 2.0) { MACD15_2 = 1; } else if (MACD >= 1.0 || MACD <= 1.5) { MACD1_15 = 1; } */ // console.log ("First MACD index: " + index); var macdStrtIndex = index; covarArr [index ++] = MACD1_15; covarArr [index ++] = MACD15_2; covarArr [index ++] = MACDlt5; covarArr [index ++] = MACD2; if (ok == true) { // console.log ("Start CIN calculation"); // dspArrWLabel (getCINVariableNamesArr(), covarArr); resultsArr = getCIN_MACD (covarArr, macdStrtIndex); // console.log ("CIN Results"); // dspArr (resultsArr); showResults_CIN (parFormID, resultsArr); } return resultsArr; } /** * @author Stephan K Eisenbarth * @date 10/17/2022 * Description: Returns a 2D array contain the 3 MACD results for (MACD 1.0 to 1.5, MACD 1.5 to 2.0, and MACD for >= 2.0) * @param tmpCovarArr Array containing the int covariate modified values * @param arrIndex int containing the index where the MACD covariate values start * @return outArr 2D Array containing the contain the 3 MACD results for (MACD 1.0 to 1.5, MACD 1.5 to 2.0, and MACD for >= 2.0) */ function getCIN_MACD (tmpCovarArr, arrIndex) { var outArr; if (tmpCovarArr != null && tmpCovarArr.length > 0 && tmpCovarArr[0] != null) { if (arrIndex > -1) { outArr = []; var currModelCalc = 0; var tmpArr = tmpCovarArr; // Calc MACD 1.0 to 1.5, this is 1 to 1.5 times the allowable dose value (calulate the contrast given divided by the maximum allowable contrast) for (var i = 0; i < 4; i++) { tmpArr [arrIndex + i] = 0; } tmpArr [arrIndex] = 1; tmpArr [arrIndex + 1] = 0; // tmpArr [arrIndex + 2] = 0; // This will always be 0 as we are not going to report on MACD < 0.5 tmpArr [arrIndex + 3] = 0; // console.log ("Get CIN for MACD 1.0 to 1.5"); outArr [currModelCalc ++] = getCIN (tmpArr); // Calc MACD 1.5 to 2.0, this is 1.5 to 2.0 times the allowable dose value (calulate the contrast given divided by the maximum allowable contrast) for (var i = 0; i < 4; i++) { tmpArr [arrIndex + i] = 0; } tmpArr [arrIndex] = 0; tmpArr [arrIndex + 1] = 1; // tmpArr [arrIndex + 2] = 0; // This will always be 0 as we are not going to report on MACD < 0.5 tmpArr [arrIndex + 3] = 0; // console.log ("Get CIN for MACD 1.5 to 2.0"); outArr [currModelCalc ++] = getCIN (tmpArr); // Calc MACD >= 2.0, this is 2.0 times or more the allowable dose value (calulate the contrast given divided by the maximum allowable contrast) for (var i = 0; i < 4; i++) { tmpArr [arrIndex + i] = 0; } tmpArr [arrIndex] = 0; tmpArr [arrIndex + 1] = 0; // tmpArr [arrIndex + 2] = 0; // This will always be 0 as we are not going to report on MACD < 0.5 tmpArr [arrIndex + 3] = 1; // console.log ("Get CIN for MACD >= 2.0"); outArr [currModelCalc ++] = getCIN (tmpArr); } } return outArr; } /** * @author Stephan K Eisenbarth * @date 11/21/2019 * Description: Calculates the associated In-Hospital percentrage value * @param tmpCovarArr Array containing the int covariate modified values * @return cinArr Array containing the Risk percentage, the Lower Limit and Upper Limit confidence intervals for various MACD ranges */ function getCIN (tmpCovarArr) { var cinArr = null; var varNameArr = getCINVariableNamesArr (); var finalCINRisk = 0.0; var cinMort = 0.0; // console.log ("Covariate Length: " + tmpCovarArr.length); // console.log ("Variable Name Length: " + varNameArr.length); if (tmpCovarArr != null && tmpCovarArr.length > 0) { // dspArr (tmpCovarArr); // Values do exist within the tmpCovarArr object // Array of the covariate modifiers // Modifier Value Assocaited Covariate var modCovarArr = [-3.877820, // Intercept 0.005926, // Age -0.146818, // Tobacco use -0.231616, // Prior_PCI -0.019090, // Prior_CABG 0.302479, // Diabetes -0.018632, // Ejection_fraction_lte40_percent 0.017887, // Prior_MI 0.174716, // Peripheral_vascular_disease 0.403200, // CKD 0.288466, // eGFR_lt60 0.624302, // eGFR_lt45 0.869378, // eGFR_lt30 0.007133, // Hypertension 0.390434, // Urgent 0.973184, // Emergent 1.289253, // Salvage -0.302112, // Unstable_angina 0.695018, // CHF_Any_Prior 0.431812, // Anemia_HMG 0.080561, // CVD 1.030027, // Shock_CART 0.196454, // STEMI 0.196932, // NSTEMI 0.096396, // MACD2021_cat[1.0 - 1.5] 0.288652, // MACD2021_cat[1.5 - 2.0] 0.207801, // MACD2021_cat<0.5 0.680307]; // MACD2021_cat>=2.0 // Generate CALC value by modify each covariate then adding everything together var LP = 0.0; for (var i = 0; i < tmpCovarArr.length; i++) { // console.log ("[" + i + "] " + varNameArr[i] + " => " + parseFloat(modCovarArr [i]) + " * " + parseFloat(tmpCovarArr [i])); LP += (parseFloat(modCovarArr [i]) * parseFloat(tmpCovarArr [i])); } // console.log ("++++++++++++++++++++++++++++++++++++++++++"); for (var i = 0; i < tmpCovarArr.length; i++) { // console.log (tmpCovarArr[i] + "\t" + modCovarArr[i] + "\t" + (tmpCovarArr[i] * modCovarArr [i])); } // console.log ("++++++++++++++++++++++++++++++++++++++++++"); // console.log ("CIN so far: " + LP); // Get the probability var PROB = 0.0; PROB = (Math.pow (e, LP))/(1+(Math.pow (e, LP))); // console.log ("Probability: " + PROB); // Generate the risk percentage cinMort = 100 * PROB; // 2D Array of matrix (17x17) var matrixCIN = [ [0.01700906, -0.00021742, -0.00071921, -0.00001420, 0.00022195, -0.00055396, -0.00024342, -0.00009480, 0.00036449, 0.00017492, 0.00032624, 0.00047957, 0.00020384, 0.00000692, -0.00042683, -0.00073555, -0.00117382, -0.00054879, -0.00031288, 0.00007590, 0.00023310, -0.00023942, -0.00040481, -0.00018359, -0.00057174, -0.00045244, -0.00124407, -0.00039889], [-0.00021742, 0.00000323, 0.00000650, -0.00000129, -0.00000427, 0.00000229, 0.00000240, -0.00000004, -0.00000513, -0.00000283, -0.00000885, -0.00000985, -0.00000433, 0.00000072, 0.00000018, 0.00000195, 0.00001250, 0.00000217, -0.00000381, -0.00000890, -0.00000365, 0.00000484, -0.00000050, -0.00000095, -0.00000247, -0.00000340, 0.00000499, -0.00000381], [-0.00071921, 0.00000650, 0.00127326, -0.00030123, -0.00009060, 0.00002220, -0.00005670, -0.00009120, -0.00035592, -0.00006130, 0.00002930, 0.00007390, 0.00008970, -0.00001520, 0.00002980, 0.00005040, -0.00003920, 0.00001680, -0.00001750, -0.00003470, -0.00012439, -0.00000741, 0.00004830, 0.00005860, -0.00002790, -0.00005440, 0.00000657, -0.00004190], [-0.00001420, -0.00000129, -0.00030123, 0.00160067, -0.00029192, -0.00007560, 0.00000008, -0.00038960, -0.00001790, -0.00002360, 0.00001650, 0.00003760, 0.00009170, -0.00010869, 0.00004750, 0.00002630, 0.00003830, -0.00018730, 0.00000669, -0.00002230, -0.00009840, 0.00001250, 0.00003010, 0.00009980, -0.00001100, -0.00002580, 0.00006680, -0.00003620], [0.00022195, -0.00000427, -0.00009060, -0.00029192, 0.00190291, -0.00010498, -0.00004660, -0.00016588, -0.00014498, -0.00002280, 0.00000774, 0.00001240, 0.00007940, -0.00008060, -0.00000715, 0.00003460, -0.00000436, -0.00004350, -0.00005470, -0.00004190, -0.00012645, 0.00001420, 0.00011462, 0.00007500, -0.00003140, -0.00002120, 0.00015065, -0.00000497], [-0.00055396, 0.00000229, 0.00002220, -0.00007560, -0.00010498, 0.00112356, 0.00001720, 0.00000136, -0.00001540, -0.00010566, -0.00003470, -0.00005620, -0.00006470, -0.00011310, 0.00003240, 0.00001310, 0.00004300, -0.00003120, -0.00003660, -0.00012894, -0.00007320, 0.00006520, 0.00001860, -0.00002820, 0.00001580, 0.00004290, -0.00002180, 0.00014096], [-0.00024342, 0.00000240, -0.00005670, 0.00000008, -0.00004660, 0.00001720, 0.00145758, -0.00005190, 0.00001270, -0.00001720, -0.00000596, -0.00001200, 0.00004330, -0.00011719, 0.00005810, 0.00013869, 0.00020463, 0.00011421, -0.00042338, -0.00003370, -0.00000939, -0.00023961, 0.00008180, 0.00010280, -0.00001750, -0.00004320, 0.00000947, -0.00002040], [-0.00009480, -0.00000004, -0.00009120, -0.00038960, -0.00016588, 0.00000136, -0.00005190, 0.00138621, -0.00011886, -0.00005760, 0.00002470, 0.00000506, 0.00000958, -0.00007680, -0.00011967, 0.00003500, -0.00023642, 0.00005700, -0.00005050, -0.00007000, -0.00007730, -0.00005300, -0.00008340, -0.00043076, -0.00000222, -0.00002700, 0.00000786, 0.00000514], [0.00036449, -0.00000513, -0.00035592, -0.00001790, -0.00014498, -0.00001540, 0.00001270, -0.00011886, 0.00562449, -0.00017591, 0.00002280, -0.00000146, -0.00009390, 0.00011841, 0.00001360, 0.00007940, 0.00024599, 0.00004280, -0.00000520, -0.00004510, -0.00029469, -0.00005370, 0.00009000, 0.00005330, -0.00005530, -0.00004000, 0.00002450, -0.00006110], [0.00017492, -0.00000283, -0.00006130, -0.00002360, -0.00002280, -0.00010566, -0.00001720, -0.00005760, -0.00017591, 0.00198179, -0.00066512, -0.00104992, -0.00122134, -0.00052418, 0.00003390, 0.00003300, -0.00012727, 0.00002420, 0.00002000, -0.00009990, -0.00006750, 0.00013373, -0.00001420, 0.00005520, -0.00004680, -0.00005610, 0.00003110, -0.00008170], [0.00032624, -0.00000885, 0.00002930, 0.00001650, 0.00000774, -0.00003470, -0.00000596, 0.00002470, 0.00002280, -0.00066512, 0.00197665, 0.00093993, 0.00103540, 0.00001510, -0.00000412, 0.00006300, 0.00025510, 0.00002780, -0.00007470, -0.00005970, 0.00000621, -0.00014461, 0.00006240, 0.00000687, -0.00008260, -0.00011795, 0.00006320, -0.00010461], [0.00047957, -0.00000985, 0.00007390, 0.00003760, 0.00001240, -0.00005620, -0.00001200, 0.00000506, -0.00000146, -0.00104992, 0.00093993, 0.00307528, 0.00139741, 0.00001160, -0.00000178, 0.00006180, 0.00020449, 0.00006290, -0.00011766, -0.00012121, 0.00002360, -0.00009020, 0.00007550, 0.00001400, -0.00004720, -0.00018034, 0.00010417, -0.00018967], [0.00020384, -0.00000433, 0.00008970, 0.00009170, 0.00007940, -0.00006470, 0.00004330, 0.00000958, -0.00009390, -0.00122134, 0.00103540, 0.00139741, 0.00781704, -0.00011330, 0.00000296, 0.00009480, 0.00021178, 0.00009560, -0.00013480, -0.00019586, 0.00006410, -0.00025791, 0.00004340, -0.00001970, -0.00008890, -0.00039725, 0.00008740, -0.00095132], [0.00000692, 0.00000072, -0.00001520, -0.00010869, -0.00008060, -0.00011310, -0.00011719, -0.00007680, 0.00011841, -0.00052418, 0.00001510, 0.00001160, -0.00011330, 0.00156921, 0.00004750, 0.00001330, 0.00016751, -0.00000293, -0.00018978, -0.00012423, -0.00011613, 0.00002470, 0.00002070, 0.00002080, 0.00000400, 0.00001680, -0.00000864, 0.00002520], [-0.00042683, 0.00000018, 0.00002980, 0.00004750, -0.00000715, 0.00003240, 0.00005810, -0.00011967, 0.00001360, 0.00003390, -0.00000412, -0.00000178, 0.00000296, 0.00004750, 0.00127959, 0.00068118, 0.00070662, -0.00036407, -0.00006290, -0.00004490, 0.00000805, -0.00013586, -0.00025994, -0.00052748, 0.00001640, 0.00003460, -0.00004150, 0.00003870], [-0.00073555, 0.00000195, 0.00005040, 0.00002630, 0.00003460, 0.00001310, 0.00013869, 0.00003500, 0.00007940, 0.00003300, 0.00006300, 0.00006180, 0.00009480, 0.00001330, 0.00068118, 0.00732998, 0.00333986, -0.00010030, -0.00002270, 0.00000470, -0.00003050, -0.00120229, -0.00571530, -0.00044758, -0.00003330, 0.00002730, 0.00005650, -0.00009580], [-0.00117382, 0.00001250, -0.00003920, 0.00003830, -0.00000436, 0.00004300, 0.00020463, -0.00023642, 0.00024599, -0.00012727, 0.00025510, 0.00020449, 0.00021178, 0.00016751, 0.00070662, 0.00333986, 0.17088392, 0.00002260, -0.00022312, 0.00002440, 0.00012149, -0.00912019, -0.00465482, -0.00022186, -0.00032629, -0.00005660, -0.00005160, -0.00174803], [-0.00054879, 0.00000217, 0.00001680, -0.00018730, -0.00004350, -0.00003120, 0.00011421, 0.00005700, 0.00004280, 0.00002420, 0.00002780, 0.00006290, 0.00009560, -0.00000293, -0.00036407, -0.00010030, 0.00002260, 0.00406094, 0.00013551, 0.00002350, -0.00001810, 0.00011037, 0.00036402, 0.00047279, -0.00005990, -0.00001410, 0.00013762, -0.00012884], [-0.00031288, -0.00000381, -0.00001750, 0.00000669, -0.00005470, -0.00003660, -0.00042338, -0.00005050, -0.00000520, 0.00002000, -0.00007470, -0.00011766, -0.00013480, -0.00018978, -0.00006290, -0.00002270, -0.00022312, 0.00013551, 0.00143326, -0.00014069, -0.00003250, -0.00013699, 0.00003610, 0.00004520, 0.00003470, 0.00004770, -0.00005510, 0.00002160], [0.00007590, -0.00000890, -0.00003470, -0.00002230, -0.00004190, -0.00012894, -0.00003370, -0.00007000, -0.00004510, -0.00009990, -0.00005970, -0.00012121, -0.00019586, -0.00012423, -0.00004490, 0.00000470, 0.00002440, 0.00002350, -0.00014069, 0.00136231, -0.00005690, -0.00011446, 0.00019056, 0.00003700, 0.00000208, -0.00002170, -0.00002520, -0.00006600], [0.00023310, -0.00000365, -0.00012439, -0.00009840, -0.00012645, -0.00007320, -0.00000939, -0.00007730, -0.00029469, -0.00006750, 0.00000621, 0.00002360, 0.00006410, -0.00011613, 0.00000805, -0.00003050, 0.00012149, -0.00001810, -0.00003250, -0.00005690, 0.00208528, -0.00003370, -0.00000840, -0.00000578, -0.00000330, -0.00000856, 0.00000556, -0.00005890], [-0.00023942, 0.00000484, -0.00000741, 0.00001250, 0.00001420, 0.00006520, -0.00023961, -0.00005300, -0.00005370, 0.00013373, -0.00014461, -0.00009020, -0.00025791, 0.00002470, -0.00013586, -0.00120229, -0.00912019, 0.00011037, -0.00013699, -0.00011446, -0.00003370, 0.01850215, 0.00034094, 0.00005050, -0.00004720, -0.00002540, 0.00000690, -0.00050073], [-0.00040481, -0.00000050, 0.00004830, 0.00003010, 0.00011462, 0.00001860, 0.00008180, -0.00008340, 0.00009000, -0.00001420, 0.00006240, 0.00007550, 0.00004340, 0.00002070, -0.00025994, -0.00571530, -0.00465482, 0.00036402, 0.00003610, 0.00019056, -0.00000840, 0.00034094, 0.01211158, 0.00067884, -0.00008140, -0.00017953, 0.00024051, -0.00011494], [-0.00018359, -0.00000095, 0.00005860, 0.00009980, 0.00007500, -0.00002820, 0.00010280, -0.00043076, 0.00005330, 0.00005520, 0.00000687, 0.00001400, -0.00001970, 0.00002080, -0.00052748, -0.00044758, -0.00022186, 0.00047279, 0.00004520, 0.00003700, -0.00000578, 0.00005050, 0.00067884, 0.00216023, -0.00007100, -0.00009730, 0.00015759, -0.00010455], [-0.00057174, -0.00000247, -0.00002790, -0.00001100, -0.00003140, 0.00001580, -0.00001750, -0.00000222, -0.00005530, -0.00004680, -0.00008260, -0.00004720, -0.00008890, 0.00000400, 0.00001640, -0.00003330, -0.00032629, -0.00005990, 0.00003470, 0.00000208, -0.00000330, -0.00004720, -0.00008140, -0.00007100, 0.00304570, 0.00084001, 0.00077615, 0.00085575], [-0.00045244, -0.00000340, -0.00005440, -0.00002580, -0.00002120, 0.00004290, -0.00004320, -0.00002700, -0.00004000, -0.00005610, -0.00011795, -0.00018034, -0.00039725, 0.00001680, 0.00003460, 0.00002730, -0.00005660, -0.00001410, 0.00004770, -0.00002170, -0.00000856, -0.00002540, -0.00017953, -0.00009730, 0.00084001, 0.00664433, 0.00075941, 0.00091759], [-0.00124407, 0.00000499, 0.00000657, 0.00006680, 0.00015065, -0.00002180, 0.00000947, 0.00000786, 0.00002450, 0.00003110, 0.00006320, 0.00010417, 0.00008740, -0.00000864, -0.00004150, 0.00005650, -0.00005160, 0.00013762, -0.00005510, -0.00002520, 0.00000556, 0.00000690, 0.00024051, 0.00015759, 0.00077615, 0.00075941, 0.00138176, 0.00074918], [-0.00039889, -0.00000381, -0.00004190, -0.00003620, -0.00000497, 0.00014096, -0.00002040, 0.00000514, -0.00006110, -0.00008170, -0.00010461, -0.00018967, -0.00095132, 0.00002520, 0.00003870, -0.00009580, -0.00174803, -0.00012884, 0.00002160, -0.00006600, -0.00005890, -0.00050073, -0.00011494, -0.00010455, 0.00085575, 0.00091759, 0.00074918, 0.00862400] ]; var outArr = new Array (tmpCovarArr.length); // Perform martix multiplication outArr = runMatrixMultiplication (tmpCovarArr, matrixCIN); var finalCINRisk = 0; // Transpose the covariate array (tmpCovarArr) and perform matirx multiplication with the above matrix (outArr) to get final result for (var i = 0; i < outArr.length; i++) { finalCINRisk += (parseFloat(outArr [i]) * parseFloat(tmpCovarArr [i])); } } var standardError = Math.sqrt (finalCINRisk); var lcl = getLowerConfidenceLevel (LP, standardError); var ucl = getUpperConfidenceLevel (LP, standardError); cinArr = [cinMort, lcl*100, ucl*100]; return cinArr; } /** * @author Stephan K Eisenbarth * @date 3/14/2018 * Description: Show the final results tables * @param parFormID String containing the CIN form's ID * @param tmpArr String array containing the RISK30DayMort Percentage, Lower Limit Confidence Interval Percentage, then the Upper Limit Confidence Interval Percentage */ function showResults_CIN (parFormID, tmpArr) { if (tmpArr != null && tmpArr.length==3) { var weightKG = parseFloat(getElemInput (parFormID, "weightLbsFld").value)*0.453592; var serumCreatin = parseFloat(getElemInput (parFormID, "serumCreatinFld").value); var MACD = getMACD2021 (weightKG, serumCreatin); MACD = MACD.toFixed(1); var str = "

VA Nephropathy

" + "
" + "
" + "This calculator provides risk estimates of acute kidney injury (AKI) associated with coronary procedures. The decision to perform a procedure, or any strategies to mitigate AKI including fluid hydration and contrast limitation, are at the discretion of the treating provider." + "
" + "
" + "Calculated MACD 2021: " +MACD + " ml" + "
using (2.5*weightKG)/serumCreatinine" + "" + "" + /* "" + */ "" + "" + "" + "" + /* "" + */ "" + "" + "" + "" + /* "" + */ "" + "" + "" + "" + /* "" + */ "" + "" + "" + "" + "" + "" + "" + "" + "
" + "MACD Multiplier" + "" + "Contrast Dose" + "" + "Risk of Nephropathy" + "
" + "MACDx1.0 - MACDx1.5" + "" + // "MACD 1.0 - 1.5:" + "" + (MACD *1.0).toFixed(1) + " - " + (MACD *1.5).toFixed(1) + " ml" + "" + "" + tmpArr[0][0].toFixed(1) + "% (95% CI: " + tmpArr [0][1].toFixed(1) + ", " + tmpArr [0][2].toFixed(1) + ")" + "
" + "MACDx1.5 - MACDx2.0" + "" + // "MACD 1.5 - 2.0:" + "" + (MACD *1.5).toFixed(1) + " - " + (MACD *2.0).toFixed(1) + " ml" + "" + "" + tmpArr[1][0].toFixed(1) + "% (95% CI: " + tmpArr [1][1].toFixed(1) + ", " + tmpArr [1][2].toFixed(1) + ")" + "
" + "MACDx2.0" + "" + // "MACD >= 2.0:" + ">= " + (MACD *2.0).toFixed(1) + " ml" + "" + "" + tmpArr[2][0].toFixed(1) + "% (95% CI: " + tmpArr [2][1].toFixed(1) + ", " + tmpArr [2][2].toFixed(1) + ")" + "
" + // "Based on a single model of all patients undergoing PCI, patients with similar characteristics would have a " + tmpArr[0].toFixed(1) + "% risk of mortality within 30 days after PCI." + "" + "
" + "

Overall risk (full population):

" + "
" + "

11.0%

" + "
" + "
" + "
" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + "" + ""; // PCI status if (getElemInput (parFormID, "statusMenu").value == "elective") { str += "" + "" + "" + ""; } else if (getElemInput (parFormID, "statusMenu").value == "emergent") { str += "" + "" + "" + ""; } else if (getElemInput (parFormID, "statusMenu").value == "salvage") { str += "" + "" + "" + ""; } else if (getElemInput (parFormID, "statusMenu").value == "urgent") { str += "" + "" + "" + ""; } else if (getElemInput (parFormID, "statusMenu").value == "noPriorPCI") { str += "" + "" + "" + ""; } // Indication if (getElemInput (parFormID, "indicaMenu").value == "Stable Angina") { str += "" + "" + "" + ""; } else if (getElemInput (parFormID, "indicaMenu").value == "Unstable Angina") { str += "" + "" + "" + ""; } else if (getElemInput (parFormID, "indicaMenu").value == "STEMI") { str += "" + "" + "" + ""; } else if (getElemInput (parFormID, "indicaMenu").value == "NSTEMI") { str += "" + "" + "" + ""; } else if (getElemInput (parFormID, "indicaMenu").value == "Chest Pain") { str += "" + "" + "" + ""; } else if (getElemInput (parFormID, "indicaMenu").value == "Other") { str += "" + "" + "" + ""; } if (getElemInput (parFormID, "TobaccoUse").checked == true) { str += "" + "" + "" + ""; } if (getElemInput (parFormID, "Diabetes").checked == true) { str += "" + "" + "" + ""; } if (getElemInput (parFormID, "PriorStroke").checked == true) { str += "" + "" + "" + ""; } if (getElemInput (parFormID, "PVD").checked == true) { str += "" + "" + "" + ""; } if (getElemInput (parFormID, "PriorMI").checked == true) { str += "" + "" + "" + ""; } if (getElemInput (parFormID, "PriorCABG").checked == true) { str += "" + "" + "" + ""; } if (getElemInput (parFormID, "CHF").checked == true) { str += "" + "" + "" + ""; } if (getElemInput (parFormID, "CKD").checked == true) { str += "" + "" + "" + ""; } if (getElemInput (parFormID, "HYP").checked == true) { str += "" + "" + "" + ""; } if (getElemInput (parFormID, "ejectFractLTE40").checked == true) { str += "" + "" + "" + ""; } if (getElemInput (parFormID, "ISANEMIC").checked == true) { str += "" + "" + "" + ""; } /* str += "" + "" + "" + "" +*/ str += "" + "" + "" + "" + "" + "" + "" + "" + "
" + "Metric" + "" + "Value" + "
" + "Age" + "" + getElemInput (parFormID, "ageFld").value + "
" + "Weight" + "" + getElemInput (parFormID, "weightLbsFld").value + " (pounds)" + "
" + "Elective PCI" + "" + "Yes" + "
" + "Emergent PCI" + "" + "Yes" + "
" + "Salvage" + "" + "Yes" + "
" + "Urgent" + "" + "Yes" + "
" + "No Prior PCI" + "" + "Yes" + "
" + "Stable Angina" + "" + "Yes" + "
" + "Unstable Angina" + "" + "Yes" + "
" + "STEMI" + "" + "Yes" + "
" + "NSTEMI" + "" + "Yes" + "
" + "Chest Pain" + "" + "Yes" + "
" + "Other Indication" + "" + "Yes" + "
" + "Tobacco Use" + "" + "Yes" + "
" + "Diabetes" + "" + "Yes" + "
" + "Prior Stroke (CVD)" + "" + "Yes" + "
" + "Peripheral Vascular" + "" + "Yes" + "
" + "Prior Myocardial" + "" + "Yes" + "
" + "Prior CABG" + "" + "Yes" + "
" + "CHF" + "" + "Yes" + "
" + "Cardiogenic Shock" + "" + "Yes" + "
" + "Hypertension" + "" + "Yes" + "
" + "Ejection Fraction" + "" + "Yes" + "
" + "Is Patient Anemic" + "" + "Yes" + "
" + "Hemoglobin" + "" + getElemInput (parFormID, "HgBFld").value + " (g/dl)" + "
" + "eGFR" + "" + (get_eGFR (parseFloat(getElemInput (parFormID, "serumCreatinFld").value), getElemInput (parFormID, "sexMenu").value, getElemInput (parFormID, "ageFld").value)).toFixed (2) + " (g/dl)" + "
" + "Serum Creatinine" + "" + getElemInput (parFormID, "serumCreatinFld").value + " (mg/dL)" + "
" + "
" + "
"; document.getElementById ("resultsArea_cinArea").innerHTML = str; } } /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ FOR TESTING +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /** * Test Function... * @author Stephan K Eisenbarth * @date 11/10/2022 * Description: Changes the values in the GUI so test can be performed with results displaying in webpage */ function setCINTest () { changeModel (modelTrgtArr ["bleeding_Area"]["modelBtn"]); // Test 1 /* getElemInput("cin_Area", "ageFld").value="70"; getElemInput("cin_Area", "weightLbsFld").value="185"; getElemInput("cin_Area", "sexMenu").value="female"; getElemInput("cin_Area", "statusMenu").value="elective"; getElemInput("cin_Area", "indicaMenu").value="NSTEMI"; getElemInput("cin_Area", "TobaccoUse").checked = true; getElemInput("cin_Area", "Diabetes").checked = true; getElemInput("cin_Area", "PriorCABG").checked = true; getElemInput("cin_Area", "ejectFractLTE40").checked = true; getElemInput("cin_Area", "PriorMI").checked = true; getElemInput("cin_Area", "CHF").checked = true; getElemInput("cin_Area", "ISANEMIC").checked = true; getElemInput("cin_Area", "PriorStroke").checked = true; getElemInput("cin_Area", "serumCreatinFld").value = "0.1"; */ // Test 2 getElemInput("cin_Area", "ageFld").value="73"; getElemInput("cin_Area", "weightLbsFld").value="185"; getElemInput("cin_Area", "sexMenu").value="female"; getElemInput("cin_Area", "statusMenu").value="urgent"; getElemInput("cin_Area", "indicaMenu").value="NSTEMI"; getElemInput("cin_Area", "Diabetes").checked = true; getElemInput("cin_Area", "PriorMI").checked = true; getElemInput("cin_Area", "CHF").checked = true; getElemInput("cin_Area", "serumCreatinFld").value = "1.6"; modelTrgtArr ["cin_Area"]["hasInputChange"] = true; } /** * Test Function... * @author Stephan K Eisenbarth * @date 11/10/2022 * Description: Runs a non-GUI based test on values (shows results in the console.log not in the webpage) */ function runTest () { console.log ("LT 60: " + get_eGFR (1, 'female', 81)); console.log ("LT 45: " + get_eGFR (1.7, 'female', 73)); console.log ("GT 60: " + get_eGFR (0.1, 'female', 70)); // var testValArr = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; //var testValArr = [1, 81, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0]; //var testValArr = [1, 70, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0]; var testValArr = [1, 73, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1]; dspArrWLabel (getCINVariableNamesArr(), testValArr); getCIN (testValArr); } function dspArrWLabel (lblArr, valArr) { if (lblArr != null && lblArr.length > 0 && lblArr [0] != null) { if (valArr != null && valArr.length > 0 && valArr [0] != null) { for (var i = 0; i < lblArr.length; i++) { console.log ("[" + i + "] " + lblArr[i] + " => " + valArr[i]); } console.log ("______________________________________"); } } }