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; } }