public ActionResult ManagePatientList()
        {
            List <Patient> lstPatients = new List <Patient>();

            DataService.Patientportal.PatientPortalService cls = new DataService.Patientportal.PatientPortalService();

            try
            {
                //the UI grid would allow filter by firstname & lastname and not from the DB
                CommonStatus cs = cls.GetPatients("", "", base.GetLoggedinUserID());

                if (cs != null && cs.OpStatus)
                {
                    if (cs.OpPayload != null && ((List <Patient>)cs.OpPayload).Count() > 0)
                    {
                        lstPatients.AddRange(((List <Patient>)cs.OpPayload).OrderByDescending(a => a.DisplayDate).ToList());
                    }
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "An error occured");
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                cls = null;
            }

            return(PartialView(lstPatients));
        }
        public ActionResult Editrx(int PatientID, int RxDataID)
        {
            RxViewModel p = new RxViewModel();

            DataService.Patientportal.PatientPortalService cls = new DataService.Patientportal.PatientPortalService();

            try
            {
                CommonStatus cs = cls.GetRxData(RxDataID, base.GetLoggedinUserID());

                if (cs != null && cs.OpStatus)
                {
                    RxData input = (RxData)cs.OpPayload;

                    p.RxDataID      = input.RxData_ID;
                    p.rxDate        = input.RxDate;
                    p.rxDoctor      = input.RxDoctor;
                    p.Prescription1 = input.Prescription1;
                    p.Prescription2 = input.Prescription2;
                    p.Prescription3 = input.Prescription3;
                    p.Prescription4 = input.Prescription4;
                    p.Prescription5 = input.Prescription5;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                cls = null;
            }

            return(PartialView(p));
        }
        public ActionResult EditPatient(int PatientID)
        {
            PatientViewModel model = new PatientViewModel();

            DataService.Patientportal.PatientPortalService cls = new DataService.Patientportal.PatientPortalService();

            try
            {
                CommonStatus cs = cls.GetPatient(PatientID, base.GetLoggedinUserID());

                if (cs != null && cs.OpStatus)
                {
                    Patient p = (Patient)cs.OpPayload;

                    model.PatientID   = p.Patient_ID;
                    model.First_Name  = p.First_Name;
                    model.Last_Name   = p.Last_Name;
                    model.DateOfBirth = p.DateOfBirth;
                    model.PhoneNumber = p.PhoneNumber;
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                cls = null;
            }

            ViewBag.FirstName = model.First_Name;
            ViewBag.LastName  = model.Last_Name;

            return(PartialView(model));
        }
        public ActionResult login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                DataService.Patientportal.PatientPortalService cls = new DataService.Patientportal.PatientPortalService();

                try
                {
                    string userName = model.UserName;
                    string password = model.Password;

                    CommonStatus cs = cls.VerifyLoginUser(userName, Utilities.PatientRxPortal.Helper.CreateMD5(password));

                    if (cs != null && cs.OpStatus)
                    {
                        PortalUser u = (PortalUser)cs.OpPayload;

                        var claims = new List <Claim>();

                        claims.Add(new Claim(ClaimTypes.NameIdentifier, userName));
                        claims.Add(new Claim(ClaimTypes.Name, u.DisplayName));
                        claims.Add(new Claim(ClaimTypes.GivenName, u.DisplayName));

                        claims.Add(new Claim("UserID", u.PortalUser_ID.ToString()));

                        claims.Add(new Claim(ClaimTypes.Hash, u.HashedPassword));

                        var claimIdenties = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);

                        var ctx = Request.GetOwinContext();
                        var authenticationManager = ctx.Authentication;
                        authenticationManager.SignIn(new AuthenticationProperties()
                        {
                            IsPersistent = false
                        }, claimIdenties);

                        return(RedirectToAction("ManagePatients", "Home"));
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Invalid user-name or password");
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    cls = null;
                }

                return(View());
            }

            return(View());
        }
        public ActionResult EditRx(int PatientID, RxViewModel input)
        {
            string status  = string.Empty;
            string message = string.Empty;

            if (ModelState.IsValid)
            {
                DataService.Patientportal.PatientPortalService cls = new DataService.Patientportal.PatientPortalService();

                try
                {
                    RxData p = new RxData();
                    p.RxData_ID     = input.RxDataID;
                    p.RxDate        = input.rxDate;
                    p.RxDoctor      = input.rxDoctor;
                    p.Prescription1 = input.Prescription1;
                    p.Prescription2 = input.Prescription2;
                    p.Prescription3 = input.Prescription3;
                    p.Prescription4 = input.Prescription4;
                    p.Prescription5 = input.Prescription5;

                    CommonStatus cs = cls.AddUpdatePatientRxData(PatientID, p, base.GetLoggedinUserID());

                    if (cs != null && cs.OpStatus)
                    {
                        status = "OK"; message = "";
                    }
                    else
                    {
                        status = "ERROR"; message = cs.OpMessage;
                    }
                }
                catch (Exception ex)
                {
                    status  = "ERROR";
                    message = ex.Message;
                }
                finally
                {
                    cls = null;
                }
            }

            var jsonData = new
            {
                status  = status,
                message = message
            };


            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
        public ActionResult AddNewPatient(PatientViewModel input)
        {
            string status  = string.Empty;
            string message = string.Empty;

            if (ModelState.IsValid)
            {
                DataService.Patientportal.PatientPortalService cls = new DataService.Patientportal.PatientPortalService();

                try
                {
                    Patient p = new Patient();
                    p.First_Name  = input.First_Name;
                    p.Last_Name   = input.Last_Name;
                    p.DateOfBirth = Convert.ToDateTime(input.DateOfBirth);
                    p.PhoneNumber = input.PhoneNumber;
                    p.Patient_ID  = 0;

                    CommonStatus cs = cls.AddUpdatePatient(p, base.GetLoggedinUserID());

                    if (cs != null && cs.OpStatus)
                    {
                        status = "OK"; message = "";
                    }
                    else
                    {
                        status = "ERROR"; message = cs.OpMessage;
                    }
                }
                catch (Exception ex)
                {
                    status  = "ERROR";
                    message = ex.Message;
                }
                finally
                {
                    cls = null;
                }
            }

            var jsonData = new
            {
                status  = status,
                message = message
            };


            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }