Ejemplo n.º 1
0
        public PatientAllergyData InitializePatientAllergy(PostInitializePatientAllergyRequest request)
        {
            try
            {
                PatientAllergyData result = null;
                IRestClient        client = new JsonServiceClient();
                //[Route("/{Version}/{ContractNumber}/PatientAllergy/Initialize", "POST")]
                var url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/PatientAllergy/Initialize",
                                                               DDAllergyUrl,
                                                               "NG",
                                                               request.Version,
                                                               request.ContractNumber), request.UserId);

                PutInitializePatientAllergyDataResponse dataDomainResponse = client.Put <PutInitializePatientAllergyDataResponse>(url, new PutInitializePatientAllergyDataRequest
                {
                    Context        = "NG",
                    ContractNumber = request.ContractNumber,
                    PatientId      = request.PatientId,
                    AllergyId      = request.AllergyId,
                    SystemName     = Constants.SystemName,
                    UserId         = request.UserId,
                    Version        = request.Version
                } as object);

                if (dataDomainResponse != null)
                {
                    result = dataDomainResponse.PatientAllergyData;
                }
                return(result);
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:InitializePatientAllergy()::" + ex.Message, ex.InnerException);
            }
        }
Ejemplo n.º 2
0
        public PatientAllergy InitializePatientAllergy(PostInitializePatientAllergyRequest request)
        {
            PatientAllergy patientAllergy = null;

            try
            {
                PatientAllergyData data = EndpointUtil.InitializePatientAllergy(request);
                if (data != null)
                {
                    patientAllergy = Mapper.Map <PatientAllergy>(data);
                }
                return(patientAllergy);
            }
            catch (Exception ex) { throw ex; }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }