Example #1
0
        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);
        }
Example #2
0
        public static PatientGoalData GetInitialGoalRequest(GetInitializeGoalRequest request)
        {
            try
            {
                PatientGoalData result = null;
                IRestClient     client = new JsonServiceClient();

                string url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Goal/Initialize",
                                                                  DDPatientGoalsServiceUrl,
                                                                  "NG",
                                                                  request.Version,
                                                                  request.ContractNumber,
                                                                  request.PatientId), request.UserId);

                PutInitializeGoalDataResponse dataDomainResponse = client.Put <PutInitializeGoalDataResponse>(
                    url, new PutInitializeGoalDataRequest() as object);

                if (dataDomainResponse != null)
                {
                    result = dataDomainResponse.Goal;
                }

                return(result);
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:GetInitialGoalRequest()::" + ex.Message, ex.InnerException);
            }
        }
Example #3
0
        public GetPatientGoalDataResponse GetPatientGoal(GetPatientGoalDataRequest request)
        {
            GetPatientGoalDataResponse result = null;

            try
            {
                result = new GetPatientGoalDataResponse();
                IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientGoal);

                PatientGoalData patientGoalData = repo.FindByID(request.Id) as PatientGoalData;
                if (patientGoalData != null)
                {
                    //Get all barriers for a given goal
                    patientGoalData.BarriersData = getBarriersByPatientGoalId(request, patientGoalData.Id);

                    //Get all tasks for a given goal
                    patientGoalData.TasksData = getTasksByPatientGoalId(request, patientGoalData.Id);

                    //Get all interventions for a given goal
                    patientGoalData.InterventionsData = getInterventionsByPatientGoalId(request, patientGoalData.Id);
                }

                result.GoalData = patientGoalData;
                result.Version  = request.Version;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
        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);
        }
Example #5
0
        public PatientGoalData GetInitialGoalRequest(GetInitializeGoalRequest request)
        {
            var pgd = new PatientGoalData
            {
                Id        = "233336745678235647821232",
                Name      = "Example Patient Goal Data",
                StartDate = DateTime.UtcNow
            };

            return(pgd);
        }
Example #6
0
 public GetInitializeGoalResponse GetInitialGoalRequest(GetInitializeGoalRequest request)
 {
     try
     {
         GetInitializeGoalResponse response = new GetInitializeGoalResponse();
         PatientGoalData           pg       = (PatientGoalData)GoalsEndpointUtil.GetInitialGoalRequest(request);
         response.Goal    = GoalsUtil.GetPatientGoalForInitialize(request, pg);
         response.Version = request.Version;
         return(response);
     }
     catch (Exception ex)
     {
         throw new Exception("AD:GetInitialGoalRequest()::" + ex.Message, ex.InnerException);
     }
 }
Example #7
0
        public object FindByTemplateId(string patientId, string entityID)
        {
            PatientGoalData goalData = null;

            try
            {
                using (PatientGoalMongoContext ctx = new PatientGoalMongoContext(_dbName))
                {
                    List <IMongoQuery> queries = new List <IMongoQuery>
                    {
                        Query.EQ(MEPatientGoal.PatientIdProperty, ObjectId.Parse(patientId)),
                        Query.EQ(MEPatientGoal.TemplateIdProperty, ObjectId.Parse(entityID)),
                        Query.In(MEPatientGoal.StatusProperty, new BsonArray {
                            1, 3
                        }),
                        Query.EQ(MEPatientGoal.DeleteFlagProperty, false),
                        Query.EQ(MEPatientGoal.TTLDateProperty, BsonNull.Value)
                    };

                    var mQuery = Query.And(queries);
                    var mePG   = ctx.PatientGoals.Collection.Find(mQuery).FirstOrDefault();

                    if (mePG != null)
                    {
                        goalData = new PatientGoalData
                        {
                            Id               = mePG.Id.ToString(),
                            PatientId        = mePG.PatientId.ToString(),
                            TemplateId       = mePG.TemplateId.ToString(),
                            FocusAreaIds     = Helper.ConvertToStringList(mePG.FocusAreaIds),
                            Name             = mePG.Name,
                            SourceId         = (mePG.SourceId == null) ? null : mePG.SourceId.ToString(),
                            ProgramIds       = Helper.ConvertToStringList(mePG.ProgramIds),
                            TypeId           = ((int)mePG.Type),
                            StatusId         = ((int)mePG.Status),
                            StartDate        = mePG.StartDate,
                            EndDate          = mePG.EndDate,
                            TargetDate       = mePG.TargetDate,
                            TargetValue      = mePG.TargetValue,
                            CustomAttributes = DTOUtil.GetCustomAttributeIdAndValues(mePG.Attributes),
                            Details          = mePG.Details
                        };
                    }
                }
                return(goalData);
            }
            catch (Exception) { throw; }
        }
Example #8
0
        public object FindByTemplateId(string patientId, string entityID)
        {
            var goalData = new PatientGoalData
            {
                Id           = "5329ce4ad6a4850ebc4a7f07",
                PatientId    = "5325db9cd6a4850adcbba9ca",
                FocusAreaIds = new List <string> {
                },
                Name         = "test",
                SourceId     = "52fa57c9d433231dd0775011",
                ProgramIds   = new List <string> {
                    "5325db9cd6a4850adcbba9ca"
                },
                TypeId   = 0,
                StatusId = 1
            };

            return(goalData);
        }
Example #9
0
        public GetPatientGoalByTemplateIdResponse GetPatientByTemplateIdGoal(GetPatientGoalByTemplateIdRequest request)
        {
            GetPatientGoalByTemplateIdResponse result = null;

            try
            {
                result = new GetPatientGoalByTemplateIdResponse();
                IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientGoal);

                PatientGoalData patientGoalData = repo.FindByTemplateId(request.PatientId, request.TemplateId) as PatientGoalData;

                result.GoalData = patientGoalData;
                result.Version  = request.Version;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #10
0
        public PutUpdateGoalDataResponse PutPatientGoal(PutUpdateGoalDataRequest request)
        {
            try
            {
                PutUpdateGoalDataResponse result = new PutUpdateGoalDataResponse();

                IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientGoal);
                if (request.Goal != null)
                {
                    bool status = (bool)repo.Update(request);
                    if (status)
                    {
                        PatientGoalData data = repo.FindByID(request.Goal.Id) as PatientGoalData;
                        result.GoalData = data;
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #11
0
        public object Initialize(object newEntity)
        {
            PutInitializeGoalDataRequest request = (PutInitializeGoalDataRequest)newEntity;
            PatientGoalData patientGoalData      = null;
            MEPatientGoal   mePg = null;

            try
            {
                mePg = new MEPatientGoal(this.UserId)
                {
                    Id        = ObjectId.GenerateNewId(),
                    PatientId = ObjectId.Parse(request.PatientId),
                    TTLDate   = System.DateTime.UtcNow.AddDays(_initializeDays)
                                //,
                                //LastUpdatedOn = DateTime.UtcNow,
                                //UpdatedBy = ObjectId.Parse(this.UserId)
                };

                using (PatientGoalMongoContext ctx = new PatientGoalMongoContext(_dbName))
                {
                    ctx.PatientGoals.Collection.Insert(mePg);

                    AuditHelper.LogDataAudit(this.UserId,
                                             MongoCollectionName.PatientGoal.ToString(),
                                             mePg.Id.ToString(),
                                             Common.DataAuditType.Insert,
                                             request.ContractNumber);

                    patientGoalData = new PatientGoalData
                    {
                        Id = mePg.Id.ToString()
                    };
                }
                return(patientGoalData);
            }
            catch (Exception) { throw; }
        }
Example #12
0
        public IEnumerable <object> FindGoalsWithAProgramId(string entityId)
        {
            List <PatientGoalData> goals = null;

            try
            {
                using (PatientGoalMongoContext ctx = new PatientGoalMongoContext(_dbName))
                {
                    List <IMongoQuery> queries = new List <IMongoQuery>();
                    queries.Add(Query.In(MEPatientGoal.ProgramProperty, new List <BsonValue> {
                        BsonValue.Create(ObjectId.Parse(entityId))
                    }));
                    queries.Add(Query.EQ(MEPatientGoal.DeleteFlagProperty, false));
                    queries.Add(Query.EQ(MEPatientGoal.TTLDateProperty, BsonNull.Value));
                    IMongoQuery          mQuery  = Query.And(queries);
                    List <MEPatientGoal> meGoals = ctx.PatientGoals.Collection.Find(mQuery).ToList();
                    if (meGoals != null && meGoals.Count > 0)
                    {
                        goals = new List <PatientGoalData>();
                        foreach (MEPatientGoal mePG in meGoals)
                        {
                            PatientGoalData data = new PatientGoalData
                            {
                                Id         = mePG.Id.ToString(),
                                PatientId  = mePG.PatientId.ToString(),
                                Name       = mePG.Name,
                                ProgramIds = Helper.ConvertToStringList(mePG.ProgramIds)
                            };
                            goals.Add(data);
                        }
                    }
                }
                return(goals);
            }
            catch (Exception ex) { throw ex; }
        }
Example #13
0
        public object Update(object entity)
        {
            bool result = false;
            PutUpdateGoalDataRequest pgr = (PutUpdateGoalDataRequest)entity;
            PatientGoalData          pt  = pgr.Goal;

            try
            {
                using (PatientGoalMongoContext ctx = new PatientGoalMongoContext(_dbName))
                {
                    var q = MB.Query <MEPatientGoal> .EQ(b => b.Id, ObjectId.Parse(pt.Id));

                    var uv = new List <MB.UpdateBuilder>();
                    uv.Add(MB.Update.Set(MEPatientGoal.TTLDateProperty, BsonNull.Value));
                    uv.Add(MB.Update.Set(MEPatientGoal.DeleteFlagProperty, false));
                    uv.Add(MB.Update.Set(MEPatientGoal.VersionProperty, pgr.Version));
                    uv.Add(MB.Update.Set(MEPatientGoal.LastUpdatedOnProperty, DateTime.UtcNow));
                    uv.Add(MB.Update.Set(MEPatientGoal.UpdatedByProperty, ObjectId.Parse(this.UserId)));
                    if (pt.PatientId != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.PatientIdProperty, ObjectId.Parse(pt.PatientId)));
                    }
                    if (pt.FocusAreaIds != null)
                    {
                        uv.Add(MB.Update.SetWrapped <List <ObjectId> >(MEPatientGoal.FocusAreaProperty, DTOUtil.ConvertObjectId(pt.FocusAreaIds)));
                    }
                    if (pt.Name != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.NameProperty, pt.Name));
                    }
                    if (pt.SourceId != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.SourceProperty, ObjectId.Parse(pt.SourceId)));
                    }
                    if (pt.ProgramIds != null)
                    {
                        uv.Add(MB.Update.SetWrapped <List <ObjectId> >(MEPatientGoal.ProgramProperty, DTOUtil.ConvertObjectId(pt.ProgramIds)));
                    }
                    if (pt.TypeId != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.TypeProperty, pt.TypeId));
                    }
                    if (pt.StatusId != 0)
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.StatusProperty, pt.StatusId));
                    }
                    if (pt.TargetValue != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.TargetValueProperty, pt.TargetValue));
                    }
                    if (pt.StartDate != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.StartDateProperty, pt.StartDate));
                    }
                    else
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.StartDateProperty, BsonNull.Value));
                    }
                    if (pt.EndDate != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.EndDateProperty, pt.EndDate));
                    }
                    else
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.EndDateProperty, BsonNull.Value));
                    }
                    if (pt.TargetDate != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.TargetDateProperty, pt.TargetDate));
                    }
                    else
                    {
                        uv.Add(MB.Update.Set(MEPatientGoal.TargetDateProperty, BsonNull.Value));
                    }
                    if (pt.CustomAttributes != null)
                    {
                        uv.Add(MB.Update.SetWrapped <List <MAttribute> >(MEPatientGoal.AttributesProperty, DTOUtil.GetAttributes(pt.CustomAttributes)));
                    }

                    IMongoUpdate update = MB.Update.Combine(uv);
                    ctx.PatientGoals.Collection.Update(q, update);

                    AuditHelper.LogDataAudit(this.UserId,
                                             MongoCollectionName.PatientGoal.ToString(),
                                             pt.Id.ToString(),
                                             Common.DataAuditType.Update,
                                             pgr.ContractNumber);
                    result = true;
                }
                return(result as object);
            }
            catch (Exception) { throw; }
        }
Example #14
0
        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);
        }