public PatientTask GetOpenNotMetPatientTaskByTemplateId(string taskid, string tempId, string patientId, string userId, IAppDomainRequest req) { try { var request = new GetPatientTaskByTemplateIdRequest(); PatientTask task = null; IRestClient client = new JsonServiceClient(); var url = Helper.BuildURL( string.Format(@"{0}/{1}/{2}/{3}/Patient/{4}/Goal/Tasks?TemplateId={5}&GoalId={6}", "http://localhost:8888/PatientGoal", "NG", req.Version, req.ContractNumber, patientId, tempId, taskid), userId); var response = client.Get <GetPatientTaskByTemplateIdResponse>(url); if (response.TaskData != null) { task = Mapper.Map <PatientTask>(response.TaskData); } return(task); } catch (Exception ex) { throw new Exception("AD:PlanElementEndpointUtil:GetGoalById()::" + ex.Message, ex.InnerException); } }
public PatientTask CloneTask(PatientTask t) { try { PatientTask pt = new PatientTask { TargetValue = t.TargetValue, TargetDate = t.TargetDate, StatusId = t.StatusId, StatusDate = t.StatusDate, StartDate = t.StartDate, PatientGoalId = t.PatientGoalId, GoalName = t.GoalName, Description = t.Description, DeleteFlag = t.DeleteFlag, CustomAttributes = t.CustomAttributes, CreatedById = t.CreatedById, BarrierIds = t.BarrierIds, ClosedDate = t.ClosedDate, Id = t.Id, Details = t.Details }; return(pt); } catch (Exception ex) { throw new Exception("AD:PlanElementUtil:CloneTask()::" + ex.Message, ex.InnerException); } }
internal static PatientTask PostUpdateTaskRequest(PostPatientTaskRequest request) { try { PatientTask task = null; if (request.Task == null) { throw new Exception("The Task property is null in the request."); } IRestClient client = new JsonServiceClient(); string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Goal/{5}/Task/{6}/Update", DDPatientGoalsServiceUrl, "NG", request.Version, request.ContractNumber, request.PatientId, request.PatientGoalId, request.Id), request.UserId); PutUpdateTaskResponse response = client.Put <PutUpdateTaskResponse>(url, new PutUpdateTaskRequest { Task = GoalsUtil.ConvertToPatientTaskData(request.Task), UserId = request.UserId } as object); if (response != null && response.TaskData != null) { //Make a call to AttributeLibrary to get attributes details for Goal and Task. List <CustomAttribute> taskAttributesLibrary = GoalsEndpointUtil.GetAttributesLibraryByType(request, 2); task = GoalsUtil.ConvertToTask(response.TaskData, taskAttributesLibrary); } return(task); } catch (WebServiceException ex) { throw new WebServiceException("AD:PostUpdateTaskRequest()::" + ex.Message, ex.InnerException); } }
internal static PatientTask GetPatientTaskForInitialize(GetInitializeTaskRequest request, PatientTaskData ptd) { PatientTask pt = null; try { if (ptd != null) { pt = new PatientTask { CustomAttributes = GoalsEndpointUtil.GetAttributesLibraryByType(request, 2), Id = ptd.Id, StartDate = ptd.StartDate, StatusId = ptd.StatusId, TargetDate = ptd.TargetDate, TargetValue = ptd.TargetValue, DeleteFlag = ptd.DeleteFlag, Details = ptd.Details }; } } catch (Exception ex) { throw new Exception("AD:GetPatientTaskForInitialize()::" + ex.Message, ex.InnerException); } return(pt); }
public static List <PatientTask> GetTasks(GetTasksRequest request) { List <PatientTask> tasks = null; try { //[Route("/{Context}/{Version}/{ContractNumber}/Goal/Tasks", "POST")] IRestClient client = new JsonServiceClient(); string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Goal/Tasks", DDPatientGoalsServiceUrl, "NG", request.Version, request.ContractNumber), request.UserId); GetPatientTasksDataResponse ddResponse = client.Post <GetPatientTasksDataResponse>(url, new GetPatientTasksDataRequest { Context = "NG", ContractNumber = request.ContractNumber, Version = request.Version, UserId = request.UserId, StatusIds = request.StatusIds, PatientId = request.PatientId } as object); if (ddResponse != null && ddResponse.TasksData != null) { tasks = new List <PatientTask>(); List <PatientTaskData> dataList = ddResponse.TasksData; foreach (PatientTaskData n in dataList) { //Make a call to AttributeLibrary to get attributes details for Goal and Task. List <CustomAttribute> taskAttributesLibrary = GoalsEndpointUtil.GetAttributesLibraryByType(request, 2); PatientTask i = GoalsUtil.ConvertToTask(n, taskAttributesLibrary); tasks.Add(i); } } } catch { throw; } return(tasks); }
public static PatientTask ConvertToTask(PatientTaskData t, List <CustomAttribute> taskAttributesLibrary) { PatientTask task = null; if (t != null) { task = new PatientTask { Id = t.Id, PatientGoalId = t.PatientGoalId, TargetValue = t.TargetValue, StatusId = t.StatusId, TargetDate = t.TargetDate, CustomAttributes = GetCustomAttributeDetails(t.CustomAttributes, taskAttributesLibrary), BarrierIds = t.BarrierIds, Description = t.Description, StatusDate = t.StatusDate, StartDate = t.StartDate, ClosedDate = t.ClosedDate, CreatedById = t.CreatedById, GoalName = t.GoalName, DeleteFlag = t.DeleteFlag, TemplateId = t.TemplateId, Details = t.Details }; } return(task); }
public static PatientTaskData ConvertToPatientTaskData(PatientTask t) { PatientTaskData data = null; if (t != null) { data = new PatientTaskData { Id = t.Id, CustomAttributes = GetAttributeData(t.CustomAttributes), BarrierIds = t.BarrierIds, Description = t.Description, PatientGoalId = t.PatientGoalId, StartDate = t.StartDate, StatusId = t.StatusId, StatusDate = t.StatusDate, TargetDate = t.TargetDate, TargetValue = t.TargetValue, DeleteFlag = t.DeleteFlag, TemplateId = t.TemplateId, ClosedDate = t.ClosedDate, Details = t.Details }; } return(data); }
public static List <PatientTask> ConvertToTasks(List <PatientTaskData> list, List <CustomAttribute> taskAttributesLibrary) { List <PatientTask> taskList = null; try { if (list != null && list.Count > 0) { taskList = new List <PatientTask>(); foreach (PatientTaskData t in list) { PatientTask task = ConvertToTask(t, taskAttributesLibrary); if (task != null) { taskList.Add(task); } } } } catch (Exception ex) { throw new Exception("AD:GetTasks()::" + ex.Message, ex.InnerException); } return(taskList); }
private static List <object> CreateItemsBag(PatientTask pTsk, PatientGoal pGoal) { try { var items = new List <object>(); if (pTsk != null) { if (!items.Contains(pTsk)) { items.Add(pTsk); } } if (pGoal != null) { if (!items.Contains(pGoal)) { items.Add(pGoal); } } return(items); } catch (Exception ex) { throw new Exception("AD:TaskActivationRule:CreateItemsBag()::" + ex.Message, ex.InnerException); } }
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 GetInitializeTaskResponse GetInitialTask(GetInitializeTaskRequest request) { try { GetInitializeTaskResponse itr = new GetInitializeTaskResponse(); PatientTaskData ptd = (PatientTaskData)GoalsEndpointUtil.GetInitialTaskRequest(request); PatientTask task = GoalsUtil.GetPatientTaskForInitialize(request, ptd); itr.Task = task; itr.Version = request.Version; return(itr); } catch (Exception ex) { throw new Exception("AD:GetInitialTask()::" + ex.Message, ex.InnerException); } }
private bool InsertTaskAllowed(PatientTask patientTask) { try { if (patientTask == null) { return(true); } //else if (patientTask.StatusId == 2 || patientTask.StatusId == 4) //{ // return true; //} return(false); } catch (Exception ex) { throw new Exception("AD:TaskActivationRule:InsertInterventionAllowed()::" + 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 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); } }