Example #1
0
        public PostPatientAllergiesResponse Post(PostPatientAllergiesRequest request)
        {
            PostPatientAllergiesResponse response = new PostPatientAllergiesResponse();
            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.PatientAllergies = AllergyManager.UpdatePatientAllergies(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 = null;
                if (request.PatientAllergies != null && request.PatientAllergies.Count > 0)
                {
                    patientIds = new List <string>();
                    request.PatientAllergies.ForEach(p =>
                    {
                        patientIds.Add(p.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);
        }
Example #2
0
        public GetAllergiesResponse Get(GetAllergiesRequest request)
        {
            GetAllergiesResponse  response = new GetAllergiesResponse();
            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.Allergies = AllergyManager.GetAllergies(request);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatterUtil.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    AllergyManager.LogException(ex);
                }
            }
            finally
            {
                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, null, browser, hostAddress, request.GetType().Name);
                }
            }

            return(response);
        }