public void calculateZScores() { double L = 0, M = 0, S = 0, WeightAgeZ = 0, WeightHeightZ = 0, HAz = 0, BMIz = 0, weight = 0, heightInCm = 0, bmi = 0; DataSet ZScoreDS = new DataSet(); ZScoreDS = KNHStatic.GetZScoreValues(Convert.ToInt32(Session["PatientId"]), Convert.ToString(Session["PatientSex"]), txtHeight.Text); //////weight for Age////////// if (Convert.ToDouble(Session["patientageinyearmonth"].ToString()) < 15) { if (ZScoreDS.Tables[0].Rows.Count > 0) { L = Convert.ToDouble(ZScoreDS.Tables[0].Rows[0]["L"].ToString()); M = Convert.ToDouble(ZScoreDS.Tables[0].Rows[0]["M"].ToString()); S = Convert.ToDouble(ZScoreDS.Tables[0].Rows[0]["S"].ToString()); if (txtWeight.Text != "") { weight = Convert.ToDouble(txtWeight.Text); } else { weight = 0; } //Weight for age calculation if (L != 0) { WeightAgeZ = ((Math.Pow((weight / M), L)) - 1) / (S * L); } else { WeightAgeZ = (Math.Log(weight / M)) / S; } if (WeightAgeZ >= 4) { lblWA.Text = "4"; lblWAClassification.Text = " Overweight"; lblWA.ForeColor = Color.Red; lblWAClassification.ForeColor = Color.Red; } else if (WeightAgeZ >= 3 && WeightAgeZ < 4) { lblWA.Text = "3"; lblWAClassification.Text = " Overweight"; lblWA.ForeColor = Color.Red; lblWAClassification.ForeColor = Color.Red; } else if (WeightAgeZ >= 2 && WeightAgeZ < 3) { lblWA.Text = "2"; lblWAClassification.Text = " Overweight"; lblWA.ForeColor = Color.Red; lblWAClassification.ForeColor = Color.Red; } else if (WeightAgeZ >= 1 && WeightAgeZ < 2) { lblWA.Text = "1"; lblWAClassification.Text = " Overweight"; lblWA.ForeColor = Color.Red; lblWAClassification.ForeColor = Color.Red; } else if (WeightAgeZ > -1 && WeightAgeZ < 1) { lblWA.Text = "0"; lblWAClassification.Text = " Normal"; lblWA.ForeColor = Color.Green; lblWAClassification.ForeColor = Color.Green; } else if (WeightAgeZ <= -1 && WeightAgeZ > -2) { lblWA.Text = "-1"; lblWAClassification.Text = " Mild"; lblWA.ForeColor = Color.Orange; lblWAClassification.ForeColor = Color.Orange; } else if (WeightAgeZ <= -2 && WeightAgeZ > -3) { lblWA.Text = "-2"; lblWAClassification.Text = " Moderate"; lblWA.ForeColor = Color.Red; lblWAClassification.ForeColor = Color.Red; } else if (WeightAgeZ <= -3 && WeightAgeZ > -4) { lblWA.Text = "-3"; lblWAClassification.Text = " Severe"; lblWA.ForeColor = Color.Red; lblWAClassification.ForeColor = Color.Red; } else if (WeightAgeZ <= -4) { lblWA.Text = "-4"; lblWAClassification.Text = " Severe"; lblWA.ForeColor = Color.Red; lblWAClassification.ForeColor = Color.Red; } } else { lblWAClassification.Text = "Out of range"; } } else { lblWA.Text = ""; lblWAClassification.Text = ""; } ///////////////////////////////// ///////Weight for height calculation////////////////////////////// if (Convert.ToDouble(Session["patientageinyearmonth"].ToString()) < 15) { if (Convert.ToDouble(txtHeight.Text) <= 120 && Convert.ToDouble(txtHeight.Text) >= 45) { try { if (ZScoreDS.Tables[1].Rows.Count > 0) { L = Convert.ToDouble(ZScoreDS.Tables[1].Rows[0]["L"].ToString()); M = Convert.ToDouble(ZScoreDS.Tables[1].Rows[0]["M"].ToString()); S = Convert.ToDouble(ZScoreDS.Tables[1].Rows[0]["S"].ToString()); if (txtWeight.Text != "") { weight = Convert.ToDouble(txtWeight.Text); } else { weight = 0; } if (L != 0) { WeightHeightZ = ((Math.Pow((weight / M), L)) - 1) / (S * L); } else { WeightHeightZ = (Math.Log(weight / M)) / S; } //lblWH.Text = string.Format("{0:f2}", WeightHeightZ);// WeightHeightZ.ToString("##.##"); } else { lblWH.Text = "Out of range"; } if (WeightHeightZ >= 4) { lblWH.Text = "4"; lblWHClassification.Text = " Overweight"; lblWH.ForeColor = Color.Red; lblWHClassification.ForeColor = Color.Red; } else if (WeightHeightZ >= 3 && WeightHeightZ < 4) { lblWH.Text = "3"; lblWHClassification.Text = " Overweight"; lblWH.ForeColor = Color.Red; lblWHClassification.ForeColor = Color.Red; } else if (WeightHeightZ >= 2 && WeightHeightZ < 3) { lblWH.Text = "2"; lblWHClassification.Text = " Overweight"; lblWH.ForeColor = Color.Red; lblWHClassification.ForeColor = Color.Red; } else if (WeightHeightZ >= 1 && WeightHeightZ < 2) { lblWH.Text = "1"; lblWHClassification.Text = " Overweight"; lblWH.ForeColor = Color.Red; lblWHClassification.ForeColor = Color.Red; } else if (WeightHeightZ > -1 && WeightHeightZ < 1) { lblWH.Text = "0"; lblWHClassification.Text = " Normal"; lblWH.ForeColor = Color.Green; lblWHClassification.ForeColor = Color.Green; } else if (WeightHeightZ <= -1 && WeightHeightZ > -2) { lblWH.Text = "-1"; lblWHClassification.Text = " Mild"; lblWH.ForeColor = Color.Orange; lblWHClassification.ForeColor = Color.Orange; } else if (WeightHeightZ <= -2 && WeightHeightZ > -3) { lblWH.Text = "-2"; lblWHClassification.Text = " Moderate"; lblWH.ForeColor = Color.Red; lblWHClassification.ForeColor = Color.Red; } else if (WeightHeightZ <= -3 && WeightHeightZ > -4) { lblWH.Text = "-3"; lblWHClassification.Text = " Severe"; lblWH.ForeColor = Color.Red; lblWHClassification.ForeColor = Color.Red; } else if (WeightHeightZ <= -4) { lblWH.Text = "-4"; lblWHClassification.Text = " Severe"; lblWH.ForeColor = Color.Red; lblWHClassification.ForeColor = Color.Red; } } catch (Exception ex) { } } else { lblWH.Text = ""; lblWHClassification.Text = ""; } } else { lblWH.Text = ""; lblWHClassification.Text = ""; } ////////////////////////////////////////////////////////////////////// ////BMIz (Z-Score Calculation)//////////////////////////// if (Convert.ToDouble(Session["patientageinyearmonth"].ToString()) <= 15) { if (ZScoreDS.Tables[2].Rows.Count > 0) { L = Convert.ToDouble(ZScoreDS.Tables[2].Rows[0]["L"].ToString()); M = Convert.ToDouble(ZScoreDS.Tables[2].Rows[0]["M"].ToString()); S = Convert.ToDouble(ZScoreDS.Tables[2].Rows[0]["S"].ToString()); if (txtHeight.Text != "" && txtWeight.Text != "") { bmi = Convert.ToDouble(txtWeight.Text) / ((Convert.ToDouble(txtHeight.Text) / 100) * (Convert.ToDouble(txtHeight.Text) / 100)); } else { bmi = 0; } if (L != 0) { BMIz = ((Math.Pow((bmi / M), L)) - 1) / (S * L); } else { BMIz = (Math.Log(bmi / M)) / S; } lblBMIz.Text = string.Format("{0:f2}", BMIz); if (BMIz >= 4) { lblBMIz.Text = "4"; lblBMIzClassification.Text = " Overweight"; lblBMIz.ForeColor = Color.Red; lblBMIzClassification.ForeColor = Color.Red; } else if (BMIz >= 3 && BMIz < 4) { lblBMIz.Text = "3"; lblBMIzClassification.Text = " Overweight"; lblBMIz.ForeColor = Color.Red; lblBMIzClassification.ForeColor = Color.Red; } else if (BMIz >= 2 && BMIz < 3) { lblBMIz.Text = "2"; lblBMIzClassification.Text = " Overweight"; lblBMIz.ForeColor = Color.Red; lblBMIzClassification.ForeColor = Color.Red; } else if (BMIz >= 1 && BMIz < 2) { lblBMIz.Text = "1"; lblBMIzClassification.Text = " Overweight"; lblBMIz.ForeColor = Color.Red; lblBMIzClassification.ForeColor = Color.Red; } else if (BMIz > -1 && BMIz < 1) { lblBMIz.Text = "0"; lblBMIzClassification.Text = " Normal"; lblBMIz.ForeColor = Color.Green; lblBMIzClassification.ForeColor = Color.Green; } else if (BMIz <= -1 && BMIz > -2) { lblBMIz.Text = "-1"; lblBMIzClassification.Text = " Mild"; lblBMIz.ForeColor = Color.Orange; lblBMIzClassification.ForeColor = Color.Orange; } else if (BMIz <= -2 && BMIz > -3) { lblBMIz.Text = "-2"; lblBMIzClassification.Text = " Moderate"; lblBMIz.ForeColor = Color.Red; lblBMIzClassification.ForeColor = Color.Red; } else if (BMIz <= -3 && BMIz > -4) { lblBMIz.Text = "-3"; lblBMIzClassification.Text = " Severe"; lblBMIz.ForeColor = Color.Red; lblBMIzClassification.ForeColor = Color.Red; } else if (BMIz <= -4) { lblBMIz.Text = "-4"; lblBMIzClassification.Text = " Severe"; lblBMIz.ForeColor = Color.Red; lblBMIzClassification.ForeColor = Color.Red; } } else { lblBMIz.Text = ""; lblBMIzClassification.Text = ""; } } else { lblBMIz.Text = ""; lblBMIzClassification.Text = ""; } ///////////////////////////////////////////////////////// ///////Height for age calculation///////////////////////////// //if (L != 0) // HAz = ((Math.Pow((heightInCm / M), L)) - 1) / (S * L); //else // HAz = (Math.Log(heightInCm / M)) / S; ///////////////////////////////////////////////////////////// ZScoreDS.Dispose(); }
private string GetZScoreDetails(int ptn_pk, int visitPK, int locationId) { string result = string.Empty; try { IClinicalEncounter clinicalencounter = (IClinicalEncounter)ObjectFactory.CreateInstance("HIVCE.BusinessLayer.BLClinicalEncounter, HIVCE.BusinessLayer"); HIVCE.Common.Entities.ClinicalEncounter cl = clinicalencounter.GetData(ptn_pk, visitPK, locationId); DataSet ZScoreDS = new DataSet(); IKNHStaticForms KNHS = (IKNHStaticForms)ObjectFactory.CreateInstance("BusinessProcess.Clinical.BKNHStaticForms, BusinessProcess.Clinical"); ZScoreDS = KNHS.GetZScoreValues(ptn_pk, Session["PatientSex"].ToString(), cl.PatientVitals.Height); ZScoreDetails zs = new ZScoreDetails(); zs.WFA = new ZScore(); zs.WFH = new ZScore(); zs.BMIz = new ZScore(); if (ZScoreDS.Tables[0].Rows.Count > 0) { DataColumnCollection columns = ZScoreDS.Tables[0].Columns; if (columns.Contains("L")) { zs.WFA.L = Convert.ToDouble(ZScoreDS.Tables[0].Rows[0]["L"].ToString()); zs.WFA.M = Convert.ToDouble(ZScoreDS.Tables[0].Rows[0]["M"].ToString()); zs.WFA.S = Convert.ToDouble(ZScoreDS.Tables[0].Rows[0]["S"].ToString()); } } if (ZScoreDS.Tables[1].Rows.Count > 0) { DataColumnCollection columns = ZScoreDS.Tables[1].Columns; if (columns.Contains("L")) { zs.WFH.L = Convert.ToDouble(ZScoreDS.Tables[1].Rows[0]["L"].ToString()); zs.WFH.M = Convert.ToDouble(ZScoreDS.Tables[1].Rows[0]["M"].ToString()); zs.WFH.S = Convert.ToDouble(ZScoreDS.Tables[1].Rows[0]["S"].ToString()); } } if (ZScoreDS.Tables[2].Rows.Count > 0) { DataColumnCollection columns = ZScoreDS.Tables[2].Columns; if (columns.Contains("L")) { zs.BMIz.L = Convert.ToDouble(ZScoreDS.Tables[2].Rows[0]["L"].ToString()); zs.BMIz.M = Convert.ToDouble(ZScoreDS.Tables[2].Rows[0]["M"].ToString()); zs.BMIz.S = Convert.ToDouble(ZScoreDS.Tables[2].Rows[0]["S"].ToString()); } } ZScoreDS.Dispose(); result = SerializerUtil.ConverToJson <HIVCE.Common.Entities.ZScoreDetails>(zs); } catch (Exception ex) { CLogger.WriteLog(ELogLevel.ERROR, "GetZScoreDetails() exception: " + ex.ToString()); ResponseType response = new ResponseType() { Success = EnumUtil.GetEnumDescription(Success.False) }; result = SerializerUtil.ConverToJson <ResponseType>(response); } finally { } return(result); }