Beispiel #1
0
            public void Put_PatientId_With_ContactId()
            {
                ContactService cs = new ContactService
                {
                    CommonFormat = new StubCommonFormatter(),
                    Helpers      = new StubHelpers(),
                    Manager      = new ContactDataManager {
                        Factory = new StubContactRepositoryFactory()
                    }
                };

                PutRecentPatientRequest request = new PutRecentPatientRequest
                {
                    PatientId      = "111156789012345678901111",
                    ContactId      = "123456789012345678901234",
                    UserId         = "666656789012345678906666",
                    Context        = "NG",
                    ContractNumber = "InHealth001",
                    Version        = 1.0
                };

                PutRecentPatientResponse response = cs.Put(request);

                bool result = response.SuccessData;

                Assert.IsTrue(result);
            }
Beispiel #2
0
        public DeleteContactByPatientIdDataResponse DeleteContactByPatientId(DeleteContactByPatientIdDataRequest request)
        {
            DeleteContactByPatientIdDataResponse response = null;
            bool success = false;

            try
            {
                response = new DeleteContactByPatientIdDataResponse();

                IContactRepository repo    = Factory.GetRepository(request, RepositoryType.Contact);
                ContactData        contact = repo.GetContactByPatientId(request.PatientId) as ContactData;
                List <ContactWithUpdatedRecentList> contactsWithUpdatedRecentList = null;
                if (contact != null)
                {
                    request.Id = contact.Id;
                    repo.Delete(request);
                    response.DeletedId = request.Id;
                    success            = true;

                    // Remove this deleted contact(PatientId) from RecentList of  other contacts(users logged in).

                    List <ContactData> contactsWithAPatientInRecentList = repo.FindContactsWithAPatientInRecentList(request.PatientId) as List <ContactData>;
                    if (contactsWithAPatientInRecentList != null && contactsWithAPatientInRecentList.Count > 0)
                    {
                        contactsWithUpdatedRecentList = new List <ContactWithUpdatedRecentList>();
                        contactsWithAPatientInRecentList.ForEach(c =>
                        {
                            PutRecentPatientRequest recentPatientRequest = new PutRecentPatientRequest
                            {
                                ContactId      = c.Id,
                                Context        = request.Context,
                                ContractNumber = request.ContractNumber,
                                UserId         = request.UserId,
                                Version        = request.Version
                            };
                            int index = c.RecentsList.IndexOf(request.PatientId);
                            if (c.RecentsList.Remove(request.PatientId))
                            {
                                if (repo.UpdateRecentList(recentPatientRequest, c.RecentsList))
                                {
                                    contactsWithUpdatedRecentList.Add(new ContactWithUpdatedRecentList {
                                        ContactId = recentPatientRequest.ContactId, PatientIndex = index
                                    });
                                    success = true;
                                }
                            }
                        });
                    }
                }
                response.ContactWithUpdatedRecentLists = contactsWithUpdatedRecentList;
                response.Success = success;
                return(response);
            }
            catch (Exception ex) { throw ex; }
        }
Beispiel #3
0
        public DereferencePatientDataResponse DereferencePatient(DereferencePatientDataRequest request)
        {
            var response = new DereferencePatientDataResponse();

            try
            {
                var repo         = Factory.GetRepository(request, RepositoryType.Contact);
                var isSuccessful = repo.DereferencePatient(request);

                if (isSuccessful)
                {
                    // Remove this deleted contact(PatientId) from RecentList of  other contacts(users logged in).

                    List <ContactData> contactsWithAPatientInRecentList = repo.FindContactsWithAPatientInRecentList(request.PatientId) as List <ContactData>;
                    if (contactsWithAPatientInRecentList != null && contactsWithAPatientInRecentList.Count > 0)
                    {
                        var contactsWithUpdatedRecentList = new List <ContactWithUpdatedRecentList>();
                        contactsWithAPatientInRecentList.ForEach(c =>
                        {
                            PutRecentPatientRequest recentPatientRequest = new PutRecentPatientRequest
                            {
                                ContactId      = c.Id,
                                Context        = request.Context,
                                ContractNumber = request.ContractNumber,
                                UserId         = request.UserId,
                                Version        = request.Version
                            };
                            int index = c.RecentsList.IndexOf(request.PatientId);
                            if (c.RecentsList.Remove(request.PatientId))
                            {
                                if (repo.UpdateRecentList(recentPatientRequest, c.RecentsList))
                                {
                                    contactsWithUpdatedRecentList.Add(new ContactWithUpdatedRecentList {
                                        ContactId = recentPatientRequest.ContactId, PatientIndex = index
                                    });
                                }
                            }
                        });
                    }
                }
                response.IsSuccessful = isSuccessful;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
Beispiel #4
0
        public PutRecentPatientResponse AddRecentPatient(PutRecentPatientRequest request)
        {
            PutRecentPatientResponse response = new PutRecentPatientResponse {
                SuccessData = false, Version = 1.0
            };

            try
            {
                string patientId;
                int    limit = Limit;

                if (request.PatientId != null && request.PatientId.Length > 0)
                {
                    patientId = request.PatientId;

                    IContactRepository repo = Factory.GetRepository(request, RepositoryType.Contact);
                    // find contact
                    ContactData mContact = (ContactData)repo.FindByID(request.ContactId);

                    if (mContact != null)
                    {
                        if (mContact.RecentsList == null)
                        {
                            mContact.RecentsList = new List <string>();
                        }

                        // update recent list
                        MruList mruList = new MruList {
                            Limit = limit, RecentList = mContact.RecentsList
                        };
                        mruList.AddPatient(patientId);

                        if (repo.UpdateRecentList(request, mruList.RecentList))
                        {
                            response.SuccessData = true;
                        }
                    }
                }
                return(response);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #5
0
        //??
        public UndoDereferencePatientDataResponse UndoDereferencePatient(UndoDereferencePatientDataRequest request)
        {
            var response = new UndoDereferencePatientDataResponse();

            try
            {
                var repo         = Factory.GetRepository(request, RepositoryType.Contact);
                var isSuccessful = repo.UnDereferencePatient(request);

                // Add the deleted contact back into the RecentList of  other contacts(users logged in) who had him/her before the delete action.
                var undeletedContact = repo.FindByID(request.ContactId) as ContactData;
                if (undeletedContact != null)
                {
                    if (request.ContactWithUpdatedRecentLists != null && request.ContactWithUpdatedRecentLists.Count > 0)
                    {
                        request.ContactWithUpdatedRecentLists.ForEach(c =>
                        {
                            var contactData = repo.FindByID(c.ContactId) as ContactData;
                            if (contactData != null)
                            {
                                contactData.RecentsList.Insert(c.PatientIndex, undeletedContact.PatientId);
                                PutRecentPatientRequest recentPatientRequest = new PutRecentPatientRequest
                                {
                                    ContactId      = c.ContactId,
                                    Context        = request.Context,
                                    ContractNumber = request.ContractNumber,
                                    UserId         = request.UserId,
                                    Version        = request.Version
                                };
                                repo.UpdateRecentList(recentPatientRequest, contactData.RecentsList);
                            }
                        });
                    }
                }

                response.IsSuccessful = isSuccessful;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(response);
        }
            public void Add_One_Patient_To_Contact_DEV_Success()
            {
                ContactDataManager cm = new ContactDataManager {
                    Factory = new StubContactRepositoryFactory()
                };
                PutRecentPatientRequest request = new PutRecentPatientRequest
                {
                    PatientId      = "5325d9e7d6a4850adcbba4ad",
                    ContactId      = "5325c81f072ef705080d347e",
                    UserId         = "5325c81f072ef705080d347e",
                    Context        = "NG",
                    ContractNumber = "InHealth001",
                    Version        = 1.0
                };

                PutRecentPatientResponse response = cm.AddRecentPatient(request);

                Assert.IsNotNull(response);
            }
            public void Add_One_Patient_To_Contact_Success()
            {
                ContactDataManager cm = new ContactDataManager {
                    Factory = new StubContactRepositoryFactory()
                };
                PutRecentPatientRequest request = new PutRecentPatientRequest
                {
                    PatientId      = "111156789012345678901111",
                    ContactId      = "123456789012345678901234",
                    UserId         = "666656789012345678906666",
                    Context        = "NG",
                    ContractNumber = "InHealth001",
                    Version        = 1.0
                };

                PutRecentPatientResponse response = cm.AddRecentPatient(request);
                bool result = response.SuccessData;

                Assert.IsTrue(result);
            }
Beispiel #8
0
        public PutRecentPatientResponse Put(PutRecentPatientRequest request)
        {
            PutRecentPatientResponse response = new PutRecentPatientResponse();

            response.Version = request.Version;
            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("ContactDD:Put()::Unauthorized Access");
                }

                response = Manager.AddRecentPatient(request);
            }
            catch (Exception ex)
            {
                CommonFormat.FormatExceptionResponse(response, base.Response, ex);

                string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0";
                Helpers.LogException(int.Parse(aseProcessID), ex);
            }
            return(response);
        }