public ActionResult Edit(StaffingLogVM model)
        {
            var request = new StaffingLogSaveRequest
            {
                ID = model.CaseID,
                ParentalRestaffRequest = model.ParentalRestaffRequest,
                HoursOfABATherapy      = model.HoursOfABATherapy,
                AidesRespondingNo      = model.AidesRespondingNo,
                AidesRespondingMaybe   = model.AidesRespondingMaybe,
                ScheduleRequest        = model.ScheduleRequest != null?model.ScheduleRequest.ToInt() : 0,
                                             SpecialAttentionNeedIds  = CheckBoxListExtension.GetSelectedValues <int>("SpecialAttentionNeedIds"),
                                             ProviderGenderPreference = model.ProviderGenderPreference != '0' ? model.ProviderGenderPreference : null
            };

            return(SaveFullAction(model, model.ViewHelper, "Search", "Edit", "ErrorPartial", () => repository.SaveStaffingLog(request)));
        }
Esempio n. 2
0
        public StaffingLogVM CreateStaffingLogVM(int caseId, StaffingLog staffingLog)
        {
            StaffingLogVM model   = null;
            var           patient = Context.Patients.SingleOrDefault(m => m.Cases.Any(c => c.ID == caseId));

            if (patient != null)
            {
                var @case                 = Context.Cases.SingleOrDefault(m => m.ID == caseId);
                var zipInfoRepository     = new ZipInfoRepository();
                var caseService           = new Data.Services.CaseService();
                var guardianRelationships = caseService.GetGuardianRelationships();
                model = new StaffingLogVM
                {
                    PatientID   = patient.ID,
                    CaseID      = caseId,
                    FirstName   = patient.FirstName,
                    LastName    = patient.LastName,
                    DateOfBirth = patient.DateOfBirth,
                    Email       = patient.Email,
                    Phone       = patient.Phone,
                    Address1    = patient.Address1,
                    Address2    = patient.Address2,
                    City        = patient.City,
                    State       = patient.State,
                    Zip         = patient.Zip,
                    County      = zipInfoRepository.GetCounty(patient.Zip),
                    Guardians   = new List <GuardianInfoVM> {
                        new GuardianInfoVM {
                            FirstName    = patient.GuardianFirstName,
                            LastName     = patient.GuardianLastName,
                            Relationship = GetGuardianRelationship(patient.GuardianRelationshipID, guardianRelationships),
                            Email        = patient.GuardianEmail,
                            CellPhone    = patient.GuardianCellPhone,
                            HomePhone    = patient.GuardianHomePhone,
                            WorkPhone    = patient.GuardianWorkPhone,
                            Notes        = patient.GuardianNotes
                        },
                        new GuardianInfoVM            {
                            FirstName    = patient.Guardian2FirstName,
                            LastName     = patient.Guardian2LastName,
                            Relationship = GetGuardianRelationship(patient.Guardian2RelationshipID, guardianRelationships),
                            Email        = patient.Guardian2Email,
                            CellPhone    = patient.Guardian2CellPhone,
                            HomePhone    = patient.Guardian2HomePhone,
                            WorkPhone    = patient.Guardian2WorkPhone,
                            Notes        = patient.Guardian2Notes
                        },
                        new GuardianInfoVM
                        {
                            FirstName    = patient.Guardian3FirstName,
                            LastName     = patient.Guardian3LastName,
                            Relationship = GetGuardianRelationship(patient.Guardian3RelationshipID, guardianRelationships),
                            Email        = patient.Guardian3Email,
                            CellPhone    = patient.Guardian3CellPhone,
                            HomePhone    = patient.Guardian3HomePhone,
                            WorkPhone    = patient.Guardian3WorkPhone,
                            Notes        = patient.Guardian3Notes
                        }
                    },
                    FunctioningLevel = @case.FunctioningLevel?.Name,
                    Notes            = patient.Notes,
                    CaseProviders    = Context.CaseProviders
                                       .Where(m => m.CaseID == caseId)
                                       .ToList()
                                       .Select(m => new CaseProviderVM
                    {
                        ProviderID        = m.Provider.ID,
                        ProviderLastName  = m.Provider.LastName,
                        ProviderFirstName = m.Provider.FirstName,
                        ProviderType      = m.Provider.GetProviderTypeFullCode(),
                        IsBCBA            = m.Provider.IsBCBA,
                        IsActive          = CaseIsActive(DateTime.Now, m.StartDate, m.EndDate)
                    })
                                       .OrderByDescending(m => m.IsActive)
                                       .ThenByDescending(m => m.IsBCBA)
                                       .ThenBy(m => m.ProviderLastName)
                                       .ThenBy(m => m.ProviderFirstName),
                    SystemSpecialAttentionNeeds = Context.SpecialAttentionNeeds
                                                  .Where(n => n.Active)
                                                  .Select(n => new SpecialAttentionNeedVM
                    {
                        ID   = n.ID,
                        Code = n.Code,
                        Name = n.Name
                    })
                                                  .ToList(),
                    SpecialAttentionNeedIDs = staffingLog.SpecialAttentionNeeds != null?staffingLog.SpecialAttentionNeeds.Select(n => n.ID).ToList() : new List <int>(),
                                                  ParentalRestaffRequest   = staffingLog.ParentalRestaffRequest,
                                                  HoursOfABATherapy        = staffingLog.HoursOfABATherapy,
                                                  AidesRespondingNo        = staffingLog.AidesRespondingNo,
                                                  AidesRespondingMaybe     = staffingLog.AidesRespondingMaybe,
                                                  ScheduleRequest          = ScheduleRequestVM.FromInt(staffingLog.ScheduleRequest),
                                                  DateWentToRestaff        = staffingLog.DateWentToRestaff,
                                                  ProviderGenderPreference = string.IsNullOrEmpty(staffingLog.ProviderGenderPreference) ? '0' : staffingLog.ProviderGenderPreference[0]
                };
            }
            return(model);
        }