示例#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;
            }
        }
示例#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;
            }
        }