public bool RevertToPreAudit(EhrRevertToPreAuditStateViewModel model) { _logger.Info("Method called : RevertToPreAudit for CustmerId: " + model.CustomerId + " EventId: " + model.EventId); var orgRoleUser = _organizationRoleUserRepository.GetByUserNameAndRoleAlias(model.UserName, model.RoleAlias); if (orgRoleUser == null) { _logger.Error(string.Format("No OrganizationRoleUser found for username: {0}, roleAlias: {1}, CustomerId: {2}, EventId: {3}", model.UserName, model.RoleAlias, model.CustomerId, model.EventId)); _logger.Info("Method completed : RevertToPreAudit for CustmerId: " + model.CustomerId + " EventId: " + model.EventId); return(false); } if (orgRoleUser.RoleId != (long)Roles.Coder) { _logger.Error(string.Format("Provided role is not NursePractitioner. username: {0}, roleAlias: {1}, CustomerId: {2}, EventId: {3}", model.UserName, model.RoleAlias, model.CustomerId, model.EventId)); _logger.Info("Method completed : RevertToPreAudit for CustmerId: " + model.CustomerId + " EventId: " + model.EventId); return(false); } _testResultService.SetResultstoState(model.EventId, model.CustomerId, (int)NewTestResultStateNumber.ResultEntryCompleted, false, orgRoleUser.Id); _logger.Info(string.Format("Undo PreAudit Has been marked successfully. Method completed : RevertToPreAudit for CustomerId: {0}, EventId: {1}", model.CustomerId, model.EventId)); return(true); }
public void SetPostAuditEvaluation(PostEvaluationEditModel model) { if (model.IsNewResultflow) { if (model.DoPostAudit) { if (_eventRepository.IsHealthPlanEvent(model.EventId)) { _testResultService.SetResultstoState(model.EventId, model.CustomerId, (int)NewTestResultStateNumber.PostAuditNew, false, model.OrganizationRoleUserId); var eventCustomerResult = _eventCustomerResultRepository.GetByCustomerIdAndEventId(model.CustomerId, model.EventId); if (eventCustomerResult.IsIpResultGenerated) { _eventCustomerResultRepository.UpdateIsIpResultGenerated(eventCustomerResult.Id, false); } } else { _testResultService.SetResultstoState(model.EventId, model.CustomerId, (int)NewTestResultStateNumber.PdfGenerated, false, model.OrganizationRoleUserId); } } else if (model.DoReque) { RevertResultForToPhysicianForEvaluation(model); } else if (model.IsRevertToCoding) { RevertResultForReadyForCoding(model); } else if (model.IsRevertToNp) { RevertResultForNpReevaluation(model); } else if (model.IsRevertToPreAudit) { ResultUndoPreAudit(model); } } else { if (model.DoPostAudit) { _testResultService.SetResultstoState(model.EventId, model.CustomerId, (int)TestResultStateNumber.PostAudit, true, model.OrganizationRoleUserId); } else if (model.DoReque) { _testResultService.SetResultstoState(model.EventId, model.CustomerId, (int)TestResultStateNumber.PostAudit, false, model.OrganizationRoleUserId); } } if (!string.IsNullOrWhiteSpace(model.Message) && model.IsNewResultflow) { _communicationRepository.SaveCommunicationDetails(model.Message, new OrganizationRoleUser(model.OrganizationRoleUserId), model.CustomerId, model.EventId); } _eventCustomerResultRepository.SetEventCustomerPennedBack(model.EventId, model.CustomerId, model.IsPennedBack); }
public ActionResult RollbackToPreviousState(long eventId, long customerId, TestResultStateLabel stateToRevertAt) { bool isPartial; bool isChartSignedOff = true; var number = 0; var isNewResultFlow = _eventRepository.IsEventHasNewResultFlow(eventId); if (isNewResultFlow) { number = (int)((stateToRevertAt).GetNewResultStatefromPresentation(out isPartial, out isChartSignedOff)); } else { number = (int)((stateToRevertAt).GetResultStatefromPresentation(out isPartial)); } _testResultService.SetResultstoState(eventId, customerId, number, isPartial, _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId, isChartSignedOff); return(Content("")); }
public bool SyncReadyForCodingForVisit(EhrReadyforCodingViewModel readyforCodingModel, long orgRoleId, string callingMethod) { try { _logger.Info("calling method " + callingMethod + " from Hra. eventId: " + readyforCodingModel.EventId + " customerId: " + readyforCodingModel.HfCustomerId); var model = new EhrToggleReadyForCodingSyncModel { OrganizationName = _organizationName, AuthToken = DateTime.UtcNow.ToLongTimeString().Encrypt(), ReadyForCodingModel = readyforCodingModel }; var isSynced = false; if (_syncWithHra) { isSynced = _medicareApiService.PostAnonymous <bool>(_medicareApiUrl + MedicareApiUrl.ToggleReadyForCodingForVisit, model); } else { _logger.Info("Sync with HRA is Off"); } _logger.Info("completed calling method " + callingMethod + " eventId: " + readyforCodingModel.EventId + " customerId: " + readyforCodingModel.HfCustomerId + " returned value from Hra : " + isSynced); if (isSynced) { _logger.Info("Sync Success for calling method " + callingMethod + " eventId: " + readyforCodingModel.EventId + " customerId: " + readyforCodingModel.HfCustomerId); _testResultService.SetResultstoState(model.ReadyForCodingModel.EventId, model.ReadyForCodingModel.HfCustomerId, (int)NewTestResultStateNumber.NpSigned, false, orgRoleId); } _logger.Info("completed calling method " + callingMethod + " eventId: " + readyforCodingModel.EventId + " customerId: " + readyforCodingModel.HfCustomerId); return(isSynced); } catch (Exception ex) { _logger.Error("error for calling method " + callingMethod + " eventId: " + readyforCodingModel.EventId + " customerid: " + readyforCodingModel.HfCustomerId); _logger.Error("ex " + ex.Message); _logger.Error("ex " + ex.StackTrace); } return(false); }
public void PollForSendNotification() { try { _logger.Info("Starting the Polling Agent to Send Notification to Nurse Practitioner after evaluation."); var eventCustomerResults = _eventCustomerResultRepository.GetEventCustomerResultByResultState((int)NewTestResultStateNumber.Evaluated, false, _settings.ResultFlowChangeDate); if (eventCustomerResults.IsNullOrEmpty()) { _logger.Info("No record found to send notification."); return; } var cryptographyService = new DigitalDeliveryCryptographyService(); _logger.Info("Total Customer: " + eventCustomerResults.Count()); var appUrl = _settings.AppUrl; var medicareAppUrl = _settings.MedicareAppUrl; foreach (var eventCustomerResult in eventCustomerResults) { try { _logger.Info("sending Notification to Np customer Id: " + eventCustomerResult.CustomerId + "event Id: " + eventCustomerResult.EventId); var eventCustomer = _eventCustomerRepository.GetRegisteredEventForUser(eventCustomerResult.CustomerId, eventCustomerResult.EventId); if (eventCustomer.AwvVisitId.HasValue) { var model = new EhrReadyForReEvaluation { EventId = eventCustomerResult.EventId, HfCustomerId = eventCustomerResult.CustomerId, Message = "", ReadyForReEvaluation = true }; _logger.Info(string.Format("Sending for Sync ready for Reevaluation to HRA for NursePractitionerId: {0} for CustomerId: {1} and EventId: {2}", eventCustomerResult.SignedOffBy.Value, eventCustomerResult.CustomerId, eventCustomerResult.EventId)); var isSynced = _newResultFlowStateService.SyncReadyForEvaluation(model, eventCustomerResult.DataRecorderMetaData.DataRecorderModifier.Id, "Calling from polling agent PollForSendNotification"); if (isSynced) { _logger.Info(string.Format(" Synced Notification send To NP and HRA has been updated NursePractitionerId: {0} for CustomerId: {1} and EventId: {2}", eventCustomerResult.SignedOffBy.Value, eventCustomerResult.CustomerId, eventCustomerResult.EventId)); var orgRoleUser = _organizationRoleUserRepository.GetOrganizationRoleUser(eventCustomerResult.SignedOffBy.Value); var urlTestDocumentation = appUrl + string.Format("/App/Common/Results.aspx?key={0}", cryptographyService.Encrypt(eventCustomerResult.EventId + "~" + eventCustomerResult.CustomerId)); var urlUnlockAssessment = medicareAppUrl + string.Format("/mailauth/{0}", eventCustomer.AwvVisitId); var urlTriggersReadyForCodingStatus = ""; // need to write code for this url variables var notificationModel = _emailNotificationModelsFactory.GetNPfordiagnosingwithlinkNotificationViewModel(eventCustomerResult.CustomerId, eventCustomerResult.EventId, urlTestDocumentation, urlUnlockAssessment, urlTriggersReadyForCodingStatus); _notifier.NotifySubscribersViaEmail(NotificationTypeAlias.NPfordiagnosingwithlinkNotification, EmailTemplateAlias.NPfordiagnosingwithlinkNotification, notificationModel, orgRoleUser.UserId, _RequestedByOrgRoleUserId, "SendNotiificationToNursePractitionerPollingAgent"); _logger.Info(string.Format("Notification sent to NursePractitionerId: {0} for CustomerId: {1} and EventId: {2}", eventCustomerResult.SignedOffBy.Value, eventCustomerResult.CustomerId, eventCustomerResult.EventId)); _testResultService.SetResultstoState(eventCustomerResult.EventId, eventCustomerResult.CustomerId, (int)NewTestResultStateNumber.NpNotificationSent, false, eventCustomerResult.DataRecorderMetaData.DataRecorderModifier.Id); _logger.Info(string.Format(" Result State has been update for CustomerId: {0} and EventId: {1}", eventCustomerResult.CustomerId, eventCustomerResult.EventId)); } _logger.Info(string.Format("Synced To NP and HRA NursePractitionerId: {0} for CustomerId: {1} and EventId: {2} and hra Result {3}", eventCustomerResult.SignedOffBy.Value, eventCustomerResult.CustomerId, eventCustomerResult.EventId, isSynced)); } else { _logger.Error(string.Format("AwvVisitId is null for CustomerId: {0} and EventId: {1}", eventCustomerResult.CustomerId, eventCustomerResult.EventId)); } } catch (Exception ex) { _logger.Error(string.Format("System failure: For NursePractitionerId: {0}, CustomerId: {1} and EventId: {2}", eventCustomerResult.SignedOffBy.Value, eventCustomerResult.CustomerId, eventCustomerResult.EventId)); _logger.Error("Error Message: " + ex.Message); } } } catch (Exception ex) { _logger.Error("Exception occurred on execution of SendNotiificationToNursePractitionerPollingAgent."); _logger.Error("Error Message: " + ex.Message); } }
private void SaveTestResult(TestResult testResult, long eventId, long customerId, long uploadedBy, int resultState, bool isPartial, bool isNewResultFlow) { bool isArtifactSynced = false; if (isNewResultFlow) { var eawvTestResult = testResult as EAwvTestResult; if (resultState >= (int)NewTestResultStateNumber.PostAuditNew) { _logger.Info("file can be parsed as result state is on or above " + NewTestResultStateLabel.PostAudit); return; } if (resultState == (int)NewTestResultStateNumber.CodingCompleted && !CheckMediaNotCompleted(eawvTestResult.ResultImages)) { resultState = (int)NewTestResultStateNumber.ArtifactSynced; isArtifactSynced = true; } else if (resultState < (int)NewTestResultStateNumber.PreAudit) { resultState = (int)NewTestResultStateNumber.ResultEntryPartial; } testResult.ResultStatus = new TestResultState { StateNumber = resultState, Status = resultState > (int)NewTestResultStateNumber.PreAudit && isPartial ? TestResultStatus.Incomplete : TestResultStatus.Complete }; } else { if (resultState >= (int)TestResultStateNumber.PostAudit) { _logger.Info("file can be parsed as result state is on or above " + TestResultStateLabel.PostAudit); return; } testResult.ResultStatus = new TestResultState { StateNumber = resultState >= (int)TestResultStateNumber.PreAudit ? resultState : (int)TestResultStateNumber.ResultsUploaded, Status = resultState > (int)TestResultStateNumber.PreAudit && isPartial ? TestResultStatus.Incomplete : TestResultStatus.Complete }; } testResult.DataRecorderMetaData = new DataRecorderMetaData { DataRecorderCreator = new OrganizationRoleUser(uploadedBy), DateCreated = DateTime.Now }; try { using (var scope = new TransactionScope()) { try { _testResultService.SaveTestResult(testResult, eventId, customerId, uploadedBy, _logger, ReadingSource.Automatic); if (isArtifactSynced) { _testResultServiceForResultState.SetResultstoState(eventId, customerId, resultState, false, uploadedBy); } scope.Complete(); } catch (Exception ex) { _logger.Error("some error occurred while saving result "); _logger.Error("message: " + ex.Message); scope.Dispose(); _logger.Error("Stack trace: " + ex.StackTrace); } } } catch (Exception exception) { _logger.Error(string.Format("Eawv HRA Result Parser SaveTestResult: exceptions- {0}\n StackTrace{1} ", exception.Message, exception.StackTrace)); } }