3
* $Id: generaldata.cpp 3681 2011-04-12 10:53:31Z tovar $
6
* Copyright 2008-10 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 <api/ientorno.h>
15
#include <wx/msgdlg.h>
16
#include <wx/filedlg.h>
17
#include <wx/valtext.h>
18
#include <wx/busyinfo.h>
20
#include <wx/filename.h>
22
#include <wx/msgdlg.h>
23
#include <wx/confbase.h>
24
#include <api/idicommanager.h>
25
#include <api/ientorno.h>
30
#include "generaldata.h"
31
#include <api/internacionalizacion.h>
32
#include <export/tagsprivadoscomunes.h>
33
#include <fooextension/license.h>
35
#include <fooextension/commands/dicomizecommand.h>
37
namespace FooExtension {
40
GeneralData::GeneralData(wxWindow* pParent,IWizard* pWizard,const std::string &dirTemporal ,GnkPtr<ImportationPersistentData> datosPersistentes ,GNC::GCS::IEntorno * pEntorno):GeneralDataBase(pParent),IPasoWizard(pWizard)
44
m_pPersistentData=datosPersistentes;
46
wxDateTime date = wxDateTime::Now();
47
m_pStudyTime->SetDateTimeValue(date);
48
m_pSeriesTime->SetDateTimeValue(date);
51
GeneralData::~GeneralData()
56
//region "IPasoWizard"
58
void GeneralData::Attach(wxSizer *sizer){
59
m_pPatientId->SetFocus();
63
sizer->Add(this,10, wxEXPAND);
64
this->GetParent()->Layout();
67
void GeneralData::Detach(wxSizer *sizer){
70
sizer->GetContainingWindow()->Layout();
73
std::string GeneralData::GetTitle(){
74
return _Std("Title of this step");
77
std::string GeneralData::GetSubTitle(){
78
return _Std("Subtitle of this step");
82
bool GeneralData::Siguiente(){
87
bool GeneralData::Anterior(){
92
bool GeneralData::Cancelar(){
97
bool GeneralData::Validar(){
98
bool ok = ValidateData();
100
//fill in dicom tags, here you can add your own tags
101
FillInCommonTags(m_pPersistentData->baseImages);
102
//throws dicomization command...
103
//first create params...
104
FooExtension::GADAPI::DicomizeCommandParameters* pParams = new FooExtension::GADAPI::DicomizeCommandParameters(m_pPersistentData, m_pEntorno);
105
//secondly create command
106
FooExtension::GADAPI::DicomizeCommand* pCmd = new FooExtension::GADAPI::DicomizeCommand(pParams);
107
//Lastly call command controller to execute command asynchronous
108
m_pEntorno->GetControladorComandos()->ProcessAsync(_Std("Dicomization"), pCmd, NULL);
113
bool GeneralData::ValidateData() {
114
wxString mensaje = wxEmptyString;
116
if (m_pPatientId->GetValue().IsEmpty()) {
117
mensaje += _("\n* The patient ID is required.");
120
if(m_pPatientSurname1->GetValue().size() + m_pPatientSurname2->GetValue().size() + m_pPatientName->GetValue().size() > 61) {
121
mensaje += _("\n* Concatenation of patient name and surnames can't be higher than 61.");
124
if ( m_pPatientBirthDate->GetValue().IsLaterThan(m_pStudyDate->GetValue()) ) {
125
mensaje += _("\n* The patient's birth date is after the date of study");
128
if(mensaje != wxEmptyString){
129
wxMessageBox(_("The following errors have occurred when validating fields") + mensaje, _("Error validating fields"), wxICON_ERROR);
133
m_pPersistentData->PatientFirstSurname = GetPatientFirstSurname();
134
m_pPersistentData->PatientSecondSurname=GetPatientSecondSurname();
135
m_pPersistentData->PatientAge=GetPatientAge();
136
m_pPersistentData->PatientBirthDate=GetPatientBirthDate();
137
m_pPersistentData->PatientId=GetPatientId();
138
m_pPersistentData->PatientName=GetPatientName();
139
m_pPersistentData->PatientSex=GetPatientSex();
140
m_pPersistentData->StudyDescription=GetStudyDescription();
141
m_pPersistentData->StudyDate=GetStudyDate();
142
m_pPersistentData->StudyTime=GetStudyTime();
143
m_pPersistentData->SeriesDescription=GetSeriesDescription();
144
m_pPersistentData->SeriesDate=GetSeriesDate();
145
m_pPersistentData->SeriesTime=GetSeriesTime();
150
void GeneralData::FillInCommonTags(GIL::DICOM::TipoJerarquia& base)
152
//list of selected files
153
for(ListaFicheros::const_iterator it=m_pListaFicheros->begin(); it!= m_pListaFicheros->end(); it++) {
154
std::string path = (*it);
155
FooExtension::GUI::ImportationPersistentData::TDicomizedFile file;
156
file.imagePath = path;
158
m_pPersistentData->m_dicomizedFiles.push_back(file);
165
if(m_pPersistentData->InstitutionName == "" ){
166
wxConfigBase::Get()->Read(wxT("/GinkgoCore/Estacion/CentroNombre"),&wxTmp,wxEmptyString);
167
if(wxTmp != wxEmptyString){
168
base.tags[std::string("0008|0080")] = std::string(wxTmp.ToUTF8());
171
base.tags[std::string("0008|0080")] = m_pPersistentData->InstitutionName;
174
//nombre del medico responsable de la institucion
175
if(m_pPersistentData->PhysicianName == ""){
176
wxConfigBase::Get()->Read(wxT("/GinkgoCore/Estacion/NombreMedico"),&wxTmp,wxEmptyString);
177
if(wxTmp != wxEmptyString){
178
base.tags[std::string("0008|0090")] = std::string(wxTmp.ToUTF8());
181
base.tags[std::string("0008|0090")] = m_pPersistentData->PhysicianName;
184
base.tags[std::string("0008|0070")] = std::string("Metaemotion S.L.");
186
//description of the extension
187
base.tags[std::string("0008|1090")] = FOO_EXTENSION_DESCRIPTION;
189
//uid of the extension, used to open imported files with this extension
190
base.tags[std::string("0018|1030")] = FOO_EXTENSION_UID;
192
base.tags[std::string("0008|0020")] = m_pPersistentData->StudyDate;
194
base.tags[std::string("0008|0030")] = m_pPersistentData->StudyTime;
196
base.tags[std::string("0008|1030")] = m_pPersistentData->StudyDescription;
198
base.tags[std::string("0008|0021")] = m_pPersistentData->SeriesDate;
200
base.tags[std::string("0008|0031")] = m_pPersistentData->SeriesTime;
202
base.tags[std::string("0008|103e")] = m_pPersistentData->SeriesDescription;
204
base.tags[std::string("0008|0022")] = m_pPersistentData->SeriesDate;
205
base.tags[std::string("0008|0032")] = m_pPersistentData->SeriesTime;
206
base.tags[std::string("0020|4000")] = m_pPersistentData->SeriesDescription;
209
base.tags[std::string("0010|0010")] = m_pPersistentData->PatientName + "^" + m_pPersistentData->PatientFirstSurname + "^" + m_pPersistentData->PatientSecondSurname;
211
base.tags[std::string("0010|0020")] = m_pPersistentData->PatientId;
213
base.tags[std::string("0010|1010")] = m_pPersistentData->PatientAge;
215
base.tags[std::string("0010|0030")] = m_pPersistentData->PatientBirthDate;
217
base.tags[std::string("0010|0040")] = m_pPersistentData->PatientSex;
222
std::string GeneralData::GetPatientName(){
223
return std::string(m_pPatientName->GetValue().ToUTF8());
226
std::string GeneralData::GetPatientFirstSurname(){
227
return std::string(m_pPatientSurname1->GetValue().ToUTF8());
230
std::string GeneralData::GetPatientSecondSurname(){
231
return std::string(m_pPatientSurname2->GetValue().ToUTF8());
234
std::string GeneralData::GetPatientId(){
235
return std::string(m_pPatientId->GetValue().ToUTF8());
238
std::string GeneralData::GetPatientBirthDate(){
239
return std::string(m_pPatientBirthDate->GetValue().Format(wxT("%Y%m%d")).ToUTF8());
242
std::string GeneralData::GetPatientAge()
244
int age = CalculateAge();
245
std::ostringstream os;
252
std::string GeneralData::GetPatientSex(){
254
switch(m_pPatientSex->GetSelection()){
256
str = std::string("M");
259
str = std::string("F");
262
str = std::string("O");
268
void GeneralData::OnKillFocusEstudioTimeControl(wxFocusEvent &event)
270
if(!m_pStudyTime->GetDateTimeValue().IsValid()){
271
wxDateTime ahora = wxDateTime::Now();
272
m_pStudyTime->SetDateTimeValue(ahora);
277
std::string GeneralData::GetStudyDate()
279
if(m_pStudyDate->GetValue().IsValid()){
280
return std::string(m_pStudyDate->GetValue().Format(wxT("%Y%m%d")).ToUTF8());
282
return std::string("");
286
std::string GeneralData::GetStudyTime()
288
if(m_pStudyTime->GetDateTimeValue().IsValid()){
289
return std::string(m_pStudyTime->GetDateTimeValue().Format(wxT("%H%M%S")).ToUTF8());
291
return std::string("");
295
std::string GeneralData::GetStudyDescription()
297
return std::string(m_pStudyDescription->GetValue().ToUTF8());
300
void GeneralData::OnKillFocusSerieTimeControl(wxFocusEvent &event)
302
if(!m_pSeriesTime->GetDateTimeValue().IsValid())
304
wxDateTime ahora = wxDateTime::Now();
305
m_pSeriesTime->SetDateTimeValue(ahora);
310
std::string GeneralData::GetSeriesDate()
312
if(m_pSeriesDate->GetValue().IsValid()){
313
return std::string(m_pSeriesDate->GetValue().Format(wxT("%Y%m%d")).ToUTF8());
315
return std::string("");
319
std::string GeneralData::GetSeriesTime()
321
if(m_pSeriesTime->GetDateTimeValue().IsValid()){
322
return std::string(m_pSeriesTime->GetDateTimeValue().Format(wxT("%H%M%S")).ToUTF8());
324
return std::string("");
328
std::string GeneralData::GetSeriesDescription()
330
return std::string(m_pSeriesDescription->GetValue().ToUTF8());
334
int GeneralData::CalculateAge()
336
wxDateTime fechaEstudio = m_pStudyDate->GetValue();
337
wxDateTime fechaNacimiento = m_pPatientBirthDate->GetValue();
339
if( (fechaEstudio.GetMonth() > fechaNacimiento.GetMonth()) ||
340
(fechaEstudio.GetMonth() == fechaNacimiento.GetMonth() && fechaEstudio.GetDay() >= fechaNacimiento.GetDay()) ){
341
edad = fechaEstudio.GetYear() - fechaNacimiento.GetYear();
343
edad = fechaEstudio.GetYear() - fechaNacimiento.GetYear() - 1;