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 serie's data from Orthanc Server |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
Class Orthanc_Serie { |
21
|
|
|
|
22
|
|
|
public $serieOrthancID; |
23
|
|
|
public $parentStudyOrthancID; |
24
|
|
|
public $seriesManufacturer; |
25
|
|
|
public $seriesModelName; |
26
|
|
|
public $modality; |
27
|
|
|
public $seriesDate; |
28
|
|
|
public $seriesTime; |
29
|
|
|
public $seriesDescription; |
30
|
|
|
public $seriesInstanceUID; |
31
|
|
|
public $seriesNumber; |
32
|
|
|
public $seriesIsStable; |
33
|
|
|
public $seriesInstances; |
34
|
|
|
public $numberOfInstanceInOrthanc; |
35
|
|
|
public $lastUpdate; |
36
|
|
|
public $sharedTags; |
37
|
|
|
public $diskSizeMb; |
38
|
|
|
public $uncompressedSizeMb; |
39
|
|
|
public $patientWeight; |
40
|
|
|
public $injectedDose; |
41
|
|
|
public $injectedTime; |
42
|
|
|
public $injectedDateTime; |
43
|
|
|
public $injectedActivity; |
44
|
|
|
public $radiopharmaceutical; |
45
|
|
|
public $halfLife; |
46
|
|
|
public $sopClassUid; |
47
|
|
|
|
48
|
|
|
private $url; |
49
|
|
|
private $context; |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
public function __construct($seriesOrthancID, $url, $context) { |
53
|
|
|
//Set Orthanc http address |
54
|
|
|
$this->url=$url; |
55
|
|
|
$this->context=$context; |
56
|
|
|
|
57
|
|
|
//Set the current serie's Orthanc ID |
58
|
|
|
$this->serieOrthancID=$seriesOrthancID; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
*Get Series related data and store them in this object |
63
|
|
|
*/ |
64
|
|
|
public function retrieveSeriesData() { |
65
|
|
|
$context=stream_context_create($this->context); |
66
|
|
|
//Store all shared tags |
67
|
|
|
$this->sharedTags=json_decode(file_get_contents($this->url.'/series/'.$this->serieOrthancID.'/shared-tags', false, $context)); |
68
|
|
|
//parse main series informations |
69
|
|
|
$json=file_get_contents($this->url.'/series/'.$this->serieOrthancID, false, $context); |
70
|
|
|
$seriesJson=json_decode($json, true); |
71
|
|
|
//add needed informations in the current object |
72
|
|
|
$this->seriesManufacturer=$seriesJson['MainDicomTags']['Manufacturer']; |
73
|
|
|
$this->modality=$seriesJson['MainDicomTags']['Modality']; |
74
|
|
|
$this->seriesDate=$seriesJson['MainDicomTags']['SeriesDate']; |
75
|
|
|
$this->seriesTime=$seriesJson['MainDicomTags']['SeriesTime']; |
76
|
|
|
$this->seriesDescription=$seriesJson['MainDicomTags']['SeriesDescription']; |
77
|
|
|
$this->seriesInstanceUID=$seriesJson['MainDicomTags']['SeriesInstanceUID']; |
78
|
|
|
$this->seriesNumber=$seriesJson['MainDicomTags']['SeriesNumber']; |
79
|
|
|
$this->seriesIsStable=$seriesJson['IsStable']; |
80
|
|
|
$this->parentStudyOrthancID=$seriesJson['ParentStudy']; |
81
|
|
|
$this->seriesInstances=$seriesJson['Instances']; |
82
|
|
|
$this->numberOfInstanceInOrthanc=sizeof($seriesJson['Instances']); |
83
|
|
|
$this->lastUpdate=$seriesJson['LastUpdate']; |
84
|
|
|
|
85
|
|
|
//add instance data using the first Instance Orthanc ID |
86
|
|
|
$this->retrieveInstancesData($seriesJson['Instances'][0]); |
87
|
|
|
|
88
|
|
|
//add statistics data |
89
|
|
|
$this->retrieveSeriesStatistics(); |
90
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Get statistics of the series (size in MB) |
95
|
|
|
*/ |
96
|
|
|
private function retrieveSeriesStatistics() { |
97
|
|
|
$context=stream_context_create($this->context); |
98
|
|
|
$json=file_get_contents($this->url.'/series/'.$this->serieOrthancID.'/statistics/', false, $context); |
99
|
|
|
$statisticsJson=json_decode($json, true); |
100
|
|
|
$this->diskSizeMb=$statisticsJson['DiskSizeMB']; |
101
|
|
|
$this->uncompressedSizeMb=$statisticsJson['UncompressedSizeMB']; |
102
|
|
|
|
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Store some data only available in the Instance level |
107
|
|
|
* @param $instanceID |
108
|
|
|
*/ |
109
|
|
|
private function retrieveInstancesData($instanceID) { |
110
|
|
|
$context=stream_context_create($this->context); |
111
|
|
|
$json=file_get_contents($this->url.'/instances/'.$instanceID.'/tags/', false, $context); |
112
|
|
|
$instanceJson=json_decode($json, true); |
113
|
|
|
$this->patientWeight=$instanceJson['0010,1030']['Value']; |
114
|
|
|
$this->seriesModelName=$instanceJson['0008,1090']['Value']; |
115
|
|
|
$this->injectedDose=$instanceJson['0054,0016']['Value'][0]['0018,1074']['Value']; |
116
|
|
|
//SK InjectedTime est deprecie en faveur de DateTime, A surveiller pour la suite |
117
|
|
|
$this->injectedTime=$instanceJson['0054,0016']['Value'][0]['0018,1072']['Value']; |
118
|
|
|
$this->injectedDateTime=$instanceJson['0054,0016']['Value'][0]['0018,1078']['Value']; |
119
|
|
|
$this->injectedActivity=$instanceJson['0054,0016']['Value'][0]['0018,1077']['Value']; |
120
|
|
|
$this->radiopharmaceutical=$instanceJson['0054,0016']['Value'][0]['0018,0031']['Value']; |
121
|
|
|
$this->halfLife=$instanceJson['0054,0016']['Value'][0]['0018,1075']['Value']; |
122
|
|
|
$this->sopClassUid=$instanceJson['0008,0016']['Value']; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Return if this serie in a secondary capture type |
127
|
|
|
* @return boolean |
128
|
|
|
*/ |
129
|
|
|
public function isSecondaryCapture() { |
130
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.7"; |
|
|
|
|
131
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.7.1"; |
132
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.7.2"; |
133
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.7.3"; |
134
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.7.4"; |
135
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.88.11"; |
136
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.88.22"; |
137
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.88.33"; |
138
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.88.40"; |
139
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.88.50"; |
140
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.88.59"; |
141
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.88.65"; |
142
|
|
|
$scUids[]="1.2.840.10008.5.1.4.1.1.88.67"; |
143
|
|
|
|
144
|
|
|
if (in_array($this->sopClassUid, $scUids)) { |
145
|
|
|
return true; |
146
|
|
|
} else { |
147
|
|
|
return false; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
} |