public void SerializeAndDeserializePrivateTags() { var privCreatorDictEntry = new DicomDictionaryEntry(new DicomTag(0x0011, 0x0010), "Private Creator", "PrivateCreator", DicomVM.VM_1, false, DicomVR.LO); DicomDictionary.Default.Add(privCreatorDictEntry); DicomPrivateCreator privateCreator1 = DicomDictionary.Default.GetPrivateCreator("TESTCREATOR1"); DicomDictionary privDict1 = DicomDictionary.Default[privateCreator1]; var dictEntry = new DicomDictionaryEntry(DicomMaskedTag.Parse("0011", "xx01"), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.CS); privDict1.Add(dictEntry); var ds = new DicomDataset(); ds.Add(dictEntry.Tag, "VAL1"); ds.Add(DicomTag.SOPClassUID, DicomUID.CTImageStorage); ds.Add(DicomTag.SOPInstanceUID, "2.25.123"); Assert.Equal(DicomVR.CS, ds.Get<DicomVR>(dictEntry.Tag)); var bytes = SerializeDicom_(ds); File.OpenWrite("C:\\Temp\\x.dcm").Write(bytes, 0, bytes.Length); var ds2 = ParseDicom_(bytes); Assert.Equal(DicomVR.CS, ds2.Get<DicomVR>(dictEntry.Tag)); }
public void Add_PrivateTag_GetsCorrectVR() { var privCreatorDictEntry = new DicomDictionaryEntry( new DicomTag(0x0011, 0x0010), "Private Creator", "PrivateCreator", DicomVM.VM_1, false, DicomVR.LO); DicomDictionary.Default.Add(privCreatorDictEntry); DicomPrivateCreator privateCreator1 = DicomDictionary.Default.GetPrivateCreator("TESTCREATOR1"); DicomDictionary privDict1 = DicomDictionary.Default[privateCreator1]; var dictEntry = new DicomDictionaryEntry( DicomMaskedTag.Parse("0011", "xx10"), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.CS); privDict1.Add(dictEntry); var ds = new DicomDataset { { dictEntry.Tag, "VAL1" } }; Assert.Equal(DicomVR.CS, ds.Get <DicomVR>(ds.GetPrivateTag(dictEntry.Tag))); }
public void AddTagAndReadOut() { var dict = new DicomDictionary(); var tag = new DicomTag(0x0010, 0x0020); var dictEntry = new DicomDictionaryEntry(tag, "TestTagName", "TestTagKeyword", DicomVM.VM_1, false, DicomVR.DT); dict.Add(dictEntry); Assert.Equal(dictEntry, dict[tag]); }
public void AddPrivateTagAndReadOut() { var dict = new DicomDictionary { new DicomDictionaryEntry(new DicomTag(0x0011, 0x0010), "Private Creator", "PrivateCreator", DicomVM.VM_1, false, DicomVR.LO) }; DicomPrivateCreator privateCreator = dict.GetPrivateCreator("TESTCREATOR"); DicomDictionary privDict = dict[privateCreator]; var dictEntry = new DicomDictionaryEntry(new DicomTag(0x0011, 0x1010), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.DT); privDict.Add(dictEntry); Assert.True(dictEntry.Equals(dict[dictEntry.Tag.PrivateCreator][dictEntry.Tag])); }
public void CheckAddedPrivateTagValueRepresentation() { var privCreatorDictEntry = new DicomDictionaryEntry(new DicomTag(0x0011, 0x0010), "Private Creator", "PrivateCreator", DicomVM.VM_1, false, DicomVR.LO); DicomDictionary.Default.Add(privCreatorDictEntry); DicomPrivateCreator privateCreator1 = DicomDictionary.Default.GetPrivateCreator("TESTCREATOR1"); DicomDictionary privDict1 = DicomDictionary.Default[privateCreator1]; var dictEntry = new DicomDictionaryEntry(DicomMaskedTag.Parse("0011", "xx10"), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.CS); privDict1.Add(dictEntry); var ds = new DicomDataset(); ds.Add(dictEntry.Tag, "VAL1"); Assert.Equal(DicomVR.CS, ds.Get<DicomVR>(dictEntry.Tag)); }
public void Add_PrivateTag_ShouldBeAddedWithCorrectVR() { var privCreatorDictEntry = new DicomDictionaryEntry(new DicomTag(0x0011, 0x0010), "Private Creator", "PrivateCreator", DicomVM.VM_1, false, DicomVR.LO); DicomDictionary.Default.Add(privCreatorDictEntry); DicomPrivateCreator privateCreator1 = DicomDictionary.Default.GetPrivateCreator("TESTCREATOR1"); DicomDictionary privDict1 = DicomDictionary.Default[privateCreator1]; var dictEntry = new DicomDictionaryEntry(DicomMaskedTag.Parse("0011", "xx10"), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.CS); privDict1.Add(dictEntry); var ds = new DicomDataset(); ds.Add(dictEntry.Tag, "VAL1"); Assert.Equal(DicomVR.CS, ds.GetDicomItem <DicomItem>(dictEntry.Tag).ValueRepresentation); }
public void Enumerate_DictionaryEntriesWithPrivateTags_ContainsAllExpectedEntries() { var dict = new DicomDictionary(); var tag1 = new DicomTag(0x0010, 0x0020); var dictEntry1 = new DicomDictionaryEntry( tag1, "TestPublicTagName", "TestPublicTagKeyword", DicomVM.VM_1, false, DicomVR.DT); var privCreatorDictEntry = new DicomDictionaryEntry( new DicomTag(0x0011, 0x0010), "Private Creator", "PrivateCreator", DicomVM.VM_1, false, DicomVR.LO); dict.Add(privCreatorDictEntry); DicomPrivateCreator privateCreator = dict.GetPrivateCreator("TESTCREATOR"); DicomDictionary privDict = dict[privateCreator]; var dictEntry2 = new DicomDictionaryEntry( DicomMaskedTag.Parse("0011", "xx10"), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.DT); privDict.Add(dictEntry2); dict.Add(dictEntry1); Assert.Contains(dictEntry1, dict); Assert.Contains(privCreatorDictEntry, dict); Assert.Contains(dictEntry2, dict[dictEntry2.Tag.PrivateCreator]); }
public void EnumerateBothPublicAndPrivateEntries() { var dict = new DicomDictionary(); var tag1 = new DicomTag(0x0010, 0x0020); var dictEntry1 = new DicomDictionaryEntry(tag1, "TestPublicTagName", "TestPublicTagKeyword", DicomVM.VM_1, false, DicomVR.DT); var privCreatorDictEntry = new DicomDictionaryEntry(new DicomTag(0x0011, 0x0010), "Private Creator", "PrivateCreator", DicomVM.VM_1, false, DicomVR.LO); dict.Add(privCreatorDictEntry); DicomPrivateCreator privateCreator = dict.GetPrivateCreator("TESTCREATOR"); DicomDictionary privDict = dict[privateCreator]; var dictEntry2 = new DicomDictionaryEntry(DicomMaskedTag.Parse("0011", "xx10"), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.DT); privDict.Add(dictEntry2); dict.Add(dictEntry1); Assert.True(dict.Contains(dictEntry1)); Assert.True(dict.Contains(privCreatorDictEntry)); Assert.True(dict[dictEntry2.Tag.PrivateCreator].Contains(dictEntry2)); Assert.True(dict.PrivateCreators.Any(pc => dict[pc].Contains(dictEntry2))); }
public void GettingPrivateTagsChangesNothingWhenNotPresent() { var dataSet = new DicomDataset { {DicomTag.SOPInstanceUID, "2.999.1241"}, {DicomTag.SOPClassUID, "2.999.1242"} }; DicomPrivateCreator privateCreator = DicomDictionary.Default.GetPrivateCreator("TESTCREATOR"); DicomDictionary privDict = DicomDictionary.Default[privateCreator]; var privTag = new DicomDictionaryEntry(DicomMaskedTag.Parse("0011", "xx10"), "TestPrivTagName", "TestPrivTagKeyword", DicomVM.VM_1, false, DicomVR.DT); privDict.Add(privTag); var dataBefore = SerializeDicom_(dataSet); var val = dataSet.Get<string>(privTag.Tag); var dataAfter = SerializeDicom_(dataSet); Assert.Equal(dataBefore, dataAfter); Assert.Null(val); }
private void ReadTags(string columnName, object value, uint[] dicomTags) { foreach (var dicomTag in dicomTags) { fo.DicomDictionaryEntry dicEntry = fo.DicomDictionary.Default[dicomTag]; if (DBNull.Value != value && value != null) { var vr = dicEntry.ValueRepresentations.First(); Type valueType = value.GetType( ); if (vr == fo.DicomVR.PN) { PersonNameParts currentPart = SchemaProvider.GetPNColumnPart(columnName); if (CurrentData.CurrentPersonNameData == null) { CurrentData.CurrentPersonNameData = new PersonNameData( ); CurrentData.CurrentPersonNameTagValue = (uint)dicEntry.Tag; CurrentData.CurrentPersonNames.Add(CurrentData.CurrentPersonNameTagValue, CurrentData.CurrentPersonNameData); } else { if (dicEntry.Tag != CurrentData.CurrentPersonNameTagValue) { if (CurrentData.CurrentPersonNames.TryGetValue((uint)dicEntry.Tag, out CurrentData.CurrentPersonNameData)) { CurrentData.CurrentPersonNameTagValue = (uint)dicEntry.Tag; } else { CurrentData.CurrentPersonNameData = new PersonNameData( ); CurrentData.CurrentPersonNameTagValue = (uint)dicEntry.Tag; CurrentData.CurrentPersonNames.Add(CurrentData.CurrentPersonNameTagValue, CurrentData.CurrentPersonNameData); } } } CurrentData.CurrentPersonNameData.SetPart(currentPart, (string)value); } if (valueType == typeof(String)) //shortcut { CurrentData.CurrentDs.AddOrUpdate <string>(dicomTag, (string)value); } else if (valueType == typeof(DateTime)) { CurrentData.CurrentDs.AddOrUpdate <DateTime>(dicomTag, (DateTime)value); } else if (valueType == typeof(Int32)) { CurrentData.CurrentDs.AddOrUpdate <Int32>(dicomTag, (Int32)value); //dicomElement.SetInt32((int)dicomElement.Count, (Int32)value); } else if (valueType == typeof(Int64)) { CurrentData.CurrentDs.AddOrUpdate <Int64>(dicomTag, (Int64)value); //dicomElement.SetInt64((int)dicomElement.Count, (Int64)value); } else { CurrentData.CurrentDs.AddOrUpdate <string>(dicomTag, value as string); //dicomElement.SetStringValue((string)value); System.Diagnostics.Debug.Assert(false, "Unknown element db value"); } } } }