Ejemplo n.º 1
0
        public void ConstraintsLogicalCombo()
        {
            var c0  = new RequiredTagConstraint(TagRequirement.PresentNotEmpty, new OrderedIntConstraint(Order.Equal, 42, DicomTag.SeriesNumber));
            var c1  = new RequiredTagConstraint(TagRequirement.PresentNotEmpty, new OrderedDoubleConstraint(Order.GreaterThan, 3.141, DicomTag.PixelSpacing, 0));
            var c2  = new RequiredTagConstraint(TagRequirement.PresentNotEmpty, new OrderedDoubleConstraint(Order.LessThan, 6.0, DicomTag.PixelSpacing, 1));
            var c3t = new StringContainsConstraint(DicomTag.PatientPosition, "HFS");
            var c3  = new RequiredTagConstraint(TagRequirement.PresentNotEmpty, c3t);

            var groupConstraintAnd = new GroupConstraint(new DicomConstraint[] { c0, c1, c2, c3 }, LogicalOperator.And);
            var groupConstraintOr  = new GroupConstraint(new DicomConstraint[] { c0, c1, c2, c3 }, LogicalOperator.Or);

            var ds = new DicomDataset
            {
                { DicomTag.SeriesNumber, 42 },
                { DicomTag.PixelSpacing, new decimal[] { 3.142M, 3.142M } },
                { DicomTag.PatientPosition, "HFS" },
            };

            Assert.IsTrue(groupConstraintAnd.Check(ds).Result);
            Assert.IsTrue(groupConstraintOr.Check(ds).Result);

            ds.AddOrUpdate(DicomTag.PatientPosition, "FAIL");
            Assert.IsFalse(groupConstraintAnd.Check(ds).Result);
            Assert.IsTrue(groupConstraintOr.Check(ds).Result);
        }
Ejemplo n.º 2
0
        public void ConstraintsNestedSerialize()
        {
            var c0  = new RequiredTagConstraint(TagRequirement.PresentNotEmpty, new OrderedIntConstraint(Order.Equal, 42, DicomTag.SeriesNumber));
            var c1  = new RequiredTagConstraint(TagRequirement.PresentNotEmpty, new OrderedDoubleConstraint(Order.GreaterThan, 3.141f, DicomTag.PixelSpacing, 0));
            var c2  = new RequiredTagConstraint(TagRequirement.PresentNotEmpty, new OrderedDoubleConstraint(Order.LessThan, 6.0f, DicomTag.PixelSpacing, 1));
            var c3t = new StringContainsConstraint(DicomTag.PatientPosition, "HFS");
            var c3  = new RequiredTagConstraint(TagRequirement.PresentNotEmpty, c3t);

            var groupConstraintAnd1 = new GroupConstraint(new DicomConstraint[] { c0, c1 }, LogicalOperator.And);
            var groupConstraintAnd2 = new GroupConstraint(new DicomConstraint[] { c2, c3 }, LogicalOperator.And);

            var groupConstraintOr = new GroupConstraint(new DicomConstraint[] { groupConstraintAnd1, groupConstraintAnd2 }, LogicalOperator.Or);

            var ds1 = new DicomDataset
            {
                { DicomTag.SeriesNumber, 42 },
                { DicomTag.PixelSpacing, new decimal[] { 3.142M, 3.142M } },
                { DicomTag.PatientPosition, "HFS" },
            };

            Assert.IsTrue(groupConstraintOr.Check(ds1).Result);

            // Serialize
            var ss2 = JsonConvert.SerializeObject(groupConstraintOr);

            var groupConstraintOrDS = JsonConvert.DeserializeObject <GroupConstraint>(ss2);

            Assert.IsTrue(groupConstraintOrDS.Check(ds1).Result);
        }
        public void ConstraintsTestOptionality()
        {
            var ds = new DicomDataset();

            var c0 = new OrderedIntConstraint(Order.Equal, 4, DicomTag.SeriesNumber);

            var c3 = new RequiredTagConstraint(TagRequirement.Optional, c0);
            var c2 = new RequiredTagConstraint(TagRequirement.PresentCanBeEmpty, c0);
            var c1 = new RequiredTagConstraint(TagRequirement.PresentNotEmpty, c0);

            Assert.IsTrue(c3.Check(ds).Result);
            Assert.IsFalse(c2.Check(ds).Result);
            Assert.IsFalse(c1.Check(ds).Result);

            ds.Add(DicomTag.SeriesNumber, string.Empty);
            Assert.IsTrue(c3.Check(ds).Result);
            Assert.IsTrue(c2.Check(ds).Result);
            Assert.IsFalse(c1.Check(ds).Result);

            ds.AddOrUpdate(DicomTag.SeriesNumber, "4");
            Assert.IsTrue(c3.Check(ds).Result);
            Assert.IsTrue(c2.Check(ds).Result);
            Assert.IsTrue(c1.Check(ds).Result);

            ds.AddOrUpdate(DicomTag.SeriesNumber, "3");
            Assert.IsFalse(c3.Check(ds).Result);
            Assert.IsFalse(c2.Check(ds).Result);
            Assert.IsFalse(c1.Check(ds).Result);
        }
Ejemplo n.º 4
0
        public void ConstraintCodeString()
        {
            DicomDataset ds = new DicomDataset();

            ds.AddOrUpdate(DicomTag.BodyPartExamined, "PELVIS");

            var d0 = new OrderedStringConstraint(Order.NotEqual, "SKULL", DicomTag.BodyPartExamined);
            var c0 = new RequiredTagConstraint(TagRequirement.Optional, d0);

            Assert.IsTrue(c0.Check(ds).Result);
        }
Ejemplo n.º 5
0
        public void ConstraintUID()
        {
            DicomDataset ds = new DicomDataset();

            ds.AddOrUpdate(DicomTag.SOPClassUID, DicomUID.CTImageStorage);

            var s0 = new UIDStringOrderConstraint(Order.Equal, DicomUID.CTImageStorage.UID, DicomTag.SOPClassUID);
            var c0 = new RequiredTagConstraint(TagRequirement.PresentNotEmpty, s0);

            Assert.IsTrue(c0.Check(ds).Result);
        }
Ejemplo n.º 6
0
        public void ConstraintRegex()
        {
            var c0  = new RegexConstraint(DicomTag.SeriesDescription, @"(hog)", RegexOptions.ECMAScript);
            var c0R = new RequiredTagConstraint(TagRequirement.Optional, c0);

            DicomDataset ds = new DicomDataset();

            ds.AddOrUpdate(DicomTag.SeriesDescription, @"hog protocol v1");

            Assert.IsTrue(c0R.Check(ds).Result);
        }