Esempio n. 1
0
 protected DicomPropertyFilter(DicomTagPath path, DicomAttributeCollection criteria)
 {
     Path                  = path;
     Criterion             = Path.GetAttribute(criteria);
     IsReturnValueRequired = false;
     AddToQueryEnabled     = true;
     FilterResultsEnabled  = false;
 }
Esempio n. 2
0
        public void TestDicomTagPathGetAttribute_NoCreate()
        {
            var collection = new DicomAttributeCollection();
            var path       = new DicomTagPath(DicomTags.PatientId);

            //PatientID IS empty
            Assert.IsNull(path.GetAttribute(collection));

            collection[DicomTags.PatientId].SetNullValue();
            //PatientID NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));

            collection[DicomTags.PatientId].SetStringValue("PatientId");
            collection[DicomTags.PatientsName].SetStringValue("PatientsName");
            //PatientID NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));

            path = new DicomTagPath(DicomTags.PatientsName);
            //PatientsName NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));

            //ViewCodeSequence IS empty
            path = new DicomTagPath(DicomTags.ViewCodeSequence);
            Assert.IsNull(path.GetAttribute(collection));

            var sequence1 = new DicomSequenceItem();

            collection[DicomTags.ViewCodeSequence].AddSequenceItem(sequence1);
            //ViewCodeSequence NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));

            path += DicomTags.CodeMeaning;
            //ViewCodeSequence/CodeMeaning IS empty
            Assert.IsNull(path.GetAttribute(collection));
            sequence1[DicomTags.CodeMeaning].SetNullValue();
            //ViewCodeSequence/CodeMeaning NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));

            //ViewCodeSequence/ConceptNameCodeSequence IS empty
            path = new DicomTagPath(DicomTags.ViewCodeSequence, DicomTags.ConceptNameCodeSequence);
            Assert.IsNull(path.GetAttribute(collection));

            var sequence2 = new DicomSequenceItem();

            sequence1[DicomTags.ConceptNameCodeSequence].AddSequenceItem(sequence2);

            //ViewCodeSequence/ConceptNameCodeSequence NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));

            path += DicomTags.CodeValue;
            //ViewCodeSequence/ConceptNameCodeSequence/CodeValue IS empty
            Assert.IsNull(path.GetAttribute(collection));

            sequence2[DicomTags.CodeValue].SetStringValue("Code");
            //ViewCodeSequence/ConceptNameCodeSequence/CodeValue IS empty
            Assert.IsNotNull(path.GetAttribute(collection));
        }
Esempio n. 3
0
 protected TimePropertyFilter(DicomTagPath path, DicomAttributeCollection criteria)
     : base(path, criteria)
 {
     Platform.CheckTrue(path.ValueRepresentation.Name == "TM", "Path is not VR=TM");
     if (Criterion != null)
     {
         Platform.CheckTrue(Criterion.Tag.VR.Name == "TM", "Criteria is not VR=TM");
     }
 }
        public void TestDicomTagPathGetAttribute_NoCreate()
        {
            var collection = new DicomAttributeCollection();
            var path = new DicomTagPath(DicomTags.PatientId);

            //PatientID IS empty
            Assert.IsNull(path.GetAttribute(collection));

            collection[DicomTags.PatientId].SetNullValue();
            //PatientID NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));

            collection[DicomTags.PatientId].SetStringValue("PatientId");
            collection[DicomTags.PatientsName].SetStringValue("PatientsName");
            //PatientID NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));
            
            path = new DicomTagPath(DicomTags.PatientsName);
            //PatientsName NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));

            //ViewCodeSequence IS empty
            path = new DicomTagPath(DicomTags.ViewCodeSequence);
            Assert.IsNull(path.GetAttribute(collection));
            
            var sequence1 = new DicomSequenceItem();
            collection[DicomTags.ViewCodeSequence].AddSequenceItem(sequence1);
            //ViewCodeSequence NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));

            path += DicomTags.CodeMeaning;
            //ViewCodeSequence/CodeMeaning IS empty
            Assert.IsNull(path.GetAttribute(collection));
            sequence1[DicomTags.CodeMeaning].SetNullValue();
            //ViewCodeSequence/CodeMeaning NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));

            //ViewCodeSequence/ConceptNameCodeSequence IS empty
            path = new DicomTagPath(DicomTags.ViewCodeSequence, DicomTags.ConceptNameCodeSequence);
            Assert.IsNull(path.GetAttribute(collection));

            var sequence2 = new DicomSequenceItem();
            sequence1[DicomTags.ConceptNameCodeSequence].AddSequenceItem(sequence2);

            //ViewCodeSequence/ConceptNameCodeSequence NOT empty
            Assert.IsNotNull(path.GetAttribute(collection));

            path += DicomTags.CodeValue;
            //ViewCodeSequence/ConceptNameCodeSequence/CodeValue IS empty
            Assert.IsNull(path.GetAttribute(collection));
            
            sequence2[DicomTags.CodeValue].SetStringValue("Code");
            //ViewCodeSequence/ConceptNameCodeSequence/CodeValue IS empty
            Assert.IsNotNull(path.GetAttribute(collection));
        }
Esempio n. 5
0
        public void TestSetVr()
        {
            var path = new DicomTagPath(new[] { DicomTags.ViewCodeSequence, DicomTags.CodeMeaning });

            Assert.AreEqual(DicomVr.SQvr, path.TagsInPath[0].VR);
            Assert.AreNotEqual(DicomVr.UNvr, path.TagsInPath[1].VR);

            path = new DicomTagPath(new[] { DicomTags.ViewCodeSequence, DicomTags.CodeMeaning }, DicomVr.UNvr);
            Assert.AreEqual(DicomVr.SQvr, path.TagsInPath[0].VR);
            Assert.AreEqual(DicomVr.UNvr, path.TagsInPath[1].VR);
        }
Esempio n. 6
0
        protected override List <IPropertyFilter <Study> > CreateFilters(DicomAttributeCollection criteria)
        {
            var filters = base.CreateFilters(criteria);
            var modalitiesInStudyPath   = new DicomTagPath(DicomTags.ModalitiesInStudy);
            var dicomFilters            = filters.OfType <DicomPropertyFilter <Study> >().ToList();
            var modalitiesInStudyIndex  = dicomFilters.FindIndex(f => f.Path.Equals(modalitiesInStudyPath));
            var modalitiesInStudyFilter = filters[modalitiesInStudyIndex];

            //Because of the potentially complex joins of the same initial query over and over, move this one to the front.
            filters.RemoveAt(modalitiesInStudyIndex);
            filters.Insert(0, modalitiesInStudyFilter);
            return(filters);
        }
Esempio n. 7
0
        public void AssertBadPath2()
        {
            var tag = new DicomTagPath(DicomTags.ViewCodeSequence);

            try
            {
                tag = tag + DicomTags.CodeMeaning;
            }
            catch (Exception)
            {
                Assert.Fail("This is a valid path");
            }

            tag += DicomTags.PatientId;
        }
Esempio n. 8
0
        private static void AddDicomAttribute(DvtkData.Dimse.AttributeSet dataset, DicomTagPath dicomTagPath, System.String dicomValue)
        {
            if (dicomTagPath.Next != null)
            {
                // Try to get the sequence identified by this Tag
                DvtkData.Dimse.Attribute sequenceAttribute = dataset.GetAttribute(dicomTagPath.Tag);
                if (sequenceAttribute == null)
                {
                    // Need to add the sequence
                    DvtkData.Dimse.SequenceItem item = new DvtkData.Dimse.SequenceItem();
                    dataset.AddAttribute(dicomTagPath.Tag.GroupNumber,
                                         dicomTagPath.Tag.ElementNumber,
                                         DvtkData.Dimse.VR.SQ, item);

                    // Get the newly added sequence
                    sequenceAttribute = dataset.GetAttribute(dicomTagPath.Tag);
                }

                // Get the contained item
                DvtkData.Dimse.SequenceOfItems sequenceOfItems = (DvtkData.Dimse.SequenceOfItems)sequenceAttribute.DicomValue;
                if (sequenceOfItems.Sequence.Count == 1)
                {
                    DvtkData.Dimse.SequenceItem item = sequenceOfItems.Sequence[0];

                    // Call recursively
                    AddDicomAttribute(item, dicomTagPath.Next, dicomValue);
                }
            }
            else
            {
                // Try to get the attribute identified by this Tag
                DvtkData.Dimse.Attribute attribute = dataset.GetAttribute(dicomTagPath.Tag);
                if (attribute != null)
                {
                    // If present - remove the attribute - we want to update the value
                    dataset.Remove(attribute);
                }

                // Add the new value
                dataset.AddAttribute(dicomTagPath.Tag.GroupNumber, dicomTagPath.Tag.ElementNumber, DicomTagVrLookup.GetVR(dicomTagPath.Tag), dicomValue);
            }
        }
Esempio n. 9
0
        public void TestGetAttributes()
        {
            var collection = new DicomAttributeCollection();

            collection[DicomTags.PatientId].SetStringValue("Test^Patient");
            var viewCodeSequence1 = new DicomSequenceItem();
            var viewCodeSequence2 = new DicomSequenceItem();

            collection[DicomTags.ViewCodeSequence].Values = new[] { viewCodeSequence1, viewCodeSequence2 };
            viewCodeSequence1[DicomTags.CodeMeaning].SetStringValue("It's");
            viewCodeSequence2[DicomTags.CodeMeaning].SetStringValue("The Bomb");

            var path       = new DicomTagPath(new[] { DicomTags.PatientId });
            var attributes = path.SelectAttributesFrom(collection).ToList();

            Assert.AreEqual(1, attributes.Count);
            Assert.AreEqual(attributes[0].ToString(), "Test^Patient");

            path       = new DicomTagPath(new[] { DicomTags.PatientsName });
            attributes = path.SelectAttributesFrom(collection).ToList();
            Assert.AreEqual(1, attributes.Count);
            Assert.IsTrue(attributes[0].IsEmpty);

            path       = new DicomTagPath(new[] { DicomTags.ViewCodeSequence, DicomTags.CodeMeaning });
            attributes = path.SelectAttributesFrom(collection).ToList();
            Assert.AreEqual(2, attributes.Count);
            Assert.AreEqual(attributes[0].ToString(), "It's");
            Assert.AreEqual(attributes[1].ToString(), "The Bomb");

            attributes[1].SetEmptyValue();
            attributes = path.SelectAttributesFrom(collection).ToList();
            Assert.AreEqual(2, attributes.Count);
            Assert.AreEqual(attributes[0].ToString(), "It's");
            Assert.IsTrue(attributes[1].IsEmpty);

            path       = new DicomTagPath(new[] { DicomTags.AcquisitionDeviceTypeCodeSequence, DicomTags.CodeMeaning });
            attributes = path.SelectAttributesFrom(collection, true).ToList();
            Assert.AreEqual(1, attributes.Count);
            Assert.IsTrue(attributes[0].IsEmpty);
        }
Esempio n. 10
0
        public void Test()
        {
            var path = new DicomTagPath("(0010,0010)");

            Assert.AreEqual(path, "(0010,0010)");
            Assert.AreEqual(path, (uint)0x00100010);
            Assert.AreEqual(path, NewDicomTag(0x00100010));
            Assert.IsTrue(path.Equals("(0010,0010)"));
            Assert.IsTrue(path.Equals(0x00100010));
            Assert.IsTrue(path.Equals(NewDicomTag(0x00100010)));

            //Test old separator - "backslash"
            path = new DicomTagPath(@"(0054,0220)\(0054,0222)");

            path = new DicomTagPath("(0054,0220)/(0054,0222)");
            Assert.AreEqual(path, "(0054,0220)/(0054,0222)");
            Assert.IsFalse(path.Equals("(0054,0220)"));
            Assert.IsFalse(path.Equals(0x00540220));
            Assert.IsFalse(path.Equals(NewDicomTag(0x00540220)));

            path = new DicomTagPath("(0054,0220)/(0054,0222)/(0010,0022)");
            Assert.AreEqual(path.ToString(), "(0054,0220)/(0054,0222)/(0010,0022)");

            path = new DicomTagPath((new[] { NewDicomTag(0x00540220) }));
            Assert.AreEqual(path.ToString(), "(0054,0220)");

            path = new DicomTagPath((new[] { NewDicomTag(0x00540220), NewDicomTag(0x00540222) }));
            Assert.AreEqual(path.ToString(), "(0054,0220)/(0054,0222)");

            path = new DicomTagPath((new[] { NewDicomTag(0x00540220), NewDicomTag(0x00540222), NewDicomTag(0x00100022) }));
            Assert.AreEqual(path.ToString(), "(0054,0220)/(0054,0222)/(0010,0022)");

            path = new DicomTagPath(new uint[] { 0x00540220, 0x00540222 });
            Assert.AreEqual(path.ToString(), "(0054,0220)/(0054,0222)");

            path = new DicomTagPath(new uint[] { 0x00540220, 0x00540222, 0x00100010 });
            Assert.AreEqual(path.ToString(), "(0054,0220)/(0054,0222)/(0010,0010)");
        }
Esempio n. 11
0
		public void Test()
		{
            var path = new DicomTagPath("(0010,0010)");

			Assert.AreEqual(path, "(0010,0010)"); 
			Assert.AreEqual(path, (uint)0x00100010);
			Assert.AreEqual(path, NewDicomTag(0x00100010));
			Assert.IsTrue(path.Equals("(0010,0010)"));
			Assert.IsTrue(path.Equals(0x00100010));
			Assert.IsTrue(path.Equals(NewDicomTag(0x00100010)));

            //Test old separator - "backslash"
            path = new DicomTagPath(@"(0054,0220)\(0054,0222)");

			path = new DicomTagPath("(0054,0220)/(0054,0222)");
			Assert.AreEqual(path, "(0054,0220)/(0054,0222)"); 
			Assert.IsFalse(path.Equals("(0054,0220)"));
			Assert.IsFalse(path.Equals(0x00540220));
			Assert.IsFalse(path.Equals(NewDicomTag(0x00540220)));

			path = new DicomTagPath("(0054,0220)/(0054,0222)/(0010,0022)");
			Assert.AreEqual(path.ToString(), "(0054,0220)/(0054,0222)/(0010,0022)");

			path = new DicomTagPath((new[] { NewDicomTag(0x00540220) }));
			Assert.AreEqual(path.ToString(), "(0054,0220)");

			path = new DicomTagPath((new[] { NewDicomTag(0x00540220), NewDicomTag(0x00540222) }));
			Assert.AreEqual(path.ToString(), "(0054,0220)/(0054,0222)");

			path = new DicomTagPath((new[] { NewDicomTag(0x00540220), NewDicomTag(0x00540222), NewDicomTag(0x00100022) }));
			Assert.AreEqual(path.ToString(), "(0054,0220)/(0054,0222)/(0010,0022)");

			path = new DicomTagPath(new uint[] { 0x00540220, 0x00540222 });
			Assert.AreEqual(path.ToString(), "(0054,0220)/(0054,0222)");

			path = new DicomTagPath(new uint[] { 0x00540220, 0x00540222, 0x00100010 });
			Assert.AreEqual(path.ToString(), "(0054,0220)/(0054,0222)/(0010,0010)");
		}
Esempio n. 12
0
        public void Test()
        {
            DicomTagPath path = new PathTest();

            ((PathTest)path).SetPath("(0010,0010)");

            Assert.AreEqual(path, "(0010,0010)");
            Assert.AreEqual(path, (uint)0x00100010);
            Assert.AreEqual(path, NewDicomTag(0x00100010));
            Assert.IsTrue(path.Equals("(0010,0010)"));
            Assert.IsTrue(path.Equals((uint)0x00100010));
            Assert.IsTrue(path.Equals(NewDicomTag(0x00100010)));

            ((PathTest)path).SetPath("(0054,0220)\\(0054,0222)");
            Assert.AreEqual(path, "(0054,0220)\\(0054,0222)");
            Assert.IsFalse(path.Equals("(0054,0220)"));
            Assert.IsFalse(path.Equals((uint)0x00540220));
            Assert.IsFalse(path.Equals(NewDicomTag(0x00540220)));

            ((PathTest)path).SetPath("(0054,0220)\\(0054,0222)\\(0010,0022)");
            Assert.AreEqual(path.ToString(), "(0054,0220)\\(0054,0222)\\(0010,0022)");

            path = new PathTest();
            ((PathTest)path).SetPath(new List <DicomTag>(new DicomTag[] { NewDicomTag(0x00540220) }));
            Assert.AreEqual(path.ToString(), "(0054,0220)");

            ((PathTest)path).SetPath(new List <DicomTag>(new DicomTag[] { NewDicomTag(0x00540220), NewDicomTag(0x00540222) }));
            Assert.AreEqual(path.ToString(), "(0054,0220)\\(0054,0222)");

            ((PathTest)path).SetPath(new List <DicomTag>(new DicomTag[] { NewDicomTag(0x00540220), NewDicomTag(0x00540222), NewDicomTag(0x00100022) }));
            Assert.AreEqual(path.ToString(), "(0054,0220)\\(0054,0222)\\(0010,0022)");

            path = new DicomTagPath(new uint[] { 0x00540220, 0x00540222 });
            Assert.AreEqual(path.ToString(), "(0054,0220)\\(0054,0222)");

            path = new DicomTagPath(new uint[] { 0x00540220, 0x00540222, 0x00100010 });
            Assert.AreEqual(path.ToString(), "(0054,0220)\\(0054,0222)\\(0010,0010)");
        }
Esempio n. 13
0
        public void TestDicomTagPathGetAttribute_Create()
        {
            var collection = new DicomAttributeCollection();

            var path = new DicomTagPath(DicomTags.ViewCodeSequence);
            Assert.IsNull(path.GetAttribute(collection));
            Assert.IsNotNull(path.GetAttribute(collection, true));

            path += DicomTags.CodeMeaning;
            Assert.IsNull(path.GetAttribute(collection));
            Assert.IsNotNull(path.GetAttribute(collection, true));
            Assert.IsNotNull(path.UpOne().GetAttribute(collection));

            path = path.UpOne() + DicomTags.ConceptNameCodeSequence;
            Assert.IsNull(path.GetAttribute(collection));
            Assert.IsNotNull(path.GetAttribute(collection, true));
            Assert.IsNotNull(path.UpOne().GetAttribute(collection));

            path += DicomTags.CodeValue;
            Assert.IsNull(path.GetAttribute(collection));
            Assert.IsNotNull(path.GetAttribute(collection, true));
            Assert.IsNotNull(path.UpOne().GetAttribute(collection));
        }
Esempio n. 14
0
		public void Test()
		{
			DicomTagPath path = new PathTest();
			((PathTest)path).SetPath("(0010,0010)");

			Assert.AreEqual(path, "(0010,0010)"); 
			Assert.AreEqual(path, (uint)0x00100010);
			Assert.AreEqual(path, NewDicomTag(0x00100010));
			Assert.IsTrue(path.Equals("(0010,0010)"));
			Assert.IsTrue(path.Equals((uint)0x00100010));
			Assert.IsTrue(path.Equals(NewDicomTag(0x00100010)));

			((PathTest)path).SetPath("(0054,0220)\\(0054,0222)");
			Assert.AreEqual(path, "(0054,0220)\\(0054,0222)"); 
			Assert.IsFalse(path.Equals("(0054,0220)"));
			Assert.IsFalse(path.Equals((uint)0x00540220));
			Assert.IsFalse(path.Equals(NewDicomTag(0x00540220)));

			((PathTest)path).SetPath("(0054,0220)\\(0054,0222)\\(0010,0022)");
			Assert.AreEqual(path.ToString(), "(0054,0220)\\(0054,0222)\\(0010,0022)");

			path = new PathTest();
			((PathTest)path).SetPath(new List<DicomTag>(new DicomTag[] { NewDicomTag(0x00540220) }));
			Assert.AreEqual(path.ToString(), "(0054,0220)");

			((PathTest)path).SetPath(new List<DicomTag>(new DicomTag[] { NewDicomTag(0x00540220), NewDicomTag(0x00540222) }));
			Assert.AreEqual(path.ToString(), "(0054,0220)\\(0054,0222)");

			((PathTest)path).SetPath(new List<DicomTag>(new DicomTag[] { NewDicomTag(0x00540220), NewDicomTag(0x00540222), NewDicomTag(0x00100022) }));
			Assert.AreEqual(path.ToString(), "(0054,0220)\\(0054,0222)\\(0010,0022)");

			path = new DicomTagPath(new uint[] { 0x00540220, 0x00540222 });
			Assert.AreEqual(path.ToString(), "(0054,0220)\\(0054,0222)");

			path = new DicomTagPath(new uint[] { 0x00540220, 0x00540222, 0x00100010 });
			Assert.AreEqual(path.ToString(), "(0054,0220)\\(0054,0222)\\(0010,0010)");
		}
Esempio n. 15
0
        public void TestDicomTagPathGetAttribute_Create()
        {
            var collection = new DicomAttributeCollection();

            var path = new DicomTagPath(DicomTags.ViewCodeSequence);

            Assert.IsNull(path.GetAttribute(collection));
            Assert.IsNotNull(path.GetAttribute(collection, true));

            path += DicomTags.CodeMeaning;
            Assert.IsNull(path.GetAttribute(collection));
            Assert.IsNotNull(path.GetAttribute(collection, true));
            Assert.IsNotNull(path.UpOne().GetAttribute(collection));

            path = path.UpOne() + DicomTags.ConceptNameCodeSequence;
            Assert.IsNull(path.GetAttribute(collection));
            Assert.IsNotNull(path.GetAttribute(collection, true));
            Assert.IsNotNull(path.UpOne().GetAttribute(collection));

            path += DicomTags.CodeValue;
            Assert.IsNull(path.GetAttribute(collection));
            Assert.IsNotNull(path.GetAttribute(collection, true));
            Assert.IsNotNull(path.UpOne().GetAttribute(collection));
        }
Esempio n. 16
0
        public static DicomAttribute GetAttribute(this DicomTagPath path, IDicomAttributeProvider attributes, bool create)
        {
            DicomAttribute attribute;
            var            tags = new Queue <DicomTag>(path.TagsInPath);

            do
            {
                var tag = tags.Dequeue();
                attribute = attributes[tag];
                if (tags.Count == 0)
                {
                    break;
                }

                var sequenceItems = attribute.Values as DicomSequenceItem[];
                if (sequenceItems == null || sequenceItems.Length == 0)
                {
                    if (!create)
                    {
                        return(null);
                    }

                    attribute.AddSequenceItem(new DicomSequenceItem());
                    sequenceItems = (DicomSequenceItem[])attribute.Values;
                }

                attributes = sequenceItems[0];
            } while (tags.Count > 0);

            if (attribute.IsEmpty && create)
            {
                attribute.SetNullValue();
            }

            return(attribute.IsEmpty ? null : attribute);
        }
 protected StringDicomPropertyFilter(DicomTagPath path, DicomAttributeCollection criteria)
     : base(path, criteria)
 {
     _rule = new MultiValuedPropertyRule <TDatabaseObject>(this);
 }
Esempio n. 18
0
 public void AssertBadPath1()
 {
     var tag = new DicomTagPath(DicomTags.PatientId);
     tag = tag + DicomTags.PatientsName;
 }
Esempio n. 19
0
        public void AssertBadPath2()
        {
            var tag = new DicomTagPath(DicomTags.ViewCodeSequence);
            try
            {
                tag = tag + DicomTags.CodeMeaning;
            }
            catch (Exception)
            {
                Assert.Fail("This is a valid path");
            }

            tag += DicomTags.PatientId;
        }
Esempio n. 20
0
        public void TestSetVr()
        {
            var path = new DicomTagPath(new[] { DicomTags.ViewCodeSequence, DicomTags.CodeMeaning });
            Assert.AreEqual(DicomVr.SQvr, path.TagsInPath[0].VR);
            Assert.AreNotEqual(DicomVr.UNvr, path.TagsInPath[1].VR);

            path = new DicomTagPath(new[] { DicomTags.ViewCodeSequence, DicomTags.CodeMeaning }, DicomVr.UNvr);
            Assert.AreEqual(DicomVr.SQvr, path.TagsInPath[0].VR);
            Assert.AreEqual(DicomVr.UNvr, path.TagsInPath[1].VR);
        }
Esempio n. 21
0
        public void TestGetAttributes()
        {
            var collection = new DicomAttributeCollection();
            collection[DicomTags.PatientId].SetStringValue("Test^Patient");
            var viewCodeSequence1 = new DicomSequenceItem();
            var viewCodeSequence2 = new DicomSequenceItem();
            collection[DicomTags.ViewCodeSequence].Values = new[] {viewCodeSequence1, viewCodeSequence2};
            viewCodeSequence1[DicomTags.CodeMeaning].SetStringValue("It's");
            viewCodeSequence2[DicomTags.CodeMeaning].SetStringValue("The Bomb");

            var path = new DicomTagPath(new[] { DicomTags.PatientId});
            var attributes = path.SelectAttributesFrom(collection).ToList();
            Assert.AreEqual(1, attributes.Count);
            Assert.AreEqual(attributes[0].ToString(), "Test^Patient");

            path = new DicomTagPath(new[] { DicomTags.PatientsName });
            attributes = path.SelectAttributesFrom(collection).ToList();
            Assert.AreEqual(1, attributes.Count);
            Assert.IsTrue(attributes[0].IsEmpty);

            path = new DicomTagPath(new[] { DicomTags.ViewCodeSequence, DicomTags.CodeMeaning });
            attributes = path.SelectAttributesFrom(collection).ToList();
            Assert.AreEqual(2, attributes.Count);
            Assert.AreEqual(attributes[0].ToString(), "It's");
            Assert.AreEqual(attributes[1].ToString(), "The Bomb");

            attributes[1].SetEmptyValue();
            attributes = path.SelectAttributesFrom(collection).ToList();
            Assert.AreEqual(2, attributes.Count);
            Assert.AreEqual(attributes[0].ToString(), "It's");
            Assert.IsTrue(attributes[1].IsEmpty);

            path = new DicomTagPath(new[] { DicomTags.AcquisitionDeviceTypeCodeSequence, DicomTags.CodeMeaning });
            attributes = path.SelectAttributesFrom(collection, true).ToList();
            Assert.AreEqual(1, attributes.Count);
            Assert.IsTrue(attributes[0].IsEmpty);
        }
Esempio n. 22
0
 private DicomTag NewDicomTag(uint tag)
 {
     return(DicomTagPath.NewTag(tag, null));
 }
 public ImageLevelUpdateEntry()
 {
     TagPath = new DicomTagPath();
 }
Esempio n. 24
0
        public void AssertBadPath1()
        {
            var tag = new DicomTagPath(DicomTags.PatientId);

            tag = tag + DicomTags.PatientsName;
        }
Esempio n. 25
0
 public TestStringPropertyFilter(DicomTagPath path, DicomAttributeCollection criteria)
     : base(path, criteria)
 {
 }
Esempio n. 26
0
 public static DicomAttribute GetAttribute(this DicomTagPath path, IDicomAttributeProvider attributes)
 {
     return(GetAttribute(path, attributes, false));
 }