Ejemplo n.º 1
0
        public SaveCareTeamDataResponse InsertCareTeam(SaveCareTeamDataRequest request)
        {
            var response = new SaveCareTeamDataResponse();

            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            var repo = _factory.GetCareTeamRepository(request, RepositoryType.CareTeam);

            if (repo == null)
            {
                throw new Exception("Repository is null");
            }

            var careTeam = repo.Insert(request) as CareTeamData;

            response.CareTeamData = careTeam;

            return(response);
        }
Ejemplo n.º 2
0
        public GetPatientsCareTeamInfoDataResponse GetPatientsCareTeamInfo(DTO.GetPatientsCareTeamInfoDataRequest dataRequest)
        {
            if (dataRequest == null)
            {
                throw new ArgumentNullException("dataRequest");
            }

            var contactRepository  = _contactRepositoryFactory.GetRepository(dataRequest, RepositoryType.Contact);
            var careTeamRepository = _careTeamRepositoryFactory.GetCareTeamRepository(dataRequest, RepositoryType.CareTeam);

            var response = new GetPatientsCareTeamInfoDataResponse();

            try
            {
                var contacts = contactRepository.GetContactsByPatientIds(dataRequest.PatientIds);


                if (contacts.IsNullOrEmpty())
                {
                    return(response);
                }

                var contactIds = contacts.Select(c => c.Id).ToList();

                //Fetch contacts
                var mappedContacts = new List <PatientCareTeamInfo>();
                foreach (var contact in contacts)
                {
                    var mappedContact = new PatientCareTeamInfo
                    {
                        ContactId = contact.Id,
                        PatientId = contact.PatientId
                    };

                    mappedContacts.Add(mappedContact);
                }

                //Fetch CareTeams
                var careTeams = careTeamRepository.GetCareTeamsByContactIds(contactIds);
                if (!careTeams.IsNullOrEmpty())
                {
                    foreach (var mc in mappedContacts)
                    {
                        var contactId = mc.ContactId;
                        if (contactId != null)
                        {
                            var careTeam = careTeams.FirstOrDefault(c => c.ContactId == contactId);

                            if (careTeam != null)
                            {
                                mc.CareTeamId = careTeam.Id;
                            }
                        }
                    }
                }

                response.ContactCareTeams = mappedContacts;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(response);
        }