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 static PutRegisterPatientObservationResponse PutNewPatientProblem(string patientId, string userId, string elementId, IAppDomainRequest request) //{ // try // { // //register call to remote serivce. // IRestClient client = new JsonServiceClient(); // string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Observation/Insert", // DDPatientObservationServiceUrl, // "NG", // request.Version, // request.ContractNumber, // patientId), request.UserId); // PutRegisterPatientObservationResponse dataDomainResponse = // client.Put<PutRegisterPatientObservationResponse>( // url, new PutRegisterPatientObservationRequest // { // Id = elementId, // StateId = 2, // DisplayId = 1, // UserId = userId // } as object); // return dataDomainResponse; // } // catch (Exception ex) // { // throw new Exception("AD:PlanElementEndpointUtil:PutNewPatientProblem()::" + ex.Message, ex.InnerException); // } //} //public static PutUpdateObservationDataResponse UpdatePatientProblem(string patientId, string userId, string elementId, PatientObservation pod, bool _active, IAppDomainRequest request) //{ // try // { // //register call to remote serivce. // IRestClient client = new JsonServiceClient(); // string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Observation/Update", // DDPatientObservationServiceUrl, // "NG", // request.Version, // request.ContractNumber, // patientId), request.UserId); // PatientObservationRecordData pdata = new PatientObservationRecordData // { // Id = pod.Id, // StateId = pod.StateId, // DeleteFlag = false // }; // PutUpdateObservationDataRequest purequest = new PutUpdateObservationDataRequest // { // PatientObservationData = pdata, // Context = "NG", // ContractNumber = request.ContractNumber, // UserId = request.UserId, // }; // PutUpdateObservationDataResponse dataDomainResponse = // client.Put<PutUpdateObservationDataResponse>( // url, purequest as object); // return dataDomainResponse; // } // catch (Exception ex) // { // throw new Exception("AD:PlanElementEndpointUtil:UpdatePatientProblem()::" + ex.Message, ex.InnerException); // } //} internal static ProgramAttributeData GetProgramAttributes(string planElemId, IAppDomainRequest request) { ProgramAttributeData progAttr = null; try { double version = request.Version; string contractNumber = request.ContractNumber; string context = "NG"; IRestClient client = new JsonServiceClient(); string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Program/Attributes/?PlanElementId={4}", DDProgramServiceUrl, context, version, contractNumber, planElemId), request.UserId); GetProgramAttributeResponse resp = client.Get <GetProgramAttributeResponse>( url); return(progAttr = resp.ProgramAttribute); } catch (Exception ex) { throw new Exception("AD:PlanElementEndpointUtil:GetProgramAttributes()::" + ex.Message, ex.InnerException); } }
public StepPlanProcessor() { ProgramAttributes = new ProgramAttributeData(); 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 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 Processing_Time_Test() { Stopwatch st = new Stopwatch(); st.Start(); ProgramDataManager dm = new ProgramDataManager { Factory = new ProgramRepositoryFactory() }; IDataDomainRequest request = new GetPatientProgramsDataRequest { ContractNumber = "InHealth001", Context = "NG", UserId = "user" }; ProgramAttributeData pad = dm.GetProgramAttributes("535808a7d6a485044cedecd6", request); st.Stop(); int seconds = st.Elapsed.Milliseconds; }
public PutUpdateProgramAttributesResponse PutUpdateProgramAttributes(PutUpdateProgramAttributesRequest request) { try { PutUpdateProgramAttributesResponse result = new PutUpdateProgramAttributesResponse(); IProgramRepository responseRepo = Factory.GetRepository(request, RepositoryType.PatientProgramAttribute);//.GetProgramAttributesRepository(request); ProgramAttributeData pa = request.ProgramAttributes; result.Result = (bool)responseRepo.Update(pa); return(result); } catch (Exception ex) { throw new Exception("DD:DataProgramManager:PutUpdateProgramAttributes()::" + ex.Message, ex.InnerException); } }
public void SetProgramAttributes_DoNot_Set_Program_State_state_1() { IPlanElementUtils pUtils = new PlanElementUtils { ProgramAttributeStrategy = new ProgramAttributeStrategy() }; var pe = new AD.PlanElement { Enabled = false }; var progAttr = new ProgramAttributeData(); var prog = new AD.Program { Name = "test" }; pUtils.SetProgramAttributes(new AD.SpawnElement { Tag = "1", ElementType = 10, ElementId = "1234" }, prog, "user", progAttr); Assert.AreEqual(0, prog.ElementState); }
public ProgramAttributeData GetProgramAttributes(string objectId, IDataDomainRequest request) { try { ProgramAttributeData pad = null; IProgramRepository repo = Factory.GetRepository(request, RepositoryType.PatientProgramAttribute); MEProgramAttribute pa = repo.FindByPlanElementID(objectId) as MEProgramAttribute; if (pa != null) { pad = new ProgramAttributeData { // AssignedBy = pa.AssignedBy.ToString(), Sprint 12 // AssignedTo = pa.AssignedTo.ToString(), Sprint 12 // AssignedOn = pa.AssignedOn, Sprint 12 Completed = (int)pa.Completed, CompletedBy = pa.CompletedBy, DateCompleted = pa.DateCompleted, DidNotEnrollReason = pa.DidNotEnrollReason, Eligibility = (int)pa.Eligibility, // AttrEndDate = pa.EndDate, , Sprint 12 Enrollment = (int)pa.Enrollment, GraduatedFlag = (int)pa.GraduatedFlag, Id = pa.Id.ToString(), IneligibleReason = pa.IneligibleReason, Locked = (int)pa.Locked, OptOut = pa.OptOut, OverrideReason = pa.OverrideReason, PlanElementId = pa.PlanElementId.ToString(), Population = pa.Population, RemovedReason = pa.RemovedReason, // AttrStartDate = pa.StartDate, Sprint 12 Status = (int)pa.Status }; } return(pad); } catch (Exception ex) { throw new Exception("DD:DataProgramManager:GetProgramAttributes()::" + ex.Message, ex.InnerException); } }
public override void Execute(SpawnElement r, Program program, string userId, ProgramAttributeData progAttr) { try { if (r.Tag == null) { throw new ArgumentException("Cannot set attribute of type " + r.ElementType + ". Tag value is null."); } progAttr.Eligibility = (!string.IsNullOrEmpty(r.Tag)) ? Convert.ToInt32(r.Tag) : 0; } catch (Exception ex) { throw new Exception("AD:SetProgramAttributes()::Eligibility" + ex.Message, ex.InnerException); } int state; // no = 1, yes = 2 var isNum = int.TryParse(r.Tag, out state); if (!isNum) { return; } // program is closed due to ineligibility switch (state) { case 1: //program.ElementState = (int) DataDomain.Program.DTO.ElementState.Completed; //5; //program.StateUpdatedOn = System.DateTime.UtcNow; progAttr.Eligibility = 1; //program.AttrEndDate = System.DateTime.UtcNow; break; case 2: //program.ElementState = (int) DataDomain.Program.DTO.ElementState.InProgress; //4; //program.StateUpdatedOn = System.DateTime.UtcNow; progAttr.Eligibility = 2; break; } }
internal static bool UpdateProgramAttributes(ProgramAttributeData pAtt, IAppDomainRequest request) { bool result = false; try { double version = request.Version; string contractNumber = request.ContractNumber; string context = "NG"; IRestClient client = new JsonServiceClient(); string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Program/Attributes/Update/", DDProgramServiceUrl, context, version, contractNumber, pAtt.PlanElementId), request.UserId); PutUpdateProgramAttributesResponse resp = client.Put <PutUpdateProgramAttributesResponse>( url, new PutUpdateProgramAttributesRequest { ProgramAttributes = pAtt } as object); if (resp.Result) { result = true; } return(result); } catch (Exception ex) { throw new Exception("AD:PlanElementEndpointUtil:UpdateProgramAttributes()::" + ex.Message, ex.InnerException); } }
public void Set_Element_State_Change_Date() { IPlanElementUtils peUtil = new PlanElementUtils { }; AD.SpawnElement spwn = new AD.SpawnElement { ElementId = "123456789012345678901234", ElementType = 12, Tag = "3" }; AD.Program program = new AD.Program { ElementState = 1 }; ProgramAttributeData progAttr = new ProgramAttributeData(); peUtil.SetProgramAttributes(spwn, program, "UserId", progAttr); DateTime control = DateTime.UtcNow.Date; DateTime sample = ((DateTime)program.StateUpdatedOn).Date; Assert.AreEqual(control, sample); }
public object Insert(object newEntity) { bool result = false; ProgramAttributeData pa = (ProgramAttributeData)newEntity; MEProgramAttribute mepa = null; try { using (ProgramMongoContext ctx = new ProgramMongoContext(_dbName)) { mepa = new MEProgramAttribute(this.UserId) { Status = (Status)pa.Status, RemovedReason = pa.OverrideReason, Population = pa.Population, PlanElementId = ObjectId.Parse(pa.PlanElementId), OverrideReason = pa.OverrideReason, //OptOutReason = pa.OptOutReason, //OptOutDate = pa.OptOutDate, OptOut = pa.OptOut, Locked = (Locked)pa.Locked, IneligibleReason = pa.IneligibleReason, Completed = (Completed)pa.Completed, //AssignedOn = pa.AssignedOn, Sprint 12 CompletedBy = pa.CompletedBy, DateCompleted = pa.DateCompleted, DidNotEnrollReason = pa.DidNotEnrollReason, //DisEnrollReason = pa.DisEnrollReason, Eligibility = (EligibilityStatus)pa.Eligibility, //EligibilityEndDate = pa.EligibilityEndDate, //EligibilityOverride = (EligibilityOverride)pa.EligibilityOverride, //EligibilityRequirements = pa.EligibilityRequirements, //EligibilityStartDate = pa.EligibilityStartDate, // EndDate = pa.AttrEndDate, , Sprint 12 Enrollment = (EnrollmentStatus)pa.Enrollment, GraduatedFlag = (Graduated)pa.GraduatedFlag, // StartDate = pa.AttrStartDate, Sprint 12 DeleteFlag = false //,LastUpdatedOn = DateTime.UtcNow, //UpdatedBy = ObjectId.Parse(this.UserId) }; //if(pa.AssignedBy != null) Sprint 12 //{ // mepa.AssignedBy = ObjectId.Parse(pa.AssignedBy); //} //if (pa.AssignedTo != null) Sprint 12 //{ // mepa.AssignedTo = ObjectId.Parse(pa.AssignedTo); //} ctx.ProgramAttributes.Collection.Insert(mepa); AuditHelper.LogDataAudit(this.UserId, MongoCollectionName.PatientProgramAttribute.ToString(), mepa.Id.ToString(), Common.DataAuditType.Insert, _dbName); result = true; } return(result); } catch (Exception ex) { throw new Exception("DD:PatientProgramAttributeRepository:Insert()::" + ex.Message, ex.InnerException); } }
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 void Run(SpawnElement r, Program program, string userId, ProgramAttributeData progAttr) { _rules.First(a => a.ProgramAttributeType == r.ElementType).Execute(r, program, userId, progAttr); }
public override SpawnType Execute(string userId, PlanElementEventArg arg, SpawnElement pe, ProgramAttributeData pad) { var spawnType = new SpawnType { Type = _alertType.ToString() }; return(spawnType); }
public GetProgramDetailsSummaryResponse GetPatientProgramDetailsById(GetProgramDetailsSummaryRequest request) { try { GetProgramDetailsSummaryResponse response = new GetProgramDetailsSummaryResponse(); IProgramRepository repo = Factory.GetRepository(request, RepositoryType.PatientProgram); MEPatientProgram mepp = repo.FindByID(request.ProgramId) as MEPatientProgram; IProgramRepository respRepo = Factory.GetRepository(request, RepositoryType.PatientProgramResponse); var stepIds = mepp.Modules.SelectMany(m => m.Actions.SelectMany(a => a.Steps.Select(s => s.Id))).ToList(); DTOUtility.ResponsesBag = respRepo.Find(stepIds).Cast <MEPatientProgramResponse>().ToList(); response.Program = new ProgramDetail { Id = mepp.Id.ToString(), Client = mepp.Client != null?mepp.Client.ToString() : null, ContractProgramId = mepp.ContractProgramId.ToString(), Description = mepp.Description, Name = mepp.Name, PatientId = mepp.PatientId.ToString(), //ProgramState = (int)mepp.ProgramState, depricated - Use Element state instead. ShortName = mepp.ShortName, StartDate = mepp.StartDate, EndDate = mepp.EndDate, AttrStartDate = mepp.AttributeStartDate, AttrEndDate = mepp.AttributeEndDate, Status = (int)mepp.Status, Version = mepp.Version, Completed = mepp.Completed, Enabled = mepp.Enabled, Next = mepp.Next != null?mepp.Next.ToString() : string.Empty, Order = mepp.Order, Previous = mepp.Previous != null?mepp.Previous.ToString() : string.Empty, SourceId = mepp.SourceId.ToString(), AssignBy = mepp.AssignedBy.ToString(), AssignDate = mepp.AssignedOn, AssignTo = mepp.AssignedTo.ToString(), ElementState = (int)mepp.State, StateUpdatedOn = mepp.StateUpdatedOn, CompletedBy = mepp.CompletedBy, DateCompleted = mepp.DateCompleted, EligibilityEndDate = mepp.EligibilityEndDate, EligibilityStartDate = mepp.EligibilityStartDate, EligibilityRequirements = mepp.EligibilityRequirements, AuthoredBy = mepp.AuthoredBy, //ObjectivesData = DTOUtils.GetObjectives(mepp.Objectives), SpawnElement = DTOUtility.GetSpawnElement(mepp), Modules = DTOUtility.GetModules(mepp.Modules, mepp.ContractProgramId.ToString(), request) }; // load program attributes ProgramAttributeData pad = GetProgramAttributes(mepp.Id.ToString(), request); response.Program.Attributes = pad; // Get the fields from Program collection. MEProgram meProgram = DTOUtility.GetLimitedProgramDetails(mepp.SourceId.ToString(), request); if (meProgram != null) { response.Program.AuthoredBy = meProgram.AuthoredBy; response.Program.TemplateName = meProgram.TemplateName; response.Program.TemplateVersion = meProgram.TemplateVersion; response.Program.ProgramVersion = meProgram.ProgramVersion; response.Program.ProgramVersionUpdatedOn = meProgram.ProgramVersionUpdatedOn; response.Program.ObjectivesData = DTOUtility.GetObjectivesData(meProgram.Objectives); } return(response); } catch (Exception ex) { throw new Exception("DD:DataProgramManager:GetPatientProgramDetailsById()::" + ex.Message, ex.InnerException); } finally { DTOUtility.ResponsesBag = null; } }
public abstract void Execute(SpawnElement r, Program program, string userId, ProgramAttributeData progAttr);
public abstract SpawnType Execute(string userId, PlanElementEventArg arg, SpawnElement pe, ProgramAttributeData pad);
public bool InsertNewProgramAttribute(ProgramAttributeData pa, IAppDomainRequest request) { throw new NotImplementedException(); }
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 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); } }
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 bool UpdateProgramAttributes(ProgramAttributeData pAtt, IAppDomainRequest request) { throw new NotImplementedException(); }
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 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 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) { 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 object Update(object entity) { ProgramAttributeData mepa = (ProgramAttributeData)entity; bool result = false; try { using (ProgramMongoContext ctx = new ProgramMongoContext(_dbName)) { var q = MB.Query <MEProgramAttribute> .EQ(b => b.PlanElementId, ObjectId.Parse(mepa.PlanElementId)); var uv = new List <MB.UpdateBuilder>(); // state //if (mepa.AssignedBy != null) uv.Add(MB.Update.Set(MEProgramAttribute.AssignByProperty, mepa.AssignedBy)); //if (mepa.AssignedTo != null) uv.Add(MB.Update.Set(MEProgramAttribute.AssignToProperty, mepa.AssignedTo)); //if (mepa.AssignedOn != null) uv.Add(MB.Update.Set(MEProgramAttribute.AssignDateProperty, mepa.AssignedOn)); if (mepa.Population != null) { uv.Add(MB.Update.Set(MEProgramAttribute.PopulationProperty, mepa.Population)); } if (mepa.Completed != 0) { uv.Add(MB.Update.Set(MEProgramAttribute.CompletedProperty, mepa.Completed)); } if (mepa.CompletedBy != null) { uv.Add(MB.Update.Set(MEProgramAttribute.CompletedByProperty, mepa.CompletedBy)); } if (mepa.DateCompleted != null) { uv.Add(MB.Update.Set(MEProgramAttribute.CompletedOnProperty, mepa.DateCompleted)); } if (mepa.RemovedReason != null) { uv.Add(MB.Update.Set(MEProgramAttribute.RemovedReasonProperty, mepa.RemovedReason)); } if (mepa.GraduatedFlag != 0) { uv.Add(MB.Update.Set(MEProgramAttribute.GraduatedFlagProperty, mepa.GraduatedFlag)); } if (mepa.Locked != 0) { uv.Add(MB.Update.Set(MEProgramAttribute.LockedProperty, mepa.Locked)); } if (mepa.OverrideReason != null) { uv.Add(MB.Update.Set(MEProgramAttribute.OverrideReasonProperty, mepa.OverrideReason)); } if (mepa.Status != 0) { uv.Add(MB.Update.Set(MEProgramAttribute.StatusProperty, (Status)mepa.Status)); } // eligibility //if (mepa.EligibilityEndDate != null) uv.Add(MB.Update.Set(MEProgramAttribute.EligibilityEndDateProperty, mepa.EligibilityEndDate)); //if (mepa.EligibilityRequirements != null) uv.Add(MB.Update.Set(MEProgramAttribute.EligibilityRequirementsProperty, mepa.EligibilityRequirements)); //if (mepa.EligibilityStartDate != null) uv.Add(MB.Update.Set(MEProgramAttribute.EligibilityStartDateProperty, mepa.EligibilityStartDate)); if (mepa.IneligibleReason != null) { uv.Add(MB.Update.Set(MEProgramAttribute.IneligibleReasonProperty, mepa.IneligibleReason)); } //if (mepa.EligibilityOverride != 0) uv.Add(MB.Update.Set(MEProgramAttribute.EligibilityOverrideProperty, (EligibilityOverride)mepa.EligibilityOverride)); if (mepa.Eligibility != 0) { uv.Add(MB.Update.Set(MEProgramAttribute.EligibilityProperty, (EligibilityStatus)mepa.Eligibility)); } // optout //if (mepa.OptOutDate != null) uv.Add(MB.Update.Set(MEProgramAttribute.OptOutDateProperty, mepa.OptOutDate)); if (mepa.OptOut != null) { uv.Add(MB.Update.Set(MEProgramAttribute.OptOutProperty, mepa.OptOut)); } //if (mepa.OptOutReason != null) uv.Add(MB.Update.Set(MEProgramAttribute.OptOutReasonProperty, mepa.OptOutReason)); // dates //if (mepa.AttrStartDate != null) uv.Add(MB.Update.Set(MEProgramAttribute.StartDateProperty, mepa.AttrStartDate)); Sprint 12 //if (mepa.AttrEndDate != null) uv.Add(MB.Update.Set(MEProgramAttribute.EndDateProperty, mepa.AttrEndDate)); Sprint 12 // enrollment if (mepa.Enrollment != 0) { uv.Add(MB.Update.Set(MEProgramAttribute.EnrollmentProperty, (EnrollmentStatus)mepa.Enrollment)); } if (mepa.DidNotEnrollReason != null) { uv.Add(MB.Update.Set(MEProgramAttribute.DidNotEnrollReasonProperty, mepa.DidNotEnrollReason)); } //if (mepa.DisEnrollReason != null) uv.Add(MB.Update.Set(MEProgramAttribute.DisEnrollReasonProperty, mepa.DisEnrollReason)); uv.Add(MB.Update.Set(MEProgramAttribute.UpdatedByProperty, ObjectId.Parse(this.UserId))); uv.Add(MB.Update.Set(MEProgramAttribute.LastUpdatedOnProperty, DateTime.UtcNow)); if (uv.Count > 0) { IMongoUpdate update = MB.Update.Combine(uv); ctx.ProgramAttributes.Collection.Update(q, update); AuditHelper.LogDataAudit(this.UserId, MongoCollectionName.PatientProgramAttribute.ToString(), mepa.PlanElementId, MEProgramAttribute.PlanElementIdProperty, Common.DataAuditType.Update, _dbName); result = true; } } return(result); } catch (Exception ex) { throw new Exception("DD:PatientProgramAttributeRepository:Update()::" + ex.Message, ex.InnerException); } }