DICOM dataset can be easily constructed by inserting tags into an empty dataset or populating an existing one:
DcmDataset dataset; dataset.setTagValue("MediaStorageSOPClassUID", "1.2.840.10008.5.1.4.1.1.1"); dataset.setTagValue("MediaStorageSOPInstanceUID", "1.2.3.4.5.6.7"); dataset.setTagValue("StudyInstanceUID", "1.2.3.4.5.6.7.1"); dataset.setTagValue("SeriesInstanceUID", "1.2.3.4.5.6.7.1.1"); dataset.setTagValue("SOPClassUID", "1.2.840.10008.5.1.4.1.1.1"); dataset.setTagValue("SOPInstanceUID", "1.2.3.4.5.6.7"); dataset.setTagValue("PatientId", "BJ750315"); dataset.setTagValue("PatientName", "Brown^John"); dataset.setTagValue("PatientSex", "M"); dataset.setTagValue("PatientBirthDate", QDate(1975, 3, 15));
Another way to populate a dataset is by using modules. Modules are sets of tags grouped logically in a single object:
DcmDataset dataset; DcmModulePatient patient; patient.setPatientId("BJ750315"); patient.setPatientName("Brown^John"); dataset.attachModule(patient);Modules contain mandatory tags well as optional tags. One may call
isValid()
method of a module object to check that all mandatory tags has been defined.