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; }