public static DTO.Program FormatProgramDetail(ProgramDetail program) { try { ProgramDetail p = program; DTO.Program pD = null; pD = new DTO.Program { AssignById = p.AssignBy, AssignDate = p.AssignDate, AssignToId = p.AssignTo, Client = p.Client, Completed = p.Completed, CompletedBy = p.CompletedBy, ContractProgramId = p.ContractProgramId, DateCompleted = p.DateCompleted, Description = p.Description, ElementState = p.ElementState, StateUpdatedOn = p.StateUpdatedOn, EligibilityEndDate = p.EligibilityEndDate, EligibilityRequirements = p.EligibilityRequirements, EligibilityStartDate = p.EligibilityStartDate, Enabled = p.Enabled, StartDate = p.StartDate, EndDate = p.EndDate, AttrEndDate = p.AttrEndDate, AttrStartDate = p.AttrStartDate, AuthoredBy = p.AuthoredBy, TemplateName = p.TemplateName, TemplateVersion = p.TemplateVersion, ProgramVersion = p.ProgramVersion, ProgramVersionUpdatedOn = p.ProgramVersionUpdatedOn, Id = p.Id, Modules = GetADModules(p.Modules), Name = p.Name, Next = p.Next, Objectives = GetADObjectives(p.ObjectivesData), Order = p.Order, PatientId = p.PatientId, Previous = p.Previous, ProgramState = p.ProgramState, ShortName = p.ShortName, SourceId = p.SourceId, SpawnElement = GetADSpawnElements(p.SpawnElement), Status = p.Status, Text = p.Text, Version = p.Version, Archived = p.Archived, ArchivedDate = p.ArchivedDate, ArchiveOriginId = p.ArchiveOriginId }; return(pD); } catch (Exception ex) { throw new Exception("AD:FormatProgramDetail()::" + ex.Message, ex.InnerException); } }
public AppDomain.NG.DTO.Outcome SaveProgramAttributeChanges(DTO.PostProgramAttributesChangeRequest request, ProgramDetail pg) { DTO.Outcome outCome = new DTO.Outcome { Result = 1, Reason = "Success!" }; return(outCome); }
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; } }
//GetProgramById public ProgramDetail GetProgramById(int id) { var model = new ProgramDetail(); using (var ctx = new ApplicationDbContext()) { var entity = ctx.Programs.FirstOrDefault(a => a.ProgramId == id); model.Name = entity.Name; model.Type = entity.Type; model.Prerequisite = entity.Prerequisite; model.AcademyId = entity.AcademyId; model.AcademyName = entity.AcademyName; } return(model); }
public ActionResult DetailPass(int id) { int Total = 0; var List = new List <ProgramDetail>(); var m_Program = new ProgramDetail(); List = AbstractDAOFactory.Instance().CreateProgramDAO().SP_Event_GetDetail_Web(id, out Total); if (List != null && List.Count > 0) { m_Program = List[0]; } else { m_Program = null; } ViewBag.List = List; ViewBag.Id = id; return(View(m_Program)); }
public AD.Outcome SaveProgramAttributeChanges( PostProgramAttributesChangeRequest request, ProgramDetail pD) { try { PostProgramAttributesChangeResponse sResponse = new PostProgramAttributesChangeResponse(); IRestClient client = new JsonServiceClient(); var url = Common.Helper.BuildURL(string.Format(@"{0}/{1}/{2}/{3}/Patient/{4}/Programs/{5}/Update", DDProgramServiceUrl, "NG", request.Version, request.ContractNumber, request.PatientId, request.ProgramId, request.Token), request.UserId); PutProgramActionProcessingResponse response = client.Put <PutProgramActionProcessingResponse>( url, new PutProgramActionProcessingRequest { Program = pD, UserId = request.UserId }); if (response != null) { sResponse.Outcome = new AD.Outcome { Reason = "Success", Result = 1 }; } return(sResponse.Outcome); } catch (Exception ex) { throw new Exception("AD:PlanElementEndpointUtil:SaveProgramAttributeChanges()::" + ex.Message, ex.InnerException); } }
public ProgramDetail GetProgramByDetail(int id) { var model = new ProgramDetail(); using (var ctx = new ApplicationDbContext()) { var entity = ctx.Programs.FirstOrDefault(i => i.ProgramId == id); var userName = ctx.Users.FirstOrDefault(u => u.Id == _userId).UserName; //var programs = ctx.Programs.Where(p => p.AcademyId == id); model.ProgramId = entity.ProgramId; model.Name = entity.Name; model.Type = entity.Type; model.Prerequisite = entity.Prerequisite; model.AcademyId = entity.AcademyId; model.AcademyName = entity.AcademyName; model.CreatedBy = entity.CreatedBy; model.Ratings = entity.Ratings; //model.Programs = entity.Programs; //model.Instructors = entity.Instructors; //model.Ratings = entity.Ratings; } return(model); }
public Outcome SaveProgramAttributeChanges(PostProgramAttributesChangeRequest request, ProgramDetail pg) { throw new NotImplementedException(); }
private static ProgramDetail GenTestProgram() { StepsDetail s = new StepsDetail() { Id = "52a641e8d433231824878c8f", ActionId = "52a0f33bd43323141c9eb274", ControlType = 1, Description = "description", Enabled = true, Question = "Are you an ABC Employee?", Notes = "Example notes", Completed = true, Order = 1, Status = 1, Responses = new List <ResponseDetail> { new ResponseDetail { Id = "52a641f1d433231824878c90", Nominal = true, Order = 1, NextStepId = "52a641f1d433231824878c90", StepId = "52a641e8d433231824878c8f" }, new ResponseDetail { Id = "52a641f1d433231824878c90", Nominal = true, Order = 2, NextStepId = "52a641f1d433231824878c90", StepId = "52a641e8d433231824878c8f" } } }; StepsDetail s1 = new StepsDetail() { Id = "52a641f1d433231824878c90", ActionId = "52a0f33bd43323141c9eb274", ControlType = 1, Description = "description", Enabled = true, Question = "Are you a spouse of an ABC Employee?", Notes = "Example notes", Completed = true, Order = 2, Status = 1, Responses = new List <ResponseDetail> { new ResponseDetail { Id = "52a641f1d433231824878c90", Nominal = true, Order = 1, NextStepId = "52a641f1d433231824878c90", StepId = "52a641f1d433231824878c90" }, new ResponseDetail { Id = "52a641f1d433231824878c90", Nominal = true, Order = 2, NextStepId = "52a641f1d433231824878c90", StepId = "52a641f1d433231824878c90" } } }; StepsDetail s2 = new StepsDetail() { Id = "52a641f1d433231824871234", ActionId = "52a0f33bd43323141c9eb274", ControlType = 1, Description = "description", Enabled = true, Question = "Are you a spouse of an ABC Employee?", Notes = "Example notes", Completed = true, Order = 2, Status = 1, StepTypeId = 7 }; List <SpawnElementDetail> se = new List <SpawnElementDetail>(); se.Add(new SpawnElementDetail { ElementId = "aaaaf33bd43323141c9eb274", ElementType = 3 }); se.Add(new SpawnElementDetail { ElementId = "52a0a775fe7a5915485b8866", ElementType = 2 }); se.Add(new SpawnElementDetail { ElementId = "52a0a775fe7a5915485b1212", ElementType = 2 }); ActionsDetail act = new ActionsDetail { Enabled = true, Id = "52a0f33bd43323141c9eb274", ModuleId = "52a0a775fe7a5915485bdfd1", Name = "act Verify P4H Eligibility", Description = "act - Assess whether individual is eligible for the program", CompletedBy = "Care Manager", Completed = false, Order = 1, Text = "testtest", Status = 1, SpawnElement = se, Steps = new List <StepsDetail> { s, s1, s2 } }; ActionsDetail act1 = new ActionsDetail { Enabled = true, Id = "5555f33bd43323141c9eb275", ModuleId = "52a0a775fe7a5915485bdfd1", Name = "act1 Verify P4H Eligibility", Description = "act1 Assess whether individual is eligible for the program", CompletedBy = "Care Manager", Completed = false, Order = 2, Text = "testtest", Status = 1, Previous = "52a0f33bd43323141c9eb274", Steps = new List <StepsDetail> { s, s1 } }; ActionsDetail act2 = new ActionsDetail { Enabled = false, Id = "aaaaf33bd43323141c9eb274", ModuleId = "52a0a775fe7a5915485bdfd1", Name = "act2 Verify P4H Eligibility", Description = "dependent on act1", CompletedBy = "Care Manager", Completed = false, Order = 3, Text = "testtest", Status = 1, Previous = "5555f33bd43323141c9eb275", Steps = new List <StepsDetail> { s, s1 } }; List <SpawnElementDetail> sem = new List <SpawnElementDetail>(); sem.Add(new SpawnElementDetail { ElementId = "9990a775fe7a5915485b1212", ElementType = 2 }); ModuleDetail mod = new ModuleDetail { Id = "52a0a775fe7a5915485bdfd1", Enabled = true, ProgramId = "52c71fd7d6a4850a1cf69494", Description = "Reduce the amount of crabs in the diet", Name = "Low Carb Diet Module", Completed = false, Order = 1, Text = "testtest", Status = 1, Actions = new List <ActionsDetail> { act, act1, act2 }, SpawnElement = sem }; ModuleDetail mod1 = new ModuleDetail { Id = "52a0a775fe7a5915485b8866", Enabled = false, ProgramId = "52c71fd7d6a4850a1cf69494", Text = "Reduce the amount of crabs in the diet", Description = "Reduce the amount of crabs in the diet", Name = "Low Carb Diet Module", Completed = false, Order = 1, Status = 1 }; ModuleDetail mod2 = new ModuleDetail { Id = "52a0a775fe7a5915485b1212", Enabled = false, ProgramId = "52c71fd7d6a4850a1cf69494", Text = "Reduce the amount of crabs in the diet", Description = "Reduce the amount of crabs in the diet", Name = "Low Carb Diet Module", Completed = false, Order = 1, Status = 1 }; ModuleDetail mod3 = new ModuleDetail { Id = "9990a775fe7a5915485b1212", Enabled = false, ProgramId = "52c71fd7d6a4850a1cf69494", Text = "Testgen module number 3", Description = "module number 3", Name = "Low Carb Diet Module", Completed = false, Order = 1, Status = 1 }; ProgramDetail pMap = new ProgramDetail() { Enabled = true, Id = "52c71fd7d6a4850a1cf69494", PatientId = "1234", Text = "THIS IS THE PROGRAM", Modules = new List <ModuleDetail> { mod, mod1, mod2, mod3 }, Completed = false, Order = 1, Status = 1 }; return(pMap); }
public object Update(object entity) { PutProgramActionProcessingRequest p = (PutProgramActionProcessingRequest)entity; ProgramDetail pg = p.Program; try { using (ProgramMongoContext ctx = new ProgramMongoContext(_dbName)) { var q = MB.Query <MEPatientProgram> .EQ(b => b.Id, ObjectId.Parse(p.ProgramId)); List <Module> mods = DTOUtils.CloneAppDomainModules(pg.Modules, this.UserId); var uv = new List <MB.UpdateBuilder>(); uv.Add(MB.Update.Set(MEPatientProgram.CompletedProperty, pg.Completed)); uv.Add(MB.Update.Set(MEPatientProgram.EnabledProperty, pg.Enabled)); uv.Add(MB.Update.Set(MEPatientProgram.OrderProperty, pg.Order)); //uv.Add(MB.Update.Set(MEPatientProgram.ProgramStateProperty, (ProgramState)pg.ProgramState)); // depricated - Use Element state instead. uv.Add(MB.Update.Set(MEPatientProgram.LastUpdatedOnProperty, System.DateTime.UtcNow)); uv.Add(MB.Update.Set(MEPatientProgram.UpdatedByProperty, ObjectId.Parse(this.UserId))); uv.Add(MB.Update.Set(MEPatientProgram.VersionProperty, pg.Version)); if (pg.AssignTo != null && !string.IsNullOrEmpty(pg.AssignTo)) { uv.Add(MB.Update.Set(MEPatientProgram.AssignToProperty, pg.AssignTo)); } else { uv.Add(MB.Update.Set(MEPatientProgram.AssignToProperty, BsonNull.Value)); } if (pg.ElementState != 0) { uv.Add(MB.Update.Set(MEPatientProgram.StateProperty, (ElementState)pg.ElementState)); } if (pg.StateUpdatedOn != null) { uv.Add(MB.Update.Set(MEPatientProgram.StateUpdatedOnProperty, pg.StateUpdatedOn)); } if (pg.Status != 0) { uv.Add(MB.Update.Set(MEPatientProgram.StatusProperty, (Status)pg.Status)); } if (pg.AssignBy != null && !string.IsNullOrEmpty(pg.AssignBy)) { uv.Add(MB.Update.Set(MEPatientProgram.AssignByProperty, pg.AssignBy)); } if (pg.AssignDate != null) { uv.Add(MB.Update.Set(MEPatientProgram.AssignDateProperty, pg.AssignDate)); } if (pg.AttrEndDate != null) { uv.Add(MB.Update.Set(MEPatientProgram.AttributeEndDateProperty, pg.AttrEndDate)); } if (pg.AttrStartDate != null) { uv.Add(MB.Update.Set(MEPatientProgram.AttributeStartDateProperty, pg.AttrStartDate)); } if (pg.Client != null) { uv.Add(MB.Update.Set(MEPatientProgram.ClientProperty, pg.Client)); } if (pg.CompletedBy != null) { uv.Add(MB.Update.Set(MEPatientProgram.CompletedByProperty, pg.CompletedBy)); } if (pg.ContractProgramId != null) { uv.Add(MB.Update.Set(MEPatientProgram.ContractProgramIdProperty, ObjectId.Parse(pg.ContractProgramId))); } if (pg.DateCompleted != null) { uv.Add(MB.Update.Set(MEPatientProgram.CompletedOnProperty, pg.DateCompleted)); } if (pg.Description != null) { uv.Add(MB.Update.Set(MEPatientProgram.DescriptionProperty, pg.Description)); } if (pg.EndDate != null) { uv.Add(MB.Update.Set(MEPatientProgram.EndDateProperty, pg.EndDate)); } if (pg.Name != null) { uv.Add(MB.Update.Set(MEPatientProgram.NameProperty, pg.Name)); } if (pg.Next != null) { uv.Add(MB.Update.Set(MEPatientProgram.NextProperty, DTOUtils.ParseObjectId(pg.Next))); } if (pg.Previous != null) { uv.Add(MB.Update.Set(MEPatientProgram.PreviousProperty, DTOUtils.ParseObjectId(pg.Previous))); } if (pg.ShortName != null) { uv.Add(MB.Update.Set(MEPatientProgram.ShortNameProperty, pg.ShortName)); } if (pg.SourceId != null) { uv.Add(MB.Update.Set(MEPatientProgram.SourceIdProperty, pg.SourceId)); } if (pg.StartDate != null) { uv.Add(MB.Update.Set(MEPatientProgram.StartDateProperty, pg.StartDate)); } if (mods != null) { uv.Add(MB.Update.SetWrapped <List <Module> >(MEPatientProgram.ModulesProperty, mods)); } if (pg.SpawnElement != null) { uv.Add(MB.Update.SetWrapped <List <SpawnElement> >(MEPatientProgram.SpawnProperty, DTOUtils.GetSpawnElements(pg.SpawnElement))); } if (pg.ObjectivesData != null) { uv.Add(MB.Update.SetWrapped <List <Objective> >(MEPatientProgram.ObjectivesInfoProperty, DTOUtils.GetObjectives(pg.ObjectivesData))); } IMongoUpdate update = MB.Update.Combine(uv); ctx.PatientPrograms.Collection.Update(q, update); AuditHelper.LogDataAudit(this.UserId, MongoCollectionName.PatientProgram.ToString(), p.ProgramId, Common.DataAuditType.Update, _dbName); } return(pg); } catch (Exception ex) { throw new Exception("DD:PatientProgramRepository:Update()::" + ex.Message, ex.InnerException); } }
public async Task <ApiResponse> Handle(AddProgramDetailCommand request, CancellationToken cancellationToken) { ApiResponse response = new ApiResponse(); if (request != null && !string.IsNullOrWhiteSpace(request.ProgramName)) { long LatestCodeId = 0; var code = string.Empty; try { ProgramDetail obj = _mapper.Map <AddProgramDetailCommand, ProgramDetail>(request); var data = await _dbContext.ProgramDetail.FirstOrDefaultAsync(x => x.IsDeleted == false && x.ProgramName.Trim().ToLower() == request.ProgramName.Trim().ToLower()); // Contains(model.ProgramName); if (data == null) { var ProgramDetail = await _dbContext.ProgramDetail .OrderByDescending(x => x.ProgramId) .FirstOrDefaultAsync(x => x.IsDeleted == false); if (ProgramDetail == null) { LatestCodeId = 1; code = ProjectUtility.GenerateCode(LatestCodeId); } else { LatestCodeId = ProgramDetail.ProgramId + 1; code = ProjectUtility.GenerateCode(LatestCodeId); } obj.ProgramName = request.ProgramName; obj.IsDeleted = false; obj.ProgramCode = code; obj.CreatedById = request.CreatedById; obj.CreatedDate = DateTime.UtcNow; await _dbContext.ProgramDetail.AddAsync(obj); await _dbContext.SaveChangesAsync(); if (obj.ProgramId != 0) { ProjectProgramModel projectProgramModel = new ProjectProgramModel { ProgramId = obj.ProgramId, ProjectId = request.ProjectId.Value, ProjectProgramId = 0 }; var addEditProjectProgram = await _iProjectServices.AddEditProjectProgram(projectProgramModel, request.CreatedById); if (addEditProjectProgram.StatusCode == 200) { response.data.ProgramDetail = obj; response.StatusCode = StaticResource.successStatusCode; response.Message = "Success"; } else { throw new Exception("Project Program could not be saved"); } } } else { response.StatusCode = StaticResource.NameAlreadyExist; response.Message = StaticResource.ListNameAlreadyExist; } } catch (Exception ex) { response.StatusCode = StaticResource.failStatusCode; response.Message = StaticResource.SomethingWrong + ex.Message; } } else if (request != null && string.IsNullOrWhiteSpace(request.ProgramName)) {//check for emptystring response.StatusCode = StaticResource.notValid; response.Message = StaticResource.validData; } else if (request == null) { response.StatusCode = StaticResource.NameAlreadyExist; } return(response); }