public void PatientToDoExistsTest_true() { var todoRule = new ToDoActivationRule { EndpointUtil = new EndpointUtils(), PlanUtils = new StubPlanElementUtils() }; const string patientId = "5325da76d6a4850adcbba656"; const string userId = "1234"; const string elemId = "5407527d1e6015290c203d36"; var eventArg = new PlanElementEventArg { Action = new Actions(), DomainRequest = new AppDomainRequest { Version = 1.0, ContractNumber = "InHealth001", UserId = "1234" }, PatientId = patientId, UserId = userId, PlanElement = new PlanElement { Id = "" } }; var result = todoRule.PatientToDoExists(eventArg, elemId); Assert.IsTrue(result); }
/// <summary> /// Handles the response initialization to deletion of false and evokes any spawnelements. /// </summary> /// <param name="e">PlanElementEventArg</param> /// <param name="s">Step</param> public void SetCompletedStepResponses(PlanElementEventArg e, Step s) { try { s.Responses.ForEach(r => { r.Delete = false; if ((s.StepTypeId == 4) || (s.StepTypeId == 1)) { if (s.SelectedResponseId.Equals(r.Id)) { HandleResponseSpawnElements(s, r, e, e.UserId); } } else { HandleResponseSpawnElements(s, r, e, e.UserId); } }); } catch (Exception ex) { throw new Exception("AD:StepPlanProcessor:StepCompletedStepResponse()::" + ex.Message, ex.InnerException); } }
public void PatientToDoExistsTest_false() { var todoRule = new ToDoActivationRule { EndpointUtil = new EndpointUtils(), PlanUtils = new StubPlanElementUtils() }; const string patientId = "5325da35d6a4850adcbba58e"; const string userId = "1234"; const string elemId = "53ff6b92d4332314bcab46e0"; var eventArg = new PlanElementEventArg { Action = new Actions(), DomainRequest = new AppDomainRequest { Version = 1.0, ContractNumber = "InHealth001", UserId = "1234" }, PatientId = patientId, UserId = userId, PlanElement = new PlanElement { Id = "" } }; var result = todoRule.PatientToDoExists(eventArg, elemId); Assert.IsFalse(result); }
public void HandleToDoTemplateRegistration_Status_Abandoned() { ToDoActivationRule rule = new ToDoActivationRule { EndpointUtil = new StubEndpointUtils(), PlanUtils = new PlanElementUtils() }; var patientId = ObjectId.GenerateNewId().ToString(); PlanElementEventArg arg = new PlanElementEventArg { Program = new Program { Id = ObjectId.GenerateNewId().ToString(), PatientId = patientId }, UserId = "5325c821072ef705080d3488", Action = new Actions { Id = ObjectId.GenerateNewId().ToString() }, PatientId = patientId, PlanElement = new Step() }; var se = new SpawnElement { ElementType = 201, ElementId = "53ff6b92d4332314bcab46e0" }; var type = rule.Execute(arg.UserId, arg, se, new ProgramAttributeData()); Assert.AreEqual(type, 200); }
public void ExecuteTest() { // goal to patientgoal Mapper.CreateMap <Goal, PatientGoal>() .ForMember(d => d.CustomAttributes, opt => opt.MapFrom(src => src.CustomAttributes.ConvertAll( c => new CustomAttribute { Id = c.Id, Values = c.Values }))); var gar = new GoalActivationRule { EndpointUtil = new StubEndpointUtils(), PlanUtils = new StubPlanElementUtils() }; string userId = "1234"; PlanElementEventArg arg = new PlanElementEventArg { Program = new DTO.Program { Id = "111111111111111111111111" }, PatientId = "2222222222222222222222pt", UserId = "1234" }; SpawnElement pe = new SpawnElement { }; ProgramAttributeData pad = new ProgramAttributeData { }; gar.Execute(userId, arg, pe, pad); }
public override SpawnType Execute(string userId, PlanElementEventArg arg, SpawnElement pe, ProgramAttributeData pad) { var spawnType = new SpawnType { Type = _alertType.ToString() }; return(spawnType); }
public override SpawnType Execute(string userId, PlanElementEventArg arg, SpawnElement se, ProgramAttributeData pad) { PlanUtils.SetProgramAttributes(se, arg.Program, arg.UserId, pad); var spawnType = new SpawnType { Type = "KickAss" }; return(spawnType); }
public override SpawnType Execute(string userId, PlanElementEventArg arg, SpawnElement pe, ProgramAttributeData pad) { HandlePatientProblemRegistration(arg, userId, pe); var spawnType = new SpawnType { Type = _alertType.ToString() }; return(spawnType); }
public override SpawnType Execute(string userId, PlanElementEventArg arg, SpawnElement se, ProgramAttributeData pad) { PlanElement value = HandlePlanElementActivation(PlanUtils, arg, se); var spawnType = new SpawnType { Type = _elementType.ToString() }; return(spawnType); }
public RegisterSpawnProblemCode(PlanElementEventArg e, SpawnElement rse) { _e = e; _se = rse; if (AppHostBase.Instance != null) { AppHostBase.Instance.Container.AutoWire(this); } }
public SpawnType Run(PlanElementEventArg e, SpawnElement rse, string userId, ProgramAttributeData pad) { SpawnType alert = null; alert = _progAttributeTypes.Contains(rse.ElementType) ? new ProgramAttributeActivationRule().Execute(userId, e, rse, pad) : _rules.First(r => r.ElementType == rse.ElementType).Execute(userId, e, rse, pad); return(alert); }
public override void PlanElementHandler(object sender, PlanElementEventArg e) { try { if (e.PlanElement.GetType() == typeof(Step)) { ProgramAttributes.PlanElementId = e.Program.Id; var s = (Step)e.PlanElement; if (e.Action.Completed) { if (s.Completed) { // see if responses have spawn elements if (s.Responses != null) { SetCompletedStepResponses(e, s); } if (s.SpawnElement != null) { PEUtils.SpawnElementsInList(s.SpawnElement, e.Program, e.UserId, ProgramAttributes); s.SpawnElement.ForEach( rse => { if (rse.ElementType > 100) { HandlePlanElementActions(e, e.UserId, rse); } }); } } else { if (s.Responses != null) { s.Responses.ForEach(r => { r.Delete = true; }); } } // save program properties PEUtils.SaveReportingAttributes(ProgramAttributes, e.DomainRequest); // raise process event to register the id OnProcessIdEvent(e.Program); } } else if (Successor != null) { Successor.PlanElementHandler(this, e); } } catch (Exception ex) { throw new Exception("AD:StepPlanProcessor:PlanElementHandler()::" + ex.Message, ex.InnerException); } }
public void Run_ToDo_Rule() { var se = new SpawnElement { ElementType = 111 }; var arg = new PlanElementEventArg { UserId = ObjectId.GenerateNewId().ToString() }; var strat = new StubElementActivationStrategy().Run(arg, se, ObjectId.GenerateNewId().ToString(), new DataDomain.Program.DTO.ProgramAttributeData()); Assert.AreEqual(strat, "ToDo"); }
public UpdateSpawnProblemCode(PlanElementEventArg e, SpawnElement rse, PatientObservation ppd, bool active) { _e = e; _se = rse; _pod = ppd; _active = active; if (AppHostBase.Instance != null) { AppHostBase.Instance.Container.AutoWire(this); } }
public void HandleResponseSpawnElements(Step s, Response r, PlanElementEventArg e, string userId) { try { if (r.SpawnElement != null) { if (PEUtils.ResponseSpawnAllowed(s, r)) { r.SpawnElement.ForEach(rse => HandlePlanElementActions(e, userId, rse)); } } } catch (Exception ex) { throw new Exception("AD:StepPlanProcessor:HandleResponseSpawnElements()::" + ex.Message, ex.InnerException); } }
public bool PatientToDoExists(PlanElementEventArg arg, string sourceId) { try { var todos = EndpointUtil.GetPatientToDos(arg.PatientId, arg.UserId, arg.DomainRequest); if (todos == null) { return(false); } var existing = todos.FirstOrDefault(r => r.SourceId == sourceId && (r.StatusId == 1 || r.StatusId == 3)); // open = 1, NotMet = 3 status if (existing == null) { return(false); } return(true); } catch (Exception ex) { throw new Exception("AD:ToDoActivationRule:PatientToDoExists()::" + ex.Message, ex.InnerException); } }
public void HandlePatientProblemRegistration(PlanElementEventArg e, string userId, SpawnElement rse) { try { // check if problem code is already registered for patient var ppd = EndpointUtil.GetPatientProblem(rse.ElementId, e, userId); if (ppd != null) { var uspc = new UpdateSpawnProblemCode(e, rse, ppd, true) { EndPointUtil = EndpointUtil }; var updateSpawnProblemCode = new SpawnElementStrategy(uspc); if (ppd.StateId != 2) { updateSpawnProblemCode.Evoke(); } } else { var spc = new RegisterSpawnProblemCode(e, rse) { EndPointUtil = EndpointUtil }; var registerSpawnProblemCode = new SpawnElementStrategy(spc); registerSpawnProblemCode.Evoke(); } // register new problem code with cohortpatientview PlanUtils.RegisterCohortPatientViewProblemToPatient(rse.ElementId, e.PatientId, e.DomainRequest); } catch (Exception ex) { throw new Exception("AD:StepPlanProcessor:HandlePatientProblemRegistration()::" + ex.Message, ex.InnerException); } }
public PatientObservation GetPatientProblem(string probId, PlanElementEventArg e, string userId) { try { PatientObservation result = null; IRestClient client = new JsonServiceClient(); //Patient/{PatientId}/Observation/{ObservationID} var url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Observation/{5}", DDPatientObservationServiceUrl, "NG", e.DomainRequest.Version, e.DomainRequest.ContractNumber, e.PatientId, probId), userId); GetPatientObservationResponse dataDomainResponse = client.Get <GetPatientObservationResponse>( url); if (dataDomainResponse.PatientObservation != null) { result = new PatientObservation { Id = dataDomainResponse.PatientObservation.Id, StateId = dataDomainResponse.PatientObservation.StateId }; } return(result); } catch (WebServiceException ex) { throw new Exception("AD:PlanElementEndpointUtil:GetPatientProblem()::" + ex.Message, ex.InnerException); } }
public PatientObservation GetPatientProblem(string probId, PlanElementEventArg e, string userId) { return(new PatientObservation { Id = "101010101010101010101010", Name = "fake Patient Observation" }); }
public override SpawnType Execute(string userId, PlanElementEventArg arg, SpawnElement pe, ProgramAttributeData pad) { try { Schedule todoTemp = null; ToDoData todo = null; if (!PatientToDoExists(arg, pe.ElementId)) { try { // get template todo from schedule endpoint todoTemp = EndpointUtil.GetScheduleToDoById(pe.ElementId, userId, arg.DomainRequest); } catch (Exception ex) { throw new ArgumentException(ex.Message); } var prog = new System.Collections.Generic.List <string>(); if (arg.Program != null) { prog.Add(arg.Program.Id); } string patientId = null; if (arg.Program != null) { patientId = arg.Program.PatientId; } try { todo = new ToDoData { SourceId = todoTemp.Id, Title = todoTemp.Title, CategoryId = todoTemp.CategoryId, CreatedById = userId, StatusId = todoTemp.StatusId, Description = todoTemp.Description, PriorityId = todoTemp.PriorityId, DueDate = HandleDueDate(todoTemp.DueDateRange), StartTime = todoTemp.StartTime, Duration = todoTemp.Duration, PatientId = patientId, ProgramIds = prog, CreatedOn = DateTime.UtcNow }; SetDefaultAssignment(userId, todoTemp, todo); // modified for ENG-709 if (todo.StatusId == 2 || todo.StatusId == 4) { todo.ClosedDate = DateTime.UtcNow; } } catch (Exception ex) { throw new ArgumentException("ToDoData Hydration Error." + ex.Message); } try { // register new todo var result = EndpointUtil.PutInsertToDo(todo, arg.UserId, arg.DomainRequest); } catch (Exception ex) { throw new Exception(ex.Message, ex.InnerException); } } var spawnType = new SpawnType { Type = _alertType.ToString() }; return(spawnType); } catch (Exception ex) { throw new Exception("AD:ToDoActivationRule:Execute()::" + ex.Message, ex.InnerException); } }
public abstract SpawnType Execute(string userId, PlanElementEventArg arg, SpawnElement pe, ProgramAttributeData pad);
protected PlanElement HandlePlanElementActivation(IPlanElementUtils planUtils, PlanElementEventArg e, SpawnElement rse) { try { PlanElement pe = planUtils.ActivatePlanElement(rse.ElementId, e.Program); return(pe); } catch (Exception ex) { throw new Exception("AD:StepPlanProcessor:HandlePlanElementActivation()::" + ex.Message, ex.InnerException); } }
public override SpawnType Execute(string userId, PlanElementEventArg arg, SpawnElement pe, ProgramAttributeData pad) { try { Goal goalTemp = null; PatientGoal patientGoal = null; PatientGoal newPGoal = null; ToDoData todo = null; try { // get template Goal from Goal endpoint goalTemp = EndpointUtil.GetGoalById(pe.ElementId, userId, arg.DomainRequest); } catch (Exception ex) { throw new ArgumentException(ex.Message); } try { // get patient Goal from template id // this will only return patientgoals that are open or notmet state patientGoal = EndpointUtil.GetOpenNotMetPatientGoalByTemplateId(pe.ElementId, arg.PatientId, userId, arg.DomainRequest); } catch (Exception ex) { throw new ArgumentException(ex.Message); } try { //Open = 1, Met = 2, NotMet =3, Abandoned =4 if (patientGoal == null) // || (patientGoal.StatusId == 2 || patientGoal.StatusId == 4)) { newPGoal = Mapper.Map <PatientGoal>(goalTemp); newPGoal.ProgramIds = new List <string> { arg.Program.Id }; newPGoal.PatientId = arg.PatientId; newPGoal.TemplateId = goalTemp.Id; newPGoal.StartDate = PlanUtils.HandleDueDate(goalTemp.StartDateRange); newPGoal.TargetDate = PlanUtils.HandleDueDate(goalTemp.TargetDateRange); newPGoal.StatusId = 1; try { // initialize patientgoal and get id var iPG = GoalsEndpointUtil.GetInitialGoalRequest(new GetInitializeGoalRequest { Context = "NG", ContractNumber = arg.DomainRequest.ContractNumber, PatientId = arg.PatientId, Token = arg.DomainRequest.Token, UserId = arg.DomainRequest.UserId, Version = arg.DomainRequest.Version }); // update patientgoal if (iPG == null) { throw new ArgumentException("Failed to Initialize patient goal"); } newPGoal.Id = iPG.Id; GoalsEndpointUtil.PostUpdateGoalRequest(new PostPatientGoalRequest { ContractNumber = arg.DomainRequest.ContractNumber, Goal = newPGoal, PatientGoalId = iPG.Id, PatientId = arg.PatientId, Token = arg.DomainRequest.Token, UserId = arg.DomainRequest.UserId, Version = arg.DomainRequest.Version }); } catch (Exception ex) { throw new Exception(ex.Message, ex.InnerException); } } } catch (Exception ex) { throw new ArgumentException("PatientGoal Hydration Error." + ex.Message); } var spawnType = new SpawnType { Type = _alertType.ToString(), Tag = new List <object> { newPGoal } }; return(spawnType); } catch (Exception ex) { throw new Exception("AD:ToDoActivationRule:Execute()::" + ex.Message, ex.InnerException); } }
public SpawnType Run(PlanElementEventArg e, SpawnElement rse, string userId, ProgramAttributeData pad) { var alert = _rules.First(r => r.ElementType == rse.ElementType).Execute(userId, e, rse, pad); return(alert); }
public override SpawnType Execute(string userId, PlanElementEventArg arg, SpawnElement pe, ProgramAttributeData pad) { try { Intervention interventionTemplate = null; Goal goalTemplate = null; PatientGoal patientGoal = null; PatientGoal newPGoal = null; PatientIntervention existingPatientIntervention = null; try { // get template intervention interventionTemplate = EndpointUtil.GetInterventionById(pe.ElementId, userId, arg.DomainRequest); } catch (Exception ex) { throw new Exception("AD:InterventionActivationRule:GetInterventionById()::" + ex.Message, ex.InnerException); } try { // get template goal goalTemplate = EndpointUtil.GetGoalById(interventionTemplate.TemplateGoalId, userId, arg.DomainRequest); } catch (Exception ex) { throw new Exception("AD:InterventionActivationRule:GetGoalById()::" + ex.Message, ex.InnerException); } try { // find if patientgoal exists patientGoal = EndpointUtil.GetOpenNotMetPatientGoalByTemplateId(goalTemplate.Id, arg.PatientId, userId, arg.DomainRequest); } catch (Exception ex) { throw new Exception("AD:InterventionActivationRule:GetOpenNotMetPatientGoalByTemplateId()::" + ex.Message, ex.InnerException); } if (patientGoal != null) { try { // find if patientintervention exists existingPatientIntervention = EndpointUtil.GetOpenNotMetPatientInterventionByTemplateId(patientGoal.Id, interventionTemplate.Id, arg.PatientId, userId, arg.DomainRequest); } catch (Exception ex) { throw new Exception( "AD:InterventionActivationRule:GetOpenNotMetPatientInterventionByTemplateId()::" + ex.Message, ex.InnerException); } } PatientIntervention pIntr = existingPatientIntervention; PatientGoal pGoal = patientGoal; List <object> items = null; if (InsertInterventionAllowed(pIntr)) { // check to see that goal exists if (InsertPatientGoalAllowed(patientGoal)) { // 1) insert patient goal pGoal = PlanUtils.InsertPatientGoal(arg, goalTemplate); } pIntr = PlanUtils.InsertPatientIntervention(arg, pGoal, interventionTemplate); items = CreateItemsBag(pIntr, pGoal); } var spawnType = new SpawnType { Type = _alertType.ToString(), Tag = items }; return(spawnType); } catch (Exception ex) { throw new Exception("AD:InterventionActivationRule:Execute()::" + ex.Message, ex.InnerException); } }
public override SpawnType Execute(string userId, PlanElementEventArg arg, SpawnElement pe, ProgramAttributeData pad) { try { #region //Goal goalTemp = null; //Intervention interventionTemp = null; //PatientIntervention patientInt = null; //PatientIntervention newPInt = null; //ToDoData todo = null; //try //{ // // get patientintervention template by id // interventionTemp = EndpointUtil.GetGoalById(pe.ElementId, userId, arg.DomainRequest); //} //catch(Exception ex) //{ // throw new ArgumentException(ex.Message); //} //try //{ // // get template Goal from Goal endpoint // patientGoal = EndpointUtil.GetOpenNotMetPatientGoalByTemplateId(pe.ElementId, arg.PatientId, userId, arg.DomainRequest); //} //catch (Exception ex) //{ // throw new ArgumentException(ex.Message); //} //try //{ // //Open = 1, Met = 2, NotMet =3, Abandoned =4 // if (patientGoal == null || (patientGoal.StatusId == 2 || patientGoal.StatusId == 4)) // { // newPGoal = Mapper.Map<PatientGoal>(goalTemp); // newPGoal.ProgramIds = new List<string> {arg.Program.Id}; // newPGoal.PatientId = arg.PatientId; // newPGoal.StatusId = 1; // try // { // // register new patientobservation // // initialize patientgoal and get id // var iPG = GoalsEndpointUtil.GetInitialGoalRequest(new GetInitializeGoalRequest // { // Context = "NG", // ContractNumber = arg.DomainRequest.ContractNumber, // PatientId = arg.PatientId, // Token = arg.DomainRequest.Token, // UserId = arg.DomainRequest.UserId, // Version = arg.DomainRequest.Version // }); // // update patientgoal // if (iPG == null) // throw new ArgumentException("Failed to Initialize patient goal"); // newPGoal.Id = iPG.Id; // GoalsEndpointUtil.PostUpdateGoalRequest(new PostPatientGoalRequest // { // ContractNumber = arg.DomainRequest.ContractNumber, // Goal = newPGoal, // PatientGoalId = iPG.Id, // PatientId = arg.PatientId, // Token = arg.DomainRequest.Token, // UserId = arg.DomainRequest.UserId, // Version = arg.DomainRequest.Version // }); // } // catch (Exception ex) // { // throw new Exception(ex.Message, ex.InnerException); // } // } //} //catch (Exception ex) //{ // throw new ArgumentException("PatientGoal Hydration Error." + ex.Message); //} #endregion Task taskTemplate = null; Goal goalTemplate = null; PatientGoal patientGoal = null; PatientGoal newPGoal = null; PatientTask existingPatientTask = null; // get template intervention taskTemplate = EndpointUtil.GetTaskById(pe.ElementId, userId, arg.DomainRequest); // get template goal goalTemplate = EndpointUtil.GetGoalById(taskTemplate.TemplateGoalId, userId, arg.DomainRequest); // find if patientgoal exists patientGoal = EndpointUtil.GetOpenNotMetPatientGoalByTemplateId(goalTemplate.Id, arg.PatientId, userId, arg.DomainRequest); if (patientGoal != null) { // find if patientintervention exists existingPatientTask = EndpointUtil.GetOpenNotMetPatientTaskByTemplateId(patientGoal.Id, taskTemplate.Id, arg.PatientId, userId, arg.DomainRequest); } PatientTask pTsk = existingPatientTask; PatientGoal pGoal = patientGoal; List <object> items = null; if (InsertTaskAllowed(existingPatientTask)) { // check to see that goal exists if (InsertPatientGoalAllowed(patientGoal)) { // 1) insert patient goal pGoal = PlanUtils.InsertPatientGoal(arg, goalTemplate); } // insert patient intervention pTsk = PlanUtils.InsertPatientTask(arg, pGoal, taskTemplate); items = CreateItemsBag(pTsk, pGoal); } var spawnType = new SpawnType { Type = _alertType.ToString(), Tag = items }; return(spawnType); } catch (Exception ex) { throw new Exception("AD:TaskActivationRule:Execute()::" + ex.Message, ex.InnerException); } }