public People getPersonHealth(short keyfield) { People p = new People(); using (SqlConnection conn = new SqlConnection(DBConnect.GetSchoolConnStr())) { using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "uspGetPersonHealth"; cmd.Parameters.Add("@keyfield", SqlDbType.SmallInt).Value = keyfield; conn.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { Allergies a = new Allergies(); a.Keyfield = DbUtilities.GetShort(rdr, "KeyField"); a.allergyDescription = rdr["Description"].ToString(); p.Allergies.Add(a); } rdr.NextResult(); if (rdr.HasRows) { while (rdr.Read()) { Insurances i = new Insurances(); i.keyfield = DbUtilities.GetShort(rdr, "keyfield"); i.InsuranceCo = rdr["InsuranceCo"].ToString(); i.PolicyNum = rdr["PolicyNum"].ToString(); i.SubscriberName = rdr["SubscriberName"].ToString(); i.SubscriberNum = rdr["SubscriberNum"].ToString(); i.SubscriberEmployer = rdr["SubscriberEmployer"].ToString(); i.SubscriberJob = rdr["SubscriberJob"].ToString(); i.SubscriberWorkPhone = rdr["SubscriberWorkPhone"].ToString(); p.Insurances.Add(i); } } rdr.NextResult(); if (rdr.HasRows) { while (rdr.Read()) { MedHist mh = new MedHist(); mh.keyfield = DbUtilities.GetShort(rdr, "KeyField"); mh.HealthCondition = DbUtilities.GetByte(rdr, "HealthCondition"); mh.ConditionExplanation = rdr["ConditionExplanation"].ToString(); mh.HealthTreatment = rdr["HealthTreatment"].ToString(); mh.HasAsthma = DbUtilities.GetBool(rdr, "HasAsthma"); mh.HasSinusitis = DbUtilities.GetBool(rdr, "HasSinusitis"); mh.HasBronchitis = DbUtilities.GetBool(rdr, "HasBronchitis"); mh.HasKidneyTrouble = DbUtilities.GetBool(rdr, "HasKidneyTrouble"); mh.HasHeartTrouble = DbUtilities.GetBool(rdr, "HasHeartTrouble"); mh.HasDiabetes = DbUtilities.GetBool(rdr, "HasDiabetes"); mh.HasDizziness = DbUtilities.GetBool(rdr, "HasDizziness"); mh.HasStomachUpset = DbUtilities.GetBool(rdr, "HasStomachUpset"); mh.HasHayFever = DbUtilities.GetBool(rdr, "HasHayFever"); mh.Explanation = rdr["Explanation"].ToString(); mh.PastOperationsOrIllnesses = rdr["PastOperationsOrIllnesses"].ToString(); mh.CurrentMeds = rdr["CurrentMeds"].ToString(); mh.SpecialDietOrNeeds = rdr["SpecialDietOrNeeds"].ToString(); mh.HadChickenPox = DbUtilities.GetBool(rdr, "HadChickenPox"); mh.HadMeasles = DbUtilities.GetBool(rdr, "HadMeasles"); mh.HadMumps = DbUtilities.GetBool(rdr, "HadMumps"); mh.HadWhoopingCough = DbUtilities.GetBool(rdr, "HadWhoopingCough"); mh.OtherChildhoodDiseases = rdr["OtherChildhoodDiseases"].ToString(); mh.DateOfTetanusShot = DbUtilities.GetDateTime(rdr, "DateOfTetanusShot"); mh.FamilyDoctor = rdr["FamilyDoctor"].ToString(); mh.FamilyDoctorPhone = rdr["FamilyDoctorPhone"].ToString(); p.MedHist.Add(mh); } } } return(p); } }