コード例 #1
0
 public IActionResult DeleteAppointment(int id, PatientAppointmentReferral par)
 {
     //this assigns the id to the PatientAppointmentReferral model's id
     par.PatientApplicationReferralID = id;
     //this deletes the guest appointment from the database
     PARrepository.DeletePAR(par);
     //this creates a confirmation message and redirects the user to the appointment homepage
     TempData["Message"] = "Appointment Deleted";
     return(RedirectToAction("Index", "Appointment"));
 }
コード例 #2
0
 public IActionResult CreateAppointment(PatientAppointmentReferral PAR)
 {
     //IPatientAppointmentReferralRepository IPAR;
     if (ModelState.IsValid)
     {
         //IPAR.createPAR(PAR);
         repository.CreatePAR(/*new */ PAR);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View());
     }
 }
コード例 #3
0
        public IActionResult EditAppointment(int id)
        {
            //this tries to assign the guest appointment from the database to a new PatientAppointmentReferral model called par
            PatientAppointmentReferral par = PARrepository.PAR.FirstOrDefault(p => p.PatientApplicationReferralID == id);

            if (par != null)
            {
                //this loads the dates and times available for appointments to be made
                ViewBag.Dates = timesRepository.ViewbagDates(PARrepository, AppointmentRepository, par.MedicalPersonnel, par.RequestedDate, timesRepository);
                //this passes the model to the EditAppointment view
                return(View(PARrepository.PAR.FirstOrDefault(p => p.PatientApplicationReferralID == id)));
            }
            else
            {
                //this creates an error message and redirects the user to the default home page
                TempData["Error"] = "Error trying to load appointment";
                return(RedirectToAction("Index", "Patient"));
            }
        }
コード例 #4
0
 public IActionResult EditAppointment(int id, PatientAppointmentReferral par)
 {
     //this checks if the model is valid and if not creates an error message and redirects the user to the default home page
     if (ModelState.IsValid)
     {
         //this alters the appointment date and time in the current par variable
         par.RequestedTime = par.RequestedDate.ToString().Substring(11);
         par.PatientApplicationReferralID = id;
         //this updates the guest appointment record's details
         PARrepository.UpdatePAR(par);
         //string ID = "";
         string   Name = par.Name;
         DateTime DOB  = par.DOB;
         //this redirects the users to the homepage
         return(RedirectToAction("Index", "Patient"));
         //return RedirectToAction("Search", "Appointment");//, [ID, Name, DOB]);
     }
     else
     {
         TempData["Error"] = "Cannot Edit Appointment";
         return(View(par));
     }
 }
コード例 #5
0
        public ViewResult CreateAppointment(string MedicalPersonnel)
        {
            PatientAppointmentReferral patientAppointmentReferral = new PatientAppointmentReferral();

            patientAppointmentReferral.MedicalPersonnel = MedicalPersonnel;
            try
            {
                if (HttpContext.Session.GetString("Type") == "Receptionist" || HttpContext.Session.GetString("Type") == "Nurse" || HttpContext.Session.GetString("Type") == "Doctor" || HttpContext.Session.GetString("Type") == null)
                {
                    patientAppointmentReferral.Name         = "Julie Doe";
                    patientAppointmentReferral.DOB          = new DateTime(1980, 6, 25, 0, 0, 0);
                    patientAppointmentReferral.County       = "Lanarkshire";
                    patientAppointmentReferral.StreetNumber = 0;
                    patientAppointmentReferral.StreetName   = "Main Road";
                    patientAppointmentReferral.Region       = "Strathclyde";
                    patientAppointmentReferral.Symptoms     = "Sore Head, Pains in Stomach";
                    patientAppointmentReferral.CurrentDate  = DateTime.Now;
                    patientAppointmentReferral.Postcode     = "G01 145";
                    patientAppointmentReferral.Email        = "*****@*****.**";
                    patientAppointmentReferral.HomePhone    = "0141 123 4567";
                    patientAppointmentReferral.WorkPhone    = "0123 567 8910";
                    patientAppointmentReferral.MobilePhone  = "01234 567890";
                    patientAppointmentReferral.NextOfKin    = "John Doe";
                    return(View("CreateAppointment", patientAppointmentReferral));
                }
                else
                {
                    Account account = new Account();
                    account = HttpContext.Session.getJson <Account>("Account");
                    Address address = new Address();
                    address = HttpContext.Session.getJson <Address>("Address");
                    ContactDetails contactDetails = new ContactDetails();
                    contactDetails = HttpContext.Session.getJson <ContactDetails>("CD");
                    patientAppointmentReferral.Name = account.Name;
                    patientAppointmentReferral.DOB  = account.DOB;
                    //patientAppointmentReferral.RequestedDate = DateTime.Now.Date;
                    patientAppointmentReferral.County       = address.County;
                    patientAppointmentReferral.StreetNumber = address.StreetNumber;
                    patientAppointmentReferral.StreetName   = address.StreetName;
                    patientAppointmentReferral.Region       = address.Region;
                    patientAppointmentReferral.CurrentDate  = DateTime.Now;
                    patientAppointmentReferral.Postcode     = address.Postcode;
                    patientAppointmentReferral.Symptoms     = "Sore Head, Pains in stomach";
                    patientAppointmentReferral.Email        = contactDetails.Email;
                    patientAppointmentReferral.HomePhone    = contactDetails.HomePhone;
                    patientAppointmentReferral.WorkPhone    = contactDetails.WorkPhone;
                    patientAppointmentReferral.MobilePhone  = contactDetails.MobilePhone;
                    patientAppointmentReferral.NextOfKin    = contactDetails.NextOfKin;
                    return(View("CreateAppointment", patientAppointmentReferral));
                }
            }
            catch (Exception ex)
            {
                patientAppointmentReferral.Name = "Julie Doe";
                patientAppointmentReferral.DOB  = new DateTime(1980, 6, 25, 0, 0, 0);
                //patientAppointmentReferral.RequestedDate = DateTime.Now.Date;
                patientAppointmentReferral.County       = "Lanarkshire";
                patientAppointmentReferral.StreetNumber = 0;
                patientAppointmentReferral.StreetName   = "Main Road";
                patientAppointmentReferral.Region       = "Strathclyde";
                patientAppointmentReferral.Symptoms     = "Sore Head, Pains in Stomach";
                patientAppointmentReferral.CurrentDate  = DateTime.Now;
                patientAppointmentReferral.Postcode     = "G01 145";
                patientAppointmentReferral.Email        = "*****@*****.**";
                patientAppointmentReferral.HomePhone    = "0141 123 4567";
                patientAppointmentReferral.WorkPhone    = "0123 567 8910";
                patientAppointmentReferral.MobilePhone  = "01234 567890";
                patientAppointmentReferral.NextOfKin    = "John Doe";
                return(View("CreateAppointment", patientAppointmentReferral));// return View();
            }
        }
コード例 #6
0
        public IActionResult CreatingAppointment(PatientAppointmentReferral PAR, string RequestedDate)
        {
            List <string> newList = new List <string>();

            //this preloads the data for the appointment page
            ViewBag.Dates     = newList;
            PAR.Decision      = "Booked";
            PAR.RequestedTime = RequestedDate.Substring(11); //PAR.RequestedDate.TimeOfDay.ToString();
            if (PAR.RequestedDate.Date >= DateTime.Now.Date && (PAR.RequestedDate.DayOfWeek.ToString() != "Saturday" || PAR.RequestedDate.DayOfWeek.ToString() != "saturday") || (PAR.RequestedDate.DayOfWeek.ToString() != "Sunday") || (PAR.RequestedDate.DayOfWeek.ToString() != "sunday"))
            {
                if (ModelState.IsValid)
                {
                    Appointment appointment = new Appointment();
                    appointment.AppointmentDate = DateTime.Parse(RequestedDate);
                    //appointment.AppointmentTime = PAR.RequestedTime;
                    appointment.AppointmentTime = RequestedDate.Substring(11);
                    appointment.AppointmentType = "Doctor's Surgery";
                    appointment.County          = PAR.County;
                    appointment.CurrentDate     = PAR.CurrentDate;
                    appointment.Diagnosis       = "";
                    appointment.DOB             = PAR.DOB;
                    appointment.PatientFullName = PAR.Name;
                    appointment.Postcode        = PAR.Postcode;
                    appointment.Region          = PAR.Region;
                    appointment.StreetName      = PAR.StreetName;
                    appointment.StreetNumber    = PAR.StreetNumber;
                    appointment.Symptoms        = PAR.Symptoms;
                    appointment.AppointmentMedicalProfessional = PAR.MedicalPersonnel;

                    //this checks if users are Medical personnel or not
                    if (HttpContext.Session.GetString("Name") != "" && (HttpContext.Session.GetString("Type") == "Doctor" || HttpContext.Session.GetString("Type") == "Nurse"))
                    {
                        try
                        {
                            //this checks if usersis already in the database and adds the appointment to the appropriate database table and displays the appropriate message
                            Account accounts = AccountRepository.Accounts.FirstOrDefault(a => a.Name == appointment.PatientFullName);
                            if (accounts == null)
                            {
                                PARrepository.CreatePAR(PAR);
                                TempData["Message"] = "Appointment Created";
                            }
                            else
                            {
                                //Account account = AccountRepository.Accounts.FirstOrDefault(a => a.Name == appointment.PatientFullName);
                                appointment.UserReferralID = accounts.ID;
                                AppointmentRepository.CreateAppointment(appointment);
                                TempData["Message"] = "Appointment Created";
                            }
                        }
                        catch
                        {
                            //this adds a valid appointment as a guest appointment
                            PARrepository.CreatePAR(PAR);
                        }
                        //this returns the user to the practitioners index view
                        return(RedirectToAction("Index", "Practitioners"));
                    }
                    else if ((HttpContext.Session.GetString("Name") != "" || HttpContext.Session.GetString("Name") != null) && HttpContext.Session.GetString("Type") == "Patient")
                    {
                        //this adds a logged in user's appointment as a logged in user appointment, displays the apppropriate message and redirects the user to their respected homepage
                        Account account = HttpContext.Session.getJson <Account>("Account");
                        appointment.UserReferralID = account.ID;
                        AppointmentRepository.CreateAppointment(appointment);
                        TempData["Message"] = "Appointment Created";
                        return(RedirectToAction("Index", "Patient"));
                    }
                    else
                    {
                        //this adds a guest user's appointment as a guest appointment, displays the apppropriate message and redirects the user to their respected homepage
                        PARrepository.CreatePAR(PAR);
                        TempData["Message"] = "Appointment Created";
                        return(RedirectToAction("Index", "Appointment"));
                    }
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }