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); }
protected HoursEntryServiceBase(CoreContext context, HoursEntryMode entryMode = HoursEntryMode.ProviderEntry)// default to more restricted of modes { Context = context; SessionReportService = new SessionReportService(Context); EntryMode = entryMode; }