From 9c51213792ddf4fd08acc8805c419793de11ab0e Mon Sep 17 00:00:00 2001 From: Simon Pelletier Date: Tue, 23 Jun 2020 16:11:12 -0400 Subject: [PATCH] [API] Creation of endpoint /project/{project}/dicoms --- .../projectimagesrowprovisioner.class.inc | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 modules/api/php/provisioners/projectimagesrowprovisioner.class.inc diff --git a/modules/api/php/provisioners/projectimagesrowprovisioner.class.inc b/modules/api/php/provisioners/projectimagesrowprovisioner.class.inc new file mode 100644 index 00000000000..b997e1a9ee4 --- /dev/null +++ b/modules/api/php/provisioners/projectimagesrowprovisioner.class.inc @@ -0,0 +1,97 @@ + + * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 + * @link https://www.github.com/aces/Loris/ + */ + +namespace LORIS\api\Provisioners; + +use \LORIS\Data\Provisioners\DBRowProvisioner; +use \LORIS\api\Models\ProjectImagesRow; +/** + * This file implements a data provisioner to get all images of a project + * created since a given date. + * + * PHP Version 7 + * + * @category API + * @package Loris + * @author Xavier Lecours Boucher + * @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 + * @link https://www.github.com/aces/Loris/ + */ +class ProjectImagesRowProvisioner extends DBRowProvisioner +{ + /** + * Create a RowProvisioner + * + * @param \Project $project The project from which images are requested + * @param \DateTime $since The project from which images are requested + */ + function __construct(\Project $project, \DateTime $since) + { + parent::__construct( + ' + SELECT + s.CandID as Candidate, + c.PSCID as PSCID, + c.Entity_type as Entity_type, + s.Visit_label as Visit, + s.Date_visit as Visit_date, + s.CenterID as CenterID, + p.Name as Site, + f.InsertTime as InsertTime, + f.File as File, + mst.Scan_type as ScanType, + qc.QCStatus as QC_status, + qc.Selected as Selected + FROM + files f + LEFT JOIN mri_scan_type mst + ON (mst.ID = f.AcquisitionProtocolID) + LEFT JOIN session s + ON (f.SessionID = s.ID) + LEFT JOIN candidate c + ON (s.CandID = c.CandID) + LEFT JOIN psc p + ON (s.CenterID = p.CenterID) + LEFT JOIN files_qcstatus qc + ON (f.FileID = qc.FileID) + LEFT JOIN Project project + ON (c.RegistrationProjectID = project.ProjectID) + WHERE + c.Active = \'Y\' AND + s.Active = \'Y\' AND + project.Name = :v_projectname AND + f.InsertTime > :v_time + ORDER BY f.InsertTime ASC + ', + [ + 'v_projectname' => $project->getName(), + 'v_time' => $since->getTimestamp(), + ] + ); + } + + /** + * Returns an instance of a ProjectImagesRow object for a given + * table row. + * + * @param array $row The database row from the LORIS Database class. + * + * @return \LORIS\Data\DataInstance An instance representing this row. + */ + public function getInstance($row) : \LORIS\Data\DataInstance + { + return new ProjectImagesRow($row); + } +} +