public ActionResult PsychologistSchedule(int id)
        {
            try
            {
                var schedule = db.Schedules.Where(c => c.PsychologistId == id && c.IsBooked == false)
                               .Select(e => new SchedulesDto()
                {
                    PsychologistName = db.Psychologists.FirstOrDefault(d => d.Id == e.PsychologistId).FullName,
                    CentreName       = db.Centre.FirstOrDefault(d => d.Id == e.Id).Name,
                    EndTime          = e.EndTime,
                    StartTime        = e.StartTime,
                    ScheduleDate     = e.ScheduleDate,
                    Id = e.Id,
                }).ToList();
                string audiuserName = User.Identity.GetUserName();
                AuditExtension.AddAudit(audiuserName, "Read", "Schedules");
                return(View(schedule));
            }
            catch (Exception error)
            {
                Console.WriteLine(error.Message);
            }

            //if we get here something is wrong
            return(View());
        }
        public ActionResult DownLoadScheduleReport()
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports/ScheduleReport.rpt")));
            rd.SetDataSource(db.Schedules.Select(e => new
            {
                CentreName       = e.CentreName,
                Id               = e.Id,
                PsychologistName = e.PsychologistName,
                PsychologistId   = e.PsychologistId,
                ScheduleDate     = e.ScheduleDate,
                StartTime        = e.StartTime,
                EndTime          = e.EndTime,
                IsBooked         = e.IsBooked,
                PatientId        = e.PatientId,
            }).ToList());
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();
            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Generated  Schedule Report", "Schedules");

            return(File(stream, "application/pdf", "ScheduleReport.pdf"));
        }
        public ActionResult EditSchedule(int id, ScheduleCollection model)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var schedule = db.Schedules.Single(c => c.Id == id);

            if (schedule.IsBooked == true)
            {
                ViewBag.Messege = "Schedule  has  been  Booked, can not be  adited";
                return(RedirectToAction("ListOfSchedules"));
            }
            schedule.PsychologistId = model.Schedule.PsychologistId;
            schedule.EndTime        = model.Schedule.EndTime;
            schedule.ScheduleDate   = model.Schedule.ScheduleDate;

            //  schedule.DepartmentId = model.Schedule.DepartmentId;
            schedule.StartTime = model.Schedule.StartTime;

            db.SaveChanges();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Updated Schedule Details", "Schedules");

            return(RedirectToAction("ListOfSchedules"));
        }
        public ActionResult AddSchedule(ScheduleCollection model)
        {
            var collection = new ScheduleCollection
            {
                Centres       = db.Centre.ToList(),
                Schedule      = model.Schedule,
                Psychologists = db.Psychologists.ToList()
            };

            if (model.Schedule.ScheduleDate < DateTime.Now.Date)
            {
                ViewBag.Messege = "Please Enter the Date greater than today or equal!!";
                return(View(collection));
            }


            if (model.Schedule.EndTime < model.Schedule.StartTime.AddHours(1) || model.Schedule.EndTime > model.Schedule.StartTime.AddHours(1))
            {
                ViewBag.Messege = "Ops ,You Only allowed to to add schedule for 1 Hour Per slot.";
                return(View(collection));
            }
            ///     to fix  this isuue
            model.Schedule.CentreName       = db.Centre.FirstOrDefault(d => d.Id == model.Schedule.PsychologistId).Name;
            model.Schedule.PsychologistName = db.Psychologists.FirstOrDefault(db => db.Id == model.Schedule.PsychologistId).FullName;
            model.Schedule.IsBooked         = false;

            db.Schedules.Add(model.Schedule);
            db.SaveChanges();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Added Schedule", "Schedules");

            return(RedirectToAction("ListOfSchedules"));
        }
        public ActionResult EditPatient(int id, Patient model)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var patient = db.Patients.Single(c => c.Id == id);

            patient.FirstName        = model.FirstName;
            patient.LastName         = model.LastName;
            patient.FullName         = model.FirstName + " " + model.LastName;
            patient.Address          = model.Address;
            patient.LevelOfEducation = model.LevelOfEducation;
            patient.Age           = model.Age;
            patient.MaritalStatus = model.MaritalStatus;
            patient.Language      = model.Language;
            patient.Contact       = model.Contact;
            patient.DateOfBirth   = model.DateOfBirth;
            patient.EmailAddress  = model.EmailAddress;
            patient.Gender        = model.Gender;
            patient.PhoneNo       = model.PhoneNo;
            db.SaveChanges();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Updated Patient", "Patients");

            return(RedirectToAction("ListOfPatients"));
        }
        public ActionResult EditPsychologists(int id, DoctorCollection model)
        {
            var psychologist = db.Psychologists.Single(c => c.Id == id);

            psychologist.FirstName      = model.Psychologist.FirstName;
            psychologist.LastName       = model.Psychologist.LastName;
            psychologist.FullName       = "Dr. " + model.Psychologist.FirstName + " " + model.Psychologist.LastName;
            psychologist.ContactNo      = model.Psychologist.ContactNo;
            psychologist.PhoneNo        = model.Psychologist.PhoneNo;
            psychologist.Education      = model.Psychologist.Education;
            psychologist.DepartmentId   = model.Psychologist.DepartmentId;
            psychologist.Specialization = model.Psychologist.Specialization;
            psychologist.Gender         = model.Psychologist.Gender;

            psychologist.DateOfBirth = model.Psychologist.DateOfBirth;
            psychologist.Address     = model.Psychologist.Address;
            psychologist.Status      = model.Psychologist.Status;
            db.SaveChanges();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Updated Psychologist Details", "psychologists");

            return(RedirectToAction("ListOfPsychologists"));
        }
        public ActionResult ListOfAppointments()
        {
            try
            {
                string user    = User.Identity.GetUserId();
                var    patient = db.Patients.Single(c => c.ApplicationUserId == user);

                var appointment = db.Appointments.Where(c => c.PatientId == patient.Id)
                                  .Select(e => new AppointmentDto()
                {
                    AppointmentDate = db.Schedules.FirstOrDefault(d => d.PatientId == patient.Id).ScheduleDate,
                    Id               = e.Id,
                    PatientName      = e.Patient.FullName,
                    Problem          = e.Problem,
                    StartTime        = e.StartTime,
                    EndTime          = e.EndTime,
                    PsychologistName = db.Psychologists.FirstOrDefault(d => d.Id == e.Schedule.PsychologistId).FullName,
                    Status           = e.Status,
                })
                                  .ToList();
                string audiuserName = User.Identity.GetUserName();
                AuditExtension.AddAudit(audiuserName, "Retrieved Appointment(s)", "Appointments");
                return(View(appointment));
            }
            catch (Exception error)
            {
                Console.WriteLine(error.Message);
            }

            //if we get here something is wrong
            return(View());
        }
Пример #8
0
        public ActionResult AddAppointment(AppointmentCollection model)
        {
            var collection = new AppointmentCollection
            {
                Appointment   = model.Appointment,
                Psychologists = db.Psychologists.ToList()
            };

            if (model.Appointment.AppointmentDate <= DateTime.Now.Date)
            {
                ViewBag.Messege = "Please Enter the Date greater than today or equal!!";
                return(View(collection));
            }
            string user        = User.Identity.GetUserId();
            var    patient     = db.Patients.Single(c => c.ApplicationUserId == user);
            var    appointment = new Appointment();

            appointment.PatientId = patient.Id;
            appointment.Schedule.PsychologistId = model.Appointment.Schedule.PsychologistId;
            appointment.AppointmentDate         = model.Appointment.AppointmentDate;
            appointment.Problem = model.Appointment.Problem;
            appointment.Status  = false;
            db.Appointments.Add(appointment);
            db.SaveChanges();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Added Appointment", "Appointments");
            return(RedirectToAction("Index"));
        }
        public ActionResult EditAppointment(int id, AppointmentCollection model)
        {
            try
            {
                var collection = new AppointmentCollection
                {
                    Appointment   = model.Appointment,
                    Psychologists = db.Psychologists.ToList()
                };

                if (model.Appointment.AppointmentDate <= DateTime.Now.Date)
                {
                    ViewBag.Messege = "Please Enter the Date greater than today or equal!!";
                    return(View(collection));
                }

                var appointment = db.Appointments.Single(c => c.Id == id);
                appointment.Schedule.PsychologistId = model.Appointment.Schedule.PsychologistId;
                appointment.AppointmentDate         = model.Appointment.AppointmentDate;
                appointment.Problem = model.Appointment.Problem;
                db.SaveChanges();
                string audiuserName = User.Identity.GetUserName();
                AuditExtension.AddAudit(audiuserName, "Updated Appointemnt(s)", "Appointments");
                return(RedirectToAction("ListOfAppointments"));
            }
            catch (Exception error)
            {
                Console.WriteLine(error.Message);
            }
            //if we get here something is wrong
            return(View());
        }
        public ActionResult ListOfConsultation()
        {
            try
            {
                string user          = User.Identity.GetUserId();
                var    petient       = db.Patients.Single(c => c.ApplicationUserId == user);
                var    consultations = db.Consultations.Where(c => c.PatientId == petient.Id)
                                       .Select(e => new ConsultationDto()
                {
                    PatientName      = db.Patients.FirstOrDefault(d => d.Id == e.Id).FullName,
                    PsychologistName = db.Psychologists.FirstOrDefault(d => d.Id == e.PsychologistId).FullName,
                    ConsultationDate = e.ConsultationDate,
                    Diagnosis        = e.Diagnosis,
                    TreatmentPlan    = e.TreatmentPlan,
                    Id = e.Id,
                }).ToList();
                string audiuserName = User.Identity.GetUserName();

                AuditExtension.AddAudit(audiuserName, "Retrieved Consultation(s)", "Consultations");
                return(View(consultations));
            }
            catch (Exception error)
            {
                Console.WriteLine(error.Message);
            }

            //if we get here something is wrong
            return(View());
        }
Пример #11
0
        public ActionResult UpdateProfile(string id, Patient model, HttpPostedFileWrapper picture)
        {
            var patient = db.Patients.Single(c => c.ApplicationUserId == id);

            if (picture != null)
            {
                var path = Path.Combine(Server.MapPath("~/Content/img"), picture.FileName);
                picture.SaveAs(path);
                patient.Image = picture.FileName;
            }
            patient.FirstName        = model.FirstName;
            patient.LastName         = model.LastName;
            patient.FullName         = model.FirstName + " " + model.LastName;
            patient.Contact          = model.Contact;
            patient.Address          = model.Address;
            patient.LevelOfEducation = model.LevelOfEducation;
            patient.Age           = model.Age;
            patient.MaritalStatus = model.MaritalStatus;
            patient.Language      = model.Language;
            patient.Gender        = model.Gender;
            patient.PhoneNo       = model.PhoneNo;
            db.SaveChanges();
            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Updated Patient Details", "Patients");
            return(RedirectToAction("Index"));
        }
        public ActionResult ListOfSchedules()
        {
            try
            {
                var schedule = db.Schedules.Include(c => c.Psychologist)
                               .Select(e => new SchedulesDto()
                {
                    PsychologistName = e.PsychologistName,
                    // CentreName = db.Centre.FirstOrDefault(d => d.Id == e.DepartmentId).Name,
                    EndTime      = e.EndTime,
                    StartTime    = e.StartTime,
                    ScheduleDate = e.ScheduleDate,



                    CentreName = e.CentreName,
                    Id         = e.Id,
                }).ToList();
                string audiuserName = User.Identity.GetUserName();
                AuditExtension.AddAudit(audiuserName, "Read Schedule(s)", "Schedules");
                return(View(schedule));
            }catch (Exception error)
            {
                Console.WriteLine(error.Message);
            }
            //if we get here something is wrong
            return(View());
        }
        public ActionResult DownLoadPatientsReport()
        {
            ReportDocument rd = new ReportDocument();

            rd.Load(Path.Combine(Server.MapPath("~/Reports/PatientsReport.rpt")));
            rd.SetDataSource(db.Patients.Select(e => new
            {
                Gender        = e.Gender,
                MaritalStatus = e.MaritalStatus,
                Id            = e.Id,
                FullName      = e.FullName,
                EmailAddress  = e.EmailAddress,
                Contact       = e.Contact,
                Age           = e.Age,
            }).ToList());
            Response.Buffer = false;
            Response.ClearContent();
            Response.ClearHeaders();
            Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

            stream.Seek(0, SeekOrigin.Begin);

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Generated Patients Report", "Patients");

            return(File(stream, "application/pdf", "PatientsReport.pdf"));
        }
        public ActionResult ListOfPsychologists()
        {
            var psychologist = db.Psychologists.Include(c => c.Centre)
                               .Select(e => new PsychologistDto()
            {
                FullName          = e.FullName,
                FirstName         = e.FirstName,
                LastName          = e.LastName,
                Address           = e.Address,
                Status            = e.Status,
                ContactNo         = e.ContactNo,
                Education         = e.Education,
                Gender            = e.Gender,
                Id                = e.Id,
                CentreName        = db.Centre.FirstOrDefault(c => c.Id == e.DepartmentId).Name,
                ApplicationUserId = e.ApplicationUserId,
            })
                               .ToList();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Retrieved Psychologists", "psychologists");

            return(View(psychologist));
        }
Пример #15
0
        public ActionResult EditAppointment(int id, AppointmentCollection model)
        {
            var collection = new AppointmentCollection
            {
                Appointment   = model.Appointment,
                Psychologists = db.Psychologists.ToList()
            };

            if (model.Appointment.AppointmentDate <= DateTime.Now.Date)
            {
                ViewBag.Messege = "Please Enter the Date greater than today or equal!!";
                return(View(collection));
            }

            var appointment = db.Appointments.Single(c => c.Id == id);

            appointment.Schedule.PsychologistId = model.Appointment.Schedule.PsychologistId;
            appointment.AppointmentDate         = model.Appointment.AppointmentDate;
            appointment.Problem = model.Appointment.Problem;
            db.SaveChanges();
            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Updated Appointment Details", "Appointments");
            return(RedirectToAction("ListOfAppointments"));
        }
 public ActionResult AvailablePsychologists()
 {
     try
     {
         var doctor = db.Psychologists.Include(c => c.Centre).Where(c => c.Status == "Active")
                      .Select(e => new PsychologistDto()
         {
             FullName   = e.FullName,
             FirstName  = e.FirstName,
             LastName   = e.LastName,
             Address    = e.Address,
             CentreName = db.Centre.FirstOrDefault(d => d.Id == e.Id).Name,
             Status     = e.Status,
             ContactNo  = e.ContactNo,
             Education  = e.Education,
             Gender     = e.Gender,
             Id         = e.Id
         }).ToList();
         string audiuserName = User.Identity.GetUserName();
         AuditExtension.AddAudit(audiuserName, "Read List of psychologist", "Psychologists");
         return(View(doctor));
     }
     catch (Exception error)
     {
         Console.WriteLine(error.Message);
     }
     //if we get here something is wrong
     return(View());
 }
        public ActionResult AddAppointment(AppointmentCollection model)
        {
            var collection = new AppointmentCollection
            {
                Appointment   = model.Appointment,
                Patients      = db.Patients.ToList(),
                Psychologists = db.Psychologists.ToList(),
                Schedules     = db.Schedules.ToList()
            };
            var appointment = new Appointment();

            appointment.PatientId       = model.Appointment.PatientId;
            appointment.AppointmentDate = model.Appointment.AppointmentDate;

            appointment.Problem = model.Appointment.Problem;
            appointment.Status  = model.Appointment.Status;
            db.Appointments.Add(appointment);

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Added Appointment", "Appointments");

            db.SaveChanges();

            if (model.Appointment.Status == true)
            {
                return(RedirectToAction("ListOfAppointments"));
            }
            else
            {
                return(RedirectToAction("PendingAppointments"));
            }
        }
Пример #18
0
        public ActionResult ListOfComplains()
        {
            var    complain     = db.Complaints.ToList();
            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Retrieved Complaints", "Complaints");
            return(View(complain));
        }
Пример #19
0
        public ActionResult PsychologistDetail(int id)
        {
            var    doctor       = db.Psychologists.Include(c => c.Centre).Single(c => c.Id == id);
            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Retrieved Psychologists", "Psychologists");
            return(View(doctor));
        }
        public ActionResult ListOfAnnouncement()
        {
            var list = db.Announcements.ToList();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Retrived Announcements", "Announcements");

            return(View(list));
        }
        public ActionResult DepartmentList()
        {
            var model = db.Centre.ToList();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Retrieved centres", "centres");

            return(View(model));
        }
Пример #22
0
        public ActionResult EditComplain(int id, Complaint model)
        {
            var complain = db.Complaints.Single(c => c.Id == id);

            complain.Complain = model.Complain;
            db.SaveChanges();
            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Updated Complaint details", "Complaints");
            return(RedirectToAction("ListOfComplains"));
        }
Пример #23
0
        public ActionResult DeleteAppointment(int id)
        {
            var appointment = db.Appointments.Single(c => c.Id == id);

            db.Appointments.Remove(appointment);
            db.SaveChanges();
            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Deleted Appointment", "Appointments");
            return(RedirectToAction("ListOfAppointments"));
        }
Пример #24
0
        public ActionResult DeleteComplain(int id)
        {
            var complain = db.Complaints.Single(c => c.Id == id);

            db.Complaints.Remove(complain);
            db.SaveChanges();
            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Deleted Complaint", "Complaints");
            return(RedirectToAction("ListOfComplains"));
        }
        public ActionResult DeleteDepartment(int id)
        {
            var department = db.Centre.SingleOrDefault(c => c.Id == id);

            db.Centre.Remove(department);
            db.SaveChanges();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Deleted Centre", "Centres");

            return(RedirectToAction("DepartmentList"));
        }
Пример #26
0
        public ActionResult AddComplain(Complaint model)
        {
            var complain = new Complaint();

            complain.Complain     = model.Complain;
            complain.ComplainDate = DateTime.Now.Date;
            db.Complaints.Add(complain);
            db.SaveChanges();
            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Added Complaint", "Complaints");
            return(RedirectToAction("ListOfComplains"));
        }
        public ActionResult DeletePatient(string id)
        {
            var patient = db.Patients.Single(c => c.ApplicationUserId == id);
            var user    = db.Users.Single(c => c.Id == id);

            db.Users.Remove(user);
            db.Patients.Remove(patient);
            db.SaveChanges();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Deleted Patient", "Patients");

            return(RedirectToAction("ListOfPatients"));
        }
 public ActionResult PsychologistDetail(int id)
 {
     try
     {
         var    doctor       = db.Psychologists.Include(c => c.Centre).Single(c => c.Id == id);
         string audiuserName = User.Identity.GetUserName();
         AuditExtension.AddAudit(audiuserName, "Read", "Psychologists");
         return(View(doctor));
     }
     catch (Exception error)
     {
         Console.WriteLine(error.Message);
     }
     //if we get here something is wrong
     return(View());
 }
        public ActionResult ListOfComplains()
        {
            try
            {
                var    complain     = db.Complaints.ToList();
                string audiuserName = User.Identity.GetUserName();
                AuditExtension.AddAudit(audiuserName, "Read", "Complaints");
                return(View(complain));
            }
            catch (Exception error)
            {
                Console.WriteLine(error.Message);
            }

            //if we get here something is wrong
            return(View());
        }
Пример #30
0
        public ActionResult PsychologistSchedule(int id)
        {
            var schedule = db.Schedules.Where(c => c.PsychologistId == id && c.IsBooked == false)
                           .Select(e => new SchedulesDto()
            {
                PsychologistName = db.Psychologists.FirstOrDefault(d => d.Id == e.PsychologistId).FullName,
                CentreName       = db.Centre.FirstOrDefault(d => d.Id == e.Id).Name,
                EndTime          = e.EndTime,
                StartTime        = e.StartTime,
                ScheduleDate     = e.ScheduleDate,
                Id = e.Id,
            }).ToList();
            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Retrieved Schedules", "Schedules");
            return(View(schedule));
        }