1 | <?php |
||
2 | /** |
||
3 | Copyright (C) 2018-2020 KANOUN Salim |
||
4 | This program is free software; you can redistribute it and/or modify |
||
5 | it under the terms of the Affero GNU General Public v.3 License as published by |
||
6 | the Free Software Foundation; |
||
7 | This program is distributed in the hope that it will be useful, |
||
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
10 | Affero GNU General Public Public for more details. |
||
11 | You should have received a copy of the Affero GNU General Public Public along |
||
12 | with this program; if not, write to the Free Software Foundation, Inc., |
||
13 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
||
14 | */ |
||
15 | |||
16 | /** |
||
17 | * Collect study's data from Orthanc Server |
||
18 | */ |
||
19 | |||
20 | class Orthanc_Study { |
||
21 | public $studyOrthancID; |
||
22 | public $studyIsStable; |
||
23 | public $studyDate; |
||
24 | public $studyTime; |
||
25 | public $studyDescription; |
||
26 | public $studyInstanceUID; |
||
27 | public $studyLastUpdate; |
||
28 | |||
29 | public $countInstances; |
||
30 | public $diskSizeMb; |
||
31 | public $uncompressedSizeMb; |
||
32 | |||
33 | public $seriesInStudy; |
||
34 | public $numberOfSeriesInStudy; |
||
35 | |||
36 | public $parentPatientName; |
||
37 | public $parentPatientID; |
||
38 | public $parentPartientOrthancID; |
||
39 | |||
40 | public $orthancSeries; |
||
41 | |||
42 | |||
43 | private $url; |
||
44 | private $context; |
||
45 | |||
46 | public function __construct($studyOrthancId, $url, $context) { |
||
47 | //Set http adress of orthanc |
||
48 | if ($url == null && $context == null) { |
||
49 | |||
50 | $this->url=GAELO_ORTHANC_PACS_ADDRESS.':'.GAELO_ORTHANC_PACS_PORT; |
||
51 | $this->context=array( |
||
52 | 'http' => array( |
||
53 | 'header' => "Authorization: Basic ".base64_encode(GAELO_ORTHANC_PACS_LOGIN.':'.GAELO_ORTHANC_PACS_PASSWORD) |
||
54 | ) |
||
55 | ); |
||
56 | |||
57 | } else { |
||
58 | $this->url=$url; |
||
59 | $this->context=$context; |
||
60 | } |
||
61 | |||
62 | //put current study orthanc ID in memory |
||
63 | $this->studyOrthancID=$studyOrthancId; |
||
64 | |||
65 | } |
||
66 | |||
67 | /** |
||
68 | *Get study related tags and store them in this object |
||
69 | */ |
||
70 | public function retrieveStudyData() { |
||
71 | $context=stream_context_create($this->context); |
||
72 | $json=file_get_contents($this->url.'/studies/'.$this->studyOrthancID, false, $context); |
||
73 | //On le decode |
||
74 | $studiesJson=json_decode($json, true); |
||
75 | //On cree un object patient avec les information |
||
76 | $this->studyDate=$studiesJson['MainDicomTags']['StudyDate']; |
||
77 | $this->studyTime=$studiesJson['MainDicomTags']['StudyTime']; |
||
78 | $this->studyDescription=$studiesJson['MainDicomTags']['StudyDescription']; |
||
79 | $this->studyInstanceUID=$studiesJson['MainDicomTags']['StudyInstanceUID']; |
||
80 | $this->studyLastUpdate=$studiesJson['LastUpdate']; |
||
81 | $this->seriesInStudy=$studiesJson['Series']; |
||
82 | $this->numberOfSeriesInStudy=sizeof($studiesJson['Series']); |
||
83 | $this->studyIsStable=$studiesJson['IsStable']; |
||
84 | $this->parentPatientName=$studiesJson['PatientMainDicomTags']['PatientName']; |
||
85 | $this->parentPatientID=$studiesJson['PatientMainDicomTags']['PatientID']; |
||
86 | $this->parentPartientOrthancID=$studiesJson['ParentPatient']; |
||
87 | |||
88 | //add statistics info |
||
89 | $this->retrieveStudyStatistics(); |
||
90 | //add series tag |
||
91 | $this->getSeriesMainTag(); |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | *Get study statistics info (size in MB, number of instances) and store them in this object |
||
96 | */ |
||
97 | private function retrieveStudyStatistics() { |
||
98 | $context=stream_context_create($this->context); |
||
99 | $json=file_get_contents($this->url.'/studies/'.$this->studyOrthancID.'/statistics/', false, $context); |
||
100 | //On le decode |
||
101 | $statisticsJson=json_decode($json, true); |
||
102 | $this->countInstances=$statisticsJson['CountInstances']; |
||
103 | $this->diskSizeMb=$statisticsJson['DiskSizeMB']; |
||
104 | $this->uncompressedSizeMb=$statisticsJson['UncompressedSizeMB']; |
||
105 | |||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Create a series object with series data for each series and store them in this object |
||
110 | */ |
||
111 | private function getSeriesMainTag() { |
||
112 | foreach ($this->seriesInStudy as $seriesID) { |
||
113 | $series=new Orthanc_Serie($seriesID, $this->url, $this->context); |
||
114 | @$series->retrieveSeriesData(); |
||
0 ignored issues
–
show
Are you sure the usage of
$series->retrieveSeriesData() targeting Orthanc_Serie::retrieveSeriesData() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
115 | $this->orthancSeries[]=$series; |
||
116 | } |
||
117 | } |
||
118 | } |
If you suppress an error, we recommend checking for the error condition explicitly: