예제 #1
0
 public ActionResult Search(Search search)
 {
     return View(search);
 }
예제 #2
0
        public PartialViewResult SearchResult(Search search)
        {
            IEnumerable<Patient> patients= null;
            DateTime date;
            if(!string.IsNullOrEmpty(search.Keyword)){
                try{
                    switch(search.Type){
                        case "Name":
                            patients= db.Patients.Where(p=> p.Name.Contains(search.Keyword)).OrderByDescending(p=> p.Name);
                            break;
                        case "Admission Date":
                            date = Convert.ToDateTime(search.Keyword);
                            patients = from p in db.Patients
                                       where p.DateOfRegistration == date
                                       select p;
                            break;
                        case "Discharge Date":
                             date= Convert.ToDateTime(search.Keyword);

                            var visits = from v in db.Visits
                                         where v.DateOfDischarge == date
                                         select v;

                            patients = from p in visits
                                       select p.Patient;
                            break;
                        default:
                            int id= Convert.ToInt16(search.Keyword);
                            patients= db.Patients.Where(p=> p.Id== id);
                            break;
                    }

                }catch(Exception){
                    ModelState.AddModelError("", "Invalid input data");
                    patients= null;
                }
            }else
                ModelState.AddModelError("", "Keyword field is required");

            return PartialView("_PatientList", patients);
        }
예제 #3
0
        public PartialViewResult SearchResult(Search search)
        {
            IEnumerable<Visit> visits = null;
            if (!string.IsNullOrEmpty(search.Keyword))
            {
                try
                {
                    switch (search.Type)
                    {
                        case "Patient Name":
                            visits = db.Visits.Where(p => p.Patient.Name.Contains(search.Keyword)).OrderByDescending(p => p.Patient.Name);
                            break;
                        case "Date of Visit":
                            DateTime date = Convert.ToDateTime(search.Keyword);
                            visits = db.Visits.Where(v => v.DateOfVisit.Equals(date));
                            break;
                        case "Discharge Date":
                            date = Convert.ToDateTime(search.Keyword);
                            visits = db.Visits.Where(v => v.DateOfVisit.Equals(date));
                            break;
                        default:
                            int id = Convert.ToInt16(search.Keyword);
                            visits = db.Visits.Where(p => p.Id == id);
                            break;
                    }

                }
                catch (Exception)
                {
                    ModelState.AddModelError("", "Invalid input data");
                    visits = null;
                }
            }
            else
                ModelState.AddModelError("", "Keyword field is required");

            return PartialView("_List", visits);
        }