diff --git a/docs/API/LorisRESTAPI_v0.0.3.md b/docs/API/LorisRESTAPI_v0.0.3.md index 5ff86571996..4e36da4e753 100644 --- a/docs/API/LorisRESTAPI_v0.0.3.md +++ b/docs/API/LorisRESTAPI_v0.0.3.md @@ -581,7 +581,23 @@ Returns file level QC information. It will return a JSON object of the form: "File" : $Filename }, "QC" : "Pass|Fail", - "Selected" : boolean + "Selected" : boolean, + "Caveats" : [ + { + "Severity" : $severity, + "Header" : $header, + "Value" : $headerValue, + "ValidRange" : $headerValidRange, + "ValidRegex" : $headerValidRegex + }, + { + "Severity" : $severity, + "Header" : $header, + "Value" : $headerValue, + "ValidRange" : $headerValidRange, + "ValidRegex" : $headerValidRegex + } + ] } ``` @@ -668,7 +684,7 @@ will return a JSON object of the form: "Description" : { "SeriesName" : "", "SeriesDescription" : "" - } + }, "Dimensions" : { "XSpace" : { "Length" : "", @@ -686,6 +702,13 @@ will return a JSON object of the form: "Length" : "", "StepSize" : "" } + }, + "ScannerInfo" : { + "Manufacturer" : $scannerManufacturer, + "Model" : $scannerModel, + "SoftwareVersion" : $scannerSoftwareVersion, + "SerialNumber" : $scannerSerialNumber, + "FieldStrength" : $scannerFieldStrength } } ``` diff --git a/htdocs/api/v0.0.2/candidates/visits/images/qc/QC.php b/htdocs/api/v0.0.2/candidates/visits/images/qc/QC.php index b34434eb6e1..36625a538fc 100644 --- a/htdocs/api/v0.0.2/candidates/visits/images/qc/QC.php +++ b/htdocs/api/v0.0.2/candidates/visits/images/qc/QC.php @@ -64,13 +64,13 @@ public function handleGET() $factory = \NDB_Factory::singleton(); $DB = $factory->Database(); $QCStatus = $DB->pselectRow( - "SELECT QCStatus, - pf.Value as Selected FROM files f - LEFT JOIN files_qcstatus fqc ON (f.FileID=fqc.FileID) - LEFT JOIN parameter_file pf ON (f.FileID=pf.FileID) - LEFT JOIN parameter_type pt - ON (pf.ParameterTypeID=pt.ParameterTypeID AND pt.Name='Selected') - WHERE f.File LIKE CONCAT('%', :FName)", + "SELECT QCStatus, Selected + FROM files_qcstatus + WHERE FileID in ( + SELECT FileID + FROM files + WHERE File LIKE CONCAT('%', :FName) + )", array('FName' => $this->Filename) ); $this->JSON = [ diff --git a/htdocs/api/v0.0.3-dev/candidates/visits/images/headers/Headers.php b/htdocs/api/v0.0.3-dev/candidates/visits/images/headers/Headers.php index fa7370a1bf2..0f37f142ec1 100644 --- a/htdocs/api/v0.0.3-dev/candidates/visits/images/headers/Headers.php +++ b/htdocs/api/v0.0.3-dev/candidates/visits/images/headers/Headers.php @@ -62,54 +62,67 @@ public function __construct($method, $CandID, $VisitLabel, $Filename) */ public function handleGET() { - $TE = $this->getHeader('acquisition:echo_time'); - $TR = $this->getHeader('acquisition:repetition_time'); - $TI = $this->getHeader('acquisition:inversion_time'); - $ST = $this->getHeader('acquisition:slice_thickness'); + $te = $this->getHeader('acquisition:echo_time'); + $tr = $this->getHeader('acquisition:repetition_time'); + $ti = $this->getHeader('acquisition:inversion_time'); + $st = $this->getHeader('acquisition:slice_thickness'); - $SeriesName = $this->getHeader("acquisition:protocol"); - $SeriesDescription = $this->getHeader("acquisition:series_description"); + $seriesName = $this->getHeader("acquisition:protocol"); + $seriesDescription = $this->getHeader("acquisition:series_description"); - $XSpace = [ - "Length" => $this->getHeader("xspace:length"), - "StepSize" => $this->getHeader("xspace:step"), - ]; - $YSpace = [ - "Length" => $this->getHeader("yspace:length"), - "StepSize" => $this->getHeader("yspace:step"), - ]; - $ZSpace = [ - "Length" => $this->getHeader("zspace:length"), - "StepSize" => $this->getHeader("zspace:step"), - ]; - $TimeD = [ - "Length" => $this->getHeader("time:length"), - "StepSize" => $this->getHeader("time:step"), - ]; - $this->JSON = [ - 'Meta' => [ + $xspace = array( + "Length" => $this->getHeader("xspace:length"), + "StepSize" => $this->getHeader("xspace:step"), + ); + $yspace = array( + "Length" => $this->getHeader("yspace:length"), + "StepSize" => $this->getHeader("yspace:step"), + ); + $zspace = array( + "Length" => $this->getHeader("zspace:length"), + "StepSize" => $this->getHeader("zspace:step"), + ); + $timeD = array( + "Length" => $this->getHeader("time:length"), + "StepSize" => $this->getHeader("time:step"), + ); + + $manufacturer = $this->getHeader("study:manufacturer"); + $model = $this->getHeader("study:device_model"); + $softwareVersion = $this->getHeader("study:software_version"); + $serialNumber = $this->getHeader("study:serial_no"); + $fieldStrength = $this->getHeader("study:field_value"); + + $this->JSON = array( + 'Meta' => array( 'CandID' => $this->CandID, 'Visit' => $this->VisitLabel, 'Filename' => $this->Filename, - ], - 'Physical' => [ - "TE" => $TE, - "TR" => $TR, - "TI" => $TI, - "SliceThickness" => $ST, - ], - 'Description' => [ - "SeriesName" => $SeriesName, - "SeriesDescription" => $SeriesDescription, - ], - 'Dimensions' => [ - "XSpace" => $XSpace, - "YSpace" => $YSpace, - "ZSpace" => $ZSpace, - "TimeDimension" => $TimeD, - ], - - ]; + ), + 'Physical' => array( + "TE" => $te, + "TR" => $tr, + "TI" => $ti, + "SliceThickness" => $st, + ), + 'Description' => array( + "SeriesName" => $seriesName, + "SeriesDescription" => $seriesDescription, + ), + 'Dimensions' => array( + "XSpace" => $xspace, + "YSpace" => $yspace, + "ZSpace" => $zspace, + "TimeDimension" => $timeD, + ), + 'ScannerInfo' => array( + "Manufacturer" => $manufacturer, + "Model" => $model, + "SoftwareVersion" => $softwareVersion, + "SerialNumber" => $serialNumber, + "FieldStrength" => $fieldStrength, + ), + ); } /** diff --git a/htdocs/api/v0.0.3-dev/candidates/visits/images/qc/QC.php b/htdocs/api/v0.0.3-dev/candidates/visits/images/qc/QC.php index bbb77196c00..c7d9763c90e 100644 --- a/htdocs/api/v0.0.3-dev/candidates/visits/images/qc/QC.php +++ b/htdocs/api/v0.0.3-dev/candidates/visits/images/qc/QC.php @@ -64,24 +64,45 @@ public function handleGET() $factory = \NDB_Factory::singleton(); $DB = $factory->Database(); $QCStatus = $DB->pselectRow( - "SELECT QCStatus, - pf.Value as Selected FROM files f - LEFT JOIN files_qcstatus fqc ON (f.FileID=fqc.FileID) - LEFT JOIN parameter_file pf ON (f.FileID=pf.FileID) - LEFT JOIN parameter_type pt - ON (pf.ParameterTypeID=pt.ParameterTypeID AND pt.Name='Selected') - WHERE f.File LIKE CONCAT('%', :FName)", + "SELECT QCStatus, Selected + FROM files_qcstatus + WHERE FileID in ( + SELECT FileID + FROM files + WHERE File LIKE CONCAT('%', :FName) + )", array('FName' => $this->Filename) ); - $this->JSON = [ - 'Meta' => [ + $caveats = $this->getImageCaveats(); + $this->JSON = array( + 'Meta' => array( 'CandID' => $this->CandID, 'Visit' => $this->VisitLabel, 'File' => $this->Filename, - ], + ), 'QC' => $QCStatus['QCStatus'], 'Selected' => $QCStatus['Selected'], - ]; + 'Caveats' => $caveats, + ); + } + + /** + * Gets the list of Caveats for the file. + * + * @return array A list of caveats for the file + */ + function getImageCaveats(): array + { + $factory = \NDB_Factory::singleton(); + $DB = $factory->Database(); + $rows = $DB->pselect( + "SELECT Severity, Header, Value, ValidRange, ValidRegex + FROM files f + LEFT JOIN mri_violations_log mvl ON (f.SeriesUID=mvl.SeriesUID) + WHERE f.File LIKE CONCAT('%', :FName)", + array('FName' => $this->Filename) + ); + return $rows; } /**