Ejemplo n.º 1
0
        public DTO.CareMemberData GetCareMember(DTO.GetCareMemberDataRequest request)
        {
            ICareMemberRepository repo       = Factory.GetRepository(request, RepositoryType.CareMember);
            CareMemberData        careMember = repo.FindByID(request.Id) as CareMemberData;

            return(careMember);
        }
Ejemplo n.º 2
0
        public object FindByID(string entityID)
        {
            CareMemberData careMemberData = null;

            try
            {
                using (CareMemberMongoContext ctx = new CareMemberMongoContext(_dbName))
                {
                    List <IMongoQuery> queries = new List <IMongoQuery>();
                    queries.Add(Query.EQ(MECareMember.IdProperty, ObjectId.Parse(entityID)));
                    queries.Add(Query.EQ(MECareMember.DeleteFlagProperty, false));
                    IMongoQuery  mQuery = Query.And(queries);
                    MECareMember meCM   = ctx.CareMembers.Collection.Find(mQuery).FirstOrDefault();
                    if (meCM != null)
                    {
                        careMemberData = new CareMemberData
                        {
                            Id        = meCM.Id.ToString(),
                            PatientId = meCM.PatientId.ToString(),
                            ContactId = meCM.ContactId.ToString(),
                            Primary   = meCM.Primary,
                            TypeId    = meCM.TypeId.ToString()
                        };
                    }
                }
                return(careMemberData);
            }
            catch (Exception) { throw; }
        }
Ejemplo n.º 3
0
        public PostCareMemberResponse InsertCareMember(PostCareMemberRequest request)
        {
            try
            {
                PostCareMemberResponse response = new PostCareMemberResponse();
                if (request.CareMember == null)
                {
                    throw new Exception("The CareMember property cannot be null in the request.");
                }

                if (!atleastOneCareMemberExists(request))
                {
                    //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/CareMember/Insert", "PUT")]
                    IRestClient client = new JsonServiceClient();
                    string      url    = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/patient/{4}/CareMember/Insert",
                                                                              DDCareMemberUrl,
                                                                              "NG",
                                                                              request.Version,
                                                                              request.ContractNumber,
                                                                              request.PatientId), request.UserId);

                    CareMemberData cmData = new CareMemberData
                    {
                        PatientId = request.CareMember.PatientId,
                        ContactId = request.CareMember.ContactId,
                        TypeId    = request.CareMember.TypeId,
                        Primary   = request.CareMember.Primary
                    };
                    PutCareMemberDataResponse dataDomainResponse =
                        client.Put <PutCareMemberDataResponse>(url, new PutCareMemberDataRequest
                    {
                        CareMember     = cmData,
                        Context        = "NG",
                        ContractNumber = request.ContractNumber,
                        Version        = request.Version,
                        UserId         = request.UserId,
                        PatientId      = request.PatientId
                    } as object);
                    if (dataDomainResponse != null && !(string.IsNullOrEmpty(dataDomainResponse.Id)))
                    {
                        response.Id      = dataDomainResponse.Id;
                        response.Version = dataDomainResponse.Version;

                        if (request.CareMember.Primary)
                        {
                            //Upsert the PrimaryCare Manager's ContactId in the CohortPatientView collection.
                            upsertCohortPatientView(request.PatientId, request.CareMember.ContactId, response.Version, request.ContractNumber, request.UserId);
                        }
                    }
                }
                return(response);
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:InsertCareMember()::" + ex.Message, ex.InnerException);
            }
        }
Ejemplo n.º 4
0
        public object Update(object entity)
        {
            PutUpdateCareMemberDataRequest request = (PutUpdateCareMemberDataRequest)entity;
            CareMemberData careMemberData          = request.CareMember;
            bool           result = false;

            try
            {
                if (careMemberData != null)
                {
                    using (CareMemberMongoContext ctx = new CareMemberMongoContext(_dbName))
                    {
                        var q = MB.Query <MECareMember> .EQ(b => b.Id, ObjectId.Parse(careMemberData.Id));

                        var uv = new List <MB.UpdateBuilder>();
                        uv.Add(MB.Update.Set(MECareMember.TTLDateProperty, BsonNull.Value));
                        uv.Add(MB.Update.Set(MECareMember.DeleteFlagProperty, false));
                        uv.Add(MB.Update.Set(MECareMember.UpdatedByProperty, ObjectId.Parse(this.UserId)));
                        uv.Add(MB.Update.Set(MECareMember.VersionProperty, request.Version));
                        uv.Add(MB.Update.Set(MECareMember.LastUpdatedOnProperty, System.DateTime.UtcNow));
                        uv.Add(MB.Update.Set(MECareMember.PrimaryProperty, careMemberData.Primary));
                        if (careMemberData.PatientId != null)
                        {
                            uv.Add(MB.Update.Set(MECareMember.PatientIdProperty, ObjectId.Parse(careMemberData.PatientId)));
                        }
                        if (careMemberData.ContactId != null)
                        {
                            uv.Add(MB.Update.Set(MECareMember.ContactIdProperty, ObjectId.Parse(careMemberData.ContactId)));
                        }
                        if (careMemberData.TypeId != null)
                        {
                            uv.Add(MB.Update.Set(MECareMember.TypeProperty, ObjectId.Parse(careMemberData.TypeId)));
                        }

                        IMongoUpdate       update = MB.Update.Combine(uv);
                        WriteConcernResult res    = ctx.CareMembers.Collection.Update(q, update);
                        if (res.Ok == false)
                        {
                            throw new Exception("Failed to update Care Member: " + res.ErrorMessage);
                        }
                        else
                        {
                            AuditHelper.LogDataAudit(this.UserId,
                                                     MongoCollectionName.CareMember.ToString(),
                                                     careMemberData.Id,
                                                     Common.DataAuditType.Update,
                                                     request.ContractNumber);
                        }

                        result = true;
                    }
                }
                return(result as object);
            }
            catch (Exception ex) { throw new Exception("CareMemberDD:MongoCareMemberRepository:Update()" + ex.Message, ex.InnerException); }
        }
Ejemplo n.º 5
0
        public void GetPrimaryCareManager_Test()
        {
            GetPrimaryCareManagerDataRequest request = new GetPrimaryCareManagerDataRequest {
                PatientId = "5325db1ad6a4850adcbba83a", Context = "NG", ContractNumber = "InHealth001", UserId = "000000000000000000000000", Version = 1.0
            };
            ICareMemberDataManager cm = new StubCareMemberDataManager {
                Factory = new StubCareMemberRepositoryFactory()
            };
            CareMemberData response = cm.GetPrimaryCareManager(request);

            Assert.IsTrue(response.Id == "53271896d6a4850adc518b1f");
        }
Ejemplo n.º 6
0
        public void GetCareMember_Test_Passes()
        {
            GetCareMemberDataRequest request = new GetCareMemberDataRequest {
                Id = "53271896d6a4850adc518b1f"
            };
            StubCareMemberDataManager cm = new StubCareMemberDataManager {
                Factory = new StubCareMemberRepositoryFactory()
            };
            CareMemberData response = cm.GetCareMember(request);

            Assert.IsTrue(response.ContactId == "5325c81f072ef705080d347e");
        }
Ejemplo n.º 7
0
        public DTO.CareMemberData GetPrimaryCareManager(DTO.GetPrimaryCareManagerDataRequest request)
        {
            CareMemberData        response    = null;
            ICareMemberRepository repo        = Factory.GetRepository(request, RepositoryType.CareMember);
            List <CareMemberData> careMembers = repo.FindByPatientId(request.PatientId) as List <CareMemberData>;

            if (careMembers != null)
            {
                response = careMembers.Find(c => c.Primary == true && c.TypeId == "530cd571d433231ed4ba969b");
            }
            return(response);
        }
Ejemplo n.º 8
0
 public CareMemberData GetCareMember(GetCareMemberDataRequest request)
 {
     try
     {
         CareMemberData        response = null;
         ICareMemberRepository repo     = Factory.GetRepository(request, RepositoryType.CareMember);
         response = repo.FindByID(request.Id) as CareMemberData;
         return(response);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 9
0
        public CareMember GetCareMember(GetCareMemberRequest request)
        {
            try
            {
                CareMember result = null;
                //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/CareMember/{Id}", "GET")]
                IRestClient client = new JsonServiceClient();
                string      url    = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/CareMember/{5}",
                                                                          DDCareMemberUrl,
                                                                          "NG",
                                                                          request.Version,
                                                                          request.ContractNumber,
                                                                          request.PatientId,
                                                                          request.Id), request.UserId);

                GetCareMemberDataResponse ddResponse = client.Get <GetCareMemberDataResponse>(url);

                if (ddResponse != null && ddResponse.CareMember != null)
                {
                    CareMemberData n          = ddResponse.CareMember;
                    List <string>  contactIds = new List <string>();
                    contactIds.Add(n.ContactId);
                    List <ContactData> contactsData = getContactDetails(contactIds, request.Version, request.ContractNumber, request.UserId);
                    string             pfName       = string.Empty;
                    string             gender       = string.Empty;
                    var contact = contactsData.Find(a => a.Id == n.ContactId);
                    if (contact != null)
                    {
                        pfName = contact.PreferredName;
                        gender = contact.Gender;
                    }
                    result = new CareMember
                    {
                        Id            = n.Id,
                        PatientId     = n.PatientId,
                        ContactId     = n.ContactId,
                        PreferredName = pfName,
                        Gender        = gender,
                        Primary       = n.Primary,
                        TypeId        = n.TypeId
                    };
                }
                return(result);
            }
            catch (WebServiceException ex)
            {
                throw new WebServiceException("AD:GetCareMember()::" + ex.Message, ex.InnerException);
            }
        }
Ejemplo n.º 10
0
        public void UpdateCareMember_Test()
        {
            CareMemberData n = new CareMemberData {
                Id = "530cf7a4d43323130096eff9", ContactId = "53043e53d433231f48de8a7a", Primary = false, TypeId = "530cd576d433231ed4ba969c", PatientId = "52f5589c072ef709f84e7798"
            };
            PutUpdateCareMemberDataRequest request = new PutUpdateCareMemberDataRequest
            {
                UserId     = "DD_Harness",
                Version    = 1,
                CareMember = n
            };
            StubCareMemberDataManager cm = new StubCareMemberDataManager {
                Factory = new StubCareMemberRepositoryFactory()
            };
            bool updated = cm.UpdateCareMember(request);

            Assert.IsTrue(updated);
        }
Ejemplo n.º 11
0
        public void InsertCareMember_Test()
        {
            CareMemberData n = new CareMemberData {
                ContactId = "53043e6cd433231f48de8a7c", Primary = true, TypeId = "530cd571d433231ed4ba969b", PatientId = "52f5589c072ef709f84e7798"
            };
            PutCareMemberDataRequest request = new PutCareMemberDataRequest
            {
                UserId     = "DD_Harness",
                Version    = 1,
                CareMember = n
            };
            StubCareMemberDataManager cm = new StubCareMemberDataManager {
                Factory = new StubCareMemberRepositoryFactory()
            };
            string id = cm.InsertCareMember(request);

            Assert.IsNotNull(id);
        }
Ejemplo n.º 12
0
        public object Insert(object newEntity)
        {
            PutCareMemberDataRequest request        = (PutCareMemberDataRequest)newEntity;
            CareMemberData           careMemberData = request.CareMember;
            MECareMember             meCM           = null;

            try
            {
                if (careMemberData != null)
                {
                    meCM = new MECareMember(this.UserId)
                    {
                        Id        = ObjectId.GenerateNewId(),
                        PatientId = ObjectId.Parse(careMemberData.PatientId),
                        ContactId = ObjectId.Parse(careMemberData.ContactId),
                        Primary   = careMemberData.Primary,
                        TypeId    = ObjectId.Parse(careMemberData.TypeId),
                        Version   = request.Version
                    };

                    using (CareMemberMongoContext ctx = new CareMemberMongoContext(_dbName))
                    {
                        WriteConcernResult wcr = ctx.CareMembers.Collection.Insert(meCM);
                        if (wcr.Ok == false)
                        {
                            throw new Exception("Care Member failed to insert: " + wcr.ErrorMessage);
                        }
                        else
                        {
                            AuditHelper.LogDataAudit(this.UserId,
                                                     MongoCollectionName.CareMember.ToString(),
                                                     meCM.Id.ToString(),
                                                     Common.DataAuditType.Insert,
                                                     request.ContractNumber);
                        }
                    }
                }
                return(meCM.Id.ToString());
            }
            catch (Exception) { throw; }
        }
Ejemplo n.º 13
0
 public CareMemberData GetPrimaryCareManager(GetPrimaryCareManagerDataRequest request)
 {
     try
     {
         CareMemberData        response    = null;
         ICareMemberRepository repo        = Factory.GetRepository(request, RepositoryType.CareMember);
         List <CareMemberData> careMembers = repo.FindByPatientId(request.PatientId) as List <CareMemberData>;
         if (careMembers != null)
         {
             GetLookUpsDataRequest lookupDataRequest = new GetLookUpsDataRequest {
                 Context = request.Context, ContractNumber = request.ContractNumber, Name = LookUpType.CareMemberType.ToString(), UserId = request.UserId, Version = request.Version
             };
             string careManagerLookUpId = getCareManagerLookupId(lookupDataRequest);
             response = careMembers.Find(c => c.Primary == true && c.TypeId == careManagerLookUpId);
         }
         return(response);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }