private void AllowAllInLine(QuestionTemplate questionTemplate) { // validate Response bool isResponseValid = ValidateResponse(questionTemplate); if (isResponseValid) { // create Response var question = Manifest.GetQuestion(questionTemplate.Id); var liveResponse = new Response(Encounter.Id, Encounter.ClientId); liveResponse.SetQuestion(question); liveResponse.SetObs(Encounter.Id, Encounter.ClientId, questionTemplate.Id, question.Concept.ConceptTypeId, questionTemplate.GetResponse()); //update encounter with Response Encounter.AddOrUpdate(liveResponse.Obs, false); //update manifest from Encounter Manifest.UpdateEncounter(Encounter); //temp store serialized Manifest + Encounter var encounterJson = JsonConvert.SerializeObject(Encounter); _settings.AddOrUpdateValue("client.encounter", encounterJson); var manifestJson = JsonConvert.SerializeObject(Manifest); _settings.AddOrUpdateValue("client.manifest", manifestJson); //determine next Live Question if (null != Manifest) { #region Partner Result Check var partnerResult = _settings.GetValue("client.partner.result", ""); if (!string.IsNullOrWhiteSpace(partnerResult)) { var presult = new Guid(partnerResult); var inc = new Guid("b25f017c-852f-11e7-bb31-be2e44b06b34"); var discordant = Questions.FirstOrDefault( x => x.QuestionTemplate.Id == new Guid("b2605c98-852f-11e7-bb31-be2e44b06b34")); if (questionTemplate.Id == new Guid("b2605964-852f-11e7-bb31-be2e44b06b34")) { var obsValue = questionTemplate.GetResponse(); var value = null == obsValue ? Guid.Empty : new Guid(obsValue.ToString()); if (value != inc && presult != inc) { if (value == presult) { //discordant discordant.QuestionTemplate.SetResponse( new Guid("b25ed04e-852f-11e7-bb31-be2e44b06b34")); } else { //not-discordant discordant.QuestionTemplate.SetResponse( new Guid("b25eccd4-852f-11e7-bb31-be2e44b06b34")); } } } } #endregion #region TRANSFORMATION // TRANSFORMATION FIRST //REMOTE var remactions = _obsService.GetTransformationActions(Manifest, questionTemplate.Id); foreach (var a in remactions) { if (a.Action.ToLower() == "Set".ToLower()) { var q = Questions.FirstOrDefault(x => x.QuestionTemplate.Id == a.QuestionId); if (null != q) { q.QuestionTemplate.SetResponse(a.Response); } } if (a.Action.ToLower() == "Block".ToLower()) { var q = Questions.FirstOrDefault(x => x.QuestionTemplate.Id == a.QuestionId); if (null != q) { q.QuestionTemplate.Allow = false; } } if (a.Action.ToLower() == "Allow".ToLower()) { var q = Questions.FirstOrDefault(x => x.QuestionTemplate.Id == a.QuestionId); if (null != q) { q.QuestionTemplate.Allow = true; } } } //LOCAL var actions = _obsService.GetTransformationActions(Manifest, questionTemplate.Id); foreach (var a in actions) { if (a.Action.ToLower() == "Set".ToLower()) { var q = Questions.FirstOrDefault(x => x.QuestionTemplate.Id == a.QuestionId); if (null != q) { q.QuestionTemplate.SetResponse(a.Response); } } if (a.Action.ToLower() == "Block".ToLower()) { var q = Questions.FirstOrDefault(x => x.QuestionTemplate.Id == a.QuestionId); if (null != q) { q.QuestionTemplate.Allow = false; } } if (a.Action.ToLower() == "Allow".ToLower()) { var q = Questions.FirstOrDefault(x => x.QuestionTemplate.Id == a.QuestionId); if (null != q) { q.QuestionTemplate.Allow = true; } } } #endregion var liveSkipQs = new List <QuestionTemplateWrap>(); // get all remaining Questions var nextQuestions = _obsService.GetLiveQuestions(Manifest, questionTemplate.Id); if (null == nextQuestions || nextQuestions.Count == 0) { AtTheEnd = true; return; } // process remaining Questions foreach (var nextQ in nextQuestions) { // get all Questions to be skipped var skipQs = nextQ.SkippedQuestionIds; var liveQ = Questions.FirstOrDefault(x => x.QuestionTemplate.Id == nextQ.Id); if (skipQs.Count > 0) { liveSkipQs = Questions.Where(x => skipQs.Contains(x.QuestionTemplate.Id)).ToList(); } if (null != liveQ) { foreach (var skipQ in liveSkipQs) { // disable skipped Question if (skipQ.QuestionTemplate.Allow) { skipQ.QuestionTemplate.ErrorSummary = string.Empty; skipQ.QuestionTemplate.Allow = false; } } // enable current nextQuestion if (!liveQ.QuestionTemplate.Allow) { liveQ.QuestionTemplate.Allow = true; } // restore response from Manifest var response = Manifest.GetResponse(liveQ.QuestionTemplate.Id); var responseValue = null == response ? null : response.GetValue().Value; if (null != responseValue) { //if (!liveQ.QuestionTemplate.ShowMultiObs) liveQ.QuestionTemplate.SetResponse(responseValue); } } } } } }