7 #include "uiMedDataQt/action/SInitNewSeries.hpp" 9 #include "uiMedDataQt/constants.hpp" 10 #include "uiMedDataQt/InsertSeries.hpp" 12 #include <fwCore/base.hpp> 14 #include <fwData/String.hpp> 16 #include <fwMedData/Equipment.hpp> 17 #include <fwMedData/Patient.hpp> 18 #include <fwMedData/Series.hpp> 19 #include <fwMedData/SeriesDB.hpp> 20 #include <fwMedData/Study.hpp> 22 #include <fwMedDataTools/helper/SeriesDB.hpp> 24 #include <fwServices/macros.hpp> 26 #include <fwTools/dateAndTime.hpp> 28 #include <boost/algorithm/string/classification.hpp> 29 #include <boost/algorithm/string/split.hpp> 30 #include <boost/date_time/posix_time/posix_time.hpp> 48 m_defaultInstitution(
"")
54 SInitNewSeries::~SInitNewSeries() noexcept
60 void SInitNewSeries::info(std::ostream& _sstream )
63 _sstream << std::string(
"SInitNewSeries");
68 void SInitNewSeries::starting()
71 this->actionServiceStarting();
76 void SInitNewSeries::stopping()
78 this->actionServiceStopping();
83 void SInitNewSeries::updating()
85 using namespace ::boost::posix_time;
87 ::fwMedData::SeriesDB::sptr seriesDB = this->getObject< ::fwMedData::SeriesDB >();
88 seriesDB->getContainer().clear();
91 SLM_ASSERT(
"Didn't find object with UID '" + m_seriesDBId +
"'", obj);
92 ::fwMedData::SeriesDB::sptr srcSeriesDB = ::fwMedData::SeriesDB::dynamicCast(obj);
96 for(const ::fwMedData::Series::sptr& series : srcSeriesDB->getContainer())
101 typedef std::map< std::string, ::fwMedData::Patient::sptr> StudyToPatientType;
102 typedef std::map< std::string, ::fwMedData::Study::sptr> StudyMapType;
104 StudyToPatientType studyToPatient;
105 StudyMapType studies;
107 for(const ::fwMedData::Series::sptr& series : seriesDB->getContainer())
109 const std::string& studyUID = series->getStudy()->getInstanceUID();
111 studies[studyUID] = series->getStudy();
112 studyToPatient[studyUID] = series->getPatient();
115 ptime now = second_clock::local_time();
117 const std::string date = ::fwTools::getDate(now);
118 const std::string time = ::fwTools::getTime(now);
120 for(
const StudyMapType::value_type& study : studies)
122 ::fwMedData::Series::sptr newSeries = ::uiMedDataQt::InsertSeries::New();
123 newSeries->setDescription(s_INSERT_NEW_SERIES_TEXT);
124 newSeries->setDate(date);
125 newSeries->setTime(time);
126 newSeries->setStudy(study.second);
127 newSeries->setPatient(studyToPatient[study.first]);
129 helper.
add(newSeries);
132 ::fwMedData::Study::sptr newStudy = ::fwMedData::Study::New();
133 newStudy->setField(s_NEW_STUDY_FIELD_NAME, ::fwData::String::New(
"NEW_STUDY"));
134 newStudy->setDate(date);
135 newStudy->setTime(time);
136 newStudy->setDescription(s_NEW_STUDY_TEXT);
138 ::fwMedData::Patient::sptr newPatient = ::fwMedData::Patient::New();
139 newPatient->setField(s_NEW_PATIENT_FIELD_NAME, ::fwData::String::New(
"NEW_PATIENT"));
140 newPatient->setName(s_NEW_PATIENT_TEXT);
141 newPatient->setBirthdate(date +
" " + time);
143 ::fwMedData::Equipment::sptr newEquipment = ::fwMedData::Equipment::New();
144 newEquipment->setInstitutionName(m_defaultInstitution);
146 ::fwMedData::Series::sptr newSeries = ::uiMedDataQt::InsertSeries::New();
147 newSeries->setDescription(s_INSERT_NEW_SERIES_TEXT);
148 newSeries->setStudy(newStudy);
149 newSeries->setPatient(newPatient);
150 newSeries->setEquipment(newEquipment);
151 newSeries->setDate(date);
152 newSeries->setTime(time);
154 helper.
add(newSeries);
160 void SInitNewSeries::configuring()
164 std::vector < ::fwRuntime::ConfigurationElement::sptr > seriesCfg = m_configuration->find(
"seriesDB");
165 SLM_ASSERT(
"Missing tag 'seriesDB'", !seriesCfg.empty());
167 m_seriesDBId = seriesCfg.front()->getValue();
168 SLM_ASSERT(
"seriesDB must not be empty", !m_seriesDBId.empty());
170 std::vector < ::fwRuntime::ConfigurationElement::sptr > institutionCfg = m_configuration->find(
"institution");
171 if(!institutionCfg.empty())
173 m_defaultInstitution = institutionCfg.front()->getValue();
The namespace uiMedDataQt contains editors for medical data.
This action allows to update uiMedDataQt::editor::SSelector UI in order to add new series...
#define FW_DEPRECATED_MSG(message, version)
Use this macro when deprecating a function to warn the developer.
Defines the service interface managing the menu items.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWGUI_API void initialize()
Initialize the action.
UIMEDDATAQT_API SInitNewSeries()
Constructor.