public PostPatientUtilizationResponse Post(PostPatientUtilizationRequest request) { PostPatientUtilizationResponse 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) { if (string.IsNullOrEmpty(request.Utilization.PatientId)) throw new Exception("Missing patientid"); if (string.IsNullOrEmpty(request.Utilization.VisitTypeId)) throw new Exception("Missing visittypeid"); request.UserId = result.UserId; response = UtilManager.InsertPatientUtilization(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; }