/// <summary> /// Returns list of selection answer sets which matches to search criteria. /// </summary> /// <param name="searchModel"></param> /// <returns></returns> public async Task <IEnumerable <UpdateSelectionAnswerSetViewModel> > FindSelectionAnswerSets( SearchCareElementsViewModel searchModel) { var searchRequest = new SearchSelectionRequestDto { IsMultipleChoice = false, Q = searchModel.Keyword, CustomerId = CustomerContext.Current.Customer.Id }; var result = await this.healthLibraryService .FindSelectionAnswerSets( searchRequest, authDataStorage.GetToken() ); return(result.Select(Mapper.Map <UpdateSelectionAnswerSetViewModel>).ToList()); }
/// <summary> /// Loads list of selection answer sets from health library. /// </summary> /// <param name="request"></param> /// <param name="token"></param> /// <returns></returns> public async Task <IList <SelectionAnswerSetResponseDto> > FindSelectionAnswerSets(SearchSelectionRequestDto request, string token) { var url = string.Format("/api/{0}/answer-sets/selection", request.CustomerId); var pagedResult = await this.apiClient.SendRequestAsync <PagedResult <SelectionAnswerSetResponseDto> >( url, request, Method.GET, null, token); return(pagedResult.Results); }
/// <summary> /// Finds the answer sets. /// </summary> /// <param name="searchAnswerSetModel">The search answer set model.</param> /// <returns></returns> public async Task <SearchAnswerSetResultDto> FindAnswerSets(SearchAnswerSetViewModel searchAnswerSetModel) { var searchResult = new SearchAnswerSetResultDto() { SelectionAnswerSets = new List <UpdateSelectionAnswerSetViewModel>(), ScaleAnswerSets = new List <SearchScaleAnswerSetResultViewModel>() }; var searchScaleAnswersetRequest = new SearchRequestDto() { CustomerId = this.customerContext.Customer.Id, Q = searchAnswerSetModel.Keyword, Tags = new string[] { searchAnswerSetModel.Tag } }; var searchSelectionAnswerSetRequest = new SearchSelectionRequestDto() { CustomerId = this.customerContext.Customer.Id, Q = searchAnswerSetModel.Keyword, Tags = new[] { searchAnswerSetModel.Tag }, IsMultipleChoice = false }; var searchCheckListAnswerSetRequest = new SearchSelectionRequestDto() { CustomerId = this.customerContext.Customer.Id, Q = searchAnswerSetModel.Keyword, Tags = new[] { searchAnswerSetModel.Tag }, IsMultipleChoice = true }; string authToken = this.authDataStorage.GetToken(); if (searchAnswerSetModel.SearchAnswerSetType == SearchAnswerSetType.All) { var mappedSelectionAnswerSets = (await this.healthLibraryService.FindSelectionAnswerSets(searchSelectionAnswerSetRequest, authToken)) .Select(Mapper.Map <UpdateSelectionAnswerSetViewModel>); searchResult.SelectionAnswerSets.AddRange(mappedSelectionAnswerSets); var mappedChecklistAnswerSets = (await this.healthLibraryService.FindSelectionAnswerSets(searchCheckListAnswerSetRequest, authToken)) .Select(Mapper.Map <UpdateSelectionAnswerSetViewModel>); searchResult.SelectionAnswerSets.AddRange(mappedChecklistAnswerSets); var mappedScaleAnswerSets = (await this.healthLibraryService.FindScaleAnswerSets(searchScaleAnswersetRequest, authToken)).Select (Mapper.Map <SearchScaleAnswerSetResultViewModel>); searchResult.ScaleAnswerSets.AddRange(mappedScaleAnswerSets); } else if (searchAnswerSetModel.SearchAnswerSetType == SearchAnswerSetType.CheckList) { var mappedChecklistAnswerSets = (await this.healthLibraryService.FindSelectionAnswerSets(searchCheckListAnswerSetRequest, authToken)) .Select(Mapper.Map <UpdateSelectionAnswerSetViewModel>); searchResult.SelectionAnswerSets.AddRange(mappedChecklistAnswerSets); } else if (searchAnswerSetModel.SearchAnswerSetType == SearchAnswerSetType.MultipleChoice) { var mappedSelectionAnswerSets = (await this.healthLibraryService.FindSelectionAnswerSets(searchSelectionAnswerSetRequest, authToken)) .Select(Mapper.Map <UpdateSelectionAnswerSetViewModel>); searchResult.SelectionAnswerSets.AddRange(mappedSelectionAnswerSets); } else if (searchAnswerSetModel.SearchAnswerSetType == SearchAnswerSetType.ScaleAnswerSet) { var scaleAnswerSets = await this.healthLibraryService.FindScaleAnswerSets(searchScaleAnswersetRequest, authToken); var mappedScaleAnswerSets = scaleAnswerSets.Select(Mapper.Map <SearchScaleAnswerSetResultViewModel>); searchResult.ScaleAnswerSets.AddRange(mappedScaleAnswerSets); } return(searchResult); }
/// <summary> /// Returns list of scale answer sets matches to search criteria. /// </summary> /// <param name="searchRequest"></param> /// <param name="token"></param> /// <returns></returns> public async Task <IList <SelectionAnswerSetResponseDto> > FindSelectionAnswerSets(SearchSelectionRequestDto searchRequest, string token) { return(await this.healthLibraryDataProvider.FindSelectionAnswerSets(searchRequest, token)); }