+/**
+ * \brief AddStudyToEnd
+ * @param dd SQ Item to enqueue to the DicomDirStudy chained List
+ */
+bool DicomDir::AddStudyToEnd(DicomDirStudy *dd)
+{
+ if( Patients.size() > 0 )
+ {
+ ListDicomDirPatient::iterator itp = Patients.end();
+ itp--;
+ (*itp)->AddStudy(dd);
+ return true;
+ }
+ return false;
+}
+
+/**
+ * \brief AddSerieToEnd
+ * @param dd SQ Item to enqueue to the DicomDirSerie chained List
+ */
+bool DicomDir::AddSerieToEnd(DicomDirSerie *dd)
+{
+ if( Patients.size() > 0 )
+ {
+ ListDicomDirPatient::iterator itp = Patients.end();
+ itp--;
+
+ DicomDirStudy *study = (*itp)->GetLastStudy();
+ if( study )
+ {
+ study->AddSerie(dd);
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * \brief AddImageToEnd
+ * @param dd SQ Item to enqueue to the DicomDirImage chained List
+ */
+bool DicomDir::AddImageToEnd(DicomDirImage *dd)
+{
+ if( Patients.size() > 0 )
+ {
+ ListDicomDirPatient::iterator itp = Patients.end();
+ itp--;
+
+ DicomDirStudy *study = (*itp)->GetLastStudy();
+ if( study )
+ {
+ DicomDirSerie *serie = study->GetLastSerie();
+ if( serie )
+ {
+ serie->AddImage(dd);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+/**
+ * \brief for each Header of the chained list,
+ * add/update the Patient/Study/Serie/Image info
+ * @param path path of the root directory
+ * @param list chained list of Headers
+ */
+void DicomDir::SetElements(std::string const &path, VectDocument const &list)
+{
+ ClearEntry();
+ ClearPatient();
+
+ std::string patPrevName = "", patPrevID = "";
+ std::string studPrevInstanceUID = "", studPrevID = "";
+ std::string serPrevInstanceUID = "", serPrevID = "";
+
+ std::string patCurName, patCurID;
+ std::string studCurInstanceUID, studCurID;
+ std::string serCurInstanceUID, serCurID;
+
+ bool first = true;
+ for( VectDocument::const_iterator it = list.begin();
+ it != list.end();
+ ++it )
+ {
+ // get the current file characteristics
+ patCurName = (*it)->GetEntryValue(0x0010,0x0010);
+ patCurID = (*it)->GetEntryValue(0x0010,0x0011);
+ studCurInstanceUID = (*it)->GetEntryValue(0x0020,0x000d);
+ studCurID = (*it)->GetEntryValue(0x0020,0x0010);
+ serCurInstanceUID = (*it)->GetEntryValue(0x0020,0x000e);
+ serCurID = (*it)->GetEntryValue(0x0020,0x0011);
+
+ if( patCurName != patPrevName || patCurID != patPrevID || first )
+ {
+ SetElement(path, GDCM_DICOMDIR_PATIENT, *it);
+ first = true;
+ }
+
+ // if new Study Deal with 'STUDY' Elements
+ if( studCurInstanceUID != studPrevInstanceUID || studCurID != studPrevID
+ || first )
+ {
+ SetElement(path, GDCM_DICOMDIR_STUDY, *it);
+ first = true;
+ }
+
+ // if new Serie Deal with 'SERIE' Elements
+ if( serCurInstanceUID != serPrevInstanceUID || serCurID != serPrevID
+ || first )
+ {
+ SetElement(path, GDCM_DICOMDIR_SERIE, *it);
+ }
+
+ // Always Deal with 'IMAGE' Elements
+ SetElement(path, GDCM_DICOMDIR_IMAGE, *it);
+
+ patPrevName = patCurName;
+ patPrevID = patCurID;
+ studPrevInstanceUID = studCurInstanceUID;
+ studPrevID = studCurID;
+ serPrevInstanceUID = serCurInstanceUID;
+ serPrevID = serCurID;
+ first = false;
+ }