Example #1
0
        public ActionResult CreateDiagnosis()
        {
            var doctorId = User.Identity.GetUserId();
            var doctDept = (from doctdept in _context.DoctorDepartments
                            where doctdept.DoctorUserId == doctorId
                            select doctdept.DepartmentId).FirstOrDefault();
            var ticks = (from t in _context.Tickets
                         where t.DepartmentId == doctDept
                         where t.TicketStatus == "Open"
                         select t.PatientUserId).ToList();
            var openTicketPatients = (from u in _context.Users
                                      where ticks.Contains(u.Id)
                                      select u).ToList();
//            var roleId = _context.Roles.Where(m => m.Name == "Patient").Select(m => m.Id).SingleOrDefault();
//            var users = _context.Users
//                .Where(u => u.Roles.Any(r => r.RoleId == roleId)).ToList();
//
//            var ticketPatients = from pat in users
//                join tic in _context.Tickets on pat.Id equals tic.PatientUserId
//                join dept in _context.DoctorDepartments on tic.DepartmentId equals dept.DepartmentId
//                where tic.TicketStatus == "Open"
//                select pat;
            var viewModel = new CreateDiagnosisViewModel
            {
                Patients  = openTicketPatients,
                Diagnosis = new Diagnosis()
            };

            return(View(viewModel));
        }
Example #2
0
 public ActionResult CreateDiagnosis(int?id)
 {
     if (id != null)
     {
         var diagnosis = new CreateDiagnosisViewModel();
         diagnosis.PatientCardId = id;
         return(View(diagnosis));
     }
     return(HttpNotFound());
 }
Example #3
0
        public ActionResult ChangeDiagnosis(CreateDiagnosisViewModel diagnosisvm)
        {
            if (!ModelState.IsValid)
            {
                return(View(diagnosisvm));
            }
            var diagnosis = _mapper.Map <CreateDiagnosisViewModel, Diagnosis>(diagnosisvm);

            _patientCardService.ChangeDiagnosis(diagnosis);
            _loggerService.Info($"{User.Identity.Name} change diagnoses for {diagnosis.PatientCard}");
            return(RedirectToAction("Index"));
        }
Example #4
0
        public ActionResult StoreDiagnosis(CreateDiagnosisViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("CreateDiagnosis", viewModel));
            }
            viewModel.Diagnosis.DoctorUserId = User.Identity.GetUserId();
            var ticketId = viewModel.Diagnosis.TicketId;

            using (var context = new ApplicationDbContext())
            {
                context.Diagnoses.Add(viewModel.Diagnosis);
                context.SaveChanges();
            }
            using (var context = new ApplicationDbContext())
            {
                var ticket = context.Tickets.Find(ticketId);
                ticket.TicketStatus = "Closed";
                context.SaveChanges();
            }
            var ctx = _context.Tickets.ToList();

            return(View("Index"));
        }