public bool Save(object entity) { bool success = false; MEPatientProgram p = (MEPatientProgram)entity; try { using (ProgramMongoContext ctx = new ProgramMongoContext(_dbName)) { ctx.PatientPrograms.Collection.Save(p); success = true; AuditHelper.LogDataAudit(this.UserId, MongoCollectionName.PatientProgram.ToString(), p.Id.ToString(), Common.DataAuditType.Update, _dbName); } return(success); } catch (Exception ex) { throw new Exception("DD:PatientProgramRepository:Save()::" + ex.Message, ex.InnerException); } }
private DateTime?getDisenrollmentActionsCompletedDate(MEPatientProgram mePP) { 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) { if (string.Compare(meA.Name, "Disenrollment", true) == 0) { if (meA.DateCompleted != null) { return(meA.DateCompleted); } } } } } } return(null); }
private DateTime?getActionsEarliestCompletedDate(MEPatientProgram mePP) { List <DateTime> completedDates = new List <DateTime>(); 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) { if (meA.DateCompleted != null) { completedDates.Add((DateTime)meA.DateCompleted); } } } } } completedDates.Sort(); if (completedDates.Count > 0) { return(completedDates[0]); } else { return(null); } }
public DeletePatientProgramDataResponse DeletePatientProgram(DeletePatientProgramDataRequest request) { DeletePatientProgramDataResponse response = null; bool success = false; try { response = new DeletePatientProgramDataResponse(); IProgramRepository ppRepo = Factory.GetRepository(request, RepositoryType.PatientProgram); MEPatientProgram mePP = ppRepo.FindByID(request.Id) as MEPatientProgram; DeletedPatientProgram deletedPatientProgram = null; if (mePP != null) { if (delete(mePP, request, ppRepo, out deletedPatientProgram)) { success = true; } } else { success = true; } response.DeletedPatientProgram = deletedPatientProgram; response.Success = success; return(response); } catch (Exception ex) { throw ex; } }
public object FindByID(string entityID) { try { MEPatientProgram result = null; using (ProgramMongoContext ctx = new ProgramMongoContext(_dbName)) { var findcp = MB.Query.And( MB.Query <MEPatientProgram> .EQ(b => b.Id, ObjectId.Parse(entityID)), MB.Query <MEPatientProgram> .EQ(b => b.DeleteFlag, false)); MEPatientProgram cp = ctx.PatientPrograms.Collection.Find(findcp).FirstOrDefault(); if (cp != null) { result = cp; } else { throw new ArgumentException("ProgramID is not valid or is missing from the records."); } } return(result); } catch (Exception ex) { throw new Exception("DD:PatientProgramRepository:FindByID()::" + ex.Message, ex.InnerException); } }
public object Insert(object newEntity) { try { MEPatientProgram nmePP = (MEPatientProgram)newEntity; ProgramInfo pi = null; using (ProgramMongoContext ctx = new ProgramMongoContext(_dbName)) { nmePP.UpdatedBy = null; nmePP.LastUpdatedOn = null; ctx.PatientPrograms.Collection.Insert(nmePP); // update programid in modules var q = MB.Query <MEPatientProgram> .EQ(b => b.Id, nmePP.Id); nmePP.Modules.ForEach(s => s.ProgramId = nmePP.Id); nmePP.Modules.ForEach(s => s.Objectives = null); ctx.PatientPrograms.Collection.Update(q, MB.Update.SetWrapped <List <Module> >(MEPatientProgram.ModulesProperty, nmePP.Modules)); // hydrate response object pi = new ProgramInfo { Id = nmePP.Id.ToString(), Name = nmePP.Name, ShortName = nmePP.ShortName, Status = (int)nmePP.Status, PatientId = nmePP.PatientId.ToString(), //ProgramState = (int)nmePP.ProgramState, // depricated - Use Element state instead. ElementState = (int)nmePP.State, ProgramSourceId = (nmePP.SourceId == null) ? null : nmePP.SourceId.ToString() }; AuditHelper.LogDataAudit(this.UserId, MongoCollectionName.PatientProgram.ToString(), nmePP.Id.ToString(), Common.DataAuditType.Insert, _dbName); } return(pi); } catch (Exception ex) { throw new Exception("DD:PatientProgram:Insert()::" + ex.Message, ex.InnerException); } }
public void DD_FindByID_AttrEndDate() { DateTime?time = Convert.ToDateTime("1/1/1901"); StubProgramRepositoryFactory factory = new StubProgramRepositoryFactory(); GetPatientProgramsDataRequest request = new GetPatientProgramsDataRequest { ContractNumber = "InHealth001", Context = "NG", UserId = "000000000000000000000000" }; IProgramRepository repo = factory.GetRepository(request, RepositoryType.PatientProgram); MEPatientProgram mep = repo.FindByID("000000000000000000000000") as MEPatientProgram; DateTime? tDate = mep.Modules[0].AttributeEndDate; Assert.AreEqual(time, tDate); }
public void DD_FindByID_AssignedBy() { string ctrl = "123456789011111111112223"; StubProgramRepositoryFactory factory = new StubProgramRepositoryFactory(); GetPatientProgramsDataRequest request = new GetPatientProgramsDataRequest { ContractNumber = "InHealth001", Context = "NG", UserId = "000000000000000000000000" }; IProgramRepository repo = factory.GetRepository(request, RepositoryType.PatientProgram); MEPatientProgram mep = repo.FindByID("000000000000000000000000") as MEPatientProgram; string sample = mep.Modules[0].AssignedBy.ToString(); Assert.AreEqual(ctrl, sample); }
public GetPatientActionDetailsDataResponse GetActionDetails(GetPatientActionDetailsDataRequest request) { try { GetPatientActionDetailsDataResponse response = new GetPatientActionDetailsDataResponse(); IProgramRepository repo = Factory.GetRepository(request, RepositoryType.PatientProgram);//.GetPatientProgramRepository(request); MEPatientProgram mepp = repo.FindByID(request.PatientProgramId) 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(); Module meModule = mepp.Modules.Where(m => m.Id == ObjectId.Parse(request.PatientModuleId)).FirstOrDefault(); if (meModule != null) { MongoDB.DTO.Action meAction = meModule.Actions.Where(a => a.Id == ObjectId.Parse(request.PatientActionId)).FirstOrDefault(); if (meAction != null) { List <Module> tMods = DTOUtility.GetTemplateModulesList(mepp.SourceId.ToString(), request.ContractNumber, request.UserId); Module tmodule = tMods.Find(tm => tm.SourceId == meModule.SourceId); if (tmodule != null) { meAction.Objectives = DTOUtility.GetTemplateObjectives(meAction.SourceId, tmodule); } response.ActionData = DTOUtility.GetAction(request.ContractNumber, request.UserId, meAction); } } return(response); } catch (Exception ex) { DTOUtility.ResponsesBag = null; throw new Exception("DD:DataProgramManager:GetActionDetails()::" + ex.Message, ex.InnerException); } finally { DTOUtility.ResponsesBag = null; } }
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; } }
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 List <MEPatientProgramResponse> RecurseAndStoreResponseObjects(MEPatientProgram prog, string contractNumber, string userId) { throw new NotImplementedException(); }
public List <global::MongoDB.Bson.ObjectId> GetStepIds(MEPatientProgram mepp) { throw new NotImplementedException(); }
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; } }
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; } }
private bool delete(MEPatientProgram mePP, DeletePatientProgramDataRequest request, IProgramRepository ppRepo, out DeletedPatientProgram deletedProgram) { DeletedPatientProgram deletedPatientProgram = null; List <string> deletedResponsesIds = null; bool success = false; try { if (mePP != null) { IProgramRepository ppAttributesRepo = Factory.GetRepository(request, RepositoryType.PatientProgramAttribute); IProgramRepository ppResponsesRepo = Factory.GetRepository(request, RepositoryType.PatientProgramResponse); #region PatientProgram request.Id = mePP.Id.ToString(); ppRepo.Delete(request); deletedPatientProgram = new DeletedPatientProgram { Id = request.Id }; success = true; deletedResponsesIds = new List <string>(); #endregion #region PPAttributes MEProgramAttribute pa = ppAttributesRepo.FindByPlanElementID(request.Id) as MEProgramAttribute; if (pa != null) { DeletePatientProgramAttributesDataRequest deletePPAttrDataRequest = new DeletePatientProgramAttributesDataRequest { Context = request.Context, ContractNumber = request.ContractNumber, Id = pa.Id.ToString(), UserId = request.UserId, Version = request.Version }; ppAttributesRepo.Delete(deletePPAttrDataRequest); deletedPatientProgram.PatientProgramAttributeId = deletePPAttrDataRequest.Id; success = true; } #endregion #region PPResponses List <Module> modules = mePP.Modules; if (modules != null && modules.Count > 0) { modules.ForEach(m => { List <MongoDB.DTO.Action> actions = m.Actions; if (actions != null && actions.Count > 0) { actions.ForEach(a => { List <Step> steps = a.Steps; if (steps != null && steps.Count > 0) { steps.ForEach(s => { List <MEPatientProgramResponse> meResponses = ppResponsesRepo.FindByStepId(s.Id.ToString()) as List <MEPatientProgramResponse>; if (meResponses != null && meResponses.Count > 0) { meResponses.ForEach(r => { DeletePatientProgramResponsesDataRequest deletePPResponsesRequest = new DeletePatientProgramResponsesDataRequest { Context = request.Context, ContractNumber = request.ContractNumber, Id = r.Id.ToString(), UserId = request.UserId, Version = request.Version }; ppResponsesRepo.Delete(deletePPResponsesRequest); deletedResponsesIds.Add(deletePPResponsesRequest.Id); success = true; deletedPatientProgram.PatientProgramResponsesIds = deletedResponsesIds; }); } }); } }); } }); } #endregion } } catch (Exception ex) { success = false; string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0"; Common.Helper.LogException(int.Parse(aseProcessID), ex); } deletedProgram = deletedPatientProgram; return(success); }
public PutProgramToPatientResponse PutPatientToProgram(PutProgramToPatientRequest request) { try { PutProgramToPatientResponse response = new PutProgramToPatientResponse(); response.Outcome = new Phytel.API.DataDomain.Program.DTO.Outcome(); #region validation calls if (!IsValidPatientId(request)) { return(FormatExceptionResponse(response, "Patient does not exist or has an invalid id.", "500")); } if (!IsValidContractProgramId(request)) { return(FormatExceptionResponse(response, "ContractProgram does not exist or has an invalid identifier.", "500")); } if (!IsContractProgramAssignable(request)) { return(FormatExceptionResponse(response, "ContractProgram is not currently active.", "500")); } #endregion /**********************************/ List <MEPatientProgram> pp = DTOUtility.FindExistingpatientProgram(request); if (!DTOUtility.CanInsertPatientProgram(pp)) { response.Outcome.Result = 0; response.Outcome.Reason = pp[0].Name + " is already assigned or reassignment is not allowed"; } else { MEProgram cp = DTOUtility.GetProgramForDeepCopy(request); var stepIdList = new List <ObjectId>(); List <MEResponse> responseList = DTOUtility.GetProgramResponseslist(stepIdList, cp, request); DTOUtils.HydrateResponsesInProgram(cp, responseList, request.UserId); MEPatientProgram nmePp = DTOUtility.CreateInitialMEPatientProgram(request, cp, stepIdList); DTOUtility.InitializePatientProgramAssignment(request, nmePp); List <MEPatientProgramResponse> pprs = DTOUtils.ExtractMEPatientProgramResponses(nmePp, request.ContractNumber, request.UserId); ProgramInfo pi = DTOUtility.SaveNewPatientProgram(request, nmePp); if (pi != null) { response.program = pi; DTOUtility.SavePatientProgramResponses(pprs, request); DTOUtility.InitializeProgramAttributes(request, response); } response.Outcome.Result = 1; response.Outcome.Reason = "Successfully assigned this program for the individual"; } return(response); } catch (Exception ex) { throw new Exception("DD:DataProgramManager:PutPatientToProgram()::" + ex.Message, ex.InnerException); } }
public void InitializePatientProgramAssignment(DTO.PutProgramToPatientRequest request, MEPatientProgram nmePP) { throw new NotImplementedException(); }
public object FindByID(string entityID) { MEPatientProgram prog = new MEPatientProgram(this.userId) { Name = "test patient program", Description = "test program description", Id = ObjectId.Parse("000000000000000000000000"), EligibilityRequirements = "Test eligibility requirements", EligibilityStartDate = System.DateTime.UtcNow, EligibilityEndDate = System.DateTime.UtcNow, Objectives = new List <Objective> { new Objective { Id = ObjectId.Parse("123456789012345678901234"), Value = "testing", Units = "lbs", Status = Status.Active } }, Modules = new List <Module>() { new Module { Id = ObjectId.Parse("000000000000000000000000"), Name = "Test stub module 1", Description = "BSHSI - Outreach & Enrollment", SourceId = ObjectId.Parse("532b5585a381168abe00042c"), Actions = new List <Phytel.API.DataDomain.Program.MongoDB.DTO.Action>() { new Phytel.API.DataDomain.Program.MongoDB.DTO.Action { Id = ObjectId.Parse("000000000000000000000000"), SourceId = ObjectId.Parse("123456789012345678901234"), State = ElementState.InProgress, Name = "test action from stub", Description = "BSHSI - Outreach & Enrollment action description", AttributeStartDate = Convert.ToDateTime("1/1/1800"), AttributeEndDate = Convert.ToDateTime("1/1/1801"), AssignedOn = Convert.ToDateTime("1/1/1899"), AssignedTo = ObjectId.Parse("123456789011111111112232"), AssignedBy = ObjectId.Parse("123456789011111111112233"), Objectives = new List <Objective> { new Objective { Id = ObjectId.Parse("123456789012345678905678"), Value = "testing", Units = "lbs", Status = Status.Active }, new Objective { Id = ObjectId.Parse("567856789012345678905678"), Value = "testing action 2", Units = "hdl", Status = Status.Inactive } } } }, AttributeStartDate = Convert.ToDateTime("1/1/1900"), AttributeEndDate = Convert.ToDateTime("1/1/1901"), AssignedOn = Convert.ToDateTime("1/1/1999"), AssignedTo = ObjectId.Parse("123456789011111111112222"), AssignedBy = ObjectId.Parse("123456789011111111112223"), Objectives = new List <Objective> { new Objective { Id = ObjectId.Parse("123456789012345678901234"), Value = "testing", Units = "lbs", Status = Status.Active } } } } }; return(prog); }
public DTO.ProgramInfo SaveNewPatientProgram(DTO.PutProgramToPatientRequest request, MEPatientProgram nmePP) { throw new NotImplementedException(); }
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; } }