Example #1
0
            public void Process_Action_With_Action_Spawn_Activated_Returned()
            {
                IPlanManager pm = new PlanManager
                {
                    PEUtils       = new StubPlanElementUtils(),
                    EndPointUtils = new StubPlanElementEndpointUtils()
                };

                ObjectId actionId = ObjectId.Parse("538ca77dfe7a59112c3649e4");

                PostProcessActionRequest request = new PostProcessActionRequest
                {
                    ContractNumber = "InHealth001",
                    PatientId      = "123456789012345678901234",
                    ProgramId      = "000000000000000000000000",
                    UserId         = "111111111111111111111111",
                    Version        = 1.0,
                    Action         = new Actions
                    {
                        Id            = actionId.ToString(),
                        Completed     = true,
                        ElementState  = 4,
                        Name          = "test action from stub",
                        Description   = "action Description",
                        Text          = "test action 1",
                        AttrEndDate   = DateTime.UtcNow.AddDays(10),
                        AttrStartDate = DateTime.UtcNow,
                        AssignDate    = DateTime.UtcNow,
                        SpawnElement  =
                            new List <SpawnElement>
                        {
                            new SpawnElement {
                                ElementId = "111116789012345678901234", ElementType = 3
                            }
                        },
                        Steps = new List <Step>
                        {
                            new Step
                            {
                                Id           = "000000000011111111111234",
                                ElementState = 1
                            }
                        }
                    }
                };

                PostProcessActionResponse response = pm.ProcessActionResults(request);

                Assert.IsNotNull(response.PlanElems);
                Assert.IsNotNull(response.PlanElems.Actions);
                Assert.AreEqual(actionId.ToString(), response.PlanElems.Actions[0].Id);
            }
Example #2
0
        public PostProcessActionResponse Post(PostProcessActionRequest request)
        {
            var response = new PostProcessActionResponse();
            var intm     = new PlanManager();
            ValidateTokenResponse result = null;

            try
            {
                request.Token = base.Request.Headers["Token"] as string;
                result        = Security.IsUserValidated(request.Version, request.Token, request.ContractNumber);
                if (result.UserId.Trim() != string.Empty)
                {
                    request.UserId = result.UserId;
                    response       = intm.ProcessActionResults(request);
                }
                else
                {
                    throw new UnauthorizedAccessException();
                }
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);
                if ((ex is WebServiceException) == false)
                {
                    intm.LogException(ex);
                }
            }
            finally
            {
                List <string> patientIds = null;
                if (!string.IsNullOrEmpty(response.PatientId))
                {
                    patientIds = new List <string> {
                        response.PatientId
                    };
                }

                if (result != null)
                {
                    AuditHelper.LogAuditData(request, result.SQLUserId, patientIds, System.Web.HttpContext.Current.Request, request.GetType().Name);
                }
            }
            return(response);
        }
Example #3
0
            public void Set_Action_State_Changed_To_Complete()
            {
                IPlanManager pm = new PlanManager
                {
                    PEUtils       = new StubPlanElementUtils(),
                    EndPointUtils = new StubPlanElementEndpointUtils()
                };

                PostProcessActionRequest request = new PostProcessActionRequest
                {
                    ContractNumber = "InHealth001",
                    PatientId      = "123456789012345678901234",
                    ProgramId      = "000000000000000000000000",
                    UserId         = "111111111111111111111111",
                    Version        = 1.0,
                    Action         = new DTO.Actions
                    {
                        Id            = "000000000000000000000000",
                        Completed     = true,
                        ElementState  = 4,
                        Name          = "test action from stub",
                        Description   = "action Description",
                        Text          = "test action 1",
                        AttrEndDate   = DateTime.UtcNow.AddDays(10),
                        AttrStartDate = DateTime.UtcNow,
                        AssignDate    = System.DateTime.UtcNow,
                        Steps         = new List <Step>
                        {
                            new Step
                            {
                                Id           = "000000000011111111111234",
                                ElementState = 1
                            }
                        }
                    }
                };

                PostProcessActionResponse response = pm.ProcessActionResults(request);

                Assert.IsNotNull(response);
            }
Example #4
0
        public void Action_problemcode_spawning_Tests()
        {
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            string      priority       = "3";
            double      version        = 1.0;
            string      token          = "52ea72f9d6a4850eb84b0dbc";
            string      programId      = "52ea84cfd6a4850eb802962d";
            string      patientId      = "52e26f5b072ef7191c11ef73";
            string      actionID       = "52dd8c44d6a4850ea8a56cbe";
            IRestClient client         = new JsonServiceClient();

            PostProcessActionResponse response = client.Post <PostProcessActionResponse>(
                string.Format(@"http://localhost:888/Nightingale/{0}/{1}/Patient/{2}/Program/Module/Action/Process/?ProgramId={3}&Token={4}",
                              version,
                              contractNumber,
                              patientId,
                              programId,
                              token), new PostProcessActionRequest()
            {
                Action = GenActionProblem(), ProgramId = programId
            });
        }
Example #5
0
        public void Action_Eligibility_spawning_Tests()
        {
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            string      priority       = "3";
            double      version        = 1.0;
            string      token          = "52e7c8b3d6a4850f88f19c4a";
            string      programId      = "52e51ef5d6a48505344c9efc";
            string      patientId      = "52e26f11072ef7191c111d6c";
            string      actionID       = "52dd8c44d6a4850ea8a56cbe";
            IRestClient client         = new JsonServiceClient();

            PostProcessActionResponse response = client.Post <PostProcessActionResponse>(
                string.Format(@"http://localhost:888/Nightingale/{0}/{1}/Patient/{2}/Program/Module/Action/Process/?ProgramId={3}&Token={4}",
                              version,
                              contractNumber,
                              patientId,
                              programId,
                              token), new PostProcessActionRequest()
            {
                Action = GenActionEligibility(), ProgramId = programId
            });
        }
Example #6
0
        public void Action_process_check_for_valid_response_spawning_Tests()
        {
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            string      priority       = "3";
            double      version        = 1.0;
            string      token          = "52e97904d6a4850eb84b0497";
            string      programId      = "52e97f4ed6a4850eb8b70d59";
            string      patientId      = "52e26f11072ef7191c111c54";
            string      actionID       = "52e97f4ed6a4850eb8b70da8";
            IRestClient client         = new JsonServiceClient();

            PostProcessActionResponse response = client.Post <PostProcessActionResponse>(
                string.Format(@"http://localhost:888/Nightingale/{0}/{1}/Patient/{2}/Program/Module/Action/Process/?ProgramId={3}&Token={4}",
                              version,
                              contractNumber,
                              patientId,
                              programId,
                              token), new PostProcessActionRequest()
            {
                Action = GenAction(), ProgramId = programId
            });
        }
Example #7
0
        public void Action_Eligibility_spawn_Tests()
        {
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            string      priority       = "3";
            double      version        = 1.0;
            string      token          = "52efa855d6a4850fb4f20fc3";
            string      programId      = "52efc1ddfe7a5921e450d7fe";
            string      patientId      = "52e26f11072ef7191c111f02";
            string      actionID       = "52efc1dffe7a5921e450d805";
            IRestClient client         = new JsonServiceClient();

            PostProcessActionResponse response = client.Post <PostProcessActionResponse>(
                string.Format(@"http://localhost:888/Nightingale/{0}/{1}/Patient/{2}/Program/Module/Action/Process/?ProgramId={3}&Token={4}",
                              version,
                              contractNumber,
                              patientId,
                              programId,
                              token), new PostProcessActionRequest()
            {
                Action = GenActionResponseEligibility(), ProgramId = programId
            });
        }
        public void Action_process_saving_response_Tests()
        {
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            string      priority       = "3";
            double      version        = 1.0;
            string      token          = "52f518add6a4850fd068481f";
            string      programId      = "52f5462bfe7a59217c8e87f5";
            string      patientId      = "52e26f34072ef7191c115320";
            string      actionID       = "52f54634fe7a59217c8e88ec";
            IRestClient client         = new JsonServiceClient();

            PostProcessActionResponse response = client.Post <PostProcessActionResponse>(
                string.Format(@"http://localhost:888/Nightingale/{0}/{1}/Patient/{2}/Program/Module/Action/Process/?ProgramId={3}&Token={4}",
                              version,
                              contractNumber,
                              patientId,
                              programId,
                              token), new PostProcessActionRequest()
            {
                Action = GenAction(), ProgramId = programId
            });
        }
        public void Get_Program_Details_summary_for_display_With_Problem_Code_Registration_Tests()
        {
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            string      priority       = "3";
            double      version        = 1.0;
            string      token          = "52de9344d6a4850faca90a8e";
            string      programId      = "52def1add6a4850fac29e3f0";
            string      patientId      = "528f6cfa072ef708ecd68c94";
            string      actionID       = "52def1add6a4850fac29e474";
            IRestClient client         = new JsonServiceClient();

            PostProcessActionResponse response = client.Post <PostProcessActionResponse>(
                string.Format(@"http://localhost:888/Nightingale/{0}/{1}/Patient/{2}/Program/Module/Action/Process/?ProgramId={3}&Token={4}",
                              version,
                              contractNumber,
                              patientId,
                              programId,
                              token), new PostProcessActionRequest()
            {
                Action = GenAction(), ProgramId = programId
            });
        }
Example #10
0
        public void Complete_Single_Action_Tests()
        {
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            string      priority       = "3";
            double      version        = 1.0;
            string      token          = "52d949d1d6a4850b882a783b";
            string      programId      = "52d9639dd6a4850b88206a3c";
            string      patientId      = "528f6c7c072ef708ecd51581";
            string      actionID       = "52d9639dd6a4850b88206a54";
            IRestClient client         = new JsonServiceClient();

            PostProcessActionResponse response = client.Post <PostProcessActionResponse>(
                string.Format(@"http://localhost:888/Nightingale/{0}/{1}/Patient/{2}/Program/Module/Action/Process/?ProgramId={3}&Token={4}",
                              version,
                              contractNumber,
                              patientId,
                              programId,
                              token), new PostProcessActionRequest()
            {
                ProgramId = programId, Action = GenAction()
            });
        }
Example #11
0
        public void Get_Program_Details_summary_for_display_Tests()
        {
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            string      priority       = "3";
            double      version        = 1.0;
            string      token          = "52dd7de7d6a4850ea84c2894";
            string      programId      = "52dd8c44d6a4850ea8a56c6f";
            string      patientId      = "528f6c4d072ef708ecd48f9a";
            string      actionID       = "52dd8c44d6a4850ea8a56cbe";
            IRestClient client         = new JsonServiceClient();

            PostProcessActionResponse response = client.Post <PostProcessActionResponse>(
                string.Format(@"http://localhost:888/Nightingale/{0}/{1}/Patient/{2}/Program/Module/Action/Process/?ProgramId={3}&Token={4}",
                              version,
                              contractNumber,
                              patientId,
                              programId,
                              token), new PostProcessActionRequest()
            {
                Action = GenAction(), ProgramId = programId
            });
        }
Example #12
0
        public PostProcessActionResponse ProcessActionResults(PostProcessActionRequest request)
        {
            try
            {
                // need to refactor this into a mediator.
                RelatedChanges.Clear();
                ProcessedElements.Clear();
                PostProcessActionResponse response = new PostProcessActionResponse();
                response.PlanElems = new PlanElements();

                Program p = EndPointUtils.RequestPatientProgramDetail(request);

                Actions action = request.Action;

                if (action.Completed)
                {
                    // 1) pre-process
                    // set program starting date
                    if (IsInitialAction.IsSatisfiedBy(p))
                    {
                        p.AttrStartDate = DateTime.UtcNow;
                        //PlanElementUtil.SetStartDateForProgramAttributes(request.ProgramId, request);
                    }

                    // get module reference
                    Module mod = PEUtils.FindElementById(p.Modules, action.ModuleId);

                    // set module to in progress
                    if (mod.ElementState == (int)ElementState.NotStarted)  //!= 4
                    {
                        mod.ElementState   = (int)ElementState.InProgress; //4;
                        mod.StateUpdatedOn = DateTime.UtcNow;
                    }

                    // 2) set in progress state
                    //new ResponseSpawnAllowed<Step>().IsSatisfiedBy(s)
                    if (PEUtils.IsActionInitial(p))
                    //if (new IsActionInitialSpecification<Program>().IsSatisfiedBy(p))
                    {
                        // set program to in progress
                        if (p.ElementState == (int)ElementState.NotStarted)
                        {
                            p.ElementState   = (int)ElementState.InProgress; //4;
                            p.StateUpdatedOn = DateTime.UtcNow;
                        }
                    }

                    // 3) set action state to completed
                    action.ElementState   = (int)ElementState.Completed;
                    action.StateUpdatedOn = DateTime.UtcNow;

                    // 4) insert action update
                    var act = NGUtils.UpdateProgramAction(action, p);

                    //// create a responsibility chain to process each elemnt in the hierachy
                    ProgramPlanProcessor pChain = InitializeProgramChain();

                    // 5)  process steps
                    action.Steps.ForEach(
                        s =>
                        pChain.ProcessWorkflow((IPlanElement)s, p, request.UserId, request.PatientId, action,
                                               request));

                    // 6) process action
                    pChain.ProcessWorkflow((IPlanElement)action, p, request.UserId, request.PatientId, action, request);

                    // 7) process module
                    if (mod != null)
                    {
                        // set enabled status for action dependencies
                        PEUtils.SetEnabledStatusByPrevious(mod.Actions, mod.AssignToId, mod.Enabled);
                        // set enable/visibility of actions after action processing.
                        pChain.ProcessWorkflow((IPlanElement)mod, p, request.UserId, request.PatientId, action, request);
                        AddUniquePlanElementToProcessedList(mod);
                    }

                    // post processing //
                    // 8) set module visibility for modules
                    PEUtils.SetEnabledStatusByPrevious(p.Modules, p.AssignToId, p.Enabled);

                    // 9) evaluate program status
                    if (PEUtils.IsProgramCompleted(p, request.UserId))
                    {
                        p.Completed = true;
                        pChain.ProcessWorkflow((IPlanElement)p, p, request.UserId, request.PatientId, action, request);
                    }

                    // 10) register changed action
                    AddUniquePlanElementToProcessedList(action);
                }
                else
                {
                    // need to update this on the p level.
                    action.ElementState = (int)ElementState.InProgress; //4; // in progress
                }

                AddUniquePlanElementToProcessedList(p);

                // save
                var pdetail = EndPointUtils.SaveAction(request, action.Id, p, false);

                // create element changed lists
                PEUtils.HydratePlanElementLists(ProcessedElements, response.PlanElems);

                response.PlanElems.Attributes = PEUtils.GetAttributes(pdetail.Attributes);
                response.RelatedChanges       = RelatedChanges;
                response.PatientId            = request.PatientId;
                response.Version = request.Version;

                return(response);
            }
            catch (Exception ex)
            {
                throw new Exception("AD:InterviewManager:ProcessActionResults()::" + ex.Message, ex.InnerException);
            }
        }
Example #13
0
            public void Process_Action_With_Task_Spawn_by_step()
            {
                IPlanManager pm = new PlanManager
                {
                    PEUtils       = new StubPlanElementUtils(),
                    EndPointUtils = new StubPlanElementEndpointUtils(),
                    StepProcessor =
                        new StubStepPlanProcessor()
                    {
                        ElementActivationStrategy = new StubElementActivationStrategy(),
                        PEUtils = new StubPlanElementUtils()
                    }
                };

                //mappers
                Mapper.CreateMap <Task, PatientTask>()
                .ForMember(d => d.CustomAttributes,
                           opt => opt.MapFrom(src => src.CustomAttributes.ConvertAll(
                                                  c => new CustomAttribute {
                    Id = c.Id, Values = c.Values
                })));

                Mapper.CreateMap <PatientTaskData, PatientTask>().ForMember(d => d.CustomAttributes,
                                                                            opt => opt.MapFrom(src => src.CustomAttributes.ConvertAll(
                                                                                                   c => new CustomAttribute {
                    Id = c.Id, Values = c.Values
                })));

                Mapper.CreateMap <PatientTask, PatientTaskData>()
                .ForMember(d => d.CustomAttributes,
                           opt => opt.MapFrom(src => src.CustomAttributes.ConvertAll(
                                                  c => new CustomAttribute {
                    Id = c.Id, Values = c.Values
                })));

                Mapper.CreateMap <TaskData, Task>()
                .ForMember(d => d.CustomAttributes,
                           opt => opt.MapFrom(src => src.CustomAttributes.ConvertAll(
                                                  c => new CustomAttribute {
                    Id = c.Id, Values = c.Values
                })));

                Mapper.CreateMap <GoalData, Goal>()
                .ForMember(d => d.CustomAttributes,
                           opt => opt.MapFrom(src => src.CustomAttributes.ConvertAll(
                                                  c => new CustomAttribute {
                    Id = c.Id, Values = c.Values
                })));

                Mapper.CreateMap <Goal, PatientGoal>()
                .ForMember(d => d.CustomAttributes,
                           opt => opt.MapFrom(src => src.CustomAttributes.ConvertAll(
                                                  c => new CustomAttribute {
                    Id = c.Id, Values = c.Values
                })));

                Mapper.CreateMap <PatientGoalData, PatientGoal>()
                .ForMember(d => d.CustomAttributes,
                           opt => opt.MapFrom(src => src.CustomAttributes.ConvertAll(
                                                  c => new CustomAttribute {
                    Id = c.Id, Values = c.Values
                })))
                .ForMember(d => d.Barriers,
                           opt => opt.MapFrom(src => src.BarriersData.ConvertAll(
                                                  c =>
                                                  new PatientBarrier
                {
                    Id            = c.Id,
                    CategoryId    = c.CategoryId,
                    DeleteFlag    = c.DeleteFlag,
                    Name          = c.Name,
                    PatientGoalId = c.PatientGoalId,
                    StatusDate    = c.StatusDate,
                    StatusId      = c.StatusId,
                    Details       = c.Details
                })))
                .ForMember(d => d.Tasks,
                           opt => opt.MapFrom(src => src.TasksData.ConvertAll(
                                                  c =>
                                                  new PatientTask
                {
                    Id               = c.Id,
                    BarrierIds       = c.BarrierIds,
                    ClosedDate       = c.ClosedDate,
                    CreatedById      = c.CreatedById,
                    CustomAttributes =
                        c.CustomAttributes.ConvertAll(
                            ca =>
                            new CustomAttribute
                    {
                        ControlType = ca.ControlType,
                        Id          = ca.Id,
                        Name        = ca.Name,
                        Order       = ca.Order,
                        Required    = ca.Required,
                        Type        = ca.Type,
                        Values      = ca.Values,
                        Options     = NGUtils.FormatOptions(ca.Options)
                    }),
                    DeleteFlag    = c.DeleteFlag,
                    Description   = c.Description,
                    GoalName      = c.GoalName,
                    PatientGoalId = c.PatientGoalId,
                    StartDate     = c.StartDate,
                    StatusDate    = c.StatusDate,
                    StatusId      = c.StatusId,
                    TargetDate    = c.TargetDate,
                    TargetValue   = c.TargetValue,
                    Details       = c.Details
                })))
                .ForMember(d => d.Interventions,
                           opt => opt.MapFrom(src => src.InterventionsData.ConvertAll(
                                                  c =>
                                                  new PatientIntervention
                {
                    AssignedToId  = c.AssignedToId,
                    BarrierIds    = c.BarrierIds,
                    CategoryId    = c.CategoryId,
                    ClosedDate    = c.ClosedDate,
                    CreatedById   = c.CreatedById,
                    DeleteFlag    = c.DeleteFlag,
                    Description   = c.Description,
                    GoalName      = c.GoalName,
                    Id            = c.Id,
                    PatientGoalId = c.PatientGoalId,
                    PatientId     = c.PatientId,
                    StartDate     = c.StartDate,
                    DueDate       = c.DueDate,
                    StatusDate    = c.StatusDate,
                    StatusId      = c.StatusId,
                    Details       = c.Details
                })));

                ObjectId actionId = ObjectId.Parse("538ca77dfe7a59112c3649e4");

                PostProcessActionRequest request = new PostProcessActionRequest
                {
                    ContractNumber = "InHealth001",
                    PatientId      = "123456789012345678901234",
                    ProgramId      = "000000000000000000000000",
                    UserId         = "111111111111111111111111",
                    Version        = 1.0,
                    Action         = new DTO.Actions
                    {
                        Id            = actionId.ToString(),
                        Completed     = true,
                        ElementState  = 4,
                        Name          = "test action from stub",
                        Description   = "action Description",
                        Text          = "test action 1",
                        AttrEndDate   = DateTime.UtcNow.AddDays(10),
                        AttrStartDate = DateTime.UtcNow,
                        AssignDate    = System.DateTime.UtcNow,
                        Steps         = new List <Step>
                        {
                            new Step
                            {
                                Id           = "000000000011111111111234",
                                Completed    = true,
                                ElementState = 1,
                                SpawnElement =
                                    new List <SpawnElement>
                                {
                                    new SpawnElement
                                    {
                                        ElementId   = "5463cd99fe7a592668f67a15",
                                        ElementType = 501,
                                        Tag         = ""
                                    }
                                }
                            }
                        }
                    }
                };

                PostProcessActionResponse response = pm.ProcessActionResults(request);

                Assert.IsNotNull(response.PlanElems);
                Assert.IsNotNull(response.PlanElems.Actions);
                Assert.IsNotNull(response.PlanElems.Interventions);
            }