public GetMedFieldsResponse Get(GetMedFieldsRequest request) { GetMedFieldsResponse response = new GetMedFieldsResponse(); 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) { request.UserId = result.UserId; var results = SearchManager.GetSearchMedFieldsResults(request); response.DosageForms = results.FormList; response.Routes = results.RouteList; response.Strengths = results.StrengthList; response.Units = results.UnitsList; } else { throw new UnauthorizedAccessException(); } } catch (Exception ex) { CommonFormatterUtil.FormatExceptionResponse(response, base.Response, ex); if ((ex is WebServiceException) == false) { SearchManager.LogException(ex); } } finally { if (result != null) { string browser = (base.Request != null) ? base.Request.UserAgent : unknownBrowserType; string hostAddress = (base.Request != null) ? base.Request.UserHostAddress : unknownUserHostAddress; AuditUtil.LogAuditData(request, result.SQLUserId, null, browser, hostAddress, request.GetType().Name); } } return(response); }
public void GetPatientMedSupps_Test() { GetMedFieldsRequest request = new GetMedFieldsRequest { ContractNumber = contractNumber, UserId = userId, Version = version }; JsonServiceClient.HttpWebRequestFilter = x => x.Headers.Add(string.Format("{0}: {1}", "Token", token)); //[Route("/{Version}/{ContractNumber}/Search/Meds/Fields", "GET")] GetMedFieldsResponse response = client.Get <GetMedFieldsResponse>(string.Format("{0}/{1}/{2}/Search/Meds/Fields?Name={3}", url, version, contractNumber, "JAIPUR")); Assert.IsNotNull(response); }