private bool IsContractProgramAssignable(PutProgramToPatientRequest request) { bool result = false; try { IProgramRepository contractProgRepo = Factory.GetRepository(request, RepositoryType.ContractProgram); ContractProgram c = contractProgRepo.FindByID(request.ContractProgramId) as ContractProgram; if (c != null) { if (c.Status == 1 && c.Delete != true) { result = true; } } return(result); } catch (Exception ex) { throw new Exception("DD:DataProgramManager:IsContractProgramAssignable" + ex.Message, ex.InnerException); } }
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 GetStepResponseResponse GetStepResponse(GetStepResponseRequest request) { try { GetStepResponseResponse response = new GetStepResponseResponse(); IProgramRepository repo = Factory.GetRepository(request, RepositoryType.PatientProgramResponse); //.GetPatientProgramStepResponseRepository(request); MEPatientProgramResponse result = repo.FindByID(request.ResponseId) as MEPatientProgramResponse; if (result != null) { response.StepResponse = new StepResponse { Id = result.Id.ToString(), NextStepId = result.NextStepId.ToString(), Nominal = result.Nominal, Order = result.Order, Required = result.Required, Spawn = DTOUtils.GetResponseSpawnElement(result.Spawn), StepId = result.StepId.ToString(), Text = result.Text, Value = result.Value }; } return(response); } catch (Exception ex) { throw new Exception("DD:DataProgramManager:GetStepResponse()::" + 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 GetProgramResponse GetProgramByID(GetProgramRequest request) { try { GetProgramResponse programResponse = new GetProgramResponse(); DTO.Program result; IProgramRepository repo = Factory.GetRepository(request, RepositoryType.Program); result = repo.FindByID(request.ProgramID) as DTO.Program; programResponse.Program = result; return(programResponse != null ? programResponse : new GetProgramResponse()); } catch (Exception ex) { throw new Exception("DD:DataProgramManager:GetProgramByID()::" + ex.Message, ex.InnerException); } }
private bool IsValidContractProgramId(PutProgramToPatientRequest request) { bool result = false; try { IProgramRepository contractProgRepo = Factory.GetRepository(request, RepositoryType.ContractProgram); object contractProgram = contractProgRepo.FindByID(request.ContractProgramId); if (contractProgram != null) { result = true; } return(result); } catch (Exception ex) { throw new Exception("DD:DataProgramManager:IsValidContractProgramId()::" + ex.Message, ex.InnerException); } }
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 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; } }