public ZScoresParameters GetZScoreValues(string PatientID, string gender, string height) { lock (this) { ClsObject PatientEncounter = new ClsObject(); ClsUtility.Init_Hashtable(); ClsUtility.AddParameters("@PatientID", SqlDbType.Int, PatientID); ClsUtility.AddParameters("@sex", SqlDbType.VarChar, gender); ClsUtility.AddParameters("@height", SqlDbType.VarChar, height); DataSet ZScoreDS = (DataSet)PatientEncounter.ReturnObject(ClsUtility.theParams, "sp_getZScores", ClsUtility.ObjectEnum.DataSet); ZScoresParameters zs = new ZScoresParameters(); if (ZScoreDS.Tables[0].Rows.Count > 0) { DataRow column = ZScoreDS.Tables[0].Rows[0]; if (column.Table.Columns.Contains("L")) { zs.L_WA = Convert.ToDouble(ZScoreDS.Tables[0].Rows[0]["L"].ToString()); } if (column.Table.Columns.Contains("M")) { zs.M_WA = Convert.ToDouble(ZScoreDS.Tables[0].Rows[0]["M"].ToString()); } if (column.Table.Columns.Contains("S")) { zs.S_WA = Convert.ToDouble(ZScoreDS.Tables[0].Rows[0]["S"].ToString()); } } if (ZScoreDS.Tables[1].Rows.Count > 0) { DataRow column = ZScoreDS.Tables[1].Rows[0]; if (column.Table.Columns.Contains("L")) { zs.L_WH = Convert.ToDouble(ZScoreDS.Tables[1].Rows[0]["L"].ToString()); } if (column.Table.Columns.Contains("M")) { zs.M_WH = Convert.ToDouble(ZScoreDS.Tables[1].Rows[0]["M"].ToString()); } if (column.Table.Columns.Contains("S")) { zs.S_WH = Convert.ToDouble(ZScoreDS.Tables[1].Rows[0]["S"].ToString()); } } if (ZScoreDS.Tables[2].Rows.Count > 0) { DataRow column = ZScoreDS.Tables[2].Rows[0]; if (column.Table.Columns.Contains("L")) { zs.L_BMIz = Convert.ToDouble(ZScoreDS.Tables[2].Rows[0]["L"].ToString()); } if (column.Table.Columns.Contains("M")) { zs.M_BMIz = Convert.ToDouble(ZScoreDS.Tables[2].Rows[0]["M"].ToString()); } if (column.Table.Columns.Contains("S")) { zs.S_BMIz = Convert.ToDouble(ZScoreDS.Tables[2].Rows[0]["S"].ToString()); } } return(zs); } }
public ZScores getZScores(string patientId, double age, string gender, double height, double weight) { IPatientEncounter patientEncounter = (IPatientEncounter)ObjectFactory.CreateInstance("BusinessProcess.CCC.BPatientEncounter, BusinessProcess.CCC"); ZScoresParameters zsParam = new ZScoresParameters(); ZScores zsValues = new ZScores(); if (age < 15) { double bmi = 0; zsParam = patientEncounter.GetZScoreValues(patientId, gender, height.ToString()); //////weight for Age////////// if (zsParam != null) { //Weight for age calculation if (zsParam.L_WA != 0 && weight != 0) { zsValues.weightForAge = ((Math.Pow((weight / zsParam.M_WA), zsParam.L_WA)) - 1) / (zsParam.S_WA * zsParam.L_WA); } else { zsValues.weightForAge = (Math.Log(weight / zsParam.M_WA)) / zsParam.S_WA; } } else { //lblWAClassification.Text = "Out of range"; } ///////Weight for height calculation////////////////////////////// if (height <= 120 && height >= 45) { try { if (zsParam != null) { if (zsParam.L_WH != 0 && weight != 0) { zsValues.weightForHeight = ((Math.Pow((weight / zsParam.M_WH), zsParam.L_WH)) - 1) / (zsParam.S_WH * zsParam.L_WH); } else { zsValues.weightForHeight = (Math.Log(weight / zsParam.M_WH)) / zsParam.S_WH; } } } catch (Exception) { } } ////BMIz (Z-Score Calculation)//////////////////////////// if (zsParam != null) { if (height != 0 && weight != 0) { bmi = weight / ((height / 100) * (height / 100)); } else { bmi = 0; } if (zsParam.L_BMIz != 0) { zsValues.BMIz = ((Math.Pow((bmi / zsParam.M_BMIz), zsParam.L_BMIz)) - 1) / (zsParam.S_BMIz * zsParam.L_BMIz); } else { zsValues.BMIz = (Math.Log(bmi / zsParam.M_BMIz)) / zsParam.S_BMIz; } //lblBMIz.Text = string.Format("{0:f2}", BMIz); } } return(zsValues); ///////////////////////////////////////////////////////// ///////Height for age calculation///////////////////////////// //if (L != 0) // HAz = ((Math.Pow((heightInCm / M), L)) - 1) / (S * L); //else // HAz = (Math.Log(heightInCm / M)) / S; ///////////////////////////////////////////////////////////// }