Skip to content

Commit df40c92

Browse files
committed
Added a Trial summary section to the Patient summary screen
1 parent 3a61f1e commit df40c92

File tree

5 files changed

+131
-0
lines changed

5 files changed

+131
-0
lines changed

components/OETrial_API.php

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
class OETrial_API extends BaseAPI
4+
{
5+
/**
6+
* @param $type
7+
* @param $partial
8+
*
9+
* @return bool|string
10+
*/
11+
public function findViewFile($type, $partial)
12+
{
13+
$viewFile = Yii::getPathOfAlias('OETrial.views.' . $type . '.' . $partial) . '.php';
14+
15+
if (file_exists($viewFile)) {
16+
return $viewFile;
17+
}
18+
19+
return false;
20+
}
21+
}

config/common.php

+7
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,12 @@
1010
'restricted' => array('TaskAdministerTrials'),
1111
),
1212
),
13+
'module_partials' => array(
14+
'patient_summary_column1' => array(
15+
'OETrial' => array(
16+
'_patient_trials',
17+
),
18+
),
19+
),
1320
),
1421
);

models/Trial.php

+25
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,14 @@ class Trial extends BaseActiveRecordVersioned
4444
*/
4545
const STATUS_CANCELLED = 3;
4646

47+
/**
48+
* The trial type for non-Intervention trial (meaning there are no restrictions on assigning patients to this the trial)
49+
*/
4750
const TRIAL_TYPE_NON_INTERVENTION = 0;
4851

52+
/**
53+
* The trial type for Intervention trials (meaning a patient can only be assigned to one ongoing Intervention trial at a time)
54+
*/
4955
const TRIAL_TYPE_INTERVENTION = 1;
5056

5157
/**
@@ -133,6 +139,25 @@ public static function getTrialTypeOptions()
133139
);
134140
}
135141

142+
/**
143+
* Returns the trial type as a string
144+
*
145+
* @return string The trial type
146+
*/
147+
public function getTypeString()
148+
{
149+
return self::getTrialTypeOptions()[$this->trial_type];
150+
}
151+
152+
/**
153+
* Returns the date this trial was created as a string
154+
*
155+
* @return string The created date
156+
*/
157+
public function getCreatedDateForDisplay()
158+
{
159+
return Helper::formatFuzzyDate($this->created_date);
160+
}
136161

137162
/**
138163
* @return array relational rules.

models/TrialPatient.php

+23
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,29 @@ public static function getAllowedStatusRange()
5454
);
5555
}
5656

57+
58+
/**
59+
* @return array
60+
*/
61+
public static function getStatusOptions()
62+
{
63+
return array(
64+
self::STATUS_SHORTLISTED => 'Shortlisted',
65+
self::STATUS_ACCEPTED => 'Accepted',
66+
self::STATUS_REJECTED => 'Rejected',
67+
);
68+
}
69+
70+
/**
71+
* Returns the status as a displayable string
72+
*
73+
* @return string The status string
74+
*/
75+
public function getStatusForDisplay()
76+
{
77+
return self::getStatusOptions()[$this->patient_status];
78+
}
79+
5780
/**
5881
* @return string the associated database table name
5982
*/
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/* @var $this PatientController */
3+
?>
4+
<section class="box patient-info js-toggle-container">
5+
<h3 class="box-title">Trials:</h3>
6+
<a href="#" class="toggle-trigger toggle-hide js-toggle">
7+
<span class="icon-showhide">
8+
Show/hide this section
9+
</span>
10+
</a>
11+
<a href="#" class="toggle-trigger toggle-hide js-toggle">
12+
<span class="icon-showhide">
13+
Show/hide this section
14+
</span>
15+
</a>
16+
</header>
17+
18+
<div class="js-toggle-body">
19+
20+
<table class="plain patient-data">
21+
<thead>
22+
<tr>
23+
<th>Trial</th>
24+
<th>Control Status</th>
25+
<th>Trial Status</th>
26+
<th>Trial Type</th>
27+
<th>Date Started</th>
28+
<th>Date Ended</th>
29+
</tr>
30+
</thead>
31+
<tbody>
32+
<?php foreach ($this->patient->trials as $trialPatient): ?>
33+
<tr>
34+
<td><?php
35+
if (Trial::checkTrialAccess(Yii::app()->user, $trialPatient->trial_id,
36+
UserTrialPermission::PERMISSION_VIEW)
37+
) {
38+
echo Chtml::link(CHtml::encode($trialPatient->trial->name),
39+
Yii::app()->controller->createUrl('/OETrial/trial/view', array('id' => $trialPatient->trial_id)));
40+
} else {
41+
echo CHtml::encode($trialPatient->trial->name);
42+
}
43+
?>
44+
</td>
45+
<td><?php echo 'TODO'; //TODO; ?></td>
46+
<td><?php echo $trialPatient->getStatusForDisplay(); ?></td>
47+
<td><?php echo $trialPatient->trial->getTypeString(); ?></td>
48+
<td><?php echo $trialPatient->trial->getCreatedDateForDisplay(); ?></td>
49+
<td><?php echo 'TODO'; //TODO; ?></td>
50+
</tr>
51+
<?php endforeach; ?>
52+
</tbody>
53+
</table>
54+
</div>
55+
</section>

0 commit comments

Comments
 (0)