Exemple #1
0
        public HoursEntryVM GetNewHoursEntryDataTemplate(int caseID, int providerID, DateTime?date)
        {
            var provider = Context.Providers.Find(providerID);
            var c        = Context.Cases.Find(caseID);
            var model    = new HoursEntryVM
            {
                IsOnAideLegacyMode = SessionReportService.IsOnAideLegacyMode(provider),
                IsEditable         = true, // this always has to be true, because a date won't be selected until later via the UI
                Status             = (int)HoursStatus.Pending,
                HasData            = false,
                CaseID             = c.ID,
                IsAdminMode        = EntryMode == HoursEntryMode.ManagementEntry,
                EntryID            = null,
                ProviderID         = providerID,
                ProviderTypeID     = provider.ProviderTypeID,
                ProviderTypeCode   = provider.ProviderType.Code,
                PatientID          = c.PatientID,
                PatientName        = c.Patient.CommonName,
                InsuranceID        = null,
                InsuranceName      = "Select a date to determine the active insurance",
                Date             = date,
                TimeIn           = null,
                TimeOut          = null,
                Note             = null,
                ServiceID        = null,
                ServiceLocations = GetServiceLocations(),
                IsTrainingEntry  = false,
                ActivePatients   = new List <HoursEntryActivePatientVM>(), // can't get these before we have a date on file...
                NoteGroups       = GetNewHoursEntryNoteGroups(provider.ProviderTypeID),
                Services         = date.HasValue ? GetHoursEntryServices(c, provider, date.Value) : new List <HoursEntryServiceVM>(),
                SessionReport    = new DomainServices.Sessions.SessionReport()
            };

            model.ServiceLocationID = model.ServiceLocations.Where(x => x.Name == "Home").FirstOrDefault()?.ID;
            return(model);
        }
        public HoursEntryVM GetCatalsytHoursVM(int entryID)
        {
            var entry     = Context.CatalystPreloadEntries.Find(entryID);
            var provider  = Context.Providers.Find(entry.ProviderID);
            var c         = Context.Cases.Find(entry.CaseID);
            var insurance = c.GetActiveInsuranceAtDate(entry.Date);
            var model     = new HoursEntryVM
            {
                IsOnAideLegacyMode = SessionReportService.IsOnAideLegacyMode(provider),
                IsEditable         = true,
                Status             = (int)Domain2.Hours.HoursStatus.Pending,
                HasData            = true,
                CatalystPreloadID  = entryID,
                IsAdminMode        = false,
                Date             = entry.Date,
                EntryID          = null,
                ProviderID       = entry.ProviderID,
                ProviderTypeID   = provider.ProviderTypeID,
                ProviderTypeCode = provider.ProviderType.Code,
                PatientID        = c.PatientID,
                PatientName      = c.Patient.CommonName,
                InsuranceID      = insurance?.ID,
                InsuranceName    = insurance?.Insurance.Name ?? "Select a date to determine the active insurance",
                TimeIn           = null,
                TimeOut          = null,
                Note             = entry.Notes,
                ServiceID        = null,
                ServiceLocations = GetServiceLocations(),
                IsTrainingEntry  = false,
                Services         = GetHoursEntryServices((Domain2.Providers.ProviderTypeIDs)provider.ProviderTypeID),
                ActivePatients   = GetHoursEntryActivePatients(entry.ProviderID, entry.Date),
                NoteGroups       = GetNewHoursEntryNoteGroups(provider.ProviderTypeID)
            };

            model.ServiceLocationID = model.ServiceLocations.Where(x => x.Name == "Home").FirstOrDefault()?.ID;
            return(model);
        }
        internal bool ValidateCoreRequirements(Domain2.Hours.Hours entry)
        {
            if (!_resolutionService.IsPreCheck)
            {
                if (entry.Date > DateTime.Now.Date)
                {
                    _resolutionService.Issues.AddIssue("Date must not be in the future.");
                    return(false);
                }
            }
            else
            {
                if (entry.Date > DateTime.Now.Date.AddDays(_resolutionService.PreCheckAdvancedDaysAllowance))
                {
                    _resolutionService.Issues.AddIssue("Cannot precheck a date more than " + _resolutionService.PreCheckAdvancedDaysAllowance + " days in advance.");
                    return(false);
                }
            }



            if (entry.StartTime >= entry.EndTime)
            {
                _resolutionService.Issues.AddIssue("Start Time cannot be greater than End Time");
                return(false);
            }

            if (entry.Service == null)
            {
                _resolutionService.Issues.AddIssue("A Service must be supplied to the hours entry.");
                return(false);
            }

            if (_resolutionService.EntryType == EntryType.Full)
            {
                var isOnAideLegacyMode = SessionReportService.IsOnAideLegacyMode(entry);
                var result             = _hoursNotesValidator.Validate(entry, _resolutionService.EntryApp, isOnAideLegacyMode);
                if (!result.IsValid)
                {
                    foreach (var e in result.Errors)
                    {
                        _resolutionService.Issues.AddIssue(e);
                    }
                    return(false);
                }
            }


            if (TargetPeriodFinalized(entry))
            {
                if (_resolutionService.EntryMode == HoursEntryMode.ManagementEntry)
                {
                    _resolutionService.Issues.AddIssue("The period for these hours has already been finalized", ValidationIssueType.Warning);
                }
                else
                {
                    _resolutionService.Issues.AddIssue("The period for these hours has already been finalized");
                    return(false);
                }
            }


            return(true);
        }