public JourneyViewModel BuildGender(JourneyViewModel model)
        {
            //if (HttpContext.Current.Session != null)
            //    SessionWrapper.NHSUserGuid = Guid.NewGuid().ToString();

            return model;
        }
        public bool Equals(JourneyViewModel x, JourneyViewModel y)
        {
            //a lot of these checks can be pulled out into their respective types
            if (x == null && y == null)
            {
                return(true);
            }

            if (x == null || y == null)
            {
                return(false);
            }

            if (ComparePathwayNo && x.PathwayNo != y.PathwayNo)
            {
                return(false);
            }

            if (CompareAge && !AgeEquals(x.UserInfo, y.UserInfo))
            {
                return(false);
            }

            if (CompareSex && !SexEquals(x.UserInfo, y.UserInfo))
            {
                return(false);
            }

            if ((!CompareQuestionNos && !CompareAnswers))
            {
                return(true); //we're done
            }
            return(JourneysEquals(x.Journey, y.Journey));
        }
 public PageResultViewModel(JourneyViewModel journeyViewModel) : base(journeyViewModel)
 {
     if (isNHSUKStyle())
     {
         _viewName = "../Question/Custom/NHSUKPage";
     }
     _viewName = "../Question/Page";
 }
 public async Task<ActionResult> JustToBeSafeFirst(JourneyViewModel model)
 {
     var newModel = new JustToBeSafeViewModel
     {
         PathwayId = model.PathwayId,
         UserInfo = model.UserInfo
     };
     return await JustToBeSafeFirst(newModel);
 }
        public async Task<Tuple<string, JourneyViewModel>> BuildNextAction(List<QuestionWithAnswers> questions, Journey journey, JustToBeSafeViewModel model, Answer selectedAnswer, QuestionWithAnswers selectedQuestion, string questionsJson)
        {
            if (!questions.Any())
            {
                journey.Steps = journey.Steps.Where(step => step.QuestionId != model.SelectedQuestionId).ToList();
                var journeyViewModel = new JourneyViewModel
                {
                    PathwayId = model.PathwayId,
                    PathwayNo = model.PathwayNo,
                    PathwayTitle = model.PathwayTitle,
                    SymptomDiscriminator = model.SymptomDiscriminator,
                    UserInfo = model.UserInfo,
                    JourneyJson = JsonConvert.SerializeObject(journey),
                    SelectedAnswer = JsonConvert.SerializeObject(selectedAnswer),
                };

                _mappingEngine.Map(selectedQuestion, journeyViewModel);
                journeyViewModel = _mappingEngine.Map(selectedAnswer, journeyViewModel);
                
                return await _questionViewModelBuilder.BuildQuestion(journeyViewModel);
            }

            if (questions.Count() == 1)
            {
                var journeyViewModel = new JourneyViewModel
                {
                    PathwayId = model.PathwayId,
                    PathwayNo = model.PathwayNo,
                    PathwayTitle = model.PathwayTitle,
                    UserInfo = model.UserInfo,
                    JourneyJson = JsonConvert.SerializeObject(journey),
                };

                _mappingEngine.Map(questions.First(), journeyViewModel);
                journeyViewModel = _mappingEngine.Map(selectedAnswer, journeyViewModel);

                return new Tuple<string, JourneyViewModel>("../Question/Question", journeyViewModel);
            }

            var viewModel = new JustToBeSafeViewModel
            {
                PathwayId = model.PathwayId,
                PathwayNo = model.PathwayNo,
                PathwayTitle = model.PathwayTitle,
                JourneyJson = JsonConvert.SerializeObject(journey),
                SymptomDiscriminator = selectedAnswer.SymptomDiscriminator ?? model.SymptomDiscriminator,
                Part = model.Part + 1,
                Questions = questions,
                QuestionsJson = questionsJson,
                UserInfo = model.UserInfo
            };

            return new Tuple<string, JourneyViewModel>("JustToBeSafe", viewModel);

        }
 public async Task<JourneyViewModel> BuildSlider(JourneyViewModel model)
 {
     var pathway = JsonConvert.DeserializeObject<Pathway>(await _restfulHelper.GetAsync(string.Format(_configuration.BusinessApiPathwayIdUrl, model.PathwayNo, model.UserInfo.Gender, model.UserInfo.Age)));
     model.PathwayId = pathway.Id;
     model.PathwayTitle = pathway.Title;
     model.PathwayNo = pathway.PathwayNo;
     model.State.Add("PATIENT_AGE", model.UserInfo.Age.ToString());
     model.State.Add("PATIENT_GENDER", string.Format("\"{0}\"", model.UserInfo.Gender.First().ToString().ToUpper()));
     model.State.Add("PATIENT_PARTY", "1");
     model.StateJson = JsonConvert.SerializeObject(model.State);
     return model;
 }
 public async Task<ActionResult> JustToBeSafe(JourneyViewModel model)
 {
     var sliderModel = await _questionViewModelBuilder.BuildSlider(model);
     var justToBeSafeViewModel = new JustToBeSafeViewModel
     {
         PathwayId = sliderModel.PathwayId,
         PathwayNo = sliderModel.PathwayNo,
         PathwayTitle = sliderModel.PathwayTitle,
         UserInfo = sliderModel.UserInfo
     };
     var next = await _justToBeSafeFirstViewModelBuilder.JustToBeSafeFirstBuilder(justToBeSafeViewModel);
     return View(next.Item1, next.Item2);
 }
Пример #8
0
 public PageDataViewModel(PageType page, JourneyViewModel journey)
 {
     Page                 = page;
     Campaign             = journey.Campaign;
     Source               = journey.Source;
     Gender               = journey.UserInfo.Demography.Gender;
     Age                  = journey.UserInfo.Demography.Age.ToString();
     SearchString         = journey.EntrySearchTerm;
     QuestionId           = journey.Id;
     TxNumber             = !string.IsNullOrEmpty(journey.QuestionNo) && journey.QuestionNo.ToLower().StartsWith("tx") ? journey.QuestionNo : null;
     StartingPathwayNo    = journey.PathwayNo;
     StartingPathwayTitle = journey.PathwayTitle;
     DxCode               = !string.IsNullOrEmpty(journey.Id) && journey.Id.ToLower().StartsWith("dx") ? journey.Id : null;
 }
        public async Task<Tuple<string, JourneyViewModel>> BuildQuestion(JourneyViewModel model)
        {
            model.PreviousTitle = model.Title;
            model.PreviousStateJson = model.StateJson;
            var answer = JsonConvert.DeserializeObject<Answer>(model.SelectedAnswer);
            var journey = JsonConvert.DeserializeObject<Journey>(model.JourneyJson);
            journey.Steps.Add(new JourneyStep { QuestionNo = model.QuestionNo, QuestionTitle = model.Title, Answer = answer, QuestionId = model.Id });
            model.JourneyJson = JsonConvert.SerializeObject(journey);
            model.State = JsonConvert.DeserializeObject<Dictionary<string, string>>(model.StateJson);

            var response = await _restfulHelper.GetAsync(string.Format(_configuration.BusinessApiNextNodeUrl, model.PathwayId,
                model.Id, answer.Title, HttpUtility.UrlEncode(JsonConvert.SerializeObject(model.State))));

            model = _mappingEngine.Map(response, model);
            model = _mappingEngine.Map(answer, model);

            return await ActionSelection(model);

        }
     public async Task<JourneyViewModel> BuildPreviousQuestion(JourneyViewModel model)
     {
         var journey = JsonConvert.DeserializeObject<Journey>(model.JourneyJson);
         var response = await _restfulHelper.GetAsync(string.Format(_configuration.BusinessApiQuestionByIdUrl, model.PathwayId, journey.Steps.Last().QuestionId));
         if (journey.Steps.Count == 1)
         {
             model.PreviousTitle = string.Empty;
             journey.Steps.RemoveAt(journey.Steps.Count - 1);
         }
         else
         {
             journey.Steps.RemoveAt(journey.Steps.Count - 1);
             model.PreviousTitle = journey.Steps.Last().IsJustToBeSafe == false ? journey.Steps.Last().QuestionTitle : string.Empty;
         }
 
         model.StateJson = model.PreviousStateJson;
         model.JourneyJson = JsonConvert.SerializeObject(journey);
         model.State = JsonConvert.DeserializeObject<Dictionary<string, string>>(model.StateJson);
         return _mappingEngine.Map(response, model);
     }
 public RegisterForSMSViewModel(JourneyViewModel journeyViewModel) : base(journeyViewModel)
 {
 }
 public PageResultViewModel(JourneyViewModel journeyViewModel, string viewName) : base(journeyViewModel)
 {
     _viewName = viewName;
 }
 public QuestionResultViewModel(JourneyViewModel journeyViewModel) : base(journeyViewModel)
 {
 }
        public async Task<Tuple<string, JourneyViewModel>> ActionSelection(JourneyViewModel model)
        {
            var nonOutcome = new[] { "Dx011", "Dx012", "Dx013", "Dx016", };

            if (nonOutcome.Contains(model.Id))
            {
                var newModel = _mappingEngine.Map<OutcomeViewModel>(model);
                return new Tuple<string, JourneyViewModel>("../Outcome/Emergency", await _outcomeViewModelBuilder.DispositionBuilder(newModel));
            }

            switch (model.NodeType)
            {
                case NodeType.Outcome:
                    {
                        var newModel = _mappingEngine.Map<OutcomeViewModel>(model);
                        newModel.CareAdviceMarkers = model.State.Keys.Where(key => key.StartsWith("Cx"));
                        var disposition2 = new[] { "Dx02", "Dx25", "Dx75", "Dx30", "Dx03", "Dx16", "Dx94", "Dx09" };
                        return disposition2.Contains(model.Id)
                            ? new Tuple<string, JourneyViewModel>("../Outcome/Disposition2", await _outcomeViewModelBuilder.DispositionBuilder(newModel))
                            : new Tuple<string, JourneyViewModel>("../Outcome/Disposition", await _outcomeViewModelBuilder.DispositionBuilder(newModel));
                    }

                case NodeType.Pathway:
                    {
                        var pathway = JsonConvert.DeserializeObject<Pathway>(await _restfulHelper.GetAsync(string.Format(_configuration.BusinessApiPathwayUrl, model.Id)));
                        var newModel = new JustToBeSafeViewModel
                        {
                            PathwayId = pathway.Id,
                            PathwayNo = pathway.PathwayNo,
                            PathwayTitle = pathway.Title,
                            UserInfo = model.UserInfo,
                            JourneyJson = model.JourneyJson,
                            SymptomDiscriminator = model.SymptomDiscriminator,
                        };
                        return await _justToBeSafeFirstViewModelBuilder.JustToBeSafeFirstBuilder(newModel);
                        //TODO delete return new Tuple<string, JourneyViewModel>("../JustToBeSafe/JustToBeSafe", await _justToBeSafeFirstViewModelBuilder.JustToBeSafeFirstBuilder(newModel));
                    }
                case NodeType.Question:
                default:
                    return new Tuple<string, JourneyViewModel>("../Question/Question", model);

            }
        }
 protected JourneyResultViewModel(JourneyViewModel journeyViewModel)
 {
     JourneyModel = journeyViewModel;
 }
 public async Task<ActionResult> Question(JourneyViewModel model)
 {
     ModelState.Clear();
     var next = await _questionViewModelBuilder.BuildQuestion(model);
     return View(next.Item1, next.Item2);
 }
 public async Task<ActionResult> PreviousQuestion(JourneyViewModel model)
 {
     ModelState.Clear();
     return View("Question", await _questionViewModelBuilder.BuildPreviousQuestion(model));
 }
 public async Task<ActionResult> Slider(JourneyViewModel model)
 {
     ModelState.Clear();
     var sliderModel = await _questionViewModelBuilder.BuildSlider(model);
     return View("Slider", sliderModel);
 }
 public CareAdviceResultViewModel(JourneyViewModel journeyViewModel) : base(journeyViewModel)
 {
 }
 public PathwaySelectionJumpResultViewModel(JourneyViewModel journeyViewModel) : base(journeyViewModel)
 {
 }
 public ActionResult Gender(JourneyViewModel model)
 {
     return View(_questionViewModelBuilder.BuildGender(model));
 }
 public DeadEndJumpResultViewModel(JourneyViewModel journeyViewModel) : base(journeyViewModel)
 {
 }
 public int GetHashCode(JourneyViewModel obj)
 {
     throw new NotImplementedException();
 }
 public NodeNotFoundViewModel(JourneyViewModel journeyViewModel) : base(journeyViewModel)
 {
 }
 public VerifyForSMSViewModel(JourneyViewModel journeyViewModel) : base(journeyViewModel)
 {
 }
 public SearchJumpViewModel(JourneyViewModel journeyViewModel) : base(journeyViewModel)
 {
 }