예제 #1
0
        public void GetCohortPatientsByID_WithDoubleFilterComma()
        {
            GetCohortPatientsDataRequest request = new GetCohortPatientsDataRequest
            {
                CohortID       = "528ed9b3072ef70e10099687",
                Version        = 1,
                Context        = "NG",
                SearchFilter   = "Tigue, Jonell",
                ContractNumber = "InHealth001",
                Skip           = 0,
                Take           = 100
            };

            IPatientDataManager           pm       = new PatientDataManager();
            GetCohortPatientsDataResponse response = pm.GetCohortPatients(request);

            Assert.IsTrue(response.CohortPatients.Count > 0);
        }
예제 #2
0
        public void GetCohortPatientsByID_WithNoFilter()
        {
            GetCohortPatientsDataRequest request = new GetCohortPatientsDataRequest
            {
                CohortID       = "530f9cff072ef715f4b411cf",
                Version        = 1,
                Context        = "NG",
                SearchFilter   = "",
                ContractNumber = "InHealth001",
                Skip           = 0,
                Take           = 100
            };

            IPatientDataManager           pm       = new PatientDataManager();
            GetCohortPatientsDataResponse response = pm.GetCohortPatients(request);

            Assert.IsTrue(response.CohortPatients.Count > 0);
        }
예제 #3
0
        public GetCohortPatientsDataResponse Get(GetCohortPatientsDataRequest request)
        {
            GetCohortPatientsDataResponse response = new GetCohortPatientsDataResponse();

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("PatientDD:Get()::Unauthorized Access");
                }

                response         = PatientManager.GetCohortPatients(request);
                response.Version = request.Version;
            }
            catch (Exception ex)
            {
                CommonFormatterUtil.FormatExceptionResponse(response, base.Response, ex);

                string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0";
                Helpers.LogException(int.Parse(aseProcessID), ex);
            }
            return(response);
        }
예제 #4
0
        public void GetCohortPatientsByID_WithStartingComma()
        {
            IPatientDataManager pm = new PatientDataManager
            {
                Factory = new PatientRepositoryFactory(),
                Helpers = new Helpers()
            };

            GetCohortPatientsDataRequest request = new GetCohortPatientsDataRequest
            {
                CohortID       = "53237514072ef709d84efe9d",
                Version        = 1,
                Context        = "NG",
                SearchFilter   = "barr",
                ContractNumber = "InHealth001",
                Skip           = 0,
                Take           = 100,
                UserId         = "0000000000000000000000000"
            };

            GetCohortPatientsDataResponse response = pm.GetCohortPatients(request);

            Assert.IsTrue(response.CohortPatients.Count > 0);
        }
예제 #5
0
 GetCohortPatientsDataResponse IPatientDataManager.GetCohortPatients(GetCohortPatientsDataRequest request)
 {
     throw new NotImplementedException();
 }
예제 #6
0
        public GetCohortPatientsDataResponse GetCohortPatients(GetCohortPatientsDataRequest request)
        {
            try
            {
                string DDCohortServiceURL = ConfigurationManager.AppSettings["DDCohortServiceUrl"];

                GetCohortPatientsDataResponse result = new GetCohortPatientsDataResponse();

                IRestClient client = new JsonServiceClient();

                string url = Helpers.BuildURL(string.Format("{0}/{1}/{2}/{3}/cohort/{4}", DDCohortServiceURL, request.Context, request.Version, request.ContractNumber, request.CohortID), request.UserId);

                // 1) lookup query for cohortid in cohorts collection
                string cohortID = request.CohortID;
                GetCohortDataResponse response = client.Get <GetCohortDataResponse>(url);

                string cohortQuery = response.Cohort.Query;
                //If #USER_ID# is present in the cohort query, replace it with the ContactId.
                if (!string.IsNullOrEmpty(request.UserId))
                {
                    cohortQuery = response.Cohort.Query.Replace("#USER_ID#", request.UserId);
                }

                //Get the filter parameters
                string field1 = string.Empty;
                string field2 = string.Empty;

                if (string.IsNullOrEmpty(request.SearchFilter) == false)
                {
                    //is there a comma in the string?
                    if (request.SearchFilter.IndexOf(',') > -1)
                    {
                        string[] info = request.SearchFilter.Split(",".ToCharArray());
                        field1 = info[1].Trim();
                        field2 = info[0].Trim();
                    }
                    else
                    {
                        string[] info = request.SearchFilter.Split(" ".ToCharArray());
                        field1 = info[0].Trim();
                        if (info.Length > 1)
                        {
                            field2 = info[1].Trim();
                        }
                    }
                }

                string[] filterParms = new string[] { field1, field2 };

                // 2) get patientIDs through cohortpatients view
                IPatientRepository repo = Factory.GetRepository(request, RepositoryType.CohortPatientView);

                result.CohortPatients = repo.Select(cohortQuery, filterParms, response.Cohort.Sort, request.Skip, request.Take);

                return(result);
            }
            catch (Exception)
            {
                throw;
            }
        }