Exemple #1
0
        public override void Implementation()
        {
            try
            {
                Results = new List <Result>();

                IProgramRepository repo = new ProgramRepositoryFactory().GetRepository(Request, RepositoryType.PatientProgram);

                List <MEPatientProgram> programs = (List <MEPatientProgram>)repo.SelectAll();

                programs.ForEach(p =>
                {
                    Request.UserId = p.UpdatedBy.ToString();
                    repo.UserId    = Constants.SystemContactId; // system

                    IProgramRepository arp  = new ProgramRepositoryFactory().GetRepository(Request, RepositoryType.PatientProgramAttribute);
                    MEProgramAttribute pAtt = (MEProgramAttribute)arp.FindByPlanElementID(p.Id.ToString());

                    if (p.AttributeStartDate == null && pAtt.StartDate != null)
                    {
                        p.AttributeStartDate = pAtt.StartDate;
                        ProgramDetail pd     = new ProgramDetail
                        {
                            AttrStartDate = p.AttributeStartDate,
                            Id            = p.Id.ToString(),
                            ProgramState  = (int)p.State,
                            Order         = p.Order,
                            Enabled       = p.Enabled,
                            Completed     = p.Completed
                        };
                        PutProgramActionProcessingRequest request = new PutProgramActionProcessingRequest {
                            Program = pd, ProgramId = p.Id.ToString()
                        };
                        repo.Update(request);
                        Results.Add(new Result {
                            Message = "PlanElement [" + p.Id.ToString() + "] in PatientProgramAttributes collection startdate moved"
                        });
                    }
                });
                Results.Add(new Result {
                    Message = "Total records updated: " + Results.Count
                });
            }
            catch (Exception ex)
            {
                Results.Add(new Result {
                    Message = ex.Message + " : " + ex.StackTrace
                });
                throw ex;
            }
        }
Exemple #2
0
        public override void Implementation()
        {
            try
            {
                Results = new List <Result>();

                IProgramRepository repo = new ProgramRepositoryFactory().GetRepository(Request, RepositoryType.PatientProgram);

                List <MEPatientProgram> programs = (List <MEPatientProgram>)repo.SelectAll();

                DateTime rco;
                programs.ForEach(p =>
                {
                    List <DTO.Action> acts = new List <DTO.Action>();
                    rco = p.RecordCreatedOn;
                    p.Modules.ForEach(m =>
                    {
                        m.Actions.ToList().ForEach(i => { acts.Add(i); });
                    });
                    DateTime?date = acts.Where(a => a.Completed == true).Select(a => a.DateCompleted).Min();
                    if (date != null)
                    {
                        rco            = (DateTime)date;
                        Request.UserId = p.UpdatedBy.ToString();

                        p.AttributeStartDate = rco;

                        IProgramRepository arp  = new ProgramRepositoryFactory().GetRepository(Request, RepositoryType.PatientProgramAttribute);
                        ProgramAttributeData pa = new ProgramAttributeData
                        {
                            PlanElementId = p.Id.ToString(),
                            //AttrStartDate = rco,
                            OptOut = false
                        };

                        arp.Update(pa);
                        Results.Add(new Result {
                            Message = "PlanElement [" + p.Id.ToString() + "] in PatientProgramAttributes collection startdate modified to " + date
                        });
                    }
                });
                Results.Add(new Result {
                    Message = "Total records updated: " + Results.Count
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
            public void Get_ContractProgram()
            {
                MongoContractProgramRepository cRepo   = new MongoContractProgramRepository("InHealth001");
                ProgramRepositoryFactory       factory = new ProgramRepositoryFactory();
                GetPatientProgramsDataRequest  request = new GetPatientProgramsDataRequest
                {
                    ContractNumber = "InHealth001",
                    Context        = "NG",
                    UserId         = "NGUser"
                };

                IProgramRepository repo = factory.GetRepository(request, RepositoryType.ContractProgram);

                Assert.AreEqual(cRepo.GetType(), repo.GetType());
            }
        public override void Implementation()
        {
            try
            {
                Results = new List <Result>();
                ObjectId           systemObjectId = ObjectId.Parse(Phytel.API.DataDomain.Program.DTO.Constants.SystemContactId);
                IRestClient        client         = new JsonServiceClient();
                IProgramRepository repo           = new ProgramRepositoryFactory().GetRepository(Request, Phytel.API.DataDomain.Program.DTO.RepositoryType.PatientProgram);

                List <MEPatientProgram> programs = (List <MEPatientProgram>)repo.SelectAll();

                foreach (MEPatientProgram mePP in programs)
                {
                    #region NIGHT-832, NIGHT831
                    mePP.AssignedBy = systemObjectId;
                    mePP.AssignedOn = mePP.RecordCreatedOn;
                    #endregion

                    #region NIGHT-833
                    GetPrimaryCareManagerDataRequest careMemberDataRequest = new GetPrimaryCareManagerDataRequest {
                        Context = Request.Context, ContractNumber = Request.ContractNumber, PatientId = mePP.PatientId.ToString(), UserId = Phytel.API.DataDomain.Program.DTO.Constants.SystemContactId, Version = 1
                    };
                    ObjectId primaryCareManagerId = Helper.GetPatientsPrimaryCareManager(careMemberDataRequest, client);
                    if (primaryCareManagerId == ObjectId.Empty)
                    {
                        mePP.AssignedTo = null;
                    }
                    else
                    {
                        mePP.AssignedTo = primaryCareManagerId;
                    }
                    #endregion

                    #region NIGHT-868
                    switch (mePP.State)
                    {
                    case ElementState.NotStarted:
                        mePP.StateUpdatedOn = mePP.AssignedOn;
                        break;

                    case ElementState.InProgress:
                        mePP.StateUpdatedOn = getActionsEarliestCompletedDate(mePP);
                        break;

                    case ElementState.Closed:
                        mePP.StateUpdatedOn = getDisenrollmentActionsCompletedDate(mePP);
                        break;
                    }
                    #endregion

                    mePP.LastUpdatedOn = DateTime.UtcNow;
                    mePP.UpdatedBy     = systemObjectId;
                    MEPatientProgram updatedProgram = mePP;
                    bool             success        = repo.Save(updatedProgram);
                    if (success)
                    {
                        Results.Add(new Result {
                            Message = string.Format("Updated Program Id : '{0}' in PatientProgram collection.", updatedProgram.Id)
                        });
                    }
                }
                Results.Add(new Result {
                    Message = "Total records updated: " + Results.Count
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public override void Implementation()
        {
            try
            {
                Results = new List <Result>();

                IProgramRepository repo = new ProgramRepositoryFactory().GetRepository(Request, RepositoryType.PatientProgram);

                List <MEPatientProgram> programs = (List <MEPatientProgram>)repo.SelectAll();

                foreach (MEPatientProgram mePP in programs)
                {
                    bool update = false;
                    if (string.Compare(mePP.Name, "BSHSI - Healthy Weight", true) == 0)
                    {
                        List <Module> modules = mePP.Modules;
                        if (modules != null & modules.Count > 0)
                        {
                            foreach (Module meM in modules)
                            {
                                if (string.Compare(meM.Name, "BSHSI - Initial Assessment", true) == 0)
                                {
                                    List <Phytel.API.DataDomain.Program.MongoDB.DTO.Action> actions = meM.Actions;
                                    if (actions != null && actions.Count > 0)
                                    {
                                        foreach (Phytel.API.DataDomain.Program.MongoDB.DTO.Action meA in actions)
                                        {
                                            if (string.Compare(meA.Name, "Health History", true) == 0)
                                            {
                                                List <Step> steps = meA.Steps;
                                                if (steps != null & steps.Count > 0)
                                                {
                                                    foreach (Step meS in steps)
                                                    {
                                                        if (string.Compare(meS.Question, "Are there any health conditions that might impact your ability to achieve your health goals?", true) == 0)
                                                        {
                                                            List <MEPatientProgramResponse> responses = meS.Responses;
                                                            if (responses != null && responses.Count > 0)
                                                            {
                                                                foreach (MEPatientProgramResponse meR in responses)
                                                                {
                                                                    if (string.Compare(meR.Text, "Diabetes", true) == 0)
                                                                    {
                                                                        meR.Text = "Diabetes mellitus";
                                                                        update   = true;
                                                                    }
                                                                    if (string.Compare(meR.Text, "HTN", true) == 0)
                                                                    {
                                                                        meR.Text = "Hypertension";
                                                                        update   = true;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (update)
                    {
                        mePP.LastUpdatedOn = DateTime.UtcNow;
                        mePP.UpdatedBy     = ObjectId.Empty;
                        MEPatientProgram updatedProgram = mePP;
                        bool             success        = repo.Save(updatedProgram);
                        if (success)
                        {
                            Results.Add(new Result {
                                Message = "Program Id [" + updatedProgram.Id.ToString() + "] updated."
                            });
                        }
                    }
                }
                Results.Add(new Result {
                    Message = "Total records updated: " + Results.Count
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #6
0
        public override void Implementation()
        {
            try
            {
                Results = new List <Result>();
                ObjectId           systemObjectId = ObjectId.Parse(Phytel.API.DataDomain.Program.DTO.Constants.SystemContactId);
                IRestClient        client         = new JsonServiceClient();
                IProgramRepository repo           = new ProgramRepositoryFactory().GetRepository(Request, Phytel.API.DataDomain.Program.DTO.RepositoryType.PatientProgram);
                IProgramRepository ppResponserepo = new ProgramRepositoryFactory().GetRepository(Request, Phytel.API.DataDomain.Program.DTO.RepositoryType.PatientProgramResponse);

                List <MEPatientProgram> programs = (List <MEPatientProgram>)repo.SelectAll();

                foreach (MEPatientProgram mePP in programs)
                {
                    bool          update  = false;
                    List <Module> modules = mePP.Modules;
                    if (modules != null & modules.Count > 0)
                    {
                        foreach (Module meM in modules)
                        {
                            List <Phytel.API.DataDomain.Program.MongoDB.DTO.Action> actions = meM.Actions;
                            if (actions != null && actions.Count > 0)
                            {
                                foreach (Phytel.API.DataDomain.Program.MongoDB.DTO.Action meA in actions)
                                {
                                    #region ENG-544
                                    if (meA.StateUpdatedOn == null)
                                    {
                                        switch (meA.State)
                                        {
                                        case ElementState.NotStarted:
                                            meA.StateUpdatedOn = mePP.RecordCreatedOn;
                                            update             = true;
                                            break;

                                        case ElementState.InProgress:
                                            meA.StateUpdatedOn = getStepResponsesEarliestUpdatedDate(meA, ppResponserepo);
                                            update             = true;
                                            break;

                                        case ElementState.Completed:
                                            meA.StateUpdatedOn = meA.DateCompleted;
                                            update             = true;
                                            break;
                                        }
                                    }
                                    #endregion
                                }
                            }
                        }
                    }
                    if (update)
                    {
                        mePP.LastUpdatedOn = DateTime.UtcNow;
                        mePP.UpdatedBy     = systemObjectId;
                        MEPatientProgram updatedProgram = mePP;
                        bool             success        = repo.Save(updatedProgram);
                        if (success)
                        {
                            Results.Add(new Result {
                                Message = string.Format("Updated Program Id : '{0}' in PatientProgram collection.", updatedProgram.Id)
                            });
                        }
                    }
                }
                Results.Add(new Result {
                    Message = "Total records updated: " + Results.Count
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #7
0
        public override void Implementation()
        {
            try
            {
                Results = new List <Result>();
                ObjectId           systemObjectId = ObjectId.Parse(Phytel.API.DataDomain.Program.DTO.Constants.SystemContactId);
                IRestClient        client         = new JsonServiceClient();
                IProgramRepository repo           = new ProgramRepositoryFactory().GetRepository(Request, Phytel.API.DataDomain.Program.DTO.RepositoryType.PatientProgram);
                IProgramRepository ppResponserepo = new ProgramRepositoryFactory().GetRepository(Request, Phytel.API.DataDomain.Program.DTO.RepositoryType.PatientProgramResponse);

                List <MEPatientProgram> programs = (List <MEPatientProgram>)repo.SelectAll();

                foreach (MEPatientProgram mePP in programs)
                {
                    GetPrimaryCareManagerDataRequest careMemberDataRequest = new GetPrimaryCareManagerDataRequest {
                        Context = Request.Context, ContractNumber = Request.ContractNumber, PatientId = mePP.PatientId.ToString(), UserId = Phytel.API.DataDomain.Program.DTO.Constants.SystemContactId, Version = 1
                    };
                    ObjectId primaryCareManagerId = Helper.GetPatientsPrimaryCareManager(careMemberDataRequest, client);

                    List <Module> modules = mePP.Modules;
                    if (modules != null & modules.Count > 0)
                    {
                        foreach (Module meM in modules)
                        {
                            List <Phytel.API.DataDomain.Program.MongoDB.DTO.Action> actions = meM.Actions;
                            if (actions != null && actions.Count > 0)
                            {
                                foreach (Phytel.API.DataDomain.Program.MongoDB.DTO.Action meA in actions)
                                {
                                    #region NIGHT-876, NIGHT-835
                                    if (meM.Enabled && meA.Enabled)
                                    {
                                        meA.AssignedBy = systemObjectId;
                                        meA.AssignedOn = mePP.RecordCreatedOn;
                                    }

                                    #endregion

                                    #region NIGHT-877
                                    if (primaryCareManagerId == ObjectId.Empty)
                                    {
                                        meA.AssignedTo = null;
                                    }
                                    else
                                    {
                                        meA.AssignedTo = primaryCareManagerId;
                                    }
                                    #endregion

                                    #region NIGHT-952
                                    switch (meA.State)
                                    {
                                    case ElementState.NotStarted:
                                        meA.StateUpdatedOn = mePP.RecordCreatedOn;
                                        break;

                                    case ElementState.InProgress:
                                        meA.StateUpdatedOn = getStepResponsesEarliestUpdatedDate(meA, ppResponserepo);
                                        break;

                                    case ElementState.Completed:
                                        meA.StateUpdatedOn = meA.DateCompleted;
                                        break;
                                    }
                                    #endregion
                                }
                            }
                        }
                        mePP.LastUpdatedOn = DateTime.UtcNow;
                        mePP.UpdatedBy     = systemObjectId;
                        MEPatientProgram updatedProgram = mePP;
                        bool             success        = repo.Save(updatedProgram);
                        if (success)
                        {
                            Results.Add(new Result {
                                Message = string.Format("Updated Program Id : '{0}' in PatientProgram collection.", updatedProgram.Id)
                            });
                        }
                    }
                }
                Results.Add(new Result {
                    Message = "Total records updated: " + Results.Count
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public override void Implementation()
        {
            try
            {
                Results = new List <Result>();
                ObjectId           systemObjectId = ObjectId.Parse(Phytel.API.DataDomain.Program.DTO.Constants.SystemContactId);
                IRestClient        client         = new JsonServiceClient();
                IProgramRepository repo           = new ProgramRepositoryFactory().GetRepository(Request, Phytel.API.DataDomain.Program.DTO.RepositoryType.PatientProgram);

                List <MEPatientProgram> programs = (List <MEPatientProgram>)repo.SelectAll();

                foreach (MEPatientProgram mePP in programs)
                {
                    bool          update  = false;
                    List <Module> modules = mePP.Modules;
                    if (mePP.State == ElementState.NotStarted)
                    {
                        if (isAnyActionInProgressOrCompletedForAProgram(modules))
                        {
                            mePP.State = ElementState.InProgress;
                            update     = true;
                        }
                    }
                    if (modules != null & modules.Count > 0)
                    {
                        foreach (Module meM in modules)
                        {
                            if (meM.State == ElementState.NotStarted)
                            {
                                List <Phytel.API.DataDomain.Program.MongoDB.DTO.Action> actions = meM.Actions;
                                if (isAnyActionInProgressOrCompletedForAModule(actions))
                                {
                                    meM.State = ElementState.InProgress;
                                    update    = true;
                                }
                            }
                        }
                    }
                    if (update)
                    {
                        mePP.LastUpdatedOn = DateTime.UtcNow;
                        mePP.UpdatedBy     = systemObjectId;
                        MEPatientProgram updatedProgram = mePP;
                        bool             success        = repo.Save(updatedProgram);
                        if (success)
                        {
                            Results.Add(new Result {
                                Message = string.Format("Updated Program Id : '{0}' in PatientProgram collection.", updatedProgram.Id)
                            });
                        }
                    }
                }
                Results.Add(new Result {
                    Message = "Total records updated: " + Results.Count
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }