3
* $Id: AnonymizePanel.cpp $
6
* Copyright 2008-12 MetaEmotion S.L. All rights reserved.
7
* http://ginkgo-cadx.com
9
* This file is licensed under LGPL v3 license.
10
* See License.txt for details
14
#include "anonymizepanel.h"
15
#include <api/dicom/idicommanager.h>
16
#include <api/dicom/dcmdictionary.h>
17
#include <main/entorno.h>
18
#include <api/ientorno.h>
19
#include <api/controllers/icontroladorlog.h>
20
#include <api/controllers/iconfigurationcontroller.h>
21
#include <api/controllers/ipacscontroller.h>
22
#include <main/controllers/commandcontroller.h>
23
#include <main/controllers/historycontroller.h>
24
#include <commands/comandoexportacion.h>
26
GNC::GUI::AnonymizePanel::AnonymizePanel(wxWindow* pParent): GNC::GUI::AnonymizePanelBase(pParent)
30
GNC::GUI::AnonymizePanel::AnonymizePanel(wxWindow* pParent, const std::list<long>& seriesPk): GNC::GUI::AnonymizePanelBase(pParent)
32
if (seriesPk.empty()) {
33
LOG_ERROR("AnonymizePanel", "you have to select at least one series to anonymize");
35
InitSeries(seriesPk.front());
39
GNC::GUI::AnonymizePanel::~AnonymizePanel()
41
m_pTagsList->Disconnect(wxEVT_PG_CHANGED,wxPropertyGridEventHandler(AnonymizePanel::OnPropertyChanged),NULL,this);
42
m_pTagsList->Disconnect(wxEVT_PG_DOUBLE_CLICK,wxPropertyGridEventHandler(AnonymizePanel::OnPropertyDobleClick),NULL,this);
45
void GNC::GUI::AnonymizePanel::InitSeries(long pkSeries)
47
GNC::GCS::HistoryController::LightFileModelList fileModels;
48
GNC::GCS::HistoryController::Instance()->GetSeriesSortedFileModels(pkSeries, fileModels);
50
GIL::DICOM::IDICOMManager* pDICOMManager = GNC::GCS::IEntorno::Instance()->GetPACSController()->CrearInstanciaDeDICOMManager();
51
pDICOMManager->CargarFichero(fileModels.front().real_path, m_base);
52
SetTags(m_base, m_pTagsList->GetRoot(), pDICOMManager);
53
GNC::Entorno::Instance()->GetPACSController()->LiberarInstanciaDeDICOMManager(pDICOMManager);
55
MapOfCheck[GKDCM_PatientName] = m_pCheckNombrePaciente;
56
MapOfCheck[GKDCM_PatientID] = m_pCheckIdPaciente;
57
MapOfCheck[GKDCM_InstitutionName] = m_pCheckInstituciones;
58
MapOfCheck[GKDCM_ReferringPhysicianName] = m_pReferringPhysician;
59
MapOfCheck[GKDCM_StudyDescription] = m_pCheckComentarios;
60
MapOfCheck[GKDCM_SeriesDescription] = m_pCheckComentarios;
61
MapOfCheck[GKDCM_ImageComments] = m_pCheckComentarios;
63
GNC::GCS::IConfigurationController::TListGroups groups;
64
GNC::GCS::IConfigurationController::Instance()->readGroupUser("/Core/AnonymizationSelection", groups);
65
for (GNC::GCS::IConfigurationController::TListGroups::iterator it = groups.begin(); it != groups.end(); ++it)
67
if ((*it).find("tag") != (*it).end() && (*it).find("value") != (*it).end()) {
68
Anonymize((*it)["tag"], true, (*it)["value"]);
72
m_pTagsList->Connect(wxEVT_PG_CHANGED,wxPropertyGridEventHandler(AnonymizePanel::OnPropertyChanged),NULL,this);
73
m_pTagsList->Connect(wxEVT_PG_DOUBLE_CLICK,wxPropertyGridEventHandler(AnonymizePanel::OnPropertyDobleClick),NULL,this);
76
void GNC::GUI::AnonymizePanel::SetTags(GIL::DICOM::DicomDataset & base,wxPGPropArg idPadre,GIL::DICOM::IDICOMManager* pDICOMManager)
78
for(GIL::DICOM::ListaTags::iterator it = base.tags.begin(); it!= base.tags.end(); ++it){
79
wxString helpString = wxString::FromUTF8(pDICOMManager->GetDescription((*it).first).c_str());
80
wxStringProperty* prop = NULL;
82
if((*it).second.size()>100) {
85
valor = wxString::FromUTF8((*it).second.c_str());
88
if(helpString.size()>0){
89
helpString = wxT("(") + wxString::FromUTF8((*it).first.c_str()) + wxT(") ") + helpString;
90
prop = new wxStringProperty(helpString,
93
prop = new wxStringProperty(wxString::FromUTF8((*it).first.c_str()),
96
prop->SetHelpString(wxString::FromUTF8((*it).first.c_str()));
97
m_pTagsList->AppendIn(idPadre, prop);
100
for(GIL::DICOM::DicomDataset::DatasetList::iterator it = base.secuencias.begin(); it!=base.secuencias.end(); ++it){
101
wxStringProperty* prop = NULL;
102
wxString helpString = wxString::FromUTF8(pDICOMManager->GetDescription((*it).tagName).c_str());
103
if(helpString.size()>0){
104
helpString = wxT("(") + wxString::FromUTF8((*it).tagName.c_str()) + wxT(") ") + helpString;
105
prop = new wxStringProperty(helpString,
106
wxPG_LABEL,wxEmptyString);
108
prop = new wxStringProperty(wxString::FromUTF8((*it).tagName.c_str()),
109
wxPG_LABEL,wxEmptyString);
111
prop->SetHelpString(wxString::FromUTF8((*it).tagName.c_str()));
112
if(m_pTagsList->GetProperty(prop->GetName()) != NULL) {
113
////////////////////////////////////std::cout<<"hasdfasdf";
115
wxPGId pIdSequencia = m_pTagsList->AppendIn(idPadre,prop);
119
for(GIL::DICOM::DicomDataset::DatasetList::iterator it2 = (*it).items.begin(); it2!= (*it).items.end(); ++it2, ++i) {
120
wxPGPropArg pIdItem = m_pTagsList->AppendIn(pIdSequencia,new wxStringProperty(wxString::Format(wxT("Item %d"),i),wxPG_LABEL,wxEmptyString));
121
SetTags((*it2),pIdItem,pDICOMManager);
126
void GNC::GUI::AnonymizePanel::OnCheckNombreApellidos( wxCommandEvent& /*event*/ )
128
//se anonimiza 0010|0010 (nombre del paciente)
129
std::string clave("0010|0010");
130
Anonymize(clave,m_pCheckNombrePaciente->IsChecked());
133
void GNC::GUI::AnonymizePanel::OnCheckIdPaciente( wxCommandEvent& /*event*/ )
135
//se anonimiza 0010|0020" (id del paciente)
136
std::string clave("0010|0020");
137
Anonymize(clave,m_pCheckIdPaciente->IsChecked());
140
void GNC::GUI::AnonymizePanel::OnCheckInstituciones( wxCommandEvent& /*event*/ )
142
//se anonimiza (0008,0080) Institution Name
143
std::string clave("0008|0080");
144
Anonymize(clave,m_pCheckInstituciones->IsChecked());
147
void GNC::GUI::AnonymizePanel::OnCheckPhysician( wxCommandEvent& /*event*/ )
149
//referring physician name
150
std::string clave("0008|0090");
151
Anonymize(clave,m_pReferringPhysician->IsChecked());
154
void GNC::GUI::AnonymizePanel::OnCheckComentarios( wxCommandEvent& /*event*/ )
156
//descripcion del estudio, serie e imagenes
159
std::string clave("0008|1030");
160
Anonymize(clave,m_pCheckComentarios->IsChecked());
164
std::string clave("0008|103e");
165
Anonymize(clave,m_pCheckComentarios->IsChecked());
169
std::string clave("0020|4000");
170
Anonymize(clave,m_pCheckComentarios->IsChecked());
174
void GNC::GUI::AnonymizePanel::Anonymize(const std::string& clave, bool anonimizar)
176
wxString value = wxEmptyString;
180
if(m_base.getTag(clave,tmp)){
181
value = wxString::FromUTF8(tmp.c_str());
185
Anonymize(clave, anonimizar, std::string(value.ToUTF8()));
188
void GNC::GUI::AnonymizePanel::Anonymize(const std::string& clave, bool anonimizar, const std::string& value)
190
if (MapOfCheck.find(clave) != MapOfCheck.end()) {
191
MapOfCheck[clave]->SetValue(anonimizar);
193
wxString valueWx = wxString::FromUTF8(value.c_str());
194
for(wxPGProperty* it=m_pTagsList->GetFirst();it!=NULL;it=m_pTagsList->GetNextSiblingProperty(it)){
195
if(it->GetHelpString() == wxString::FromUTF8(clave.c_str())){
196
it->SetValueFromString(valueWx);
198
m_pTagsList->SetPropertyCell(it->GetId(),0,it->GetLabel(),wxNullBitmap,*wxWHITE,*wxRED);
199
m_pTagsList->SetPropertyCell(it->GetId(),1,it->GetValue(),wxNullBitmap,*wxWHITE,*wxRED);
201
m_pTagsList->SetPropertyCell(it->GetId(),0,it->GetLabel());
202
m_pTagsList->SetPropertyCell(it->GetId(),1,it->GetValue());
204
it->ChangeFlag(wxPG_PROP_MODIFIED,anonimizar);
205
m_pTagsList->RefreshProperty(it);
212
void GNC::GUI::AnonymizePanel::RemoveFromTable(const std::string& clave)
214
for(wxPGProperty* it=m_pTagsList->GetFirst();it!=NULL;it=m_pTagsList->GetNextSiblingProperty(it)){
215
if(it->GetHelpString() == wxString::FromUTF8(clave.c_str())){
216
m_pTagsList->DeleteProperty(it->GetId());
222
void GNC::GUI::AnonymizePanel::GetTagsAnonymized(GIL::DICOM::DicomDataset & base)
225
GNC::GCS::IConfigurationController::TListGroups configGroups;
226
for(wxPGProperty* it=m_pTagsList->GetFirst();it!=NULL;it=m_pTagsList->GetNextSiblingProperty(it)){
227
if(it->IsFlagSet(wxPG_PROP_MODIFIED)){
228
std::string clave(it->GetHelpString().ToUTF8());
229
std::string valor(it->GetValueAsString().ToUTF8());
230
base.tags[clave] = valor;
232
GNC::GCS::IConfigurationController::TMapValues group;
233
group["tag"] = clave;
234
group["value"] = valor;
235
configGroups.push_back(group);
238
GNC::GCS::IConfigurationController::Instance()->writeGroupUser("/Core/AnonymizationSelection", configGroups);
242
bool GNC::GUI::AnonymizePanel::AnonymizePrivateTags()
244
return m_pCheckAtributosPrivadosGinkgo->IsChecked();
247
void GNC::GUI::AnonymizePanel::OnPropertyChanged(wxPropertyGridEvent& event)
249
wxPGProperty* selected= event.GetProperty();
250
m_pTagsList->SetPropertyCell(selected->GetId(),0,selected->GetLabel(),wxNullBitmap,*wxWHITE,*wxRED);
251
m_pTagsList->SetPropertyCell(selected->GetId(),1,selected->GetValue(),wxNullBitmap,*wxWHITE,*wxRED);
254
void GNC::GUI::AnonymizePanel::OnPropertyDobleClick(wxPropertyGridEvent& event)
256
std::string clave(event.GetProperty()->GetHelpString().ToUTF8());
257
Anonymize(clave,!event.GetProperty()->IsFlagSet(wxPG_PROP_MODIFIED));