forked from aces/Loris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[API] Added features for dicoms : PatientName and images: isPhantom (a…
…ces#6899) Patientname is added to dicoms endpoint view and IsPhantom is added to images endpoint view.
- Loading branch information
1 parent
9ec7bed
commit b34fdef
Showing
11 changed files
with
239 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* PHP Version 7 | ||
* | ||
* @category ApiViews | ||
* @package Loris | ||
* @author Xavier Lecours Boucher <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
|
||
namespace LORIS\api\Views\Visit; | ||
|
||
use \LORIS\Data\Models\DicomTarDTO; | ||
use \LORIS\Data\Models\DicomSeriesDTO; | ||
/** | ||
* Creates a representation of a visit dicoms following the api response | ||
* specifications. | ||
* | ||
* @category ApiViews | ||
* @package Loris | ||
* @author Xavier Lecours Boucher <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
|
||
class Dicoms_0_0_4_Dev | ||
{ | ||
private $_timepoint; | ||
private $_dicoms; | ||
|
||
/** | ||
* Constructor which sets the instance variables based on the provided timepoint | ||
* | ||
* @param \Timepoint $timepoint The timepoint to represent | ||
* @param DicomTarDTO ...$dicoms An array of dicomtars | ||
*/ | ||
public function __construct(\Timepoint $timepoint, DicomTarDTO ...$dicoms) | ||
{ | ||
$this->_timepoint = $timepoint; | ||
$this->_dicoms = $dicoms; | ||
} | ||
|
||
/** | ||
* This is a mapper function that formats a dicomtar following the | ||
* API specifications. | ||
* | ||
* @param DicomTarDTO $dicom The dicomtar to format. | ||
* | ||
* @return array | ||
*/ | ||
private static function _formatDicomTars(DicomTarDTO $dicom): array | ||
{ | ||
return [ | ||
'Tarname' => $dicom->getTarname(), | ||
'Patientname' => $dicom->getPatientname(), | ||
'SeriesInfo' => array_map( | ||
[ | ||
'self', | ||
'_formatSeries' | ||
], | ||
$dicom->getSeries() | ||
), | ||
]; | ||
} | ||
|
||
/** | ||
* This is a mapper function that formats a dicom series following the | ||
* API specifications. | ||
* | ||
* @param DicomSeriesDTO $series The series to format. | ||
* | ||
* @return array | ||
*/ | ||
private static function _formatSeries(DicomSeriesDTO $series): array | ||
{ | ||
return [ | ||
'SeriesDescription' => $series->getSeriesDescription(), | ||
'SeriesNumber' => $series->getSeriesNumber(), | ||
'EchoTime' => $series->getEchotime(), | ||
'RepetitionTime' => $series->getRepetitiontime(), | ||
'InversionTime' => $series->getInversiontime(), | ||
'SliceThickness' => $series->getSlicethickness(), | ||
'Modality' => $series->getModality(), | ||
'SeriesUID' => $series->getSeriesuid(), | ||
]; | ||
} | ||
|
||
/** | ||
* Creates an serializable array of this object's data | ||
* | ||
* @return array | ||
*/ | ||
public function toArray(): array | ||
{ | ||
$meta = [ | ||
'CandID' => $this->_timepoint->getCandID(), | ||
'Visit' => $this->_timepoint->getVisitLabel(), | ||
]; | ||
|
||
$dicomtars = array_map( | ||
'self::_formatDicomTars', | ||
$this->_dicoms | ||
); | ||
|
||
return [ | ||
'Meta' => $meta, | ||
'DicomTars' => $dicomtars, | ||
]; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* PHP Version 7 | ||
* | ||
* @category ApiViews | ||
* @package Loris | ||
* @author Xavier Lecours Boucher <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
|
||
namespace LORIS\api\Views\Visit; | ||
|
||
use \LORIS\Data\Models\ImageDTO; | ||
/** | ||
* Creates a representation of a visit images following the api response | ||
* specifications. | ||
* | ||
* @category ApiViews | ||
* @package Loris | ||
* @author Xavier Lecours Boucher <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
|
||
class Images_0_0_4_Dev | ||
{ | ||
private $_timepoint; | ||
private $_images; | ||
|
||
/** | ||
* Constructor which sets the instance variables based on the provided timepoint | ||
* | ||
* @param \Timepoint $timepoint The timepoint to represent | ||
* @param ImageDTO ...$images An array of images | ||
*/ | ||
public function __construct(\Timepoint $timepoint, ImageDTO ...$images) | ||
{ | ||
$this->_timepoint = $timepoint; | ||
$this->_images = $images; | ||
} | ||
|
||
/** | ||
* Creates an serializable array of this object's data | ||
* | ||
* @return array | ||
*/ | ||
public function toArray(): array | ||
{ | ||
$meta = [ | ||
'CandID' => $this->_timepoint->getCandID(), | ||
'Visit' => $this->_timepoint->getVisitLabel(), | ||
]; | ||
|
||
$imagesdata = array_map( | ||
function ($image) { | ||
return [ | ||
'OutputType' => $image->getOutputType(), | ||
'Filename' => $image->getFilename(), | ||
'AcquisitionType' => $image->getAcquisitionprotocol(), | ||
'IsPhantom' => $image->isPhantom(), | ||
]; | ||
}, | ||
$this->_images | ||
); | ||
|
||
return [ | ||
'Meta' => $meta, | ||
'Files' => $imagesdata, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters