Пример #1
0
        public void InitializePatientAllergy_Test()
        {
            PostInitializePatientAllergyRequest request = new PostInitializePatientAllergyRequest {
                AllergyId      = "54489a3efe7a59146485bb05",
                Context        = context,
                ContractNumber = contractNumber,
                PatientId      = "54087f43d6a48509407d69cb",
                UserId         = userId,
                Version        = version
            };

            JsonServiceClient.HttpWebRequestFilter = x => x.Headers.Add(string.Format("{0}: {1}", "Token", token));
            //[Route("/{Version}/{ContractNumber}/PatientAllergy/{PatientId}/Initialize", "GET")]
            PostInitializePatientAllergyResponse response = client.Post <PostInitializePatientAllergyResponse>(
                string.Format("{0}/{1}/{2}/PatientAllergy/Initialize", url, version, contractNumber), request);

            Assert.IsNotNull(response);
        }
Пример #2
0
        public PostInitializePatientAllergyResponse Post(PostInitializePatientAllergyRequest request)
        {
            PostInitializePatientAllergyResponse response = new PostInitializePatientAllergyResponse();
            ValidateTokenResponse result = null;

            try
            {
                if (base.Request != null)
                {
                    request.Token = base.Request.Headers["Token"] as string;
                }
                result = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber);
                if (result.UserId.Trim() != string.Empty)
                {
                    request.UserId          = result.UserId;
                    response.PatientAllergy = AllergyManager.InitializePatientAllergy(request);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    AllergyManager.LogException(ex);
                }
            }
            finally
            {
                List <string> patientIds = new List <string>();
                patientIds.Add(request.PatientId);
                if (result != null)
                {
                    string browser     = (base.Request != null) ? base.Request.UserAgent : unknownBrowserType;
                    string hostAddress = (base.Request != null) ? base.Request.UserHostAddress : unknownUserHostAddress;
                    AuditUtil.LogAuditData(request, result.SQLUserId, patientIds, browser, hostAddress, request.GetType().Name);
                }
            }
            return(response);
        }