Ejemplo n.º 1
0
        public ActionResult FullDetails(int RequestId)
        {
            DischargeViewModel         model            = new DischargeViewModel();
            DischargeDetailsController dischargeDetails = new DischargeDetailsController();

            model.RequestModel     = dischargeDetails.PopulateModel(RequestId, true);
            model.ComplaintModel   = new DischargeComplaintModel();
            model.DischargeActions = GetDischargeActions(model.RequestModel);
            model.AuditLogs        = GetRequestHistory(RequestId);
            List <tblDischargeComplaint> complaints = new List <tblDischargeComplaint>();
            DateTime dtmLive = Convert.ToDateTime("05/21/2018");

            using (var context = new lifeflightapps())
            {
                complaints = context.tblDischargeComplaints.Where(x => x.RequestID == RequestId && x.ComplaintEntereddatetime > dtmLive).ToList();
            }
            List <DischargeComplaintModel> cModels = new List <DischargeComplaintModel>();

            foreach (var entry in complaints)
            {
                DischargeComplaintModel complaintModel = new DischargeComplaintModel();

                complaintModel = ConvertToModel(entry);
                cModels.Add(complaintModel);
            }
            model.ComplaintModels = cModels;
            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Discharge(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var residentToDischarge = db.Residents
                                      .Include(p => p.ProgramEvents.Select(j => j.ProgramType))
                                      .Where(r => r.ResidentID == id)
                                      .Single();

            var dischargeModel = new DischargeViewModel
            {
                ResidentID    = residentToDischarge.ResidentID,
                DischargeDate = null,
                FullName      = residentToDischarge.Fullname,
                Birthdate     = residentToDischarge.ClearBirthdate?.ToShortDateString(),
                Note          = residentToDischarge.Note,
                ServiceBranch = residentToDischarge.ServiceBranch,
                LastAdmitted  = residentToDischarge.ProgramEvents.LastOrDefault(i => i.ProgramType.EventType == EnumEventType.ADMISSION).ClearStartDate.Date
            };

            ViewBag.ProgramTypeID = new SelectList(db.ProgramTypes
                                                   .Where(t => t.EventType == EnumEventType.DISCHARGE), "ProgramTypeID", "ProgramDescription");

            return(View("Discharge", dischargeModel));
        }
Ejemplo n.º 3
0
        public ActionResult Discharge(DischargeViewModel model)
        {
            ViewBag.ProgramTypeID = new SelectList(db.ProgramTypes
                                                   .Where(t => t.EventType == EnumEventType.DISCHARGE), "ProgramTypeID", "ProgramDescription");


            if (ModelState.IsValid)
            {
                Resident residentToDischarge = db.Residents
                                               .Include(p => p.ProgramEvents.Select(i => i.ProgramType))
                                               .Where(r => r.ResidentID == model.ResidentID)
                                               .Single();

                // To close admission events
                var ev = residentToDischarge.ProgramEvents
                         .LastOrDefault(i => i.ProgramType.EventType == EnumEventType.ADMISSION);

                // Set age at release for resident for reporting more accurate cumulative age.
                residentToDischarge.AgeAtRelease = residentToDischarge.Age;

                ev.ClearEndDate    = model.DischargeDate;
                db.Entry(ev).State = EntityState.Modified;

                // Discharge event
                residentToDischarge.ProgramEvents.Add(new ProgramEvent
                {
                    ProgramTypeID  = model.ProgramTypeID,
                    ClearStartDate = model.DischargeDate.Value
                });

                if (residentToDischarge.ActualDaysStayed == null)
                {
                    residentToDischarge.ActualDaysStayed = residentToDischarge.DaysInCenter;
                }
                else
                {
                    residentToDischarge.ActualDaysStayed += residentToDischarge.DaysInCenter;
                }

                residentToDischarge.IsCurrent = false;
                db.SaveChanges();
                TempData["UserMessage"] = residentToDischarge.ClearLastName + " has been discharged from your center.  ";
                return(RedirectToAction("Index"));
            }

            return(View("Discharge", model));
        }
        /// <summary>
        /// To the view model.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        public static DischargeViewModel ToViewModel(this DischargeModel entity)
        {
            if (entity == null)
            {
                return(null);
            }
            var model = new DischargeViewModel
            {
                DischargeID       = entity.DischargeID,
                ProgressNoteID    = entity.ProgressNoteID,
                DischargeTypeID   = entity.DischargeTypeID,
                TakenBy           = entity.TakenBy,
                DischargeDate     = entity.DischargeDate,
                DischargeReasonID = entity.DischargeReasonID,
                ModifiedOn        = entity.ModifiedOn
            };

            return(model);
        }
        /// <summary>
        /// To the model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public static DischargeModel ToModel(this DischargeViewModel model)
        {
            if (model == null)
            {
                return(null);
            }

            var entity = new DischargeModel
            {
                DischargeID       = model.DischargeID,
                ProgressNoteID    = model.ProgressNoteID,
                DischargeTypeID   = model.DischargeTypeID,
                TakenBy           = model.TakenBy,
                DischargeDate     = model.DischargeDate,
                DischargeReasonID = model.DischargeReasonID,
                ModifiedOn        = model.ModifiedOn
            };

            return(entity);
        }