public JsonResult GetSearchPatients(vwSearchPatients objView)
        {
            try {

                var objSearchPatients = (from p in objDBContext.vwSearch
                                         where p.PracticeID == objView.PracticeID
                                         select p).ToList();

                if (objView.FirstName != null && objView.FirstName != "")
                    objSearchPatients = objSearchPatients.Where(p => p.FirstName == objView.FirstName).ToList();
                if (objView.LastName != null && objView.LastName != "")
                    objSearchPatients = objSearchPatients.Where(p => p.LastName == objView.LastName).ToList();
                if (objView.PhoneNumber1 != null && objView.PhoneNumber1 != "")
                    objSearchPatients = objSearchPatients.Where(p => p.PhoneNumber1 == objView.PhoneNumber1).ToList();
                if (objView.ProviderID != 0 && objView.ProviderID != null)
                    objSearchPatients = objSearchPatients.Where(p => p.ProviderID == objView.ProviderID).ToList();
                if (objView.InsuranceName != null &&  objView.InsuranceName != "")
                    objSearchPatients = objSearchPatients.Where(p => p.InsuranceName == objView.InsuranceName).ToList();
                if (objView.Date_Of_Birth != null)
                     objSearchPatients = objSearchPatients.Where(p => p.Date_Of_Birth == objView.Date_Of_Birth).ToList();
                if (objView.FromDate != null)
                     objSearchPatients = objSearchPatients.Where(p => p.FromDate >= objView.FromDate).ToList();
                if (objView.ToDate != null)
                    objSearchPatients = objSearchPatients.Where(p => p.ToDate >= objView.FromDate).ToList();

                if (objSearchPatients != null)
                {
                    return Json(objSearchPatients, JsonRequestBehavior.AllowGet);
                }
                else
                {
                    return Json(new { result = "No Data found" }, JsonRequestBehavior.AllowGet);
                }

                //return Json(objView, JsonRequestBehavior.AllowGet);

            }
            catch(Exception ex)
            {
                return Json(new { result = ex.Message }, JsonRequestBehavior.AllowGet);
            }
        }
Ejemplo n.º 2
0
        public ActionResult SearchEncounters(vwSearchPatients objView)
        {
            try
             {
                 int PracticeID = Convert.ToInt32(Session["sespracticeid"]);
                 objView.PracticeID = PracticeID;
                 IEnumerable<vwSearchPatients> objSearchPatients = (from p in db.vwSearch

                                          where p.PracticeID == objView.PracticeID
                                          select p).ToList();

                 if (objView.FirstName != null && objView.FirstName != "")
                     objSearchPatients = objSearchPatients.Where(p => p.FirstName == objView.FirstName).ToList();
                 if (objView.LastName != null && objView.LastName != "")
                     objSearchPatients = objSearchPatients.Where(p => p.LastName == objView.LastName).ToList();
                 if (objView.PhoneNumber1 != null && objView.PhoneNumber1 != "")
                     objSearchPatients = objSearchPatients.Where(p => p.PhoneNumber1 == objView.PhoneNumber1).ToList();
                 if (objView.ProviderID != 0 && objView.ProviderID != null)
                     objSearchPatients = objSearchPatients.Where(p => p.ProviderID == objView.ProviderID).ToList();
                 if (objView.InsuranceName != null && objView.InsuranceName != "")
                     objSearchPatients = objSearchPatients.Where(p => p.InsuranceName == objView.InsuranceName).ToList();
                 if (objView.Date_Of_Birth != null)
                     objSearchPatients = objSearchPatients.Where(p => p.Date_Of_Birth == objView.Date_Of_Birth).ToList();
                 if (objView.FromDate != null)
                     objSearchPatients = objSearchPatients.Where(p => p.FromDate >= objView.FromDate).ToList();
                 if (objView.ToDate != null)
                     objSearchPatients = objSearchPatients.Where(p => p.ToDate >= objView.FromDate).ToList();

                 //if (objSearchPatients.Count()>0)
                 //{
                 //    //return Json(objSearchPatients, JsonRequestBehavior.AllowGet);
                 //}
                 //else
                 //{
                 //    return Json(new { result = "No Data found" }, JsonRequestBehavior.AllowGet);
                 //}

                 //return Json(objView, JsonRequestBehavior.AllowGet);
                 return PartialView("PartialViews/PatEncSearchGrid", objSearchPatients);
             }
             catch (Exception ex)
             {
                 return Json(new { result = ex.Message }, JsonRequestBehavior.AllowGet);
             }
        }