- case gdcmDicomDir::GDCM_PATIENT:
- AddPatientToEnd(begin,end);
- break;
- case gdcmDicomDir::GDCM_STUDY:
- AddStudyToEnd(begin,end);
- break;
- case gdcmDicomDir::GDCM_SERIE:
- AddSerieToEnd(begin,end);
- break;
- case gdcmDicomDir::GDCM_IMAGE:
- AddImageToEnd(begin,end);
- break;
+ d = tmpSI->GetDocEntry(0x0004, 0x1430); // Directory Record Type
+ if ( ValEntry* valEntry = dynamic_cast<ValEntry *>(d) )
+ {
+ v = valEntry->GetValue();
+ }
+ else
+ {
+ gdcmVerboseMacro( "Not a ValEntry.");
+ continue;
+ }
+
+ if( v == "PATIENT " )
+ {
+ si = new DicomDirPatient(true);
+ if( !AddPatientToEnd( static_cast<DicomDirPatient *>(si)) )
+ {
+ delete si;
+ si = NULL;
+ gdcmErrorMacro( "Add PatientToEnd failed");
+ }
+ }
+ else if( v == "STUDY " )
+ {
+ si = new DicomDirStudy(true);
+ if( !AddStudyToEnd( static_cast<DicomDirStudy *>(si)) )
+ {
+ delete si;
+ si = NULL;
+ gdcmErrorMacro( "Add AddStudyToEnd failed");
+ }
+ }
+ else if( v == "SERIES" )
+ {
+ si = new DicomDirSerie(true);
+ if( !AddSerieToEnd( static_cast<DicomDirSerie *>(si)) )
+ {
+ delete si;
+ si = NULL;
+ gdcmErrorMacro( "Add AddSerieToEnd failed");
+ }
+ }
+ else if( v == "IMAGE " )
+ {
+ si = new DicomDirImage(true);
+ if( !AddImageToEnd( static_cast<DicomDirImage *>(si)) )
+ {
+ delete si;
+ si = NULL;
+ gdcmErrorMacro( "Add AddImageToEnd failed");
+ }
+ }
+ else
+ {
+ // It was not a 'PATIENT', nor a 'STUDY', nor a 'SERIE',
+ // neither an 'IMAGE' SQItem. Skip to next item.
+ continue;
+ }
+ if( si )
+ MoveSQItem(si,tmpSI);
+
+ tmpSI=s->GetNextSQItem();