예제 #1
0
        public PutPatientUtilizationResponse Put(PutPatientUtilizationRequest request)
        {
            PutPatientUtilizationResponse response = null;
            ValidateTokenResponse result = null;

            try
            {
                request.Token = base.Request.Headers["Token"] as string;
                result = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber);
                if (result.UserId.Trim() != string.Empty)
                {
                    // refactor this validators to a pattern
                    if (string.IsNullOrEmpty(request.Utilization.Id))
                        throw new ArgumentException("Missing utilization id");

                    if (string.IsNullOrEmpty(request.Utilization.PatientId))
                        throw new ArgumentException("Missing patientid");

                    if (string.IsNullOrEmpty(request.Utilization.VisitTypeId))
                        throw new ArgumentException("Missing visittypeid");

                    request.UserId = result.UserId;
                    response = UtilManager.UpdatePatientUtilization(request);
                }
                else
                    throw new UnauthorizedAccessException();
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                    UtilManager.LogException(ex);
            }
            finally
            {
                List<string> patientIds = new List<string>();

                if (response.Result)
                {
                    patientIds.Add(request.PatientId);
                    AuditHelper.LogAuditData(request, result.SQLUserId, patientIds, HttpContext.Current.Request, request.GetType().Name);
                }
            }
            return response;
        }
예제 #2
0
        public PutPatientUtilizationResponse UpdatePatientUtilization(PutPatientUtilizationRequest request)
        {
            try
            {
                var result = new PutPatientUtilizationResponse();

                //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Notes/", "GET")]
                IRestClient client = new JsonServiceClient();
                var         url    = Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Notes/Utilizations/{5}",
                                                                   DdPatientNoteUrl,
                                                                   "NG",
                                                                   request.Version,
                                                                   request.ContractNumber,
                                                                   request.PatientId,
                                                                   request.UtilizationId), request.UserId);

                var ddRequest = new PutPatientUtilizationDataRequest
                {
                    Context            = request.ContractNumber,
                    ContractNumber     = request.ContractNumber,
                    PatientId          = request.PatientId,
                    PatientUtilization = Mapper.Map <PatientUtilizationData>(request.Utilization),
                    UserId             = request.UserId,
                    Version            = request.Version
                };

                PutPatientUtilizationDataResponse ddResponse = client.Put <PutPatientUtilizationDataResponse>(url,
                                                                                                              ddRequest);

                if (ddResponse == null || ddResponse.Status != null)
                {
                    return(result);
                }
                result.Utilization = Mapper.Map <PatientUtilization>(ddResponse.Utilization);
                result.Result      = true;

                return(result);
            }
            catch (WebServiceException ex)
            {
                throw ex;
            }
        }