コード例 #1
0
        public GetPatientSystemsResponse Get(GetPatientSystemsRequest request)
        {
            GetPatientSystemsResponse response = new GetPatientSystemsResponse();
            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)
                {
                    ServiceContext.UserId   = result.UserId;
                    response.PatientSystems = PatientSystemManager.GetPatientSystems(ServiceContext, request.PatientId);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatterUtil.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    PatientSystemManager.LogException(ex);
                }
            }
            finally
            {
                if (result != null)
                {
                    List <string> patientIds = null;
                    if (response.PatientSystems != null)
                    {
                        patientIds = response.PatientSystems.Select(x => x.PatientId).ToList();
                    }
                    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);
        }
コード例 #2
0
        public void GetPatientSystems_Test()
        {
            GetPatientSystemsRequest request = new GetPatientSystemsRequest
            {
                ContractNumber = contractNumber,
                UserId         = userId,
                Version        = version,
                Token          = token,
                PatientId      = "5325dacad6a4850adcbba756"
            };

            JsonServiceClient.HttpWebRequestFilter = x =>
                                                     x.Headers.Add(string.Format("{0}: {1}", "Token", token));

            //[Route("/{Version}/{ContractNumber}/Patient/{PatientId}PatientSystems", "GET")]
            GetPatientSystemsResponse response = client.Get <GetPatientSystemsResponse>(string.Format("{0}/{1}/{2}/Patient/{3}/PatientSystems", url, version, contractNumber, request.PatientId));

            Assert.IsNotNull(response);
        }