public void Determine_Problems(string OQ, UIElementCollection toggle)
		{
			PatientProblem patProb = new PatientProblem();
			FCS_DBModel db = new FCS_DBModel();
			string checkBoxContent = "";
			int probID = 0;
			var problemTable = db.Problems;
			foreach (var item in toggle)
			{
				if (((ToggleButton)item).IsChecked == true)
				{
					int patID = db.Patients.Where(x => x.PatientOQ == OQ).Select(x => x.PatientID).Distinct().First();
					checkBoxContent = ((((ContentControl)item).Content).ToString());
					switch (checkBoxContent)
					{
						case "Depression":
							probID = 1;
							break;
						case "Bereavement/Loss":
							probID = 2;
							break;
						case "Communication":
							probID = 3;
							break;
						case "Domestic Violence":
							probID = 4;
							break;
						case "Hopelessness":
							probID = 5;
							break;
						case "Work Problems":
							probID = 6;
							break;
						case "Parent Problems":
							probID = 7;
							break;
						case "Substance Abuse":
							probID = 8;
							break;
						case "Problems w/ School":
							probID = 9;
							break;
						case "Marriage/Relationship/Family":
							probID = 10;
							break;
						case "Thoughts of Hurting Self":
							probID = 11;
							break;
						case "Angry Feelings":
							probID = 12;
							break;
						case "Sexual Abuse":
							probID = 13;
							break;
						case "Emotional Abuse":
							probID = 14;
							break;
						case "Physical Abuse":
							probID = 15;
							break;
						case "Problems with the Law":
							probID = 16;
							break;
						case "Unhappy with Life":
							probID = 17;
							break;
						case "Anxiety":
							probID = 18;
							break;
						case "Other":
							probID = 19;
							break;
					}
					patProb.PatientID = patID;
					patProb.ProblemID = probID;
					db.PatientProblems.Add(patProb);
					db.SaveChanges();
				}
			}
		}
        private void DetermineProblems()
        {
            var toggle = PatientProblemsCheckBoxes.Children;
            List<string> currentProblems = new List<string>();

            FCS_DBModel db = new FCS_DBModel();
            PatientProblem patProb = new PatientProblem();
            int patID = db.Patients.Where(x => x.PatientOQ == patientOQ).Select(x => x.PatientID).Distinct().First();
            foreach (var item in db.PatientProblems.Where(x => x.PatientID == patID).Select(x => x.ProblemID))
            {
                switch (item)
                {
                    case 1:
                        currentProblems.Add("Depression");
                        break;
                    case 2:
                        currentProblems.Add("Bereavement/Loss");
                        break;
                    case 3:
                        currentProblems.Add("Communication");
                        break;
                    case 4:
                        currentProblems.Add("Domestic Violence");
                        break;
                    case 5:
                        currentProblems.Add("Hopelessness");
                        break;
                    case 6:
                        currentProblems.Add("Work Problems");
                        break;
                    case 7:
                        currentProblems.Add("Parent Problems");
                        break;
                    case 8:
                        currentProblems.Add("Substance Abuse");
                        break;
                    case 9:
                        currentProblems.Add("Problems w/ School");
                        break;
                    case 10:
                        currentProblems.Add("Marriage/Relationship/Family");
                        break;
                    case 11:
                        currentProblems.Add("Thoughts of Hurting Self");
                        break;
                    case 12:
                        currentProblems.Add("Angry Feelings");
                        break;
                    case 13:
                        currentProblems.Add("Sexual Abuse");
                        break;
                    case 14:
                        currentProblems.Add("Emotional Abuse");
                        break;
                    case 15:
                        currentProblems.Add("Physical Abuse");
                        break;
                    case 16:
                        currentProblems.Add("Problems with the Law");
                        break;
                    case 17:
                        currentProblems.Add("Unhappy with Life");
                        break;
                    case 18:
                        currentProblems.Add("Anxiety");
                        break;
                    case 19:
                        currentProblems.Add("Other");
                        break;
                }
            }
            foreach (var item in toggle)
            {
                foreach (var curProb in currentProblems)
                {
                    if ((((ContentControl)item).Content).ToString() == curProb)
                    {
                        ((ToggleButton)item).IsChecked = true;
                    }
                }
            }
            GC.Collect();
        }
        private void UpdateProblems()
        {
            
            FCS_DBModel db = new FCS_DBModel();
            int patID = db.Patients.Where(x => x.PatientOQ == pOQ).Select(x => x.PatientID).Distinct().First();
            var toggle = PatientProblemsCheckBoxes.Children;
            var patProblems = (from p in db.PatientProblems where p.PatientID == patID select p);
            //CreateNewPatient cnp = new CreateNewPatient();
            PatientProblem patProb = new PatientProblem();
            string checkBoxContent = "";
            int probID = 0;
            var problemTable = db.Problems;
            foreach (var item in toggle)
            {
                checkBoxContent = ((((ContentControl)item).Content).ToString());
                //var distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID select p);
                if (((ToggleButton)item).IsChecked == true)
                {

                    switch (checkBoxContent)
                    {
                        case "Depression":
                            probID = 1;
                            break;
                        case "Bereavement/Loss":
                            probID = 2;
                            break;
                        case "Communication":
                            probID = 3;
                            break;
                        case "Domestic Violence":
                            probID = 4;
                            break;
                        case "Hopelessness":
                            probID = 5;
                            break;
                        case "Work Problems":
                            probID = 6;
                            break;
                        case "Parent Problems":
                            probID = 7;
                            break;
                        case "Substance Abuse":
                            probID = 8;
                            break;
                        case "Problems w/ School":
                            probID = 9;
                            break;
                        case "Marriage/Relationship/Family":
                            probID = 10;
                            break;
                        case "Thoughts of Hurting Self":
                            probID = 11;
                            break;
                        case "Angry Feelings":
                            probID = 12;
                            break;
                        case "Sexual Abuse":
                            probID = 13;
                            break;
                        case "Emotional Abuse":
                            probID = 14;
                            break;
                        case "Physical Abuse":
                            probID = 15;
                            break;
                        case "Problems with the Law":
                            probID = 16;
                            break;
                        case "Unhappy with Life":
                            probID = 17;
                            break;
                        case "Anxiety":
                            probID = 18;
                            break;
                        case "Other":
                            probID = 19;
                            break;
                    }

                    patProb.PatientID = patID;
                    patProb.ProblemID = probID;
                    db.PatientProblems.Add(patProb);
                    db.SaveChanges();
                    patProb = new PatientProblem();
                }
                else
                {
                    var distinctPatProblems = new List<PatientProblem>().AsQueryable();
                    switch (checkBoxContent)
                    {
                        case "Depression":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 1 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {
                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Bereavement/Loss":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 2 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Communication":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 3 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Domestic Violence":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 4 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Hopelessness":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 5 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Work Problems":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 6 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Parent Problems":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 7 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Substance Abuse":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 8 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Problems w/ School":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 9 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Marriage/Relationship/Family":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 10 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Thoughts of Hurting Self":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 11 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Angry Feelings":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 12 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Sexual Abuse":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 13 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Emotional Abuse":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 14 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Physical Abuse":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 15 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Problems with the Law":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 16 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Unhappy with Life":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 17 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Anxiety":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 18 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {

                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                        case "Other":
                            try
                            {
                                distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patID && p.ProblemID == 19 select p);
                                foreach (var thing in distinctPatProblems)
                                {
                                    db.PatientProblems.Remove(thing);
                                }
                                db.SaveChanges();
                            }
                            catch
                            {
                            }
                            distinctPatProblems = new List<PatientProblem>().AsQueryable();
                            break;
                    }
                }
            }
            GC.Collect();
        }
		private void ShowProblems()
		{
			var toggle = PatientProblemsCheckBoxes.Children;
			List<int> currentProblems = new List<int>();

			FCS_DBModel db = new FCS_DBModel();
			PatientProblem patProb = new PatientProblem();
			int patID = db.Patients.Where(x => x.PatientOQ == patientOQ).Select(x => x.PatientID).Distinct().First();
			foreach (var item in db.PatientProblems.Where(x => x.PatientID == patID).Select(x => x.ProblemID))
			{
				currentProblems.Add(item);
			}

			foreach (var item in toggle)
			{
				foreach (var curProb in currentProblems)
				{
					if (curProb == GetProblemID(((ContentControl)item).Content.ToString()))
					{
						((ToggleButton)item).IsChecked = true;
					}
				}
			}
		}
		private void UpdateProblems()
		{
			FCS_DBModel db = new FCS_DBModel();

			var toggle = PatientProblemsCheckBoxes.Children;
			var problemTable = db.Problems;

			foreach (var item in toggle)
			{
				string checkboxProblemName = (((ContentControl)item).Content).ToString();
				if (((ToggleButton)item).IsChecked == true)
				{
					PatientProblem patProb = new PatientProblem();
					patProb.PatientID = patientID;
					patProb.ProblemID = GetProblemID(checkboxProblemName);
					db.PatientProblems.Add(patProb);
					db.SaveChanges();
				}
				else
				{
					var distinctPatProblems = new List<PatientProblem>().AsQueryable();
					try
					{
						distinctPatProblems = (from p in db.PatientProblems where p.PatientID == patientID && p.ProblemID == GetProblemID(checkboxProblemName) select p);
						foreach (var thing in distinctPatProblems)
						{
							db.PatientProblems.Remove(thing);
						}
					}
					catch { }

					db.SaveChanges();
				}
			}
			GC.Collect();
		}
		public void Determine_Problems(string OQ)
		{
			FCS_DBModel db = new FCS_DBModel();
			var toggle = PatientProblemsCheckBoxes.Children;
			var problemTable = db.Problems;

			foreach (var item in toggle)
			{
				string checkboxProblemName = (((ContentControl)item).Content).ToString();
				if (((ToggleButton)item).IsChecked == true)
				{
					try
					{
						PatientProblem patProb = new PatientProblem();
						int patID = db.Patients.Where(x => x.PatientOQ == OQ).Select(x => x.PatientID).Distinct().First();
						patProb.PatientID = patID;
						patProb.ProblemID = GetProblemID(checkboxProblemName);
						db.PatientProblems.Add(patProb);
						db.SaveChanges();

						//var problem = 
					}
					catch (Exception error) { }
				}
			}
		}