forked from Zwucki/OneArmPhaseTwoStudy_GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstudyprogresspage.cpp
755 lines (683 loc) · 29.7 KB
/
studyprogresspage.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
// This file is part of OneArmPhaseTwoStudy.
//
// OneArmPhaseTwoStudy is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// OneArmPhaseTwoStudy is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details (http://www.gnu.org/licenses/).
#include "studyprogresspage.h"
#include "ui_studyprogresspage.h"
StudyProgressPage::StudyProgressPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::StudyProgressPage)
{
ui->setupUi(this);
ui->dE_Eventdate->setDate(QDate::currentDate());
ui->dE_Recroutdate->setDate(QDate::currentDate());
ui->pB_AddPatient->setEnabled(false);
ui->t_EnrolledPatients->setEditTriggers(QAbstractItemView::NoEditTriggers);
simon = NULL;
sub1 = NULL;
ui->gB_flex->hide();
flex_cp_changed = false;
flex_n_changed = false;
tmp_r_flex = 0;
// Set tooltips for the differnt GUI elements
ui->l_alpha->setToolTip("Probability for a type one error.");
ui->l_beta->setToolTip("Probability for a type two error.");
ui->l_cp->setToolTip("Conditional power for the given state of the study.");
ui->l_cut->setToolTip("Chosen cut for the (non) statistical curtailment");
ui->l_enp0->setToolTip("Expected number of patients involved in the study given the zero hypothesis holds true.");
ui->l_enrolledPats->setToolTip("Enrolled patients so far.");
ui->l_n->setToolTip("Over all needed patients.");
ui->l_n1->setToolTip("Needed patients for the first stage of the study.");
ui->l_petp0->setToolTip("Propability for an early termination of the study given that the zero hypothesis is true.");
ui->l_r->setToolTip("Responses in this study must be higher than this value to reject the zero hypothesis.");
ui->l_r1->setToolTip("Number of responses must be higer than this value to proceed to the second stage of the study.");
ui->l_responses->setToolTip("Observed responses so far.");
// Hide currently obsolete GUI elements
ui->label_5->hide();
ui->label_6->hide();
ui->dE_Eventdate->hide();
ui->dE_Recroutdate->hide();
ui->cB_Response->hide();
ui->l_n->hide();
ui->l_n1->hide();
}
StudyProgressPage::~StudyProgressPage()
{
delete ui;
if(simon != NULL)
delete simon;
}
void StudyProgressPage::setStudy(Study *study)
{
this->currentStudy = study;
if(study->getIsSimondesign())
{
// If the current study uses a "simon's two stage design" the column for endpoint two is not needed.
ui->w_Rplot->setStudy(study);
if(ui->t_EnrolledPatients->columnCount() >= 3)
ui->t_EnrolledPatients->removeColumn(2);
ui->t_EnrolledPatients->horizontalHeaderItem(1)->setText("Response");
ui->gB_response_detail->hide();
}
else
{
// If the current study uses a "subset design" the column for endpoint two is needed.
ui->w_Rplot->setStudy(study);
ui->t_EnrolledPatients->insertColumn(2);
ui->t_EnrolledPatients->setHorizontalHeaderItem(2, new QTableWidgetItem("Response endpoint two"));
ui->t_EnrolledPatients->horizontalHeaderItem(1)->setText("Response endpoint one");
ui->gB_response_detail->show();
}
ui->l_Studyname->setText("<b>Studyname</b>: "+ currentStudy->getStudyName());
ui->l_Investigator->setText("<b>Investigator</b>: " + currentStudy->getInvestigator());
ui->l_Biometrician->setText("<b>Biometrician</b>: " + currentStudy->getBiometrician());
showStudyDetails(study);
// Allready enrolled patients are added to the corresponding table.
ui->t_EnrolledPatients->clearContents();
ui->t_EnrolledPatients->setRowCount(0);
std::vector<Study::Patient>::iterator it;
for(it = currentStudy->getEnrolledPatients()->begin(); it != currentStudy->getEnrolledPatients()->end(); it++)
{
this->addPatientToTable((*it));
}
}
void StudyProgressPage::showStudyDetails(Study *study)
{
QString s;
QTextStream ts(&s, QIODevice::ReadWrite);
ts.setRealNumberPrecision(2);
if(study->getIsSimondesign())
{
// Display all available informations about the study (including the used "simons's two stage design").
Result *res = study->getSolutionStrategy();
ui->l_pt1->hide();
ui->l_pt0->hide();
ui->l_responses_ep2->hide();
ts << "<b>r/n</b>: " << res->r << "/" << res->n;
ui->l_r->setText(s);
s.clear();
ts << "<b>r1/n1</b>: " << res->r1 << "/"<< res->n1;
ui->l_r1->setText(s);
s.clear();
ts << "<b>p0</b>: " << res->p0;
ui->l_p0->setText(s);
s.clear();
ts << "<b>p1</b>: " << res->p1;
ui->l_p1->setText(s);
s.clear();
ts << "<b>EN(p0)</b>: " << res->enP0;
ui->l_enp0->setText(s);
s.clear();
ts << "<b>PET(p0)</b>: " << res->petP0;
ui->l_petp0->setText(s);
s.clear();
ts << "<b>Alpha</b>: " << res->alpha;
ui->l_alpha->setText(s);
s.clear();
ts << "<b>Beta</b>: " << res->beta;
ui->l_beta->setText(s);
s.clear();
if(res->admissible)
{
ts << "<b>Admissible</b>: True";
ui->l_admiss->setText(s);
s.clear();
ts << "<b>Admissible-range</b>: " << res->admissibleStart << " <-> " << res->admissibleStop;
ui->l_admissrange->setText(s);
s.clear();
ts << "<b>Solution typ</b>: " << *(res->name);
ui->l_solname->setText(s);
s.clear();
}
else
{
// Hide gui elements which are unnecessary for the current study ( /are not used by the current study).
ui->l_admiss->hide();
ui->l_admissrange->hide();
ui->l_solname->hide();
}
ts << "<b>Enrolled patients</b>: " << study->getEnrolledPatients()->size();
ui->l_enrolledPats->setText(s);
s.clear();
ts << "<b>Responses</b>: " << study->getNumOfResponses();
ui->l_responses->setText(s);
s.clear();
if(simon == NULL)
{
simon = new R_simondesign();
simon->loadPackage();
}
ts << "<b>Conditional power</b>: " << simon->getConditionalPower(study->getNumOfResponses(), study->getEnrolledPatients()->size(), res->r1, res->n1, res->r, res->n, res->p1);
ui->l_cp->setText(s);
s.clear();
if(res->useCurtailment)
{
ts << "<b>Cut</b>: " << res->cut <<"%";
ui->l_cut->setText(s);
s.clear();
}
else
{
// Hide gui elements which are unnecessary for the current study ( /are not used by the current study).
ui->gB_Curtailment->hide();
ui->l_cut->hide();
}
}
else
{
// Display all available informations about the study (including the used "subset design").
Sub1_result *res = study->getSolutionStrategy_Sub1();
ui->l_pt1->show();
ui->l_pt0->show();
ui->l_responses_ep2->show();
ts << "<b>r,s/n</b>: " << res->getR() << "," << res->getS() << "/" << res->getN();
ui->l_r->setText(s);
s.clear();
ts << "<b>r1/n1</b>: " << res->getR1() << "/"<< res->getN1();
ui->l_r1->setText(s);
s.clear();
ts << "<b>pc0</b>: " << res->getPc0();
ui->l_p0->setText(s);
s.clear();
ts << "<b>pt0</b>: " << res->getPt0();
ui->l_pt0->setText(s);
s.clear();
ts << "<b>p1</b>: " << res->getPc1();
ui->l_p1->setText(s);
s.clear();
ts << "<b>pt1</b>: " << res->getPt1();
ui->l_pt1->setText(s);
s.clear();
ts << "<b>EN(p0)</b>: " << res->getEnP0();
ui->l_enp0->setText(s);
s.clear();
ts << "<b>PET(p0)</b>: " << res->getPetP0();
ui->l_petp0->setText(s);
s.clear();
ts << "<b>Alpha</b>: " << res->getAlpha();
ui->l_alpha->setText(s);
s.clear();
ts << "<b>Beta</b>: " << res->getBeta();
ui->l_beta->setText(s);
s.clear();
if(res->getAdmissible())
{
ts << "<b>Admissible</b>: True";
ui->l_admiss->setText(s);
s.clear();
ts << "<b>Admissible-range</b>: " << res->getAdmissibleStart() << " <-> " << res->getAdmissibleStop();
ui->l_admissrange->setText(s);
s.clear();
ts << "<b>Solution typ</b>: " << *(res->getName());
ui->l_solname->setText(s);
s.clear();
}
else
{
// Hide gui elements which are unnecessary for the current study ( /are not used by the current study).
ui->l_admiss->hide();
ui->l_admissrange->hide();
ui->l_solname->hide();
}
ts << "<b>Enrolled patients</b>: " << study->getEnrolledPatients()->size();
ui->l_enrolledPats->setText(s);
s.clear();
ts << "<b>Responses endpoint one</b>: " << study->getNumOfResponses();
ui->l_responses->setText(s);
s.clear();
ts << "<b>Responses endpoint two</b>: " << study->getNumOfResponses_ep2();
ui->l_responses_ep2->setText(s);
s.clear();
if(sub1 == NULL)
{
sub1 = new R_Sub1Design();
sub1->loadPackage();
}
ts << "<b>Conditional power</b>: " << sub1->get_conditionalPower(study->getNumOfResponses(), study->getNumOfResponses_ep2() ,study->getEnrolledPatients()->size(), res->getR1(), res->getN1(), res->getR(), res->getS(), res->getN(), res->getPc1(), res->getPt1());
ui->l_cp->setText(s);
s.clear();
if(res->getUseCurtailment())
{
ts << "<b>Cut</b>: " << res->getCut() <<"%";
ui->l_cut->setText(s);
s.clear();
}
else
{
// Hide gui elements which are unnecessary for the current study ( /are not used by the current study).
ui->gB_Curtailment->hide();
ui->l_cut->hide();
}
}
}
void StudyProgressPage::on_pB_AddPatient_clicked()
{
// Adding a new patient cn result in different consequences for the current study.
// 1. The study continues without any changes.
// 2. A stopping rule gets violated and the study has to be stopped for futility.
// 3. "n1" patients are enrolled and the interim analysis has to be performed.
// 4. If currently the interim analysis is performed adding a new patients stops the interim analysis.
// Only add new patients if the study is not stopped.
if(!(this->currentStudy->getStopped()))
{
Study::Patient p;
p.patID = ui->lE_patID->text();
if(currentStudy->getIsSimondesign())
{
p.response = ui->rb_response->isChecked() ? true : false;
}
else
{
p.response = ui->cB_ep1->isChecked() ? true : false;
p.response_ep2 = ui->cB_ep2->isChecked() ? true : false;
ui->cB_ep2->setChecked(false);
ui->cB_ep1->setChecked(false);
}
ui->rb_response->setCheckable(false);
ui->rb_noResponse->setCheckable(false);
ui->rb_response->setCheckable(true);
ui->rb_noResponse->setCheckable(true);
bool prossed = true;
// If currently the interim analysis is performed, the user gets informed (through a message box)
// about the fact that adding a new patients will stop the interim analysis and the second
// enrollment phase of the study starts.
if(currentStudy->getIsSimondesign())
{
if((currentStudy->getSolutionStrategy()->n1 == (int)(currentStudy->getEnrolledPatients()->size()))
&& (currentStudy->getSolutionStrategy()->useFlexible))
{
// If the flexible extension is used it will be impossible to alter the sample size of
// the second phase of the study if the interim analysis is stopped.
if(currentStudy->getSolutionStrategy()->useFlexible)
{
QMessageBox msgBox;
msgBox.setInformativeText("Add patient?");
msgBox.setText("If you add new patients the interim analysis is over \nand you will not be able to make any changes regarding to the flexible extendition. \nAdd the patient?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setIcon(QMessageBox::Information);
int ret = msgBox.exec();
if( ret != QMessageBox::Yes)
prossed = false;
else
{
ui->gB_flex->hide();
}
}
else
{
QMessageBox msgBox;
msgBox.setInformativeText("Add patient?");
msgBox.setText("If you add new patients the interim analysis is over. \nAdd the patient?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setIcon(QMessageBox::Information);
int ret = msgBox.exec();
if( ret != QMessageBox::Yes)
prossed = false;
}
}
}
else
{
if(currentStudy->getSolutionStrategy_Sub1()->getN1() == (int)(currentStudy->getEnrolledPatients()->size()))
{
QMessageBox msgBox;
msgBox.setInformativeText("Add patient?");
msgBox.setText("If you add new patients the interim analysis is over. \nAdd the patient?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setIcon(QMessageBox::Information);
int ret = msgBox.exec();
if( ret != QMessageBox::Yes)
prossed = false;
}
}
if(prossed)
{
if(currentStudy->addPatient(p))
{
this->addPatientToTable(p);
this->updateDetails();
ui->pB_removePat->setEnabled(true);
ui->lE_patID->setText("");
// Check if the study has to be stopped for futility (if stochastic curtailment is used).
if(currentStudy->getIsSimondesign())
{
if(currentStudy->stopForFutility() && currentStudy->getSolutionStrategy()->useCurtailment)
{
QMessageBox msgBox;
msgBox.setText("Study can be stopped for futility regarding to the stopping rules.");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
this->currentStudy->setStopped(true);
}
}
else
{
if(currentStudy->stopForFutility() && currentStudy->getSolutionStrategy_Sub1()->getUseCurtailment())
{
QMessageBox msgBox;
msgBox.setText("Study can be stopped for futility regarding to the stopping rules.");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
this->currentStudy->setStopped(true);
}
}
if(currentStudy->getIsSimondesign())
{
if((size_t)(currentStudy->getSolutionStrategy()->n1) == currentStudy->getEnrolledPatients()->size())
{
// Check if "n1" patients are enrolled. (If there are in fact "n1" patients are enrolled the interim analysis is performed.)
if(currentStudy->getNumOfResponses() > currentStudy->getSolutionStrategy()->r1)
{
// If the felxible extension is used the sample size of the secondphase of the study ("n2") can be altered.
if(currentStudy->getSolutionStrategy()->useFlexible)
{
QMessageBox msgBox;
msgBox.setText("You have reached the interim analysis. \nYou are using the flexible extension so you may now change the number of patients to be recruited.");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
Result *res = currentStudy->getSolutionStrategy();
ui->sB_flex_n->setValue(res->n);
ui->dsb_flex_cp->setValue(simon->getCP_flex(res->n - res->n1, res, currentStudy->getNumOfResponses(), currentStudy->getAlphaNominal()));
ui->tabWidget->setCurrentIndex(0);
ui->gB_flex->show();
ui->gB_flex->setFocus();
}
else
{
QMessageBox msgBox;
msgBox.setText("You have reached the interim analysis. ");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
ui->tabWidget->setCurrentIndex(0);
}
}
else // There are not enough responses among the "n1" enrolled patients to procceed with the second phase of the study.
{
QMessageBox msgBox;
msgBox.setText("You have reached the interim analysis. \nAccording to the chosen study design, there are not enough responses observed to procceed to the next stage of the study. \nThe study is to be stopped with acceptance of the null hypothesis.");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
this->currentStudy->setStopped(true);
}
}
else if((size_t)(currentStudy->getSolutionStrategy()->n) <= currentStudy->getEnrolledPatients()->size())
{
// There are "n" patients enrolled in total. Therefore the study is finished and the "studyFinished" is emited.
this->currentStudy->setFinished(true);
emit studyFinished(true);
}
}
else
{
if((size_t)(currentStudy->getSolutionStrategy_Sub1()->getN1()) == currentStudy->getEnrolledPatients()->size())
{
// Check if "n1" patients are enrolled. (If there are in fact "n1" patients are enrolled the interim analysis is performed.)
if(currentStudy->getNumOfResponses() > currentStudy->getSolutionStrategy_Sub1()->getR1())
{
QMessageBox msgBox;
msgBox.setText("You have reached the interim analysis. ");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
ui->tabWidget->setCurrentIndex(0);
}
else // There are not enough responses among the "n1" enrolled patients to procceed with the second phase of the study.
{
QMessageBox msgBox;
msgBox.setText("You have reached the interim analysis. \nAccording to the chosen study design, there are not enough responses observed to procceed to the next stage of the study. \nThe study is to be stopped with acceptance of the null hypothesis.");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
this->currentStudy->setStopped(true);
}
}
else if((size_t)(currentStudy->getSolutionStrategy_Sub1()->getN()) <= currentStudy->getEnrolledPatients()->size())
{
// There are "n" patients enrolled in total. Therefore the study is finished and the "studyFinished" is emited.
this->currentStudy->setFinished(true);
emit studyFinished(true);
}
}
}
else
{
QMessageBox msgBox;
msgBox.setText("Patient already enrolled.");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
}
}
}
else // Study is stopped.
{
QMessageBox msgBox;
msgBox.setText("Study was stopped. It is impossible to add further patients.");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
}
ui->gB_response->repaint();
}
void StudyProgressPage::addPatientToTable(Study::Patient p)
{
QTableWidgetItem *item;
ui->t_EnrolledPatients->setRowCount(ui->t_EnrolledPatients->rowCount() +1);
item = new QTableWidgetItem(p.patID);
ui->t_EnrolledPatients->setItem(ui->t_EnrolledPatients->rowCount() -1, 0, item);
if(p.response)
item = new QTableWidgetItem("Yes");
else
item = new QTableWidgetItem("No");
ui->t_EnrolledPatients->setItem(ui->t_EnrolledPatients->rowCount() -1, 1, item);
if(!(currentStudy->getIsSimondesign()))
{
//Display second endpoint.
if(p.response_ep2)
item = new QTableWidgetItem("Yes");
else
item = new QTableWidgetItem("No");
ui->t_EnrolledPatients->setItem(ui->t_EnrolledPatients->rowCount() -1, 2, item);
}
ui->pB_removePat->setEnabled(true);
}
void StudyProgressPage::updateDetails()
{
QString s;
QTextStream ts(&s, QIODevice::ReadWrite);
ts.setRealNumberPrecision(2);
ts << "<b>Enrolled Patients</b>: " << currentStudy->getEnrolledPatients()->size();
ui->l_enrolledPats->setText(s);
s.clear();
if(currentStudy->getIsSimondesign())
{
Result *res = currentStudy->getSolutionStrategy();
ts << "<b>Responses</b>: " << currentStudy->getNumOfResponses();
ui->l_responses->setText(s);
s.clear();
if(simon == NULL)
{
simon = new R_simondesign();
simon->loadPackage();
}
ts << "<b>Conditional Power</b>: " << simon->getConditionalPower(currentStudy->getNumOfResponses(), currentStudy->getEnrolledPatients()->size(), res->r1, res->n1, res->r, res->n, res->p1);
ui->l_cp->setText(s);
s.clear();
}
else
{
Sub1_result *res = currentStudy->getSolutionStrategy_Sub1();
ts << "<b>Responses endpoint one</b>: " << currentStudy->getNumOfResponses();
ui->l_responses->setText(s);
s.clear();
ts << "<b>Responses endpoint two</b>: " << currentStudy->getNumOfResponses_ep2();
ui->l_responses_ep2->setText(s);
s.clear();
if(sub1 == NULL)
{
sub1 = new R_Sub1Design();
sub1->loadPackage();
}
ts << "<b>Conditional power</b>: " << sub1->get_conditionalPower(currentStudy->getNumOfResponses(), currentStudy->getNumOfResponses_ep2()
,currentStudy->getEnrolledPatients()->size(), res->getR1(), res->getN1(), res->getR(), res->getS(), res->getN(), res->getPc1(), res->getPt1());
ui->l_cp->setText(s);
s.clear();
}
}
void StudyProgressPage::on_lE_patID_textChanged(const QString &arg1)
{
// Only enable the "AddPatient"-button if a patient ID is entered.
ui->pB_AddPatient->setEnabled(!(ui->lE_patID->text().isEmpty())
&& (ui->rb_noResponse->isChecked() || ui->rb_response->isChecked()));
}
void StudyProgressPage::on_sB_flex_n_valueChanged(int arg1)
{
if(currentStudy->getIsSimondesign())
{
if(!flex_cp_changed && !flex_n_changed)
{
flex_n_changed = true;
Result *res = currentStudy->getSolutionStrategy();
ui->dsb_flex_cp->setValue(simon->getCP_flex(arg1 - res->n1, res, currentStudy->getNumOfResponses(), currentStudy->getAlphaNominal()));
std::map<int, double> *flexValues = NULL;
std::map<int, double>::iterator it;
switch(res->flexSol)
{
case Result::Proportional:
flexValues = res->flexibleAdaptionProp;
break;
case Result::Equal:
flexValues = res->flexibleAdaptionEqua;
break;
case Result::ToOne:
flexValues = res->flexibleAdaptionToOne;
break;
case Result::None:
flexValues = res->flexibleAdaptionNone;
break;
default:
break;
}
it = flexValues->find(currentStudy->getNumOfResponses());
double ce = it->second;
int r2 = 0;
r2 = simon->getR2forFlex(ce, res->p0, arg1 - res->n1);
QString new_r;
QTextStream ts(&new_r, QIODevice::ReadWrite);
tmp_r_flex = res->r1 + r2;
ts << "<b>R</b> flexieble: " << (tmp_r_flex);
ui->l_r_flex->setText(new_r);
flex_n_changed =false;
}
}
}
void StudyProgressPage::on_dsb_flex_cp_valueChanged(double arg1)
{
if(currentStudy->getIsSimondesign())
{
if(!flex_n_changed && !flex_cp_changed)
{
flex_cp_changed = true;
Result *res = currentStudy->getSolutionStrategy();
int new_n = simon->getN(arg1,res, currentStudy->getNumOfResponses(), currentStudy->getAlphaNominal());
ui->sB_flex_n->setValue(new_n);
std::map<int, double> *flexValues = NULL;
std::map<int, double>::iterator it;
switch(res->flexSol)
{
case Result::Proportional:
flexValues = res->flexibleAdaptionProp;
break;
case Result::Equal:
flexValues = res->flexibleAdaptionEqua;
break;
case Result::ToOne:
flexValues = res->flexibleAdaptionToOne;
break;
case Result::None:
flexValues = res->flexibleAdaptionNone;
break;
default:
break;
}
it = flexValues->find(currentStudy->getNumOfResponses());
double ce = it->second;
int r2 = 0;
r2 = simon->getR2forFlex(ce, res->p0, new_n - res->n1);
QString new_r;
QTextStream ts(&new_r, QIODevice::ReadWrite);
tmp_r_flex = res->r1 + r2;
ts << "<b>R flexieble</b>: " << (tmp_r_flex);
ui->l_r_flex->setText(new_r);
flex_cp_changed = false;
}
}
}
void StudyProgressPage::on_pB_set_Flex_values_clicked()
{
// Save changes to the study design (based on the flexible extension).
if(currentStudy->getIsSimondesign())
{
this->currentStudy->getSolutionStrategy()->n = ui->sB_flex_n->value();
this->currentStudy->getSolutionStrategy()->r = tmp_r_flex;
ui->w_Rplot->setSimonStoppingRulesSet(false);
this->showStudyDetails(this->currentStudy);
}
}
void StudyProgressPage::on_rb_response_clicked(bool checked)
{
if(currentStudy->getIsSimondesign())
ui->pB_AddPatient->setEnabled( !(ui->lE_patID->text().isEmpty())
&& (ui->rb_noResponse->isChecked() || ui->rb_response->isChecked()));
else
{
ui->pB_AddPatient->setEnabled(!(ui->lE_patID->text().isEmpty())
&& (ui->rb_noResponse->isChecked() || (ui->rb_response->isChecked() && ui->cB_ep2->isChecked() )));
}
}
void StudyProgressPage::on_rb_noResponse_clicked(bool checked)
{
if(currentStudy->getIsSimondesign())
ui->pB_AddPatient->setEnabled( !(ui->lE_patID->text().isEmpty())
&& (ui->rb_noResponse->isChecked() || ui->rb_response->isChecked()));
else
{
ui->pB_AddPatient->setEnabled(!(ui->lE_patID->text().isEmpty())
&& (ui->rb_noResponse->isChecked() || (ui->rb_response->isChecked() && ui->cB_ep2->isChecked() )));
}
}
void StudyProgressPage::on_pB_removePat_clicked()
{
if(currentStudy->removePatient())
{
ui->t_EnrolledPatients->removeRow(ui->t_EnrolledPatients->rowCount()-1);
if(ui->t_EnrolledPatients->rowCount() <= 0)
ui->pB_removePat->setEnabled(false);
this->updateDetails();
currentStudy->setStopped(false);
}
else
{
QMessageBox msgBox;
msgBox.setText("No patient currently enrolled.");
msgBox.setIcon(QMessageBox::Information);
msgBox.exec();
}
}
void StudyProgressPage::on_cB_ep2_clicked(bool checked)
{
if(!checked)
ui->cB_ep1->setChecked(false);
ui->pB_AddPatient->setEnabled(!(ui->lE_patID->text().isEmpty())
&& (ui->rb_noResponse->isChecked() || (ui->rb_response->isChecked() && ui->cB_ep2->isChecked() )));
}
void StudyProgressPage::on_cB_ep1_clicked(bool checked)
{
if(checked)
ui->cB_ep2->setChecked(true);
ui->pB_AddPatient->setEnabled(!(ui->lE_patID->text().isEmpty())
&& (ui->rb_noResponse->isChecked() || (ui->rb_response->isChecked() && ui->cB_ep2->isChecked() )));
}