00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "gdcmDicomDirPatient.h"
00020 #include "gdcmDicomDirElement.h"
00021 #include "gdcmGlobal.h"
00022 #include "gdcmDicomDirStudy.h"
00023 #include "gdcmSQItem.h"
00024 #include "gdcmDebug.h"
00025
00026 namespace gdcm
00027 {
00028
00029
00034 DicomDirPatient::DicomDirPatient(bool empty)
00035 :DicomDirObject()
00036 {
00037 if( !empty )
00038 {
00039 ListDicomDirStudyElem const &elemList =
00040 Global::GetDicomDirElements()->GetDicomDirPatientElements();
00041 FillObject(elemList);
00042 }
00043 }
00044
00048 DicomDirPatient::~DicomDirPatient()
00049 {
00050 ClearStudy();
00051 }
00052
00053
00054
00060 void DicomDirPatient::WriteContent(std::ofstream *fp, FileType t)
00061 {
00062 DicomDirObject::WriteContent(fp, t);
00063
00064 for(ListDicomDirStudy::iterator cc = Studies.begin();
00065 cc!= Studies.end();
00066 ++cc )
00067 {
00068 (*cc)->WriteContent( fp, t );
00069 }
00070 }
00071
00076 DicomDirStudy* DicomDirPatient::NewStudy()
00077 {
00078 DicomDirStudy *st = new DicomDirStudy();
00079 Studies.push_back(st);
00080 return st;
00081 }
00082
00086 void DicomDirPatient::ClearStudy()
00087 {
00088 for(ListDicomDirStudy::const_iterator cc = Studies.begin();
00089 cc != Studies.end();
00090 ++cc )
00091 {
00092 delete *cc;
00093 }
00094 Studies.clear();
00095 }
00096
00101 DicomDirStudy *DicomDirPatient::GetFirstStudy()
00102 {
00103 ItStudy = Studies.begin();
00104 if (ItStudy != Studies.end())
00105 return *ItStudy;
00106 return NULL;
00107 }
00108
00114 DicomDirStudy *DicomDirPatient::GetNextStudy()
00115 {
00116 gdcmAssertMacro (ItStudy != Studies.end())
00117
00118 ++ItStudy;
00119 if (ItStudy != Studies.end())
00120 return *ItStudy;
00121 return NULL;
00122 }
00123
00128 DicomDirStudy *DicomDirPatient::GetLastStudy()
00129 {
00130 ItStudy = Studies.end();
00131 if (ItStudy != Studies.begin())
00132 {
00133 --ItStudy;
00134 return *ItStudy;
00135 }
00136 return NULL;
00137 }
00138
00139
00140
00141
00142
00143
00144
00145
00146
00152 void DicomDirPatient::Print(std::ostream &os, std::string const & )
00153 {
00154 os << "PATIENT" << std::endl;
00155 DicomDirObject::Print(os);
00156
00157 for(ListDicomDirStudy::const_iterator cc = Studies.begin();
00158 cc != Studies.end();
00159 ++cc )
00160 {
00161 (*cc)->SetPrintLevel(PrintLevel);
00162 (*cc)->Print(os);
00163 }
00164 }
00165
00166
00167 }