public PatientIntervention GetOpenNotMetPatientInterventionByTemplateId(string gid, string templateId, string patientId, string userId, IAppDomainRequest req) { try { var request = new GetPatientInterventionByTemplateIdRequest(); PatientIntervention intervention = null; IRestClient client = new JsonServiceClient(); var url = Helper.BuildURL( string.Format(@"{0}/{1}/{2}/{3}/Patient/{4}/Goal/Interventions?TemplateId={5}&GoalId={6}", "http://localhost:8888/PatientGoal", "NG", req.Version, req.ContractNumber, patientId, "5461bb4ffe7a59064cd074c0", "54652e3a84ac050f50239ded"), userId); var response = client.Get <GetPatientInterventionByTemplateIdResponse>(url); if (response.InterventionData != null) { intervention = Mapper.Map <PatientIntervention>(response.InterventionData); } return(intervention); } catch (Exception ex) { throw new Exception("AD:PlanElementEndpointUtil:GetGoalById()::" + ex.Message, ex.InnerException); } }
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); } }
public PatientIntervention CloneIntervention(PatientIntervention i) { try { PatientIntervention pi = new PatientIntervention { PatientDetails = i.PatientDetails, StatusId = i.StatusId, StatusDate = i.StatusDate, StartDate = i.StartDate, DueDate = i.DueDate, PatientId = i.PatientId, PatientGoalId = i.PatientGoalId, Id = i.Id, GoalName = i.GoalName, Description = i.Description, DeleteFlag = i.DeleteFlag, CreatedById = i.CreatedById, AssignedToId = i.AssignedToId, BarrierIds = i.BarrierIds, CategoryId = i.CategoryId, ClosedDate = i.ClosedDate, Details = i.Details }; return(pi); } catch (Exception ex) { throw new Exception("AD:PlanElementUtil:CloneIntervention()::" + ex.Message, ex.InnerException); } }
public PatientIntervention GetOpenNotMetPatientInterventionByTemplateId(string goalid, string tempId, string patientId, string userId, IAppDomainRequest req) { try { var request = new GetPatientInterventionByTemplateIdRequest(); PatientIntervention intervention = null; IRestClient client = new JsonServiceClient(); var url = Common.Helper.BuildURL( string.Format(@"{0}/{1}/{2}/{3}/Patient/{4}/Goal/Interventions?TemplateId={5}&GoalId={6}", DDPatientGoalsServiceUrl, "NG", req.Version, req.ContractNumber, patientId, tempId, goalid), userId); var response = client.Get <GetPatientInterventionByTemplateIdResponse>(url); if (response.InterventionData != null) { intervention = Mapper.Map <PatientIntervention>(response.InterventionData); } return(intervention); } catch (Exception ex) { throw new Exception("AD:PlanElementEndpointUtil:GetOpenNotMetPatientInterventionByTemplateId()::" + ex.Message, ex.InnerException); } }
internal static PatientIntervention PostUpdateInterventionRequest(PostPatientInterventionRequest request) { try { PatientIntervention intervention = null; if (request.Intervention == null) { throw new Exception("The Intervention 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}/Intervention/{6}/Update", DDPatientGoalsServiceUrl, "NG", request.Version, request.ContractNumber, request.PatientId, request.PatientGoalId, request.Id), request.UserId); PutUpdateInterventionResponse response = client.Put <PutUpdateInterventionResponse>(url, new PutUpdateInterventionRequest { Intervention = GoalsUtil.ConvertToInterventionData(request.Intervention), UserId = request.UserId } as object); if (response != null && response.InterventionData != null) { intervention = GoalsUtil.ConvertToIntervention(response.InterventionData); // Call Patient DD to get patient details. intervention.PatientDetails = GetPatientDetails(request.Version, request.ContractNumber, request.UserId, client, response.InterventionData.PatientId); intervention.PatientId = response.InterventionData.PatientId; } return(intervention); } catch (WebServiceException ex) { throw new WebServiceException("AD:PostUpdateInterventionRequest()::" + ex.Message, ex.InnerException); } }
public static PatientIntervention ConvertToIntervention(PatientInterventionData i) { PatientIntervention pi = null; if (i != null) { pi = new PatientIntervention { Id = i.Id, PatientGoalId = i.PatientGoalId, CategoryId = i.CategoryId, StatusId = i.StatusId, AssignedToId = i.AssignedToId, BarrierIds = i.BarrierIds, Description = i.Description, StatusDate = i.StatusDate, StartDate = i.StartDate, DueDate = i.DueDate, ClosedDate = i.ClosedDate, CreatedById = i.CreatedById, GoalName = i.GoalName, DeleteFlag = i.DeleteFlag, TemplateId = i.TemplateId, Details = i.Details }; } return(pi); }
public static List <PatientIntervention> ConvertToInterventions(IAppDomainRequest request, IRestClient client, List <PatientInterventionData> list) { List <PatientIntervention> interventionList = null; try { if (list != null && list.Count > 0) { interventionList = new List <PatientIntervention>(); foreach (PatientInterventionData i in list) { PatientIntervention pi = ConvertToIntervention(i); if (pi != null) { // Call Patient DD to get patient details. pi.PatientDetails = GoalsEndpointUtil.GetPatientDetails(request.Version, request.ContractNumber, request.UserId, client, i.PatientId); pi.PatientId = i.PatientId; interventionList.Add(pi); } } } } catch (Exception ex) { throw new Exception("AD:GetInterventions()::" + ex.Message, ex.InnerException); } return(interventionList); }
public static PatientInterventionData ConvertToInterventionData(PatientIntervention i) { PatientInterventionData data = null; if (i != null) { data = new PatientInterventionData { AssignedToId = i.AssignedToId, BarrierIds = i.BarrierIds, CategoryId = i.CategoryId, Description = i.Description, Id = i.Id, PatientGoalId = i.PatientGoalId, TemplateId = i.TemplateId, StartDate = i.StartDate, DueDate = i.DueDate, StatusId = i.StatusId, StatusDate = i.StatusDate, DeleteFlag = i.DeleteFlag, ClosedDate = i.ClosedDate, Details = i.Details }; } return(data); }
public static List <PatientIntervention> GetInterventions(GetInterventionsRequest request) { List <PatientIntervention> interventions = null; try { //[Route("/{Context}/{Version}/{ContractNumber}/Goal/Interventions", "POST")] IRestClient client = new JsonServiceClient(); string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Goal/Interventions", DDPatientGoalsServiceUrl, "NG", request.Version, request.ContractNumber), request.UserId); GetPatientInterventionsDataResponse ddResponse = client.Post <GetPatientInterventionsDataResponse>(url, new GetPatientInterventionsDataRequest { Context = "NG", ContractNumber = request.ContractNumber, Version = request.Version, UserId = request.UserId, AssignedToId = request.AssignedToId, CreatedById = request.CreatedById, PatientId = request.PatientId, StatusIds = request.StatusIds } as object); if (ddResponse != null && ddResponse.InterventionsData != null) { var filteredInterventions = ddResponse.InterventionsData; if (request.InterventionFilterType != 0) { filteredInterventions = GetFilteredInterventions(ddResponse.InterventionsData, request); } interventions = new List <PatientIntervention>(); var patientIds = filteredInterventions.Select(x => x.PatientId).ToList(); var patientsDetails = GetPatientsDetails(request.Version, request.ContractNumber, request.UserId, client, patientIds); foreach (PatientInterventionData n in filteredInterventions) { PatientIntervention i = GoalsUtil.ConvertToIntervention(n); i.PatientDetails = patientsDetails.FirstOrDefault(x => x.Id == n.PatientId); i.PatientId = n.PatientId; interventions.Add(i); } } } catch { throw; } return(interventions); }
public List <PatientIntervention> GetInterventions(GetInterventionsRequest request) { List <PatientIntervention> interventions = null; try { //[Route("/{Context}/{Version}/{ContractNumber}/Goal/Interventions", "POST")] IRestClient client = new JsonServiceClient(); string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Goal/Interventions", DDPatientGoalsServiceUrl, "NG", request.Version, request.ContractNumber), request.UserId); GetPatientInterventionsDataResponse ddResponse = client.Post <GetPatientInterventionsDataResponse>(url, new GetPatientInterventionsDataRequest { Context = "NG", ContractNumber = request.ContractNumber, Version = request.Version, UserId = request.UserId, AssignedToId = request.AssignedToId, CreatedById = request.CreatedById, PatientId = request.PatientId, StatusIds = request.StatusIds } as object); if (ddResponse != null && ddResponse.InterventionsData != null) { interventions = new List <PatientIntervention>(); List <PatientInterventionData> dataList = ddResponse.InterventionsData; foreach (PatientInterventionData n in dataList) { PatientIntervention i = GoalsUtil.ConvertToIntervention(n); // Call Patient DD to get patient details. i.PatientDetails = GetPatientDetails(request.Version, request.ContractNumber, request.UserId, client, n.PatientId); i.PatientId = n.PatientId; interventions.Add(i); } } } catch { throw; } return(interventions); }
private bool InsertInterventionAllowed(PatientIntervention patientIntr) { try { if (patientIntr == null) { return(true); } //if (patientIntr.StatusId == 2 || patientIntr.StatusId == 4) //{ // return true; //} return(false); } catch (Exception ex) { throw new Exception("AD:InterventionActivationRule:InsertInterventionAllowed()::" + 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 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); } }