Example #1
0
        public async Task <Domain.Models.ResponseModels.PaitentAuthModel> GetPersonDetialsByAccountNoAsync(string patientNumber)
        {
            Domain.Models.RequestModels.PaitentAuthModel domainUser = new Domain.Models.RequestModels.PaitentAuthModel();

            SetBaseProperties(domainUser);
            domainUser.AccountNumber = patientNumber;

            // Call REST service
            Domain.Models.ResponseModels.PaitentAuthModel res = await _authService.GetPersonDetialsByAccountNoAsync(domainUser);

            return(res);
        }
Example #2
0
        /// <summary>Searches for a, <c>Person</c> given a specific <paramref name="accountNumber"/>..</summary>
        /// <param name="accountNumber">The Person's account number.</param>
        /// <returns>A <see cref="Domain.Models.ResponseModels.PaitentAuthModel"/> found to have the matching
        /// <paramref name="accountNumber"/>.</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="accountNumber"/>is null <c>or</c> the
        /// <see cref="accountNumber.AccountNumber"/> property is null.</exception>
        /// <exception cref="ArgumentException">If <paramref name="accountNumber.AccountNumber"/>is <c>empty</c>.</exception>
        public async Task <Domain.Models.ResponseModels.PaitentAuthModel> GetPersonDetialsByAccountNoAsync(
            Domain.Models.RequestModels.PaitentAuthModel accountNumber)
        {
            // bool argsAreNotNull = accountNumber?.AccountNumber != null;

            if (null == accountNumber || null == accountNumber.AccountNumber)
            {
                throw new ArgumentNullException(nameof(accountNumber), "Argument: accountNumber can not be null.");
            }

            if (string.IsNullOrWhiteSpace(accountNumber.AccountNumber))
            {
                throw new ArgumentException("Argument: accountNumber can not be null.", nameof(accountNumber));
            }

            Domain.Models.ResponseModels.PaitentAuthModel response = null;

            var basePath   = Settings.GetBaseUrl();
            var apiSegment = "/efr/patient";

            var callingThisUri          = Path.Combine(Settings.GetBaseUrl(), apiSegment);
            var callingThisUriExtraStep = Path.Combine(basePath, apiSegment);

            try
            {
                using (HttpClient client = new HttpClient())
                // using (HttpResponseMessage response = new HttpResponseMessage())
                {
                    // var client = new HttpClient();
                    client.BaseAddress = new Uri(Settings.GetBaseUrl());
                    var data    = JsonConvert.SerializeObject(accountNumber);
                    var content = new StringContent(data, Encoding.UTF8, "application/json");

                    // Search for a specific Person (patient) by Account Number.
                    HttpResponseMessage result =
                        await client.PostAsync(Settings.GetBaseUrl() + "/efr/patient", content).ConfigureAwait(false);

                    response = JsonConvert.DeserializeObject <Domain.Models.ResponseModels.PaitentAuthModel>(
                        result.Content.ReadAsStringAsync().Result);

                    // TODO; Move this
                    content.Dispose();
                }
            }
            catch (Exception erf)
            {
                Debug.Write(erf);
            }

            return(response);
        }