public PatientGoal GetOpenNotMetPatientGoalByTemplateId(string gid, string patientId, string userId, IAppDomainRequest req) { try { PatientGoal goal = null; IRestClient client = new JsonServiceClient(); //"/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Goal/" var url = Common.Helper.BuildURL(string.Format(@"{0}/{1}/{2}/{3}/Patient/{4}/Goal/?TemplateId={5}", DDPatientGoalsServiceUrl, "NG", req.Version, req.ContractNumber, patientId, gid), userId); var response = client.Get <GetPatientGoalByTemplateIdResponse>(url); if (response.GoalData != null) { goal = Mapper.Map <PatientGoal>(response.GoalData); } return(goal); } catch (Exception ex) { throw new Exception("AD:PlanElementEndpointUtil:GetOpenNotMetPatientGoalByTemplateId()::" + ex.Message, ex.InnerException); } }
private PatientGoal PostInitializeGoalRequest() { PatientGoal goal = new PatientGoal { Id = "52e26f0b072ef7191c111234", EndDate = System.DateTime.UtcNow.AddDays(30), Interventions = GetInterventions(), Name = "Remember cat facts.", PatientId = "52f55852072ef709f84e5be1", SourceId = "Source of all cat knowledge", StartDate = System.DateTime.UtcNow, StatusId = 1, TargetDate = System.DateTime.UtcNow, TargetValue = "Cats have nine lives.", Tasks = GetPatientTasks(), TypeId = 2, ProgramIds = GetProgramsList(), Barriers = GetBarriers(), CustomAttributes = GetAttributes(), FocusAreaIds = GetFocusAreas() }; return(goal); }
public PatientGoal CloneGoal(PatientGoal g) { try { PatientGoal pg = new PatientGoal { Id = g.Id, StatusId = g.StatusId, PatientId = g.PatientId, ProgramIds = g.ProgramIds, Interventions = g.Interventions, Tasks = g.Tasks, Barriers = g.Barriers, CustomAttributes = g.CustomAttributes, EndDate = g.EndDate, FocusAreaIds = g.FocusAreaIds, Name = g.Name, SourceId = g.SourceId, StartDate = g.StartDate, TargetDate = g.TargetDate, TargetValue = g.TargetValue, TypeId = g.TypeId, Details = g.Details }; return(pg); } catch (Exception ex) { throw new Exception("AD:PlanElementUtil:CloneGoal()::" + ex.Message, ex.InnerException); } }
public static PatientGoal ConvertToGoal(PatientGoalData g, List <CustomAttribute> goalAttributesLibrary) { PatientGoal goal = null; if (g != null) { goal = new PatientGoal { Id = g.Id, PatientId = g.PatientId, Name = g.Name, FocusAreaIds = g.FocusAreaIds, TemplateId = g.TemplateId, SourceId = g.SourceId, ProgramIds = g.ProgramIds, TypeId = g.TypeId, StatusId = g.StatusId, StartDate = g.StartDate, EndDate = g.EndDate, TargetDate = g.TargetDate, TargetValue = g.TargetValue, CustomAttributes = GoalsUtil.GetCustomAttributeDetails(g.CustomAttributes, goalAttributesLibrary), Details = g.Details }; } return(goal); }
internal static PatientGoal GetPatientGoalForInitialize(GetInitializeGoalRequest request, PatientGoalData pgd) { PatientGoal pg = null; try { if (pgd != null) { pg = new PatientGoal { CustomAttributes = GoalsEndpointUtil.GetAttributesLibraryByType(request, 1), //GetAttributesForInitialize(pgd.Attributes), // change this call when attributes are ready EndDate = pgd.EndDate, Id = pgd.Id, Name = pgd.Name, PatientId = pgd.PatientId, SourceId = pgd.SourceId, StartDate = pgd.StartDate, StatusId = pgd.StatusId, TargetDate = pgd.TargetDate, TargetValue = pgd.TargetValue, TypeId = pgd.TypeId }; } } catch (Exception ex) { throw new Exception("AD:GetPatientGoalForInitialize()::" + ex.Message, ex.InnerException); } return(pg); }
private static List <object> CreateItemsBag(PatientIntervention pIntr, PatientGoal pGoal) { try { var items = new List <object>(); if (pIntr != null) { if (!items.Contains(pIntr)) { items.Add(pIntr); } } if (pGoal != null) { if (!items.Contains(pGoal)) { items.Add(pGoal); } } return(items); } catch (Exception ex) { throw new Exception("AD:InterventionActivationRule:CreateItemsBag()::" + ex.Message, ex.InnerException); } }
private static PatientGoalData convertToPatientGoalData(PatientGoal pg) { PatientGoalData pgd = new PatientGoalData { Id = pg.Id, CustomAttributes = GetPatientGoalAttributes(pg.CustomAttributes), EndDate = pg.EndDate, FocusAreaIds = pg.FocusAreaIds, Name = pg.Name, PatientId = pg.PatientId, ProgramIds = pg.ProgramIds, SourceId = pg.SourceId, StartDate = pg.StartDate, StatusId = pg.StatusId, TargetDate = pg.TargetDate, TargetValue = pg.TargetValue, TypeId = pg.TypeId, TemplateId = pg.TemplateId, Details = pg.Details }; return(pgd); }
public PatientTask InsertPatientTask(PlanCOR.PlanElementEventArg arg, PatientGoal pGoal, DTO.Goal.Task taskTemplate) { try { PatientTask newPTask = Mapper.Map <PatientTask>(taskTemplate); newPTask.StartDate = HandleDueDate(taskTemplate.StartDateRange); newPTask.TargetDate = HandleDueDate(taskTemplate.TargetDateRange); newPTask.TemplateId = taskTemplate.Id; newPTask.PatientGoalId = pGoal.Id; // initialize patientgoal and get id var iPG = new GoalsEndpointUtils().GetInitialTaskRequest(new GetInitializeTaskRequest { Context = "NG", ContractNumber = arg.DomainRequest.ContractNumber, PatientId = arg.PatientId, Token = arg.DomainRequest.Token, UserId = arg.DomainRequest.UserId, Version = arg.DomainRequest.Version, PatientGoalId = pGoal.Id }); // update patientgoal if (iPG == null) { throw new ArgumentException("Failed to Initialize patient Task"); } newPTask.Id = iPG.Id; new GoalsEndpointUtils().PostUpdateTaskRequest(new PostPatientTaskRequest { ContractNumber = arg.DomainRequest.ContractNumber, Task = newPTask, PatientGoalId = iPG.Id, PatientId = arg.PatientId, Token = arg.DomainRequest.Token, UserId = arg.DomainRequest.UserId, Version = arg.DomainRequest.Version, Id = newPTask.Id }); return(newPTask); } catch (Exception ex) { throw new Exception("InsertPatientTask()::" + ex.Message, ex.InnerException); } }
public PatientGoal PostUpdateGoalRequest(PostPatientGoalRequest request) { try { PatientGoal goal = null; if (request.Goal == null) { throw new Exception("The Goal property is null in the request."); } else if (string.IsNullOrEmpty(request.Goal.Name) || string.IsNullOrEmpty(request.Goal.SourceId)) { throw new Exception("The goal name and source are required fields."); } IRestClient client = new JsonServiceClient(); string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Goal/{5}/Update", DDPatientGoalsServiceUrl, "NG", request.Version, request.ContractNumber, request.PatientId, request.Goal.Id), request.UserId); PutUpdateGoalDataResponse response = client.Put <PutUpdateGoalDataResponse>( url, new PutUpdateGoalDataRequest { Goal = convertToPatientGoalData(request.Goal), UserId = request.UserId } as object); if (response != null && response.GoalData != null) { //Make a call to AttributeLibrary to get attributes details for Goal. List <CustomAttribute> goalAttributesLibrary = GoalsEndpointUtil.GetAttributesLibraryByType(request, 1); goal = GoalsUtil.ConvertToGoal(response.GoalData, goalAttributesLibrary); } return(goal); } catch (WebServiceException ex) { throw new WebServiceException("AD:PostUpdateGoalRequest()::" + ex.Message, ex.InnerException); } }
private bool InsertPatientGoalAllowed(PatientGoal patientGoal) { try { if (patientGoal == null) { return(true); } //else if (patientGoal.StatusId == 2 || patientGoal.StatusId == 4) //{ // return true; //} return(false); } catch (Exception ex) { throw new Exception("AD:TaskActivationRule:InsertPatientGoalAllowed()::" + ex.Message, ex.InnerException); } }
public static PatientGoal GetPatientGoal(GetPatientGoalRequest request) { try { PatientGoal result = null; //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Goal/{Id}", "GET")] IRestClient client = new JsonServiceClient(); string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Goal/{5}", DDPatientGoalsServiceUrl, "NG", request.Version, request.ContractNumber, request.PatientId, request.Id), request.UserId); GetPatientGoalDataResponse ddResponse = client.Get <GetPatientGoalDataResponse>( url); if (ddResponse != null && ddResponse.GoalData != null) { //Make a call to AttributeLibrary to get attributes details for Goal and Task. List <CustomAttribute> goalAttributesLibrary = GoalsEndpointUtil.GetAttributesLibraryByType(request, 1); List <CustomAttribute> taskAttributesLibrary = GoalsEndpointUtil.GetAttributesLibraryByType(request, 2); result = GoalsUtil.ConvertToGoal(ddResponse.GoalData, goalAttributesLibrary); result.Barriers = GoalsUtil.ConvertToBarriers(ddResponse.GoalData.BarriersData); result.Tasks = GoalsUtil.ConvertToTasks(ddResponse.GoalData.TasksData, taskAttributesLibrary); result.Interventions = GoalsUtil.ConvertToInterventions(request, client, ddResponse.GoalData.InterventionsData); } return(result); } catch (WebServiceException ex) { throw new WebServiceException("AD:GetPatientGoal()::" + ex.Message, ex.InnerException); } }
public void HydratePlanElementLists(List <object> processedElements, DTO.PlanElements planElems) { object _obj = null; try { if (planElems == null) { throw new ArgumentException("planElems is null."); } if (processedElements == null) { throw new ArgumentException("processedElements is null."); } if (processedElements != null && processedElements.Count > 0) { foreach (Object obj in processedElements) { _obj = obj; if (obj.GetType() == typeof(Program)) { try { if (!planElems.Programs.Contains(obj)) { Program p = CloneProgram((Program)obj); planElems.Programs.Add(p); } } catch (Exception ex) { throw new ArgumentException("plan elems programs collection null" + ex.Message); } } else if (obj.GetType() == typeof(Module)) { try { if (!planElems.Modules.Contains(obj)) { Module m = CloneModule((Module)obj); planElems.Modules.Add(m); } } catch (Exception ex) { throw new ArgumentException("plan elems modules collection null" + ex.Message); } } else if (obj.GetType() == typeof(Actions)) { try { if (!planElems.Actions.Contains(obj)) { Actions a = CloneAction((Actions)obj); planElems.Actions.Add(a); } } catch (Exception ex) { throw new ArgumentException("plan elems actions collection null" + ex.Message); } } else if (obj.GetType() == typeof(Step)) { try { if (!planElems.Steps.Contains(obj)) { Step s = CloneStep((Step)obj); planElems.Steps.Add(s); } } catch (Exception ex) { throw new ArgumentException("plan elems step collection null" + ex.Message); } } else if (obj.GetType() == typeof(PatientGoal)) { try { if (!planElems.Goals.Contains(obj)) { PatientGoal s = CloneGoal((PatientGoal)obj); planElems.Goals.Add(s); } } catch (Exception ex) { throw new ArgumentException("plan elems patientgoal collection null" + ex.Message); } } else if (obj.GetType() == typeof(PatientIntervention)) { try { if (!planElems.Interventions.Contains(obj)) { PatientIntervention s = CloneIntervention((PatientIntervention)obj); planElems.Interventions.Add(s); } } catch (Exception ex) { throw new ArgumentException("plan elems PatientIntervention collection null" + ex.Message); } } else if (obj.GetType() == typeof(PatientTask)) { try { if (!planElems.Tasks.Contains(obj)) { PatientTask s = CloneTask((PatientTask)obj); planElems.Tasks.Add(s); } } catch (Exception ex) { throw new ArgumentException("plan elems patienttask collection null" + ex.Message); } } } } } catch (Exception ex) { throw new Exception("AD:PlanElementUtil:HydratePlanElementLists()::" + _obj.GetType().ToString() + ex.Message, ex.InnerException); } }
public PatientIntervention InsertPatientIntervention(PlanCOR.PlanElementEventArg arg, PatientGoal patientGoal, Intervention interventionTemplate) { return(new PatientIntervention { AssignedToId = arg.UserId, GoalName = interventionTemplate.GoalName, Id = interventionTemplate.Id, Description = interventionTemplate.Description, StartDate = interventionTemplate.StartDate, DueDate = interventionTemplate.DueDate, PatientId = arg.PatientId, StatusDate = interventionTemplate.StatusDate, StatusId = interventionTemplate.StatusId }); }
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) { 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 { 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 PatientGoalData convertToPatientGoalData(PatientGoal pg) { throw new NotImplementedException(); }