Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 18f8049

Browse files
committed
ENH: Refs #0924. Added progress indicator and registration status for dicom image registration; other minor changes.
1 parent 8a23fce commit 18f8049

File tree

17 files changed

+290
-43
lines changed

17 files changed

+290
-43
lines changed

modules/dicomserver/Notification.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function init()
3030
$this->addCallBack('CALLBACK_CORE_ITEM_VIEW_ACTIONMENU', 'getItemMenuLink');
3131
$this->addCallBack('CALLBACK_CORE_ITEM_VIEW_JS', 'getJs');
3232
$this->addCallBack('CALLBACK_CORE_GET_DASHBOARD', 'getDashboard');
33+
$this->addCallBack('CALLBACK_CORE_ITEM_VIEW_INFO', 'getItemInfo');
3334
}//end init
3435

3536
/** Get the link to place in the item action menu */
@@ -39,8 +40,8 @@ public function getItemMenuLink($params)
3940
return '<li id="dicomRegisterListItem" style="display: none;">'.
4041
'<a id="dicomRegisterAction" href="#">'.
4142
'<img alt="" src="'.$webroot.'/modules/'.
42-
$this->moduleName.'/public/images/dicom_icon.jpg" /> '.
43-
$this->t('Register Dicom Images').'</a></li>';
43+
$this->moduleName.'/public/images/dicom_register_icon.jpg" /> '.
44+
$this->t('Register for DICOM Query/Retrieve').'</a></li>';
4445
}
4546

4647
/** Get javascript for the item view that will specify the ajax call
@@ -61,4 +62,14 @@ public function getDashboard()
6162
return $return;
6263
}//end _getDasboard
6364

65+
/** Some html to be appended to the item view sidebar */
66+
public function getItemInfo($params)
67+
{
68+
return '<div class="sideElement" id="sideElementDicomRegistration" style="display: none;">
69+
<h1>DICOM</h1>
70+
<span>This item was registered for DICOM Query/Retrieve services.</span><br/>
71+
<span>Note: if the latest revision is updated, registration action needs to be rerun.</span>
72+
</div>';
73+
}
74+
6475
} //end class

modules/dicomserver/controllers/components/ApiComponent.php

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function start($args)
199199
* Check DICOM server status
200200
* @param storescp_cmd (Optional) The command to run storescp
201201
* @param dcmqrscp_cmd (Optional) The command to run dcmqrscp
202-
* @return
202+
* @return array('status' => string)
203203
*/
204204
function status($args)
205205
{
@@ -353,9 +353,9 @@ function stop($args)
353353
}
354354

355355
/**
356-
* Register dicom image files from a revision
356+
* Register DICOM images from a revision to let them be available for DICOM query/retrieve services.
357357
* @param item the id of the item to be registered
358-
* @return the id of the revision
358+
* @return the revision dao (latest revision of the item) that was registered
359359
*/
360360
function register($args)
361361
{
@@ -377,7 +377,39 @@ function register($args)
377377

378378
$dicomComponent = MidasLoader::loadComponent('Server', 'dicomserver');
379379
$dicomComponent->register($revisionDao);
380-
return json_encode($revisionDao);
380+
return $revisionDao->toArray();
381+
}
382+
383+
/**
384+
* Check if the DICOM images in the item was registered and can be accessed by DICOM query/retrieve services.
385+
* @param item the id of the item to be checked
386+
* @return array('status' => bool)
387+
*/
388+
function registrationStatus($args)
389+
{
390+
$this->_validateParams($args, array('item'));
391+
392+
$itemModel = MidasLoader::loadModel("Item");
393+
$authComponent = MidasLoader::loadComponent('Authentication', 'api');
394+
$itemDao = $itemModel->load($args['item']);
395+
$userDao = $authComponent->getUser($args,
396+
Zend_Registry::get('userSession')->Dao);
397+
if(!$itemModel->policyCheck($itemDao, $userDao, MIDAS_POLICY_WRITE))
398+
{
399+
throw new Exception('You didn\'t log in or you don\'t have the write '.
400+
'permission for the given item.', MIDAS_INVALID_POLICY);
401+
}
402+
403+
$modelLoad = new MIDAS_ModelLoader();
404+
$registrationModel = $modelLoad->loadModel('Registration', 'dicomserver');
405+
if(!$registrationModel->checkByItemId($args['item']))
406+
{
407+
return array('status' => false);
408+
}
409+
else
410+
{
411+
return array('status' => true);
412+
}
381413
}
382414
}
383415

modules/dicomserver/controllers/components/ServerComponent.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,12 @@ public function register($revision)
140140
$command = $modulesConfig['dicomserver']->dcmqridx;
141141
$command = str_replace("'", '',$command);
142142
$command_params = array();
143-
$aeStorage = $modulesConfig['dicomserver']->receptiondir . PACS_DIR;
143+
$reciptionDir = $modulesConfig['dicomserver']->receptiondir;
144+
if(!is_writable($reciptionDir))
145+
{
146+
throw new Zend_Exception("Please configure Dicom Server module correctly. Its reception directory is NOT writable!", MIDAS_INVALID_POLICY);
147+
}
148+
$aeStorage = $reciptionDir . PACS_DIR;
144149
$aeStorage = str_replace("'", '', $aeStorage);
145150
$command_params[] = $aeStorage;
146151
foreach($bitstreams as $bitstream)
@@ -155,6 +160,14 @@ public function register($revision)
155160
throw new Zend_Exception(htmlspecialchars($exception_string, ENT_QUOTES), MIDAS_INVALID_POLICY);
156161
}
157162
}
163+
164+
$modelLoad = new MIDAS_ModelLoader();
165+
$registrationModel = $modelLoad->loadModel('Registration', 'dicomserver');
166+
$itemId = $revision->getItemId();
167+
if(!$registrationModel->checkByItemId($itemId))
168+
{
169+
$registrationModel->createRegistration($itemId);
170+
}
158171
}
159172

160173
} // end class
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE TABLE IF NOT EXISTS `dicomserver_registration` (
2+
`registration_id` bigint(20) NOT NULL AUTO_INCREMENT,
3+
`item_id` bigint(20) NOT NULL,
4+
PRIMARY KEY (`registration_id`)
5+
) DEFAULT CHARSET=utf8;
6+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CREATE TABLE dicomserver_registration (
2+
registration_id serial PRIMARY KEY,
3+
item_id bigint NOT NULL
4+
);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
5+
All rights reserved.
6+
More information http://www.kitware.com
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0.txt
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
=========================================================================*/
20+
21+
class Dicomserver_AppDao extends MIDAS_GlobalDao
22+
{
23+
public $moduleName='dicomserver';
24+
} //end class
25+
26+
?>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
5+
All rights reserved.
6+
More information http://www.kitware.com
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0.txt
13+
14+
Unless required by applicable law or agreed to in writing, software
15+
distributed under the License is distributed on an "AS IS" BASIS,
16+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
See the License for the specific language governing permissions and
18+
limitations under the License.
19+
=========================================================================*/
20+
21+
class Dicomserver_AppModel extends MIDASModel
22+
{
23+
public $moduleName = 'dicomserver';
24+
25+
}
26+
?>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
5+
69328 Lyon, FRANCE.
6+
7+
See Copyright.txt for details.
8+
This software is distributed WITHOUT ANY WARRANTY; without even
9+
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10+
PURPOSE. See the above copyright notices for more information.
11+
=========================================================================*/
12+
include_once BASE_PATH . '/modules/dicomserver/constant/module.php';
13+
/** RegistrationModel Base class */
14+
abstract class Dicomserver_RegistrationModelBase extends Dicomserver_AppModel {
15+
16+
/**
17+
* constructor
18+
*/
19+
public function __construct()
20+
{
21+
parent::__construct();
22+
$this->_name = 'dicomserver_registration';
23+
$this->_key = 'registration_id';
24+
$this->_daoName = 'RegistrationDao';
25+
26+
$this->_mainData = array(
27+
'registration_id' => array('type' => MIDAS_DATA),
28+
'item_id' => array('type' => MIDAS_DATA),
29+
'revision_id' => array('type' => MIDAS_DATA)
30+
);
31+
$this->initialize(); // required
32+
}
33+
34+
/** Check registration information by an itemId */
35+
abstract function checkByItemId($itemId);
36+
37+
/**
38+
* Register an item
39+
*
40+
* @param string $item_id
41+
* @return Dicomserver_RegistrationDao
42+
*/
43+
function createRegistration($item_id)
44+
{
45+
$registrationDao = MidasLoader::newDao('RegistrationDao', 'dicomserver');
46+
$registrationDao->setItemId($item_id);
47+
$this->save($registrationDao);
48+
return $registrationDao;
49+
}
50+
51+
52+
} // end class Dicomserver_RegistrationModelBase
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
5+
69328 Lyon, FRANCE.
6+
7+
See Copyright.txt for details.
8+
This software is distributed WITHOUT ANY WARRANTY; without even
9+
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10+
PURPOSE. See the above copyright notices for more information.
11+
=========================================================================*/
12+
/** Dicomserver_RegistrationDao */
13+
class Dicomserver_RegistrationDao extends AppDao {
14+
15+
public $_model = 'Registration';
16+
public $_module = 'dicomserver';
17+
18+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/*=========================================================================
3+
MIDAS Server
4+
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
5+
69328 Lyon, FRANCE.
6+
7+
See Copyright.txt for details.
8+
This software is distributed WITHOUT ANY WARRANTY; without even
9+
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10+
PURPOSE. See the above copyright notices for more information.
11+
=========================================================================*/
12+
require_once BASE_PATH . '/modules/dicomserver/models/base/RegistrationModelBase.php';
13+
14+
15+
/** Dicomserver_RegistrationModel */
16+
class Dicomserver_RegistrationModel extends Dicomserver_RegistrationModelBase {
17+
18+
/**
19+
* Returns registration by a itemId
20+
* @param type $itemId
21+
* @return type
22+
*/
23+
24+
function checkByItemId($itemId)
25+
{
26+
$row = $this->database->fetchRow($this->database->select()->where('item_id=?', $itemId));
27+
return $this->initDao('Registration', $row, 'dicomserver');
28+
}
29+
30+
}

0 commit comments

Comments
 (0)