Exemplo n.º 1
0
        public GetMedNamesResponse Get(GetMedNamesRequest request)
        {
            GetMedNamesResponse   response = new GetMedNamesResponse();
            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 res   = SearchManager.GetSearchMedNameResults(request);
                    var count = res.Count;
                    if (request.Take > 0 && res.Count > request.Take)
                    {
                        res = res.Take(request.Take).ToList();
                        response.Message = request.Take + " out of " + count + ". Please refine your search.";
                    }

                    response.ProprietaryNames = res;
                }
                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);
        }
Exemplo n.º 2
0
 public List <TextValuePair> GetSearchMedNameResults(GetMedNamesRequest request)
 {
     try
     {
         var matches = EndpointUtil.GetTermSearchResults(request, SearchEnum.Medication, request.Term).Cast <TextValuePair>().ToList();
         matches.All(x => { x.Text = x.Text.Trim(); return(true); });
         var groupby = matches.GroupBy(a => a.Text).Select(s => s.First()).ToList();
         var result  = groupby;
         return(result);
     }
     catch (WebServiceException ex)
     {
         throw new WebServiceException("AD:GetSearchAllergyResults()::" + ex.Message, ex.InnerException);
     }
 }