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<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); }
public async Task<Tuple<string, JourneyViewModel>> JustToBeSafeNextBuilder(JustToBeSafeViewModel model) { model.State = JsonConvert.DeserializeObject<Dictionary<string, string>>(model.StateJson); var questionsWithAnswers = JsonConvert.DeserializeObject<List<QuestionWithAnswers>>(model.QuestionsJson); var selectedQuestion = questionsWithAnswers.FirstOrDefault(q => q.Question.Id == model.SelectedQuestionId); var selectedAnswer = model.SelectedNoneApply() ? new Answer() : selectedQuestion.Answers.FirstOrDefault(a => a.Title.ToLower().StartsWith("yes")) ?? new Answer(); var journey = JsonConvert.DeserializeObject<Journey>(model.JourneyJson).Add( new Journey { Steps = questionsWithAnswers. Select(q => new JourneyStep { QuestionId = q.Question.Id, QuestionNo = q.Question.QuestionNo, QuestionTitle = q.Question.Title, Answer = q.Question.Id == model.SelectedQuestionId ? selectedAnswer : q.Answers.First(a => a.Title.ToLower().StartsWith("no")), IsJustToBeSafe = true }).ToList() }); var questionsJson = await _restfulHelper.GetAsync(string.Format(_configuration.BusinessApiJustToBeSafePartTwoUrl, model.PathwayId, model.SelectedQuestionId ?? "", String.Join(",", questionsWithAnswers.Select(question => question.Question.Id)), selectedQuestion != null && selectedQuestion.Answers.Count > 3)); var questions = JsonConvert.DeserializeObject<List<QuestionWithAnswers>>(questionsJson); journey.Steps = journey.Steps.Where(step => !questions.Exists(question => question.Question.Id == step.QuestionId)).ToList(); return await BuildNextAction(questions, journey, model, selectedAnswer, selectedQuestion, questionsJson); }
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); } }
public async Task<ActionResult> JustToBeSafeNext(JustToBeSafeViewModel model) { ModelState.Clear(); var next = await _justToBeSafeViewModelBuilder.JustToBeSafeNextBuilder(model); return View(next.Item1, next.Item2); }
public async Task<ActionResult> JustToBeSafeFirst(JustToBeSafeViewModel model) { var viewData = await _justToBeSafeFirstViewModelBuilder.JustToBeSafeFirstBuilder(model); return View(viewData.Item1, viewData.Item2); }