private async Task <LoginResponse> AuthenticateUser(LoginRequest login)
        {
            LoginResponse response = new LoginResponse();

            if (AppSettings.SuperAdminHospitalCode.ToLower() == login.HospitalCode.ToLower() ||
                await _hospitalService.CheckHospitalCode(login.HospitalCode))
            {
                string userName = AppSettings.SuperAdminHospitalCode.ToLower() == login.HospitalCode.ToLower()
                    ? login.Username
                    : login.HospitalCode + "|" + login.Username;

                login.Username = userName;
                var user = await _usersService.UserNameExists(userName);

                if (user)
                {
                    login.Password = login.Password.Trim();
                    var result = await _usersService.PasswordSignIn(login);

                    if (result.Succeeded)
                    {
                        var userData = await _usersService.GetUserInfoByUserName(userName);

                        userData.Token           = GenerateJSONWebToken(login, userData.UserRoles.ToArray(), userData);
                        response.ResponseData    = userData;
                        response.ResponseCode    = ResponseCodes.Success;
                        response.ResponseMessage = SystemMessagesHelper.UserLoginSuccessfully;
                    }
                    else if (result.IsLockedOut)
                    {
                        response.ResponseCode    = ResponseCodes.InvalidModel;
                        response.ResponseMessage = SystemMessagesHelper.AccountLocked;
                    }
                    else
                    {
                        response.ResponseCode    = ResponseCodes.InvalidModel;
                        response.ResponseMessage = SystemMessagesHelper.UserLoginFailed;
                    }
                }
                else
                {
                    response.ResponseCode    = ResponseCodes.InvalidModel;
                    response.ResponseMessage = SystemMessagesHelper.UserLoginFailed;
                }
            }
            else
            {
                response.ResponseCode    = ResponseCodes.InvalidModel;
                response.ResponseMessage = SystemMessagesHelper.UserLoginFailed;
            }
            return(response);
        }