public void WhenHistoryReadForEntireSystem_ThenBundleReturned()
        {
            // Create an observation so we're guaranteed there's at least one item to be returned
            _fhirClient.Create(_resource);

            var historyResults = _fhirClient.WholeSystemHistory();

            Assert.NotNull(historyResults);
            Assert.NotEmpty(historyResults.Entry);
            AssertHelper.CheckStatusCode(HttpStatusCode.OK, _fhirClient.LastResult.Status);
        }
示例#2
0
        public void History()
        {
            DateTimeOffset timestampBeforeCreationAndDeletions = DateTimeOffset.Now;

            CreateEditDelete(); // this test does a create, update, update, delete (4 operations)

            FhirClient client  = new FhirClient(testEndpoint);
            Bundle     history = client.History(createdTestPatientUrl);

            Assert.IsNotNull(history);
            Assert.AreEqual(4, history.Entry.Count());
            Assert.AreEqual(3, history.Entry.Where(entry => entry.Resource != null).Count());
            Assert.AreEqual(1, history.Entry.Where(entry => entry.IsDeleted()).Count());

            //// Now, assume no one is quick enough to insert something between now and the next
            //// tests....

            history = client.TypeHistory("Patient", timestampBeforeCreationAndDeletions);
            Assert.IsNotNull(history);
            Assert.AreEqual(4, history.Entry.Count());
            Assert.AreEqual(3, history.Entry.Where(entry => entry.Resource != null).Count());
            Assert.AreEqual(1, history.Entry.Where(entry => entry.IsDeleted()).Count());

            history = client.WholeSystemHistory(timestampBeforeCreationAndDeletions);
            Assert.IsNotNull(history);
            Assert.AreEqual(3, history.Entry.Count());
            Assert.AreEqual(2, history.Entry.Where(entry => entry.Resource != null).Count());
            Assert.AreEqual(1, history.Entry.Where(entry => entry.IsDeleted()).Count());
        }
        [TestMethod, TestCategory("FhirClient"), TestCategory("IntegrationTest"), Ignore]  // Keeps failing periodically. Grahame's server?
        public void History()
        {
            System.Threading.Thread.Sleep(500);
            DateTimeOffset timestampBeforeCreationAndDeletions = DateTimeOffset.Now;

            CreateEditDelete(); // this test does a create, update, update, delete (4 operations)

            FhirClient client = new FhirClient(testEndpoint);

            System.Diagnostics.Trace.WriteLine("History of this specific patient since just before the create, update, update, delete (4 operations)");

            Bundle history = client.History(createdTestPatientUrl);

            Assert.IsNotNull(history);
            DebugDumpBundle(history);

            Assert.AreEqual(4, history.Entry.Count());
            Assert.AreEqual(3, history.Entry.Where(entry => entry.Resource != null).Count());
            Assert.AreEqual(1, history.Entry.Where(entry => entry.IsDeleted()).Count());

            //// Now, assume no one is quick enough to insert something between now and the next
            //// tests....


            System.Diagnostics.Trace.WriteLine("\r\nHistory on the patient type");

            history = client.TypeHistory("Patient", timestampBeforeCreationAndDeletions);
            Assert.IsNotNull(history);
            DebugDumpBundle(history);
            Assert.AreEqual(4, history.Entry.Count());   // there's a race condition here, sometimes this is 5.
            Assert.AreEqual(3, history.Entry.Where(entry => entry.Resource != null).Count());
            Assert.AreEqual(1, history.Entry.Where(entry => entry.IsDeleted()).Count());


            System.Diagnostics.Trace.WriteLine("\r\nHistory on the patient type (using the generic method in the client)");

            history = client.TypeHistory <Patient>(timestampBeforeCreationAndDeletions, summary: SummaryType.True);
            Assert.IsNotNull(history);
            DebugDumpBundle(history);
            Assert.AreEqual(4, history.Entry.Count());
            Assert.AreEqual(3, history.Entry.Where(entry => entry.Resource != null).Count());
            Assert.AreEqual(1, history.Entry.Where(entry => entry.IsDeleted()).Count());

            System.Diagnostics.Trace.WriteLine("\r\nWhole system history since the start of this test");

            history = client.WholeSystemHistory(timestampBeforeCreationAndDeletions);
            Assert.IsNotNull(history);
            DebugDumpBundle(history);
            Assert.IsTrue(4 <= history.Entry.Count(), "Whole System history should have at least 4 new events");
            // Check that the number of patients that have been created is what we expected
            Assert.AreEqual(3, history.Entry.Where(entry => entry.Resource != null && entry.Resource is Patient).Count());
            Assert.AreEqual(1, history.Entry.Where(entry => entry.IsDeleted() && entry.Request.Url.Contains("Patient")).Count());
        }
        public void History()
        {
            DateTimeOffset timestampBeforeCreationAndDeletions = DateTimeOffset.Now;

            CreateEditDelete(); // this test does a create, update, update, delete (4 operations)

            FhirClient client = new FhirClient(testEndpoint);
            Bundle history = client.History(createdTestPatientUrl);
            Assert.IsNotNull(history);
            Assert.AreEqual(4, history.Entry.Count());
            Assert.AreEqual(3, history.Entry.Where(entry => entry.Resource != null).Count());            
            Assert.AreEqual(1, history.Entry.Where(entry => entry.IsDeleted()).Count());

            //// Now, assume no one is quick enough to insert something between now and the next
            //// tests....

            history = client.TypeHistory("Patient",timestampBeforeCreationAndDeletions);
            Assert.IsNotNull(history);
            Assert.AreEqual(4, history.Entry.Count());
            Assert.AreEqual(3, history.Entry.Where(entry => entry.Resource != null).Count());
            Assert.AreEqual(1, history.Entry.Where(entry => entry.IsDeleted()).Count());

            history = client.WholeSystemHistory(timestampBeforeCreationAndDeletions);
            Assert.IsNotNull(history);
            Assert.AreEqual(3, history.Entry.Count());
            Assert.AreEqual(2, history.Entry.Where(entry => entry.Resource != null).Count());
            Assert.AreEqual(1, history.Entry.Where(entry => entry.IsDeleted()).Count());
        }