public HoursEntryResponseVM SubmitHoursForProviderAppManualEntryInitialValidation(BaseHoursEntryRequestVM request, bool isOnAideLegacyMode) { // this runs when the mobile app is pre-validating a manual entry // there are no notes present: we're validating the base information only // we are not saving anything var resolutionDataContext = new CoreContext(); using (var transaction = resolutionDataContext.Database.BeginTransaction()) { var helper = new HoursResolutionHelper(resolutionDataContext); try { var entry = helper.GetHoursObject(request, isOnAideLegacyMode); var issues = helper.GetResults(entry, HoursEntryMode.ProviderEntry, EntryApp.ProviderApp, EntryType.Basic); var response = new HoursEntryResponseVM { WasProcessed = false }; if (issues.HasErrors || issues.HasWarnings) { response.Messages = helper.GetResponseMessages(issues); } return(response); } catch (Exception e) { Exceptions.Handle(e); return(new HoursEntryResponseVM { HoursID = request.HoursID, WasProcessed = false, Messages = new List <HoursEntryResponseMessage> { new HoursEntryResponseMessage { Severity = MessageSeverity.Error, Message = "We're sorry, but an unknown error has occurred. Please contact your system administrator for more information." } } }); } finally { // we're just validating, rollback Rollback(transaction); } } }
public ValidationResponse Validate(ValidationRequest request, bool save) { // this runs on basic validations // does not have notes // for manual hours entry, save will be False // for session prechecks, save will be true var provider = ProviderProvider.GetProvider(request.UserProviderID); if (provider == null) { throw new InvalidOperationException("Unknown provider"); } var patientID = Context.Cases.SingleOrDefault(m => m.ID == request.RequestedValidatedSession.CaseID).PatientID; var hoursEntryModel = Mapper.FromSessionValidationRequest(request, provider.ID, patientID); var apiResponse = new ValidationResponse(); HoursEntryResponseVM hoursEntryResponse = null; if (save) { hoursEntryModel.Status = (int)HoursStatus.PreChecked; hoursEntryResponse = HoursEntryService.SubmitHoursForProviderAppPreCheck(hoursEntryModel, true); //json, take a look at the second parameter } else { hoursEntryResponse = HoursEntryService.SubmitHoursForProviderAppManualEntryInitialValidation(hoursEntryModel, true); //json, take a look at the second parameter } var messages = hoursEntryResponse.Messages; apiResponse.Errors = messages.Where(x => x.Severity == MessageSeverity.Error).Select(x => x.Message).ToList(); apiResponse.Warnings = messages.Where(x => x.Severity == MessageSeverity.Warning).Select(x => x.Message).ToList(); apiResponse.Messages = messages.Where(x => x.Severity == MessageSeverity.General).Select(x => x.Message).ToList(); var messagesToLog = "ERRORS: " + string.Join("|", apiResponse.Errors) + Environment.NewLine + "WARNINGS: " + string.Join("|", apiResponse.Warnings) + Environment.NewLine + "MESSAGES: " + string.Join("|", apiResponse.Messages) + Environment.NewLine; if (hoursEntryResponse.WasProcessed) { log.Info("Validate Complete, Was Processed with Hours ID: " + hoursEntryResponse.HoursID.Value); log.Info(messagesToLog); apiResponse.ServerValidatedSessionID = hoursEntryResponse.HoursID.Value; } else { log.Info("Validate Complete, Was Not Processed, therefore Hours ID: 0"); log.Info(messagesToLog); apiResponse.ServerValidatedSessionID = 0; } if (provider.ProviderTypeID == (int)ProviderTypeIDs.BoardCertifiedBehavioralAnalyst) { throw new NotImplementedException(); } else { // Aides only have one required not for now... apiResponse.NoteQuestions = new List <NoteQuestion> { new NoteQuestion { NoteQuestionID = 0, Question = "Please enter your session notes" } }; } return(apiResponse); }