Exemplo n.º 1
0
        public void TestIdReassignOnImport()
        {
            var importer = new ResourceImporter(new Uri("http://fhir.furore.com/fhir/"));
            importer.AddSharedIdSpacePrefix("http://localhost");

            importer.QueueNewResourceEntry(new Uri("http://someserver.nl/fhir/patient/@1012"), new Patient());
            importer.QueueNewResourceEntry(new Uri("http://fhir.furore.com/fhir/patient/@13"), new Patient());
            importer.QueueNewResourceEntry(new Uri("http://localhost/svc/patient/@24"), new Patient());
            importer.QueueNewResourceEntry(new Uri("cid:332211223316"), new Patient());
            importer.QueueNewDeletedEntry(new Uri("http://someserver.nl/fhir/patient/@17"));
            var imported = importer.ImportQueued();

            Assert.AreEqual("patient/@1", imported.First().Id.ToString());
            Assert.AreEqual("patient/@13", imported.Skip(1).First().Id.ToString());
            Assert.AreEqual("patient/@24", imported.Skip(2).First().Id.ToString());
            Assert.AreEqual("patient/@25", imported.Skip(3).First().Id.ToString());
            Assert.AreEqual("patient/@26", imported.Skip(4).First().Id.ToString());
        }
Exemplo n.º 2
0
        public void SimpleStoreSpeedTest()
        {
            Stopwatch w = new Stopwatch();

            w.Start();
            _store.EraseData();

            w.Stop();

            Debug.Print("Erasing data took {0} ms", w.ElapsedMilliseconds);

            w.Restart();
            //var errs = new ErrorList();
            //var entries = new List<BundleEntry>();

            //for (var i = 0; i < 500; i++)
            //{
            //    var xml = FhirSerializer.SerializeBundleEntryToXml(_stockPatient);
            //    var copy = FhirParser.ParseBundleEntryFromXml(xml, errs);
            //    var rl = ResourceLocation.Build("patient", i.ToString());
            //    copy.Id = rl.ToUri();
            //    rl.VersionId = "1";
            //    copy.SelfLink = rl.ToUri();
            //    entries.Add(copy);
            //}

            var bundle = loadExamples();

            w.Stop();

            Debug.Print("Loading examples took {0} ms", w.ElapsedMilliseconds);

            w.Restart();

            foreach (var entry in bundle.Entries)
            {
                var rl = new ResourceLocation(entry.Id);
                rl.VersionId = "1";
                entry.SelfLink = rl.ToUri();
            }

            var importer = new ResourceImporter(new Uri("http://localhost"));
            importer.AddSharedIdSpacePrefix("http://hl7.org/fhir/");

            foreach (var be in bundle.Entries)
                importer.QueueNewEntry(be);

            w.Stop();

            Debug.Print("Queueing examples took {0} ms", w.ElapsedMilliseconds);

            w.Restart();

            var entriesToStore = importer.ImportQueued();
            w.Stop();

            Debug.Print("Importing examples took {0} ms", w.ElapsedMilliseconds);

            w.Restart();

            var guid = Guid.NewGuid();
                     
            _store.AddEntries(entriesToStore,guid);

            w.Stop();

            Debug.Print("Storing {0} patients took {1} ms", entriesToStore.Count(), w.Elapsed.Milliseconds);
        }