33
33
#include <main/controllers/historycontroller.h>
34
34
#include <main/controllers/controladoreventos.h>
35
35
#include <main/controllers/controladorpermisos.h>
36
#include <main/controllers/controladorcomandos.h>
36
#include <main/controllers/commandcontroller.h>
37
37
#include <main/controllers/configurationcontroller.h>
38
38
#include <main/controllers/controladorvistas.h>
39
39
#include <main/controllers/controladorlog.h>
42
42
#include <main/controllers/streaming/streamingloader.h>
43
43
#include <main/controllers/integrationcontroller.h>
44
44
#include <main/controllers/hangingprotocolcontroller.h>
45
#include <main/controllers/windowattributescontroller.h>
46
47
#include <commands/comandoincluirhistorial.h>
48
#include <commands/synchronizationcommand.h>
48
50
#include <main/gui/import/wxwizardimportacionginkgo.h>
49
51
#include <main/gui/acquisition/dialogoadquisicion.h>
70
72
#define ICONO_ESTUDIO 0
71
73
#define ICONO_SERIE 1
72
#define ICONO_HOMBRE 2
77
#define SIZE_THUMBNAILS 96
74
#define ICONO_LOCAL_DATABASE 2
75
#define ICONO_LOCAL_LINKED 3
76
#define ICONO_WADO_LINKED 4
79
#define SIZE_THUMBNAILS 76
80
#define HISTORY_WINDOW_ID "GinkgoCADxHistory"
163
166
wxTreeItemId nodeStudy = mapOfStudies[pk_study];
164
m_pTree->DeleteChildren(nodeStudy);
167
//m_pTree->DeleteChildren(nodeStudy);
165
168
GNC::GCS::HistoryController::SeriesModelList seriesList;
166
169
GNC::GCS::HistoryController::Instance()->GetSeriesFromStudy(pk_study, seriesList);
167
170
for(GNC::GCS::HistoryController::SeriesModelList::const_iterator it = seriesList.begin(); it != seriesList.end(); ++it) {
168
InsertSeries(nodeStudy,(*it));
171
InsertOrUpdateSeries(nodeStudy,(*it));
173
//delete series that doesn't exists...
170
174
m_pTree->SortChildren(nodeStudy, m_sortCriteria, m_reverse);
261
if(studyModel.pat_sex == 'M') {
262
icono = ICONO_HOMBRE;
263
} else if(studyModel.pat_sex == 'F') {
265
switch(studyModel.location)
267
case GNC::GCS::IHistoryController::TL_LocalDatabase:
268
icono = ICONO_LOCAL_DATABASE;
270
case GNC::GCS::IHistoryController::TL_LocalLinked:
271
icono = ICONO_LOCAL_LINKED;
273
case GNC::GCS::IHistoryController::TL_WadoLinked:
274
icono = ICONO_WADO_LINKED;
269
278
if(itMap != mapOfStudies.end())
271
280
idNode = (*itMap).second;
272
281
m_pTree->SetItemText(m_pTree->GetRootItem(), wxString::FromUTF8(studyModel.pat_name.c_str()));
282
m_pTree->SetItemImage(idNode, icono, wxTreeItemIcon_Max);
273
283
if (m_pTree->GetChildrenCount(idNode) == 0) {
274
284
m_pTree->AppendItem(idNode, _("Searching..."));
309
319
m_pTree->SetItemText(idNode, COL_DATE_TIME, dateTimeStr);
310
320
m_pTree->SetItemText(idNode, COL_ACCNUMBER, wxString::FromUTF8(studyModel.study_acc_no.c_str()));
311
321
m_pTree->SetItemText(idNode, COL_PK, wxString::Format(wxT("%d"),(studyModel.pk)));
322
m_pTree->SetItemText(idNode, COL_LOCATION, wxString::Format(wxT("%c"),(GNC::GCS::IHistoryController::LocationToChar(studyModel.location))));
312
324
if (studyModel.pending_tasks > 0) {
313
325
m_pTree->SetItemBackgroundColour(idNode, wxColour(255,128,64));
317
329
m_pTree->SetItemText(idNode, COL_PENDING_TASKS, wxString::Format(wxT("%d"),studyModel.pending_tasks));
319
//to enable expand...
320
if (m_pTree->GetChildrenCount(idNode) == 0) {
321
//m_pTree->AppendItem(idNode, _("Searching..."));
331
//if it's expanded then refresh series...
332
if (m_pTree->IsExpanded(idNode)) {
333
ExpandStudy(studyModel.pk);
348
wxTreeItemId InsertSeries(wxTreeItemId parent, const GNC::GCS::HistoryController::SeriesModel& model)
360
wxTreeItemId InsertOrUpdateSeries(wxTreeItemId parent, const GNC::GCS::HistoryController::SeriesModel& model)
350
362
wxDateTime seriesDate;
351
363
seriesDate.ParseFormat(wxString::FromUTF8( model.series_datetime.c_str() ).GetData(), wxT("%Y-%m-%dT%H:%M:%S"), wxDefaultDateTime);
362
wxTreeItemId idNode = m_pTree->AppendItem(parent, wxString::FromUTF8(model.series_desc.c_str()), -1, -1, NULL);
375
switch(model.location)
377
case GNC::GCS::IHistoryController::TL_LocalDatabase:
378
icono = ICONO_LOCAL_DATABASE;
380
case GNC::GCS::IHistoryController::TL_LocalLinked:
381
icono = ICONO_LOCAL_LINKED;
383
case GNC::GCS::IHistoryController::TL_WadoLinked:
384
icono = ICONO_WADO_LINKED;
389
wxTreeItemIdValue cookie;
390
wxTreeItemId searchingNode;
391
wxString modelPK = wxString::Format(wxT("%d"),model.pk);
392
for (wxTreeItemId child = m_pTree->GetFirstChild(parent, cookie); child.IsOk(); child = m_pTree->GetNextChild(parent, cookie)) {
393
if (m_pTree->GetItemText(child, COL_PK).CompareTo(modelPK) == 0) {
395
m_pTree->SetItemText(idNode, wxString::FromUTF8(model.series_desc.c_str()));
396
m_pTree->SetItemImage(idNode, icono, wxTreeItemIcon_Max);
398
} else if (m_pTree->GetItemText(child, COL_PK).IsEmpty()) {
399
searchingNode = child;
402
if (searchingNode.IsOk()) {
403
m_pTree->Delete(searchingNode);
405
if (!idNode.IsOk()) {
406
idNode = m_pTree->AppendItem(parent, wxString::FromUTF8(model.series_desc.c_str()), icono, icono, NULL);
363
408
m_pTree->SetItemText(idNode, COL_MODALITY, wxString::FromUTF8(model.series_modality.c_str()));
364
409
m_pTree->SetItemText(idNode, COL_DESCRIPTION, wxString::FromUTF8(model.series_desc.c_str()));
365
410
m_pTree->SetItemText(idNode, COL_DATE_TIME, dateTimeStr);
366
411
m_pTree->SetItemText(idNode, COL_PENDING_TASKS, wxString::Format(wxT("%d"),model.pendingTasks.size()));
367
m_pTree->SetItemText(idNode, COL_PK, wxString::Format(wxT("%d"),model.pk));
412
m_pTree->SetItemText(idNode, COL_PK, modelPK);
413
m_pTree->SetItemText(idNode, COL_LOCATION, wxString::Format(wxT("%c"),(GNC::GCS::IHistoryController::LocationToChar(model.location))));
414
460
void OnOpenMenu(wxCommandEvent& )
416
HistoryPanel->OpenSeriesOrStudy(SeriesPk, true);
462
HistoryPanel->OpenSeriesOrStudy(SeriesPk, true,!GNC::GCS::IControladorPermisos::Instance()->Get("core.restrictions", "reutilize_study"));
419
465
void OnOpenWithMenu(wxCommandEvent& )
438
484
//TODO all tasks are sendcommands
439
485
GADAPI::SendPACSCommand* pCmd = new GADAPI::SendPACSCommand((*it).pk, (*it).seriesId);
440
486
pCmd->init((*it).data);
441
GNC::ControladorComandos::Instance()->ProcessAsync("",pCmd,NULL);
487
GNC::CommandController::Instance()->ProcessAsync("",pCmd,NULL);
444
490
//---------------------------------------------------------------------------
462
508
GNC::GUI::HistoryPanel3* GNC::GUI::HistoryPanel3::m_pInstance = NULL;
465
GNC::GUI::HistoryPanel3::HistoryPanel3(wxWindow* pParent) : HistoryPanel3Base(pParent), Loader(new GNC::StreamingLoader())
511
GNC::GUI::HistoryPanel3::HistoryPanel3(wxWindow* pParent) : HistoryPanel3Base(pParent), Loader(new GNC::StreamingLoader()),
512
m_RefreshOnIdle(false)
515
GNC::GCS::WindowAttributesController::LoadWindowAttributes(HISTORY_WINDOW_ID, this, false);
467
518
m_pImageList = new wxImageList(SIZE_ICONOS,SIZE_ICONOS,true);
468
519
m_pTimerReload = new ReloadHistoryTimer(this);
491
542
if (bmp.IsOk()) {
492
543
m_pImageList->Add(bmp);
494
bmp = GinkgoResourcesManager::History::GetIcoHombre();
496
m_pImageList->Add(bmp);
498
bmp = GinkgoResourcesManager::History::GetIcoMujer();
500
m_pImageList->Add(bmp);
502
bmp = GinkgoResourcesManager::History::GetIcoOtro();
545
bmp = GinkgoResourcesManager::History::GetIcoLocalFile();
547
m_pImageList->Add(bmp);
549
bmp = GinkgoResourcesManager::History::GetIcoLocalLinked();
551
m_pImageList->Add(bmp);
553
bmp = GinkgoResourcesManager::History::GetIcoWadoLinked();
503
554
if (bmp.IsOk()) {
504
555
m_pImageList->Add(bmp);
565
616
ViewImage2D->Detach();
566
617
//necesario para que no haga un doble delete
567
618
ViewInteractor2D->Delete();
568
ViewInteractor2D->Reparent(NULL);
619
ViewInteractor2D->Reparent(NULL);
621
//save window attributes
622
GNC::GCS::WindowAttributesController::SaveWindowAttributes(HISTORY_WINDOW_ID, this);
571
626
void GNC::GUI::HistoryPanel3::ReloadHistory()
709
765
void GNC::GUI::HistoryPanel3::RefreshSearch(bool force)
770
m_RefreshOnIdle = true;
774
void GNC::GUI::HistoryPanel3::checkPendingTasks()
776
//throw pending commands...
777
if (GNC::GCS::HistoryController::Instance()->IsPendingTasks()) {
778
if (wxMessageBox(_("There are pending tasks, do you want to execute them?"), _("Pending tasks"), wxYES_NO , GNC::Entorno::Instance()->GetVentanaRaiz()) == wxYES)
780
std::list<GNC::GCS::HistoryController::TaskModel> tasks;
781
GNC::GCS::HistoryController::Instance()->GetPendingTasks(tasks);
788
void GNC::GUI::HistoryPanel3::GetSelectedSeriesPk(std::list<long>& listOfPks)
790
std::set<long> setOfPks;
791
m_pTableModel->GetSeriesPkSelected(setOfPks);
792
for (std::set<long>::iterator it = setOfPks.begin(); it != setOfPks.end(); ++it) {
793
listOfPks.push_back((*it));
797
void GNC::GUI::HistoryPanel3::OnHistoryPanelIdle( wxIdleEvent& /*event*/ )
799
if (m_RefreshOnIdle) {
804
void GNC::GUI::HistoryPanel3::doRefresh(bool force)
711
806
RefreshPatientFilter();
712
807
RefreshModalityFilter();
713
808
RefreshDateFilter();
742
void GNC::GUI::HistoryPanel3::checkPendingTasks()
744
//throw pending commands...
745
if (GNC::GCS::HistoryController::Instance()->IsPendingTasks()) {
746
if (wxMessageBox(_("There are pending tasks, do you want to execute them?"), _("Pending tasks"), wxYES_NO , GNC::Entorno::Instance()->GetVentanaRaiz()) == wxYES)
748
std::list<GNC::GCS::HistoryController::TaskModel> tasks;
749
GNC::GCS::HistoryController::Instance()->GetPendingTasks(tasks);
756
void GNC::GUI::HistoryPanel3::GetSelectedSeriesPk(std::list<long>& listOfPks)
758
std::set<long> setOfPks;
759
m_pTableModel->GetSeriesPkSelected(setOfPks);
760
for (std::set<long>::iterator it = setOfPks.begin(); it != setOfPks.end(); ++it) {
761
listOfPks.push_back((*it));
835
m_RefreshOnIdle = false;
766
838
void GNC::GUI::HistoryPanel3::RefreshPatientFilter()
904
976
m_pTreeListResults->GetItemText(item, COL_PK).ToLong(&pk);
905
977
if (m_pTreeListResults->GetItemParent(item) != m_pTreeListResults->GetRootItem()){
906
OpenSeriesOrStudy(pk, true);
978
OpenSeriesOrStudy(pk, true,!GNC::GCS::IControladorPermisos::Instance()->Get("core.restrictions", "reutilize_study"));
908
OpenSeriesOrStudy(pk, false);
980
OpenSeriesOrStudy(pk, false,!GNC::GCS::IControladorPermisos::Instance()->Get("core.restrictions", "reutilize_study"));
910
982
event.Skip(false);
950
1022
menu.AppendSeparator();
952
1024
GNC::HistoryToolsController::Instance()->AppendsToolInMenu(&menu, &menu, GNC::GCS::IHistoryTool::TFamily_Q_R);
1026
//synchronize option
1027
bool enableSynchronize = GNC::GCS::IHistoryController::Instance()->CharToLocation(*m_pTreeListResults->GetItemText(item, COL_LOCATION).ToUTF8())
1028
== GNC::GCS::IHistoryController::TL_WadoLinked;
1029
wxMenuItem* pMenuSynchronize = new wxMenuItem(&menu, idMenuItem, wxString( _("Synchronize") ), _("Synchronize"), wxITEM_NORMAL );
1031
pMenuSynchronize->SetBitmaps(GinkgoResourcesManager::Acquisition::GetIcoDownload());
1033
pMenuSynchronize->SetBitmap(GinkgoResourcesManager::Acquisition::GetIcoDownload());
1035
menu.Append(pMenuSynchronize);
1036
menu.Enable(idMenuItem, enableSynchronize);
1037
menu.Connect(idMenuItem++,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler( HistoryPanel3::OnSynchronizeSelected),NULL,this);
953
1039
if (menu.GetMenuItemCount() > 0 && !menu.GetMenuItems().back()->IsSeparator()) {
954
1040
menu.AppendSeparator();
1110
1196
wxHistoryImageThumbnailItem* pItem = static_cast<wxHistoryImageThumbnailItem*>(m_pThumbnails->GetItem(selected));
1111
1197
if (pItem->GetType() == wxHistoryImageThumbnailItem::TI_Series) {
1113
OpenSeriesOrStudy(pItem->GetSeriesPk(), true);
1199
OpenSeriesOrStudy(pItem->GetSeriesPk(), true,!GNC::GCS::IControladorPermisos::Instance()->Get("core.restrictions", "reutilize_study"));
1116
1202
GNC::GCS::IVista* pView = GetViewFromSeries(pItem->GetSeriesPk());
1119
1205
std::string pathOfFile(TOPATH(pItem->GetFilename()));
1120
1206
pView->ActivarRuta(pItem->GetFilePk());
1122
OpenSeriesOrStudy(pItem->GetSeriesPk(), true);
1208
OpenSeriesOrStudy(pItem->GetSeriesPk(), true,!GNC::GCS::IControladorPermisos::Instance()->Get("core.restrictions", "reutilize_study"));
1147
1233
if (item.IsOk() && m_pTreeListResults->GetItemParent(item) != m_pTreeListResults->GetRootItem()) {
1149
1235
m_pTreeListResults->GetItemText(item, COL_PK).ToLong(&pk);
1150
OpenSeriesOrStudy(pk, true);
1236
OpenSeriesOrStudy(pk, true,!GNC::GCS::IControladorPermisos::Instance()->Get("core.restrictions", "reutilize_study"));
1151
1237
} else if (item.IsOk() && m_pTreeListResults->GetItemParent(item) == m_pTreeListResults->GetRootItem()) {
1153
1239
m_pTreeListResults->GetItemText(item, COL_PK).ToLong(&pk);
1154
OpenSeriesOrStudy(pk, false);
1240
OpenSeriesOrStudy(pk, false,!GNC::GCS::IControladorPermisos::Instance()->Get("core.restrictions", "reutilize_study"));
1235
1326
OpenWithDialog::ListaModalidades listaModalidades;
1236
1327
for (GNC::GCS::IHistoryController::SeriesModelList::iterator itSeries = seriesModelList.begin(); itSeries != seriesModelList.end(); ++itSeries) {
1237
for (GNC::GCS::HistoryController::StringList::iterator it = (*itSeries).tsuids.begin(); it != (*itSeries).tsuids.end(); ++it) {
1238
listaModalidades.push_back(std::pair<std::string,std::string>((*itSeries).series_modality, (*it)));
1328
GNC::GCS::IHistoryController::SeriesModel& seriesModel = (*itSeries);
1329
for (GNC::GCS::HistoryController::StringList::iterator it = seriesModel.tsuids.begin(); it != seriesModel.tsuids.end(); ++it) {
1330
listaModalidades.push_back(std::pair<std::string,std::string>(seriesModel.series_modality, (*it)));
1353
if (seriesIsAlreadyOpen) {
1354
int answer = wxMessageBox(_("The series selected is already open\nDo you want to open it again?"),_("Open again"), wxYES_NO , GNC::Entorno::Instance()->GetVentanaRaiz());
1355
if (answer != wxYES) {
1360
1445
if(pModo != NULL && pModulo != NULL){
1362
1447
OpenSeries(seriesModelList, pModulo, pModo->GetId(), hp);
1550
1635
RefreshSearch();
1638
void GNC::GUI::HistoryPanel3::SynchronizeSelected()
1640
std::set<long> setOfPks;
1641
m_pTableModel->GetSeriesPkSelected(setOfPks);
1643
if (setOfPks.empty()) {
1644
wxMessageBox(_("Select at least one series"), _("Info"), wxOK | wxICON_WARNING);
1648
GNC::GCS::HistoryController::IdList pkList;
1649
pkList.insert(pkList.begin(), setOfPks.begin(), setOfPks.end());
1651
GADAPI::SynchronizationCommandParameters* pParams = new GADAPI::SynchronizationCommandParameters(pkList, NULL);
1652
GADAPI::SynchronizationCommand* pCmd = new GADAPI::SynchronizationCommand(pParams);
1653
GNC::GCS::ICommandController::Instance()->ProcessAsync("syncronizing...", pCmd, NULL);
1553
1656
void GNC::GUI::HistoryPanel3::LoadPreviewsFromStudy(const wxTreeItemId& itemStudy)
1555
1658
wxWindowDisabler disableAll;
1562
1665
m_pTreeListResults->GetItemText(itemStudy, COL_PK).ToLong(&pkStudy);
1667
GNC::GCS::IHistoryController::TLocation location = GNC::GCS::IHistoryController::CharToLocation(*m_pTreeListResults->GetItemText(itemStudy, COL_LOCATION).ToUTF8());
1564
1669
GNC::GCS::HistoryController::SeriesModelList seriesList;
1565
1670
GNC::GCS::HistoryController::Instance()->GetSeriesFromStudy(pkStudy, seriesList);
1567
1672
for (GNC::GCS::HistoryController::SeriesModelList::const_iterator it = seriesList.begin(); it != seriesList.end(); ++it) {
1568
1673
GNC::GCS::HistoryController::FileModel frame = GNC::GCS::HistoryController::Instance()->GetFrameOfReference((*it).pk);
1569
1674
wxString pathOfItem = wxString::Format(wxT("%ld"),frame.pk);
1570
wxHistoryImageThumbnailItem* pItem = new wxHistoryImageThumbnailItem(pathOfItem, wxHistoryImageThumbnailItem::TI_Series, (*it).pk, frame.pk, !frame.file_path.empty());
1677
wxHistoryImageThumbnailItem* pItem = new wxHistoryImageThumbnailItem(pathOfItem, wxHistoryImageThumbnailItem::TI_Series, (*it).pk, frame.pk, location);
1571
1678
m_pThumbnails->Insert(pItem);
1573
1680
m_pThumbnails->Thaw();
1585
1692
m_pTreeListResults->GetItemText(itemSeries, COL_PK).ToLong(&pk);
1586
GNC::GCS::HistoryController::FileModelList listOfFiles;
1693
GNC::GCS::HistoryController::LightFileModelList listOfFiles;
1587
1694
GNC::GCS::HistoryController::Instance()->GetSeriesSortedFileModels(pk, listOfFiles);
1589
for (GNC::GCS::HistoryController::FileModelList::const_iterator it = listOfFiles.begin(); it != listOfFiles.end(); ++it) {
1696
for (GNC::GCS::HistoryController::LightFileModelList::const_iterator it = listOfFiles.begin(); it != listOfFiles.end(); ++it) {
1590
1697
wxString pathOfItem = wxString::Format(wxT("%ld"),(*it).pk);
1591
wxHistoryImageThumbnailItem* pItem = new wxHistoryImageThumbnailItem(pathOfItem, wxHistoryImageThumbnailItem::TI_Image, pk, (*it).pk, !(*it).file_path.empty());
1698
wxHistoryImageThumbnailItem* pItem = new wxHistoryImageThumbnailItem(pathOfItem, wxHistoryImageThumbnailItem::TI_Image, pk, (*it).pk, (*it).location);
1592
1699
m_pThumbnails->Append(pItem);
1594
1701
m_pThumbnails->Thaw();