private void ExportToMedicare(UserEditModel userEditModel, List <string> removedRoleAlias) { try { var canProceed = userEditModel.UsersRoles.Any( x => x.RoleId == (long)Roles.CallCenterRep || x.RoleId == (long)Roles.Technician || x.RoleId == (long)Roles.NursePractitioner || x.RoleId == (long)Roles.Coder || x.RoleId == (long)Roles.MedicalVendorUser); if (!canProceed && removedRoleAlias != null && !removedRoleAlias.Any()) { return; } var roleIds = userEditModel.UsersRoles.Select(x => x.RoleId).ToList(); var roles = _roleRepository.GetByRoleIds(roleIds); //var existRole=_roleRepository. var defaultRole = userEditModel.UsersRoles.FirstOrDefault(x => x.IsDefault); var defaultRoleAlias = ""; defaultRoleAlias = defaultRole != null?roles.First(x => x.Id == defaultRole.RoleId).Alias : roles.First().Alias; var token = (Session.SessionID + "_" + _sessionContext.UserSession.UserId + "_" + _sessionContext.UserSession.CurrentOrganizationRole.RoleId + "_" + _sessionContext.UserSession.CurrentOrganizationRole.OrganizationId).Encrypt(); var settings = IoC.Resolve <ISettings>(); if (settings.SyncWithHra) { var auth = new MedicareAuthenticationModel { UserToken = token, CustomerId = 0, OrgName = settings.OrganizationNameForHraQuestioner, Tag = settings.OrganizationNameForHraQuestioner, IsForAdmin = true, RoleAlias = "CallCenterRep" }; _medicareApiService.PostAnonymous <string>(settings.MedicareApiUrl + MedicareApiUrl.AuthenticateUser, auth); var medicareUserEditModel = _medicareService.CreateUserEditModel(userEditModel, defaultRoleAlias, roles.Select(x => x.Alias), removedRoleAlias); _medicareApiService.Connect(_sessionContext.UserSession.UserLoginLogId); _medicareApiService.Post <bool>(MedicareApiUrl.CreateUpdateUserForEhr, medicareUserEditModel); } else { _logger.Info("Sync with HRA is Off"); } } catch (Exception exception) { _logger.Error( string.Format( "Error while Exproting to penguin, \n message: {0} \n stack Trace {1}", exception.Message, exception.StackTrace)); } }
public JsonResult UpdateCustomerVisitInfo(string guid, long visitId) { if (!_settings.SyncWithHra) { return(Json(new { Result = false }, JsonRequestBehavior.DenyGet)); } if (string.IsNullOrEmpty(guid) || Session[guid] == null) { return(Json(new { Result = false }, JsonRequestBehavior.DenyGet)); } var registrationFlowModel = (RegistrationFlowModel)Session[guid]; registrationFlowModel.AwvVisitId = visitId; var account = _corporateAccountRepository.GetbyEventId(registrationFlowModel.EventId); if (account != null) { var theEvent = _eventRepository.GetById(registrationFlowModel.EventId); _medicareApiService.Connect(_sessionContext.UserSession.UserLoginLogId); _medicareApiService.Post <long>(MedicareApiUrl.EventInfoUpdateUrl, new MedicareEventEditModel { EventId = registrationFlowModel.EventId, Tag = account.Tag, VisitId = visitId, VisitDate = theEvent.EventDate }); } return(Json(new { Result = true }, JsonRequestBehavior.DenyGet)); }
public void SaveCheckListAnswer(CheckListAnswerEditModel model, long orgUserId, long userLoginLogId, string token) { if (model.Answers.IsNullOrEmpty()) { return; } var eventCustomer = ((IUniqueItemRepository <EventCustomer>)_eventCustomerRepository).GetById(model.EventCustomerId); var lastestVersion = model.Version; if (model.Version == 0) { lastestVersion = _checkListAnswerRepository.GetLatestVersion(model.EventCustomerId); } if (model.Answers.IsNullOrEmpty()) { return; } var checklistAnswer = new List <CheckListAnswer>(); foreach (var answer in model.Answers) { checklistAnswer.Add(new CheckListAnswer { Answer = answer.Answer, QuestionId = answer.QuestionId, Version = lastestVersion + 1, Id = model.EventCustomerId, IsActive = true, DataRecorderMetaData = new DataRecorderMetaData(orgUserId, DateTime.Now, null), Type = (long)CheckListType.CheckList }); } _checkListAnswerRepository.SaveAnswer(checklistAnswer); try { var result = _eventCustomerResultRepository.GetById(model.EventCustomerId); if (token != "" && (result == null || result.ResultState < (long)TestResultStateNumber.PreAudit)) { var questionIds = model.Answers.Where(x => TestQuestionList.Contains(x.QuestionId)).Select(x => x.QuestionId); if (!questionIds.IsNullOrEmpty()) { var testIdsToBeUpdated = GetStandingOrderTest(questionIds); if (!testIdsToBeUpdated.IsNullOrEmpty()) { UpdateCustomerOrder(eventCustomer.EventId, eventCustomer.CustomerId, testIdsToBeUpdated, orgUserId); } } } } catch (Exception ex) { _logger.Error(string.Format("Some Error Occurred While Customer Updating Order. Exception Message {0} \t\n Stack Trace: {1}", ex.Message, ex.StackTrace)); } if (_settings.SyncWithHra) { if (token != "") { try { var visitId = _eventCustomerRepository.GetById(model.EventCustomerId).AwvVisitId; if (visitId.HasValue) { var answers = new MedicareStandingOrderViewModel { PatientVisitId = visitId.Value, Version = lastestVersion + 1, IsSync = true, Questions = model.Answers.Select(answer => new MedicareCheckListQuestionViewModel { Answer = answer.Answer, QuestionId = answer.QuestionId }).ToList() }; try { _medicareApiService.Connect(userLoginLogId); } catch (Exception) { var auth = new MedicareAuthenticationModel { UserToken = token, CustomerId = 0, OrgName = _settings.OrganizationNameForHraQuestioner, Tag = _settings.OrganizationNameForHraQuestioner, IsForAdmin = false, RoleAlias = "CallCenterRep" }; _medicareApiService.PostAnonymous <string>(_settings.MedicareApiUrl + MedicareApiUrl.AuthenticateUser, auth); _medicareApiService.Connect(userLoginLogId); } _medicareApiService.Post <bool>(MedicareApiUrl.SaveCheckList, answers); } } catch (Exception ex) { _logger.Error(string.Format("Some Error Occured Whicle Saving Checklist Answer To MEDICARE\n Exception Message {0} \t\n Stack Trace: {1}", ex.Message, ex.StackTrace)); } } } else { _logger.Info("Syncing with HRA is off "); } }
private string GetSession(string[] userData, bool isPopupOpened = false) { var userId = Convert.ToInt64(userData[1]); var user = _userRepository.GetUser(userId); var userName = user.UserLogin.UserName; FormsAuthentication.SetAuthCookie(userName, true); _sessionContext.UserSession = _loginService.GetUserSessionModel(userName); if (_sessionContext.UserSession.CurrentOrganizationRole == null) { throw new Exception("Your default role has been removed. Please contact your administrator."); } //Code Removed as it was redundant hit to Database //var loggedInUser = _userRepository.GetUser(userId); //_sessionContext.UserSession = _loginService.GetUserSessionModel(userId); //_loginOtpService.ResetOtp(loggedInUser.Id); _sessionContext.LastLoggedInTime = user.UserLogin.LastLogged.ToString(); _loginRepository.UpdateLoginStatus(_sessionContext.UserSession.UserId, true); var browserName = Request.Browser.Browser + " " + Request.Browser.Version; string sessionId = ""; var loginLog = new UserLoginLog(); var roles = _roleRepository.GetRolesByAlias(userData[0]); roles = roles.Where(x => x.ParentId == null); var role = roles.First(); var availableRole = _sessionContext.UserSession.AvailableOrganizationRoles.FirstOrDefault(x => x.RoleId == role.Id); if (availableRole == null) { throw new Exception("Your role is not available in HIP. Please contact your administrator."); } if (!isPopupOpened) { loginLog = _loginService.GetLatestUserLogin(userId); if (loginLog == null) //if no login present then we'll login the user in case of NON-POPUP request logins { sessionId = RegenrateSessionId(); MedicareLoginTask(user, sessionId, browserName, role, availableRole); } else { _sessionContext.UserSession.UserLoginLogId = loginLog.Id; sessionId = loginLog.BrowserSession; //if old login is found then use old session id too } } else { sessionId = RegenrateSessionId(); MedicareLoginTask(user, sessionId, browserName, role, availableRole); } // send the EHR Session to Medicare var token = (sessionId + "_" + _sessionContext.UserSession.UserId + "_" + _sessionContext.UserSession.CurrentOrganizationRole.RoleId + "_" + _sessionContext.UserSession.CurrentOrganizationRole.OrganizationId).Encrypt(); var auth = new MedicareUpdateTokenModel { Token = token, SessionId = sessionId }; if (_settings.SyncWithHra) { _medicareApiService.Post <string>(_settings.MedicareApiUrl + MedicareApiUrl.SetEhrToken, auth); } return(JsonConvert.SerializeObject(auth)); }