///// <summary> ///// Example to return a HttpResult object with a decorated response. ///// </summary> ///// <param name="request">GetPatientUtilizationRequest</param> ///// <returns>object</returns> //public object Get(GetPatientUtilizationRequest request) //{ // GetPatientUtilizationResponse 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) // { // request.UserId = result.UserId; // response = UtilManager.GetPatientUtilization(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.Utilization != null) // patientIds.Add(response.Utilization.PatientId); // if (result != null) // AuditHelper.LogAuditData(request, result.SQLUserId, patientIds, HttpContext.Current.Request, request.GetType().Name); // } // return new HttpResult(response, HttpStatusCode.OK) // { // StatusDescription = "this is really cool!", // Location = "www.google.com" // }; //} public GetPatientUtilizationResponse Get(GetPatientUtilizationRequest request) { GetPatientUtilizationResponse 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) { request.UserId = result.UserId; response = UtilManager.GetPatientUtilization(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.Utilization != null) patientIds.Add(response.Utilization.PatientId); if (result != null) AuditHelper.LogAuditData(request, result.SQLUserId, patientIds, HttpContext.Current.Request, request.GetType().Name); } return response; }
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; }