Пример #1
0
        public void Get_CohortPatientsList_Test()
        {
            double version        = 1.0;
            string contractNumber = "InHealth001";
            string context        = "NG";
            string cohortID       = "528ed9b3072ef70e10099687";

            IRestClient client = new JsonServiceClient();

            JsonServiceClient.HttpWebRequestFilter = x =>
                                                     x.Headers.Add(string.Format("{0}: {1}", "x-Phytel-UserID", "531f2df9072ef727c4d2a3df"));

            Stopwatch sw = new Stopwatch();

            sw.Start();

            //GetCohortPatientsDataResponse response =
            //    client.Get<GetCohortPatientsDataResponse>(string.Format("{0}/{1}/{2}/{3}/CohortPatients/{4}?Skip=0&Take=5000",
            //    "http://azurephytel.cloudapp.net:59901/CohortPatients", context, version, contractNumber, cohortID));

            GetCohortPatientsDataResponse response =
                client.Get <GetCohortPatientsDataResponse>(string.Format("{0}/{1}/{2}/{3}/CohortPatients/{4}?Skip=0&Take=1000",
                                                                         "http://localhost:8888/Patient", context, version, contractNumber, cohortID));

            sw.Stop();
            string elapsed = sw.Elapsed.ToString();
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        public void GetCohortPatientsByID()
        {
            string      controlValue = "Tony";
            string      sampleValue;
            string      cohortID       = "52781cd8fe7a5925fcee5bf3";
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            IRestClient client         = new JsonServiceClient();

            JsonServiceClient.HttpWebRequestFilter = x =>
                                                     x.Headers.Add(string.Format("{0}: {1}", "x-Phytel-UserID", "531f2df9072ef727c4d2a3df"));

            GetCohortPatientsDataResponse response = client.Post <GetCohortPatientsDataResponse>("http://localhost:8888/NG/data/CohortPatients",
                                                                                                 new GetCohortPatientsDataRequest {
                CohortID = cohortID, ContractNumber = contractNumber, Context = context
            } as object);

            sampleValue = string.Empty;

            Assert.AreEqual(controlValue, sampleValue);
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
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;
            }
        }