예제 #1
0
        public void History()
        {
            DateTimeOffset now = DateTimeOffset.Now;

            CreateEditDelete();

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

            Assert.IsNotNull(history);
            Assert.AreEqual(3, history.Entries.Count());
            Assert.AreEqual(2, history.Entries.Where(entry => entry is ResourceEntry).Count());
            Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());

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

            history = client.History <Organization>(now);
            Assert.IsNotNull(history);
            Assert.AreEqual(3, history.Entries.Count());
            Assert.AreEqual(2, history.Entries.Where(entry => entry is ResourceEntry).Count());
            Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());

            history = client.History(now);
            Assert.IsNotNull(history);
            Assert.AreEqual(3, history.Entries.Count());
            Assert.AreEqual(2, history.Entries.Where(entry => entry is ResourceEntry).Count());
            Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());
        }
        public void WhenHistoryReadForParticularResource_ThenAllVersionsReturned()
        {
            var createdModelOnTheServer = _fhirClient.Create(_resource);

            createdModelOnTheServer.Comment = "This is an update to the observation";
            createdModelOnTheServer         = _fhirClient.Update(createdModelOnTheServer);
            var historyResults = _fhirClient.History($"Observation/{createdModelOnTheServer.Id}");

            Assert.NotNull(historyResults);
            Assert.Equal(2, historyResults.Entry.Count);
            AssertHelper.CheckStatusCode(HttpStatusCode.OK, _fhirClient.LastResult.Status);
        }
예제 #3
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(createdTestOrganizationUrl);

            Assert.IsNotNull(history);
            Assert.AreEqual(4, history.Entries.Count());
            Assert.AreEqual(3, history.Entries.Where(entry => entry is ResourceEntry).Count());
            Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());

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

            history = client.TypeHistory <Organization>(timestampBeforeCreationAndDeletions);
            Assert.IsNotNull(history);
            Assert.AreEqual(4, history.Entries.Count());
            Assert.AreEqual(3, history.Entries.Where(entry => entry is ResourceEntry).Count());
            Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());

            //EK: Our server can't yet do this
            //history = client.WholeSystemHistory(now);
            //Assert.IsNotNull(history);
            //Assert.AreEqual(3, history.Entries.Count());
            //Assert.AreEqual(2, history.Entries.Where(entry => entry is ResourceEntry).Count());
            //Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());
        }
        public ActionResult Index(ResourceHistoryViewModel model)
        {
            var patientId = model.patientID;

            try
            {
                // We have hard-coded the resource type to Patient to get history details of the patient
                var historyRead = FhirClient.History(ResourceIdentity.Build("Patient", patientId));

                string _history = fhirJsonSerializer.SerializeToString(historyRead);

                Bundle historyBundle = (Bundle)fhirJsonParser.Parse(_history, typeof(Bundle));

                model.OperationOutcomePatient = historyBundle.Entry.Select(Resource => (Patient)Resource.Resource).ToList();

                //Displaying the Div element of the text section
                foreach (var hist in model.OperationOutcomePatient)
                {
                    ViewBag.operationOutcomeText = hist.Text == null ? string.Empty : hist.Text.Div;
                }

                ViewBag.patientHistory = JValue.Parse(_history).ToString();
            }
            catch (FhirOperationException FhirOpExec)
            {
                var response     = FhirOpExec.Outcome;
                var errorDetails = fhirJsonSerializer.SerializeToString(response);
                ViewBag.error = JValue.Parse(errorDetails).ToString();
            }

            return(View());
        }
예제 #5
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());
        }
예제 #6
0
        public ActionResult HistoryObservation(string id, string type, string patientID)
        {
            bool   status  = false;
            string Message = "";
            List <HistoryObservation> fullVersion = new List <HistoryObservation>();

            //SPRAWDZENIE MODELU
            if (ModelState.IsValid)
            {
                //PODŁĄCZENIE KLIENTA
                var client = new FhirClient("http://localhost:8080/baseR4");
                client.PreferredFormat = ResourceFormat.Json;
                //WYSZUKANIE HISTORII
                Bundle history = client.History("Observation/" + id);

                while (history != null)
                {
                    foreach (var e in history.Entry)
                    {
                        if (e.Resource.TypeName == "Observation")
                        {
                            //POBRANIE POTRZBNYCH DANYCH
                            HistoryObservation observation = new Models.HistoryObservation();
                            observation.LastUpdate = e.Resource.Meta.LastUpdated;
                            observation.VersionId  = int.Parse(e.Resource.VersionId);

                            Observation obs = (Observation)e.Resource;
                            observation.Reason = obs.Code.Text;
                            observation.Status = obs.Status;

                            fullVersion.Add(observation);
                        }
                    }
                    history = client.Continue(history, PageDirection.Next);
                }
                status = true;
            }
            else
            {
                Message = "You haven't got right model";
            }

            for (int i = 0; i < fullVersion.Count - 1; i++)
            {
                if (fullVersion[i].Reason != fullVersion[i + 1].Reason)
                {
                    fullVersion[i].color[0] = "green";
                }
                if (fullVersion[i].Status != fullVersion[i + 1].Status)
                {
                    fullVersion[i].color[1] = "green";
                }
            }

            ViewBag.ID      = patientID;
            ViewBag.Status  = status;
            ViewBag.Message = Message;
            return(View(fullVersion));
        }
예제 #7
0
        [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 async Task <Bundle> DiagnosticReportHistoryByIdAsync(Action <Exception> errorAction, string reportId, SummaryType summary = SummaryType.True)
 {
     return(await Task.Run(() =>
     {
         try
         {
             return client.History($"DiagnosticReport/{reportId}", null, null, summary);
         }
         catch (Exception e)
         {
             DispatcherHelper.CheckBeginInvokeOnUI(() => errorAction(e));
             return null;
         }
     }));
 }
예제 #9
0
        /// <summary>
        /// Executes the specified arguments.
        /// </summary>
        /// <param name="arguments">The arguments.</param>
        /// <returns>System.Int32.</returns>
        /// <remarks>N/A</remarks>
        public override int Execute(Arguments arguments)
        {
            // Get us the needed parameters first
            //
            var url = arguments["url"];
            var id  = arguments["id"];

            // Call the FHIR server
            //
            try
            {
                // First find patient on the server
                //
                var client   = new FhirClient(url);
                var identity = ResourceIdentity.Build("Patient", id);
                var patient  = client.Read(identity);

                if (patient == null)
                {
                    Console.WriteLine("Did not find patient resource {0} on server {1}", id, url);
                    return(1);
                }

                // Get the history for that patient and display it
                //
                var result = client.History(patient.Id);
                foreach (var e in result.Entries)
                {
                    var rid = new ResourceIdentity(e.SelfLink);
                    Console.WriteLine("Found version {0} of patient resource {1}", rid.VersionId, rid.Id);
                }
                return(0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return(1);
            }
        }
예제 #10
0
        public void History()
        {
            DateTimeOffset now = DateTimeOffset.Now;

            CreateEditDelete();

            FhirClient client = new FhirClient(testEndpoint);
            Bundle history = client.History(createdTestOrganization);
            Assert.IsNotNull(history);
            Assert.AreEqual(3, history.Entries.Count());
            Assert.AreEqual(2, history.Entries.Where(entry => entry is ResourceEntry).Count());
            Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());

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

            history = client.History<Organization>(now);
            Assert.IsNotNull(history);
            Assert.AreEqual(3, history.Entries.Count());
            Assert.AreEqual(2, history.Entries.Where(entry => entry is ResourceEntry).Count());
            Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());

            history = client.History(now);
            Assert.IsNotNull(history);
            Assert.AreEqual(3, history.Entries.Count());
            Assert.AreEqual(2, history.Entries.Where(entry => entry is ResourceEntry).Count());
            Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());
        }
예제 #11
0
        public ActionResult HistoryMedicationRequest(string id, string type, string patientID)
        {
            bool   status  = false;
            string Message = "";
            List <HistoryMedicationRequest> fullVersion = new List <HistoryMedicationRequest>();

            //SPRAWDZENIE MODELU
            if (ModelState.IsValid)
            {
                //PODŁĄCZENIE KLIENTA
                var client = new FhirClient("http://localhost:8080/baseR4");
                client.PreferredFormat = ResourceFormat.Json;
                //WYSZUKANIE HISTORII
                Bundle history = client.History("MedicationRequest/" + id);

                while (history != null)
                {
                    foreach (var e in history.Entry)
                    {
                        if (e.Resource.TypeName == "MedicationRequest")
                        {
                            //POBRANIE POTRZBNYCH DANYCH
                            HistoryMedicationRequest request = new HistoryMedicationRequest();
                            request.LastUpdate = e.Resource.Meta.LastUpdated;
                            request.VersionId  = int.Parse(e.Resource.VersionId);

                            MedicationRequest medication = (MedicationRequest)e.Resource;
                            request.Reason += (medication.Medication as CodeableConcept).Text;
                            foreach (var elem in medication.DosageInstruction)
                            {
                                request.Instruction += elem.Text + " ";
                            }

                            fullVersion.Add(request);
                        }
                    }
                    history = client.Continue(history, PageDirection.Next);
                }
                status = true;
            }
            else
            {
                Message = "You haven't got right model";
            }

            for (int i = 0; i < fullVersion.Count - 1; i++)
            {
                if (fullVersion[i].Reason != fullVersion[i + 1].Reason)
                {
                    fullVersion[i].color[0] = "green";
                }
                if (fullVersion[i].Instruction != fullVersion[i + 1].Instruction)
                {
                    fullVersion[i].color[1] = "green";
                }
            }

            ViewBag.ID      = patientID;
            ViewBag.Status  = status;
            ViewBag.Message = Message;
            return(View(fullVersion));
        }
예제 #12
0
        public ActionResult HistoryPatient(string id, string type)
        {
            bool   status  = false;
            string Message = "";
            List <HistoryPatient> fullVersion = new List <HistoryPatient>();

            //SPRAWDZENIE MODELU
            if (ModelState.IsValid)
            {
                //PODŁĄCZENIE KLIENTA
                var client = new FhirClient("http://localhost:8080/baseR4");
                client.PreferredFormat = ResourceFormat.Json;
                //WYSZUKANIE HISTORII
                Bundle history = client.History("Patient/" + id);

                while (history != null)
                {
                    foreach (var e in history.Entry)
                    {
                        if (e.Resource.TypeName == "Patient")
                        {
                            //POBRANIE POTRZBNYCH DANYCH
                            HistoryPatient p = new HistoryPatient();
                            p.LastUpdate = e.Resource.Meta.LastUpdated;
                            p.VersionId  = int.Parse(e.Resource.VersionId);

                            Patient patient1 = (Patient)e.Resource;
                            p.FirstName += patient1.Name[0].Given.FirstOrDefault();
                            p.Surname   += patient1.Name[0].Family;

                            foreach (var elem in patient1.Address)
                            {
                                p.Address += elem.Text + " ";
                            }
                            fullVersion.Add(p);
                        }
                    }
                    history = client.Continue(history, PageDirection.Next);
                }
                status     = true;
                ViewBag.ID = id;
            }
            else
            {
                Message = "You haven't got right model";
            }

            for (int i = 0; i < fullVersion.Count - 1; i++)
            {
                if (fullVersion[i].FirstName != fullVersion[i + 1].FirstName)
                {
                    fullVersion[i].color[0] = "green";
                }
                if (fullVersion[i].Surname != fullVersion[i + 1].Surname)
                {
                    fullVersion[i].color[1] = "green";
                }
                if (fullVersion[i].Address != fullVersion[i + 1].Address)
                {
                    fullVersion[i].color[2] = "green";
                }
            }

            ViewBag.Status  = status;
            ViewBag.Message = Message;
            return(View(fullVersion));
        }
예제 #13
0
        public void TryParse()
        {
            var client = new FhirClient(new Uri("http://spark.furore.com/fhir"));

            var history = client.History <Patient>("15");
        }
예제 #14
0
        public void TryParse()
        {
            var client = new FhirClient(new Uri("http://spark.furore.com/fhir"));

            var history = client.History<Patient>("15");
        }
        public ViewResult Chart(string id, string dateType = "all")
        {
            List <DataPoint> dataPoints = new List <DataPoint>();

            var conn = new FhirClient("http://localhost:8080/baseR4");

            conn.PreferredFormat = ResourceFormat.Json;

            Patient patient = conn.Read <Patient>("Patient/" + id);

            var x = conn.History("Patient/" + id);

            UriBuilder uriBuilder = new UriBuilder("http://localhost:8080/baseR4");

            uriBuilder.Path = "Patient/" + patient.Id;
            Resource resultResource = conn.InstanceOperation(uriBuilder.Uri, "everything");

            ViewBag.ID   = patient.Id;
            ViewBag.Name = patient.Name[0].Given.FirstOrDefault() + " " + patient.Name[0].Family;

            if (resultResource is Bundle)
            {
                Bundle resultBundle = resultResource as Bundle;
                while (resultBundle != null)
                {
                    foreach (var i in resultBundle.Entry)
                    {
                        switch (i.Resource.TypeName)
                        {
                        case "Observation":
                            Observation observation = (Observation)i.Resource;

                            if (observation.Code.Text.Contains("Glucose"))
                            {
                                var date = observation.Effective.ToString().Substring(0, 10);

                                Quantity value  = observation.Value as Quantity;
                                var      amount = double.Parse((value.Value).ToString());

                                dataPoints.Add(new DataPoint(date, amount));
                            }
                            break;
                        }
                    }
                    resultBundle = conn.Continue(resultBundle, PageDirection.Next);
                }
            }
            ViewBag.MessagePost = dateType;

            switch (dateType)
            {
            case "5years":
                dataPoints = dataPoints.Where(s => Convert.ToDateTime(s.label) >= DateTime.Now.Date.AddYears(-5)).ToList();
                break;

            case "1year":
                dataPoints = dataPoints.Where(s => Convert.ToDateTime(s.label) >= DateTime.Now.Date.AddYears(-1)).ToList();
                break;

            case "6months":
                dataPoints = dataPoints.Where(s => Convert.ToDateTime(s.label) >= DateTime.Now.Date.AddMonths(-6)).ToList();
                break;

            case "3month":
                dataPoints = dataPoints.Where(s => Convert.ToDateTime(s.label) >= DateTime.Now.Date.AddMonths(-3)).ToList();
                break;

            case "1month":
                dataPoints = dataPoints.Where(s => Convert.ToDateTime(s.label) >= DateTime.Now.Date.AddMonths(-1)).ToList();
                break;

            default:
                break;
            }

            ViewBag.DataPoints = JsonConvert.SerializeObject(dataPoints);

            return(View());
        }
예제 #16
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());
        }
예제 #17
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(createdTestOrganizationUrl);
            Assert.IsNotNull(history);
            Assert.AreEqual(4, history.Entries.Count());
            Assert.AreEqual(3, history.Entries.Where(entry => entry is ResourceEntry).Count());
            Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());

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

			history = client.TypeHistory<Organization>(timestampBeforeCreationAndDeletions);
            Assert.IsNotNull(history);
            Assert.AreEqual(4, history.Entries.Count());
            Assert.AreEqual(3, history.Entries.Where(entry => entry is ResourceEntry).Count());
            Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());

            //EK: Our server can't yet do this
            //history = client.WholeSystemHistory(now);
            //Assert.IsNotNull(history);
            //Assert.AreEqual(3, history.Entries.Count());
            //Assert.AreEqual(2, history.Entries.Where(entry => entry is ResourceEntry).Count());
            //Assert.AreEqual(1, history.Entries.Where(entry => entry is DeletedEntry).Count());
        }