Exemple #1
0
        /// <summary>
        /// Used to map questionnaire IDs to their corresponding names in DetailView.
        /// As the FHIR QRs does not contain the name of the questionnaire,
        /// this is done to avoid having to return the Questionnaire resources to the view.
        /// </summary>
        /// <param name="patID">ID of the patient with the requested QRs</param>
        /// <returns>Dict with (name: id)</returns>
        public Dictionary <string, string> getQMap(long patID)
        {
            //get QRs
            var QRs = QRHandler.getCachedQRsForPatient(patID);

            //get unique QIDs
            List <string> uniqueQIDs = new List <string>();

            foreach (var QR in QRs)
            {
                string qid = QR.Questionnaire.Reference;
                if (!uniqueQIDs.Contains(qid))
                {
                    uniqueQIDs.Add(qid);
                }
            }

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();


            //get Qs for each ID
            List <Questionnaire> questionnaires = new List <Questionnaire>();

            foreach (var qid in uniqueQIDs)
            {
                Bundle results = client.SearchById <Questionnaire>(qid);

                foreach (var entry in results.Entry) //should be one
                {
                    Questionnaire questionnaire = (Questionnaire)entry.Resource;
                    questionnaires.Add(questionnaire);
                }
            }

            stopwatch.Stop();
            log.logTimeSpan("get_questionnaires_for_patient(" + patID.ToString() + ")_from_server", stopwatch.Elapsed, questionnaires.Count);

            //assemble map
            Dictionary <string, string> qMap = new Dictionary <string, string>();

            foreach (var questionnaire in questionnaires)
            {
                string qid = questionnaire.Id;
                qMap[qid] = questionnaire.Title;
            }

            return(qMap);
        }
        public void Search()
        {
            FhirClient client = new FhirClient(testEndpoint);
            Bundle     result;

            result = client.Search <DiagnosticReport>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Entries.Count() > 10, "Test should use testdata with more than 10 reports");

            result = client.Search <DiagnosticReport>(count: 10);
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Entries.Count <= 10);

            var withSubject =
                result.Entries.ByResourceType <DiagnosticReport>().FirstOrDefault(dr => dr.Resource.Subject != null);

            Assert.IsNotNull(withSubject, "Test should use testdata with a report with a subject");

            ResourceIdentity ri = new ResourceIdentity(withSubject.Id);

            result = client.SearchById <DiagnosticReport>(ri.Id,
                                                          includes: new string[] { "DiagnosticReport.subject" });
            Assert.IsNotNull(result);

            // Doesn't currently work on Grahames server
            //Assert.AreEqual(2, result.Entries.Count);  // should have subject too

            //Assert.IsNotNull(result.Entries.Single(entry => new ResourceIdentity(entry.Id).Collection ==
            //            typeof(DiagnosticReport).GetCollectionName()));
            //Assert.IsNotNull(result.Entries.Single(entry => new ResourceIdentity(entry.Id).Collection ==
            //            typeof(Patient).GetCollectionName()));

            result = client.Search <Patient>(new SearchParam[]
            {
                new SearchParam("name", "Everywoman"),
                new SearchParam("name", "Eve")
            });

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Entries.Count > 0);
        }
        public void Search()
        {
            FhirClient client = new FhirClient(testEndpoint);
            Bundle     result;

            result = client.Search <DiagnosticReport>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Entry.Count() > 10, "Test should use testdata with more than 10 reports");

            result = client.Search <DiagnosticReport>(pageSize: 10);
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Entry.Count <= 10);

            var withSubject =
                result.Entry.ByResourceType <DiagnosticReport>().FirstOrDefault(dr => dr.Subject != null);

            Assert.IsNotNull(withSubject, "Test should use testdata with a report with a subject");

            ResourceIdentity ri = withSubject.ResourceIdentity();

            result = client.SearchById <DiagnosticReport>(ri.Id,
                                                          includes: new string[] { "DiagnosticReport:subject" });
            Assert.IsNotNull(result);

            Assert.AreEqual(2, result.Entry.Count);  // should have subject too

            Assert.IsNotNull(result.Entry.Single(entry => entry.Resource.ResourceIdentity().ResourceType ==
                                                 typeof(DiagnosticReport).GetCollectionName()));
            Assert.IsNotNull(result.Entry.Single(entry => entry.Resource.ResourceIdentity().ResourceType ==
                                                 typeof(Patient).GetCollectionName()));

            result = client.Search <Patient>(new string[] { "name=Chalmers", "name=Peter" });

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Entry.Count > 0);
        }
        public void Search()
        {
            FhirClient client = new FhirClient(testEndpoint);
            Bundle result;

            result = client.Search<DiagnosticReport>();
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Entry.Count() > 10, "Test should use testdata with more than 10 reports");

            result = client.Search<DiagnosticReport>(pageSize: 10);
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Entry.Count <= 10);

            var withSubject =
                result.Entry.ByResourceType<DiagnosticReport>().FirstOrDefault(dr => dr.Subject != null);
            Assert.IsNotNull(withSubject, "Test should use testdata with a report with a subject");

            ResourceIdentity ri = withSubject.ResourceIdentity();

            result = client.SearchById<DiagnosticReport>(ri.Id,
                        includes: new string[] { "DiagnosticReport.subject" });
            Assert.IsNotNull(result);

            Assert.AreEqual(2, result.Entry.Count);  // should have subject too

            Assert.IsNotNull(result.Entry.Single(entry => entry.Resource.ResourceIdentity().ResourceType ==
                        typeof(DiagnosticReport).GetCollectionName()));
            Assert.IsNotNull(result.Entry.Single(entry => entry.Resource.ResourceIdentity().ResourceType ==
                        typeof(Patient).GetCollectionName()));

            result = client.Search<Patient>(new string[] { "name=Everywoman", "name=Eve" });

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Entry.Count > 0);
        }