Skip to content

Commit 09151b8

Browse files
committed
Ceciles review comments
1 parent 06b51e4 commit 09151b8

File tree

7 files changed

+114
-12
lines changed

7 files changed

+114
-12
lines changed

modules/mri_violations/jsx/protocolModal.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ function ProtocolViolationModal(props) {
5353

5454
let violations = [];
5555

56+
let title = 'Violations for SeriesUID ' + props.SeriesUID;
5657
for (const violation of data) {
58+
title = 'Violations for ' + violation[4];
5759
violations.push(
5860
<div key={violation[4]}>
5961
<dl style={{display: 'flex', width: '100%',
@@ -76,13 +78,21 @@ function ProtocolViolationModal(props) {
7678
<dd>{violation[3]}</dd>
7779
</div>
7880
<div>
79-
<dt>Minc Location</dt>
81+
<dt>Image Location</dt>
8082
<dd>{violation[4]}</dd>
8183
</div>
8284
<div>
8385
<dt>Patient Name</dt>
8486
<dd>{violation[5]}</dd>
8587
</div>
88+
<div>
89+
<dt>Series UID</dt>
90+
<dd>{props.SeriesUID}</dd>
91+
</div>
92+
<div>
93+
<dt>Echo Time</dt>
94+
<dd>{violation[8]}</dd>
95+
</div>
8696
</dl>
8797

8898
<table className="table table-hover table-primary table-bordered">
@@ -214,15 +224,16 @@ function ProtocolViolationModal(props) {
214224
}
215225
}
216226
pushgroup(curgroupname, curgroup);
227+
console.log(props);
217228

218229
return <Modal onClose={props.onClose}
219230
show={true}
220231
width="90%"
221-
title={'Violations for SeriesUID ' + props.SeriesUID}>
232+
title={title}>
233+
<h2>Image Protocol</h2>
234+
{violations}
222235
<h2>Study Protocols</h2>
223236
{protocolgroups}
224-
<h2>Violations</h2>
225-
{violations}
226237
</Modal>;
227238
}
228239

modules/mri_violations/jsx/resolvedViolations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function resolvedFilters(fieldoptions) {
5454
},
5555
},
5656
{
57-
label: 'Minc File', show: true, filter: {
57+
label: 'Image File', show: true, filter: {
5858
name: 'mincFile',
5959
type: 'text',
6060
},

modules/mri_violations/jsx/unresolvedViolations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function unresolvedFilters(fieldoptions) {
4646
},
4747
},
4848
{
49-
label: 'Minc File', show: true, filter: {
49+
label: 'Image File', show: true, filter: {
5050
name: 'mincFile',
5151
type: 'text',
5252
},

modules/mri_violations/php/mri_violations.class.inc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,28 @@ class Mri_Violations extends \DataFrameworkMenu
135135
return (new ProtocolViolationProvisioner($this->seriesUID));
136136
case 'protocolcheck':
137137
return (new ProtocolCheckViolationProvisioner($this->seriesUID))
138-
->filter(new UserCenterMatchOrNull);
138+
->filter(
139+
new UserCenterMatchOrNullOrAnyPermission(
140+
$this->allSitePermissionNames(),
141+
)
142+
);
139143
default:
140144
return (new Provisioner())
141145
->filter(new UserProjectMatchOrNull);
142146
}
143147
}
144148

149+
/**
150+
* Overload filters to allow posssibility of a null CenterID. Filters are
151+
* added in getBaseDataProvisioner depending on the type
152+
*
153+
* @return \LORIS\Data\Provisioner
154+
*/
155+
public function getDataProvisionerWithFilters() : \LORIS\Data\Provisioner
156+
{
157+
return $this->getBaseDataProvisioner();
158+
}
159+
145160
/**
146161
* Include additional JS files
147162
*

modules/mri_violations/php/resolved_violations.class.inc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,21 @@ class Resolved_Violations extends \DataFrameworkMenu
8484
return (new ResolvedViolationsProvisioner())
8585
->filter(new UserProjectMatchOrNull);
8686
}
87+
88+
/**
89+
* Overload filters to allow posssibility of a null CenterID
90+
*
91+
* @return \LORIS\Data\Provisioner
92+
*/
93+
public function getDataProvisionerWithFilters() : \LORIS\Data\Provisioner
94+
{
95+
$provisioner = $this->getBaseDataProvisioner()->filter(
96+
new UserCenterMatchOrNullOrAnyPermission(
97+
$this->allSitePermissionNames()
98+
)
99+
);
100+
101+
return $provisioner;
102+
}
87103
}
88104

modules/mri_violations/php/resolvedviolation.class.inc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ namespace LORIS\mri_violations;
77
*
88
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
99
*/
10-
class ResolvedViolation implements \LORIS\Data\DataInstance,
11-
\LORIS\StudyEntities\SiteHaver
10+
class ResolvedViolation implements \LORIS\Data\DataInstance
1211
{
1312
protected $DBRow;
1413
protected $CenterID;
@@ -37,11 +36,14 @@ class ResolvedViolation implements \LORIS\Data\DataInstance,
3736
* Returns the CenterID for this instance, for filters such as
3837
* \LORIS\Data\Filters\UserSiteMatch to match against.
3938
*
40-
* @return \CenterID
39+
* @return ?\CenterID
4140
*/
42-
public function getCenterID(): \CenterID
41+
public function getCenterID(): ?\CenterID
4342
{
44-
return new \CenterID($this->DBRow['CenterId']);
43+
if ($this->DBRow['Site'] === null) {
44+
return null;
45+
}
46+
return new \CenterID($this->DBRow['Site']);
4547
}
4648

4749
/**
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
namespace LORIS\mri_violations;
3+
4+
/**
5+
* UserCenterMatchOrNull filters out data for any resource which is not
6+
* part of one of the user's centers unless the user has one of the
7+
* given permissions. If the resource has no CenterID defined, it is not
8+
* excluded from the results.
9+
*
10+
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
11+
*/
12+
class UserCenterMatchOrNullOrAnyPermission implements \LORIS\Data\Filter
13+
{
14+
/**
15+
* {@constructor}
16+
*
17+
* @param string[] $permissions - List of possible permissions
18+
*/
19+
public function __construct(protected array $permissions)
20+
{
21+
}
22+
23+
/**
24+
* Implements the \LORIS\Data\Filter interface
25+
*
26+
* @param \User $user The user that the data is being
27+
* filtered for.
28+
* @param \LORIS\Data\DataInstance $resource The data being filtered.
29+
*
30+
* @return bool
31+
*/
32+
public function filter(\User $user, \Loris\Data\DataInstance $resource) : bool
33+
{
34+
// phan only understands method_exists on simple variables.
35+
// Assigning to a variable is the a workaround
36+
// for false positive 'getProjectID doesn't exist errors suggested
37+
// in https://github.com/phan/phan/issues/2628
38+
$res = $resource;
39+
'@phan-var object $res';
40+
41+
if ($user->hasAnyPermission($this->permissions)) {
42+
return true;
43+
}
44+
45+
if (method_exists($res, 'getCenterID')) {
46+
$resourceCenter = $res->getCenterID();
47+
if (!is_null($resourceCenter)) {
48+
return $user->hasCenter(
49+
new \CenterID(strval($resourceCenter))
50+
);
51+
}
52+
return true;
53+
}
54+
throw new \LorisException(
55+
"Can not implement filter on a resource type that has no centers."
56+
);
57+
}
58+
}

0 commit comments

Comments
 (0)