예제 #1
0
        public void UpdateMedicareVisitStatus(long eventCustomerId, int visitStatus, string sessionId, ISessionContext sessionContext)
        {
            if (!_settings.SyncWithHra)
            {
                return;
            }

            var eventCustomer = _eventCustomerRepository.GetById(eventCustomerId);

            if (eventCustomer.AwvVisitId.HasValue)
            {
                try
                {
                    _medicareApiService.Connect(sessionContext.UserSession.UserLoginLogId);
                }
                catch (Exception)
                {
                    var userSession = sessionContext.UserSession;
                    var token       = (sessionId + "_" + userSession.UserId + "_" + userSession.CurrentOrganizationRole.RoleId + "_" + userSession.CurrentOrganizationRole.OrganizationId).Encrypt();

                    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(sessionContext.UserSession.UserLoginLogId);
                }

                _medicareApiService.Get <bool>(MedicareApiUrl.UpdateVisitStatus + "?visitId=" + eventCustomer.AwvVisitId.Value + "&status=" + visitStatus + "&unlock=true");
            }
        }
예제 #2
0
        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));
            }
        }
예제 #3
0
        private void ExportToMedicareForDeActivateUser(long userId, bool isActive, OrganizationRoleUser[] organizationRoleUser)
        {
            try
            {
                var settings = IoC.Resolve <ISettings>();

                if (settings.SyncWithHra)
                {
                    var canProceed = organizationRoleUser.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 && !isActive)
                    {
                        return;
                    }

                    var token =
                        (Session.SessionID + "_" + _sessionContext.UserSession.UserId + "_" +
                         _sessionContext.UserSession.CurrentOrganizationRole.RoleId + "_" +
                         _sessionContext.UserSession.CurrentOrganizationRole.OrganizationId).Encrypt();



                    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 medicareUserDeActivateModel = _medicareService.DeactivateUserModel(userId, isActive);
                    _medicareApiService.Connect(_sessionContext.UserSession.UserLoginLogId);
                    _medicareApiService.Post <bool>(MedicareApiUrl.ActivateDeactivateUser, medicareUserDeActivateModel);
                }
                else
                {
                    _logger.Info("Sync with HRA is Off");
                }
            }
            catch (Exception exception)
            {
                _logger.Error(
                    string.Format(
                        "Error while Deactivate/Activate user to penguin, \n message: {0} \n stack Trace {1}", exception.Message, exception.StackTrace));
            }
        }
예제 #4
0
        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 ");
            }
        }