Exemplo n.º 1
0
        public GetPatientsCareTeamInfoDataResponse Post(GetPatientsCareTeamInfoDataRequest dataRequest)
        {
            if (dataRequest == null)
            {
                throw new ArgumentNullException("dataRequest");
            }
            var response = new GetPatientsCareTeamInfoDataResponse();

            try
            {
                if (string.IsNullOrEmpty(dataRequest.UserId))
                {
                    throw new UnauthorizedAccessException("ContactDD:GetPatientsCareTeamInfoRequest()::Unauthorized Access");
                }

                response         = CommonDataManager.GetPatientsCareTeamInfo(dataRequest);
                response.Version = dataRequest.Version;
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);

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

            return(response);
        }
Exemplo 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);
        }