public async Task <SurveyLinkViewModel> SurveyLinkBuilder(OutcomeViewModel model)
        {
            var jsonParser            = new JourneyJsonParser(model.JourneyJson);
            var businessApiPathwayUrl = _configuration.GetBusinessApiPathwayIdUrl(jsonParser.LastPathwayNo, model.UserInfo.Demography.Gender, model.UserInfo.Demography.Age);
            var response = await _restClient.ExecuteAsync <Pathway>(new JsonRestRequest(businessApiPathwayUrl, Method.GET));

            CheckResponse(response);

            var pathway         = response.Data;
            var resultingDxCode = model.Is999Callback ? FromOutcomeViewModelToDosViewModel.DispositionResolver.Remap(model.Id) : model.Id;
            var result          = new SurveyLinkViewModel
            {
                DispositionCode             = model.Id,
                DispositionDateTime         = model.DispositionTime,
                EndPathwayNo                = (pathway != null) ? pathway.PathwayNo : string.Empty,
                EndPathwayTitle             = (pathway != null) ? pathway.Title : string.Empty,
                JourneyId                   = model.JourneyId.ToString(),
                SessionId                   = model.SessionId,
                PathwayNo                   = model.PathwayNo,
                DigitalTitle                = model.DigitalTitle,
                Campaign                    = model.Campaign,
                CampaignSource              = model.Source,
                ValidationCallbackOffered   = model.HasAcceptedCallbackOffer.HasValue,
                GuidedSelection             = GetGuidedSelectionParameterFrom(model),
                RecommendedServiceTypeAlias = ServiceViewModel.GetServiceTypeAliasValue(model),
                StartUrl                    = model.StartParameter
            };

            var isPharmacyPathway = result.EndPathwayNo == "PW1827";

            result.SurveyId = isPharmacyPathway ? _surveyLinkFeature.PharmacySurveyId : _surveyLinkFeature.SurveyId;
            AddServiceInformation(model, result);

            model.SurveyLink = result;
            AddEmbeddedDataInformation(model, result);

            return(result);
        }
        private async Task <JustToBeSafeViewModel> BuildIdentifiedModel(JustToBeSafeViewModel model)
        {
            var pathway = JsonConvert.DeserializeObject <Pathway>(await _restfulHelper.GetAsync(_configuration.GetBusinessApiPathwayIdUrl(model.PathwayNo, model.UserInfo.Demography.Gender, model.UserInfo.Demography.Age)));

            if (pathway == null)
            {
                return(null);
            }

            model.PathwayId         = pathway.Id;
            model.PathwayTitle      = pathway.Title;
            model.PathwayNo         = pathway.PathwayNo;
            model.State             = JourneyViewModelStateBuilder.BuildState(model.UserInfo.Demography.Gender, model.UserInfo.Demography.Age, model.State);
            model.StateJson         = JourneyViewModelStateBuilder.BuildStateJson(model.State);
            model.CollectedKeywords = new KeywordBag(_keywordCollector.ParseKeywords(pathway.Keywords, false).ToList(), _keywordCollector.ParseKeywords(pathway.ExcludeKeywords, false).ToList());
            return(model);
        }
Ejemplo n.º 3
0
        private async Task <JustToBeSafeViewModel> BuildIdentifiedModel(JustToBeSafeViewModel model)
        {
            var response = await _restClient.ExecuteAsync <Pathway>(new JsonRestRequest(_configuration.GetBusinessApiPathwayIdUrl(model.PathwayNo, model.UserInfo.Demography.Gender, model.UserInfo.Demography.Age), Method.GET));

            CheckResponse(response);

            if (response.Data == null)
            {
                return(null);
            }

            var pathway = response.Data;

            model.PathwayId         = pathway.Id;
            model.PathwayTitle      = pathway.Title;
            model.PathwayNo         = pathway.PathwayNo;
            model.PathwayTraumaType = pathway.TraumaType;
            model.State             = JourneyViewModelStateBuilder.BuildState(model.UserInfo.Demography.Gender, model.UserInfo.Demography.Age, model.State);
            model.StateJson         = JourneyViewModelStateBuilder.BuildStateJson(model.State);
            model.CollectedKeywords = new KeywordBag(_keywordCollector.ParseKeywords(pathway.Keywords, false).ToList(), _keywordCollector.ParseKeywords(pathway.ExcludeKeywords, false).ToList());
            return(model);
        }