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

Commit

Permalink
ENH: Refs #0924. Added progress indicator and registration status for…
Browse files Browse the repository at this point in the history
… dicom image registration; other minor changes.
  • Loading branch information
yuzhengZ committed Jan 28, 2013
1 parent 8a23fce commit 18f8049
Show file tree
Hide file tree
Showing 17 changed files with 290 additions and 43 deletions.
15 changes: 13 additions & 2 deletions modules/dicomserver/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function init()
$this->addCallBack('CALLBACK_CORE_ITEM_VIEW_ACTIONMENU', 'getItemMenuLink');
$this->addCallBack('CALLBACK_CORE_ITEM_VIEW_JS', 'getJs');
$this->addCallBack('CALLBACK_CORE_GET_DASHBOARD', 'getDashboard');
$this->addCallBack('CALLBACK_CORE_ITEM_VIEW_INFO', 'getItemInfo');
}//end init

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

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

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

} //end class
40 changes: 36 additions & 4 deletions modules/dicomserver/controllers/components/ApiComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function start($args)
* Check DICOM server status
* @param storescp_cmd (Optional) The command to run storescp
* @param dcmqrscp_cmd (Optional) The command to run dcmqrscp
* @return
* @return array('status' => string)
*/
function status($args)
{
Expand Down Expand Up @@ -353,9 +353,9 @@ function stop($args)
}

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

$dicomComponent = MidasLoader::loadComponent('Server', 'dicomserver');
$dicomComponent->register($revisionDao);
return json_encode($revisionDao);
return $revisionDao->toArray();
}

/**
* Check if the DICOM images in the item was registered and can be accessed by DICOM query/retrieve services.
* @param item the id of the item to be checked
* @return array('status' => bool)
*/
function registrationStatus($args)
{
$this->_validateParams($args, array('item'));

$itemModel = MidasLoader::loadModel("Item");
$authComponent = MidasLoader::loadComponent('Authentication', 'api');
$itemDao = $itemModel->load($args['item']);
$userDao = $authComponent->getUser($args,
Zend_Registry::get('userSession')->Dao);
if(!$itemModel->policyCheck($itemDao, $userDao, MIDAS_POLICY_WRITE))
{
throw new Exception('You didn\'t log in or you don\'t have the write '.
'permission for the given item.', MIDAS_INVALID_POLICY);
}

$modelLoad = new MIDAS_ModelLoader();
$registrationModel = $modelLoad->loadModel('Registration', 'dicomserver');
if(!$registrationModel->checkByItemId($args['item']))
{
return array('status' => false);
}
else
{
return array('status' => true);
}
}
}

Expand Down
15 changes: 14 additions & 1 deletion modules/dicomserver/controllers/components/ServerComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ public function register($revision)
$command = $modulesConfig['dicomserver']->dcmqridx;
$command = str_replace("'", '',$command);
$command_params = array();
$aeStorage = $modulesConfig['dicomserver']->receptiondir . PACS_DIR;
$reciptionDir = $modulesConfig['dicomserver']->receptiondir;
if(!is_writable($reciptionDir))
{
throw new Zend_Exception("Please configure Dicom Server module correctly. Its reception directory is NOT writable!", MIDAS_INVALID_POLICY);
}
$aeStorage = $reciptionDir . PACS_DIR;
$aeStorage = str_replace("'", '', $aeStorage);
$command_params[] = $aeStorage;
foreach($bitstreams as $bitstream)
Expand All @@ -155,6 +160,14 @@ public function register($revision)
throw new Zend_Exception(htmlspecialchars($exception_string, ENT_QUOTES), MIDAS_INVALID_POLICY);
}
}

$modelLoad = new MIDAS_ModelLoader();
$registrationModel = $modelLoad->loadModel('Registration', 'dicomserver');
$itemId = $revision->getItemId();
if(!$registrationModel->checkByItemId($itemId))
{
$registrationModel->createRegistration($itemId);
}
}

} // end class
6 changes: 6 additions & 0 deletions modules/dicomserver/database/mysql/1.0.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE TABLE IF NOT EXISTS `dicomserver_registration` (
`registration_id` bigint(20) NOT NULL AUTO_INCREMENT,
`item_id` bigint(20) NOT NULL,
PRIMARY KEY (`registration_id`)
) DEFAULT CHARSET=utf8;

4 changes: 4 additions & 0 deletions modules/dicomserver/database/pgsql/1.0.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE dicomserver_registration (
registration_id serial PRIMARY KEY,
item_id bigint NOT NULL
);
26 changes: 26 additions & 0 deletions modules/dicomserver/models/AppDao.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
All rights reserved.
More information http://www.kitware.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/

class Dicomserver_AppDao extends MIDAS_GlobalDao
{
public $moduleName='dicomserver';
} //end class

?>
26 changes: 26 additions & 0 deletions modules/dicomserver/models/AppModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 26 rue Louis Guérin. 69100 Villeurbanne, FRANCE
All rights reserved.
More information http://www.kitware.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/

class Dicomserver_AppModel extends MIDASModel
{
public $moduleName = 'dicomserver';

}
?>
52 changes: 52 additions & 0 deletions modules/dicomserver/models/base/RegistrationModelBase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
69328 Lyon, FRANCE.
See Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
include_once BASE_PATH . '/modules/dicomserver/constant/module.php';
/** RegistrationModel Base class */
abstract class Dicomserver_RegistrationModelBase extends Dicomserver_AppModel {

/**
* constructor
*/
public function __construct()
{
parent::__construct();
$this->_name = 'dicomserver_registration';
$this->_key = 'registration_id';
$this->_daoName = 'RegistrationDao';

$this->_mainData = array(
'registration_id' => array('type' => MIDAS_DATA),
'item_id' => array('type' => MIDAS_DATA),
'revision_id' => array('type' => MIDAS_DATA)
);
$this->initialize(); // required
}

/** Check registration information by an itemId */
abstract function checkByItemId($itemId);

/**
* Register an item
*
* @param string $item_id
* @return Dicomserver_RegistrationDao
*/
function createRegistration($item_id)
{
$registrationDao = MidasLoader::newDao('RegistrationDao', 'dicomserver');
$registrationDao->setItemId($item_id);
$this->save($registrationDao);
return $registrationDao;
}


} // end class Dicomserver_RegistrationModelBase
18 changes: 18 additions & 0 deletions modules/dicomserver/models/dao/RegistrationDao.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
69328 Lyon, FRANCE.
See Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
/** Dicomserver_RegistrationDao */
class Dicomserver_RegistrationDao extends AppDao {

public $_model = 'Registration';
public $_module = 'dicomserver';

}
30 changes: 30 additions & 0 deletions modules/dicomserver/models/pdo/RegistrationModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/*=========================================================================
MIDAS Server
Copyright (c) Kitware SAS. 20 rue de la Villette. All rights reserved.
69328 Lyon, FRANCE.
See Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
require_once BASE_PATH . '/modules/dicomserver/models/base/RegistrationModelBase.php';


/** Dicomserver_RegistrationModel */
class Dicomserver_RegistrationModel extends Dicomserver_RegistrationModelBase {

/**
* Returns registration by a itemId
* @param type $itemId
* @return type
*/

function checkByItemId($itemId)
{
$row = $this->database->fetchRow($this->database->select()->where('item_id=?', $itemId));
return $this->initDao('Registration', $row, 'dicomserver');
}

}
24 changes: 2 additions & 22 deletions modules/dicomserver/public/css/config/config.index.css
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
span#running_status{
span.running_status{
font-weight: bold;
color: #009900;
}

span#not_running_status{
font-weight: bold;
color: #C80000;
}

span#only_storescp_running_status{
font-weight: bold;
color: #C80000;
}

span#only_dcmqrscp_running_status{
font-weight: bold;
color: #C80000;
}

span#not_supported_status{
font-weight: bold;
color: #C80000;
}

textarea#apicall_failure_reason{
span.not_running_status, span.only_storescp_running_status, span.only_dcmqrscp_running_status, span.not_supported_status, textarea#apicall_failure_reason{
font-weight: bold;
color: #C80000;
}
Expand Down
Binary file removed modules/dicomserver/public/images/dicom_icon.jpg
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added modules/dicomserver/public/images/registering.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion modules/dicomserver/public/js/config/config.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ midas.dicomserver.manualstart = function (email, apikey) {
'&dest_folder=' + dest_folder_val +
'&dcmqrscp_cmd=' + dcmqrscp_val +
'&get_command=' + '',
log: $('<p></p>'),
success: function (retVal) {
$('span#manual_start').html(retVal.data);
}
Expand Down Expand Up @@ -105,6 +106,7 @@ midas.dicomserver.manualstop = function () {
'&dcmqrscp_cmd=' + dcmqrscp_val +
'&incoming_dir=' + incoming_dir_val +
'&get_command=' + '',
log: $('<p></p>'),
success: function (retVal) {
$('span#manual_stop').html(retVal.data);
}
Expand Down Expand Up @@ -183,6 +185,7 @@ midas.dicomserver.successConfig = function (responseText, statusText, xhr, form)
}
if(jsonResponse[0]) {
midas.createNotice(jsonResponse[1], 4000);
window.location.reload();
}
else {
midas.createNotice(jsonResponse[1], 4000, 'error');
Expand All @@ -191,7 +194,7 @@ midas.dicomserver.successConfig = function (responseText, statusText, xhr, form)


$(document).ready(function() {
$("div#tmpdir").qtip({
$("div#receptiondir").qtip({
content: 'The file-system location of the DICOM server work directory. (required)',
show: 'mouseover',
hide: 'mouseout',
Expand All @@ -201,6 +204,18 @@ $(document).ready(function() {
viewport: $(window), // Keep the qtip on-screen at all times
effect: true // Disable positioning animation
}
});

$("div#peer_aes").qtip({
content: 'Please follow the above instructions to define your Peer AE list and it cannot be empty. (required)',
show: 'mouseover',
hide: 'mouseout',
position: {
target: 'mouse',
my: 'bottom left',
viewport: $(window), // Keep the qtip on-screen at all times
effect: true // Disable positioning animation
}
})

$('#configForm').ajaxForm({
Expand Down Expand Up @@ -260,10 +275,12 @@ $(document).ready(function() {
var dcm2xml_val = $(document).find('#dcm2xml').val();
var storescp_val = $(document).find('#storescp').val();
var dcmqrscp_val = $(document).find('#dcmqrscp').val();
var dcmqridx_val = $(document).find('#dcmqridx').val();
var incoming_dir_val = $(document).find('#receptiondir').val();
$('span#dcm2xml_command').html(dcm2xml_val);
$('span#storescp_command').html(storescp_val);
$('span#dcmqrscp_command').html(dcmqrscp_val);
$('span#dcmqridx_command').html(dcmqridx_val);
$('span#reception_dir').html(incoming_dir_val);
midas.dicomserver.manualstart();
midas.dicomserver.manualstop();
Expand Down
Loading

0 comments on commit 18f8049

Please sign in to comment.