예제 #1
0
        public void ManualCreateTest()
        {
            lock (sentry)
            {
                string folder = Path.Combine(Tools.RootFolder, @"EK\Capture\Dicom\DicomToolKit\Test\Data\DicomDir");
                string path   = Path.Combine(folder, "ManualCreateTest");

                Directory.CreateDirectory(path);

                DicomDir dir = new DicomDir(path);
                dir.Empty();

                DateTime now = DateTime.Now;

                Patient patient = dir.NewPatient("Sadler^Michael", "12345");
                Study   study   = patient.NewStudy(now, now, Element.NewUid(), "1");
                Series  series  = study.NewSeries("CR", Element.NewUid());
                Image   image   = series.NewImage(Path.Combine(folder, "THGLUZ5J.dcm"));

                dir.Save();
                string before = Dump(dir, "before");

                dir = new DicomDir(path);
                string after = Dump(dir, "after");

                Assert.AreEqual(before, after, "before does not match after");
            }
        }
예제 #2
0
        public void BaseQueryTest()
        {
            DicomDir dir = new DicomDir(".");

            DateTime now = DateTime.Now;

            // create a patient with two studies, each with one series,
            // the first series with one image, the second with two
            Patient patient = dir.NewPatient("Patient^Test", "10");
            Study   study   = patient.NewStudy(now, now, "10", "10");
            Series  series  = study.NewSeries("CR", "10");
            Image   image   = series.NewImage("10"); image.ReferencedSOPInstanceUIDinFile = "10";

            study  = patient.NewStudy(now, now, "20", "20");
            series = study.NewSeries("CR", "20");
            image  = series.NewImage("20"); image.ReferencedSOPInstanceUIDinFile = "20";
            image  = series.NewImage("30"); image.ReferencedSOPInstanceUIDinFile = "30";

            // create a patient with one study, containing two series,
            // the first series with two images, the second with one
            patient = dir.NewPatient("Subject^Test", "20");
            study   = patient.NewStudy(now, now, "30", "30");
            series  = study.NewSeries("DX", "30");
            image   = series.NewImage("40"); image.ReferencedSOPInstanceUIDinFile = "40";
            image   = series.NewImage("50"); image.ReferencedSOPInstanceUIDinFile = "50";
            series  = study.NewSeries("CR", "40");
            image   = series.NewImage("60"); image.ReferencedSOPInstanceUIDinFile = "60";

            // create a patient with a single study and series containing thrww images
            patient = dir.NewPatient("Patietn^Pink", "30");
            study   = patient.NewStudy(now, now, "40", "40");
            series  = study.NewSeries("MG", "50");
            image   = series.NewImage("70"); image.ReferencedSOPInstanceUIDinFile = "70";
            image   = series.NewImage("80"); image.ReferencedSOPInstanceUIDinFile = "80";
            image   = series.NewImage("90"); image.ReferencedSOPInstanceUIDinFile = "90";

            dir.Save();

            /*  P   ST  SE  IM
             *  10
             *      10
             *          10
             *              10
             *      20
             *          20
             *              20
             *              30
             *  20
             *      30
             *          30
             *              40
             *              50
             *          40
             *              60
             *  30
             *      40
             *          50
             *              70
             *              80
             *              90
             *
             */

            patient = new Patient();
            RecordCollection records = query("PATIENT", patient.Elements);

            Assert.AreEqual(3, records.Count);

            study   = new Study();
            records = query("STUDY", study.Elements);
            Assert.AreEqual(4, records.Count);

            series  = new Series();
            records = query("SERIES", series.Elements);
            Assert.AreEqual(5, records.Count);

            image   = new Image();
            records = query("IMAGE", image.Elements);
            Assert.AreEqual(9, records.Count);

            dir.Empty();
        }
예제 #3
0
        public void BaseQueryTest()
        {
            DicomDir dir = new DicomDir(".");

            DateTime now = DateTime.Now;

            // create a patient with two studies, each with one series,
            // the first series with one image, the second with two
            Patient patient = dir.NewPatient("10", "10");
            Study   study   = patient.NewStudy(now, now, "10", "10");
            Series  series  = study.NewSeries("CR", "10");
            Image   image   = series.NewImage("10"); image.ReferencedSOPInstanceUIDinFile = "10";

            study  = patient.NewStudy(now, now, "20", "20");
            series = study.NewSeries("CR", "20");
            image  = series.NewImage("20"); image.ReferencedSOPInstanceUIDinFile = "20";
            image  = series.NewImage("30"); image.ReferencedSOPInstanceUIDinFile = "30";

            // create a patient with one study, containing two series,
            // the first series with two images, the second with one
            patient = dir.NewPatient("20", "20");
            study   = patient.NewStudy(now, now, "30", "30");
            series  = study.NewSeries("CR", "30");
            image   = series.NewImage("40"); image.ReferencedSOPInstanceUIDinFile = "40";
            image   = series.NewImage("50"); image.ReferencedSOPInstanceUIDinFile = "50";
            series  = study.NewSeries("CR", "40");
            image   = series.NewImage("60"); image.ReferencedSOPInstanceUIDinFile = "60";

            // create a patient with a single study and series containing thrww images
            patient = dir.NewPatient("30", "30");
            study   = patient.NewStudy(now, now, "40", "40");
            series  = study.NewSeries("CR", "50");
            image   = series.NewImage("70"); image.ReferencedSOPInstanceUIDinFile = "70";
            image   = series.NewImage("80"); image.ReferencedSOPInstanceUIDinFile = "80";
            image   = series.NewImage("90"); image.ReferencedSOPInstanceUIDinFile = "90";

            dir.Save();

            /*  P   ST  SE  IM
             *  10
             *      10
             *          10
             *              10
             *      20
             *          20
             *              20
             *              30
             *  20
             *      30
             *          30
             *              40
             *              50
             *          40
             *              60
             *  30
             *      40
             *          50
             *              70
             *              80
             *              90
             *
             */

            Assert.AreEqual("10,20,30", query("PATIENT", "10"));
            Assert.AreEqual("10", query("STUDY", "10"));
            Assert.AreEqual("10", query("SERIES", "10"));
            Assert.AreEqual("20,30", query("STUDY", "20"));
            Assert.AreEqual("20,30", query("SERIES", "20"));

            Assert.AreEqual("40,50,60", query("PATIENT", "20"));
            Assert.AreEqual("40,50,60", query("STUDY", "30"));
            Assert.AreEqual("40,50", query("SERIES", "30"));
            Assert.AreEqual("60", query("SERIES", "40"));

            Assert.AreEqual("70,80,90", query("PATIENT", "30"));
            Assert.AreEqual("70,80,90", query("STUDY", "40"));
            Assert.AreEqual("70,80,90", query("SERIES", "50"));

            Assert.AreEqual("10", query("IMAGE", "10"));
            Assert.AreEqual("20", query("IMAGE", "20"));
            Assert.AreEqual("30", query("IMAGE", "30"));
            Assert.AreEqual("40", query("IMAGE", "40"));
            Assert.AreEqual("50", query("IMAGE", "50"));
            Assert.AreEqual("60", query("IMAGE", "60"));
            Assert.AreEqual("70", query("IMAGE", "70"));
            Assert.AreEqual("80", query("IMAGE", "80"));
            Assert.AreEqual("90", query("IMAGE", "90"));

            dir.Empty();
        }