Skip to content

Commit 32f2503

Browse files
committed
Ceciles review comments
1 parent 06b51e4 commit 32f2503

File tree

7 files changed

+106
-12
lines changed

7 files changed

+106
-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: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,26 @@ 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(new UserCenterMatchOrNullOrAnyPermission(
139+
$this->allSitePermissionNames(),
140+
));
139141
default:
140142
return (new Provisioner())
141143
->filter(new UserProjectMatchOrNull);
142144
}
143145
}
144146

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

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

0 commit comments

Comments
 (0)