public ActionResult Edit_history(int id, Addhistoryviewmodel collection)
        {
            try
            {
                // TODO: Add update logic here
                hospital_managementEntities db = new hospital_managementEntities();
                Patient_History             p  = db.Patient_History.Find(id);
                if (p == null)
                {
                    return(HttpNotFound());
                }
                else
                {
                    p.Age         = collection.Age;
                    p.BP          = collection.BP;
                    p.Gender      = collection.Gender;
                    p.indications = collection.indications;
                    p.patient_id  = collection.PatientId;
                    p.Pulse       = collection.Pulse;
                    p.Weight      = collection.Weight;

                    db.SaveChanges();
                }

                return(RedirectToAction("checkdetails"));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
        public ActionResult Edit_history(int id)
        {
            hospital_managementEntities db = new hospital_managementEntities();
            Patient_History             p  = db.Patient_History.Find(id);

            if (p == null)
            {
                return(HttpNotFound());
            }
            else
            {
                Addhistoryviewmodel model = new Addhistoryviewmodel();
                model.Age         = p.Age;
                model.BP          = p.BP;
                model.Gender      = p.Gender;
                model.id          = p.id;
                model.indications = p.indications;
                model.PatientId   = p.patient_id;
                model.Pulse       = p.Pulse;
                model.Weight      = p.Weight;

                ViewBag.collection = model;
                return(View(model));
            }
        }
        public ActionResult AddHistory(Addhistoryviewmodel model)
        {
            hospital_managementEntities db = new hospital_managementEntities();

            Register_patient S = db.Register_patient.Find(model.PatientId);

            if (S == null)
            {
                return(HttpNotFound());
            }
            else
            {
                Patient_History h = new Patient_History();
                h.Gender      = model.Gender;
                h.Age         = model.Age;
                h.Weight      = model.Weight;
                h.BP          = model.BP;
                h.Pulse       = model.Pulse;
                h.patient_id  = model.PatientId;
                h.indications = model.indications;
                db.Patient_History.Add(h);
                db.SaveChanges();

                return(RedirectToAction("checkdetails"));
            }
            return(View());
        }
        public ActionResult checkdetailslist(int id)
        {
            int r = 0;
            int k = 0;
            list_pat_details            list = new list_pat_details();
            hospital_managementEntities db   = new hospital_managementEntities();

            foreach (Patient_Prescription p in db.Patient_Prescription)
            {
                if (p.Registerid == id)
                {
                    r = 1;
                }
            }
            foreach (Patient_History p in db.Patient_History)
            {
                if (p.patient_id == id)
                {
                    k = 1;
                }
            }



            if (r == 0 && k == 0)
            {
                return(HttpNotFound());
            }
            else
            {
                Addprescriptionviewmodel S = new Addprescriptionviewmodel();
                Addhistoryviewmodel      Q = new Addhistoryviewmodel();



                foreach (Patient_Prescription p in db.Patient_Prescription)
                {
                    if (p.Registerid == id)
                    {
                        S.Duration  = p.Duration;
                        S.Evening   = p.Evening;
                        S.Medicine  = p.Medicine;
                        S.Morning   = p.Morning;
                        S.Noon      = p.Noon;
                        S.id        = p.SR;
                        S.PatientId = p.Registerid;
                    }
                }
                foreach (Patient_History p in db.Patient_History)
                {
                    if (p.patient_id == id)
                    {
                        Q.Age         = p.Age;
                        Q.BP          = p.BP;
                        Q.Gender      = p.Gender;
                        Q.indications = p.indications;
                        Q.PatientId   = p.patient_id;
                        Q.Pulse       = p.Pulse;
                        Q.id          = p.id;
                        Q.Weight      = p.Weight;
                    }
                }

                list.list_history.Add(Q);
                list.list_prescription.Add(S);
            }

            return(View(list));

            /*else
             * {
             *
             *  Addprescriptionviewmodel S = new Addprescriptionviewmodel();
             *  Addhistoryviewmodel Q = new Addhistoryviewmodel();
             *
             *
             *  S.PatientId = mod.PatientId;
             *  S.Medicine = R.Medicine;
             *  S.Duration = R.Duration;
             *  S.Morning = R.Noon;
             *  S.Evening = R.Evening;
             *  S.Morning = R.Morning;
             *  Q.Gender = K.Gender;
             *  Q.Age = K.Age;
             *  Q.BP = K.BP;
             *  Q.Weight = K.Weight;
             *  Q.Pulse = K.Pulse;
             *  Q.indications = K.indications;
             *  Q.PatientId = mod.PatientId;
             *  list.list_history.Add(Q);
             *
             *  list.list_prescription.Add(S);
             *
             * }*/
        }