Only the mandatory elements (and one or two others we’ve been talked into adding) are put into the DICOMDIR by the AddToDirectory (.NET version) or AddToDirectory (COM version) method, but you can add others yourself very easily.
The AddToDirectory method returns a 4 item DicomDataSetCollection (.NET) or DicomDataSets collection(COM), and the 4 items are references to the 4 datasets referred to (existing or created as necessary) by that method call. They represent (in numerical order)
You can then add any additional attributes you wish to any of these levels. You do not need to worry about adding them multiple times (if the item already exists) as they will simply over-write the (presumably identical) existing copy.
The code below shows how to add the patient sex (which is not added by default) using DicomObjects.
DicomDirLevels = Directory.AddToDirectory(Image, FileName, TransferSyntax, 0); DicomDirLevels.Sex = Image.Sex;
Of course, exactly the same could be achieved (and must be done this way) for attributes which do not have convenient shortcuts:
DicomDirLevels = Directory.AddToDirectory(Image, FileName, TransferSyntax, 0); DicomDirLevels.Attributes.Add(Keyword.PatientSex, Image.Attributes(Keyword.PatientSex).Value);
Dim dir As New DicomDataSet Dim dirLevels As DicomDataSets Set dirLevels = dir.AddToDirectory(image, "\IMAGES\1", image.ReceivedSyntax, 0) dirLevels(1).Sex = image.Sex ' alternatively attribute can be added by group and element numbers dirLevels(1).Attributes.Add &H10, &H40, image.Sex