Passed
Pull Request — dev (#25)
by
unknown
03:47
created

replaceEmpty()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
nc 2
nop 1
dl 0
loc 5
c 0
b 0
f 0
cc 2
rs 10
1
<?php
2
/**
3
 Copyright (C) 2018 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
// If Not done do not display anything
17
if ($visitObject->statusDone == Visit::NOT_DONE) {
18
	echo ("<h1>Visit Not Done</h1>");
19
	return;
20
} ?>
21
22
<script type="text/javascript">
23
    
24
	$(document).ready(function(){
25
    		$("#formInvestigator").load('/specific_form', {
26
    			id_visit : <?=$id_visit?>,
27
    			type_visit : '<?=$type_visit?>',
28
    			patient_num : <?=$patient_num?>
29
            });
30
            
31
        	//If upload validated display the detailed tables
32
            <?php
33
			if ($visitObject->uploadStatus == Visit::NOT_DONE && $role === User::INVESTIGATOR) {
34
			?>
35
                checkBrowserSupportDicomUpload('#uploadDicom');
36
               	new DicomUpload('#uploadDicom', {
37
                    expectedVisitsURL: '../../scripts/get_possible_import.php',
38
                    validationScriptURL: '../../scripts/validate_dicom_upload.php',
39
                    dicomsReceiptsScriptURL: '../../scripts/dicoms_receipts.php',
40
                    isNewStudyURL: '../../scripts/is_new_study.php',
41
                    callbackOnComplete: refreshDivContenu,
42
                    idVisit: <?= $id_visit ?? 'null' ?>
43
                }); 
44
           <?php
45
			}
46
			?>
47
          
48
			//If current user is controller diplay the quality controle form, the included QC form is disabled according to QC status
49
	       <?php
50
			if ($role == User::CONTROLLER && ($visitObject->stateQualityControl == Visit::QC_NOT_DONE || $visitObject->stateQualityControl == Visit::QC_WAIT_DEFINITVE_CONCLUSION)) {
51
				?>  
52
                $("#controlerForm").load('/controller_form', {
53
                    id_visit : <?= $id_visit ?>,
54
                    type_visit : '<?= $type_visit ?>',
55
                    patient_num : <?= $patient_num ?>
56
                });
57
    
58
    	       <?php
59
				// If investigator has reponded to the quality control, display the corrective action form
60
				if ($visitObject->stateQualityControl == Visit::QC_WAIT_DEFINITVE_CONCLUSION) {
61
				?>
62
            		$("#correctiveAction").load('/corrective_action', {
63
            			id_visit : <?= $id_visit ?>,
64
            			type_visit : '<?= $type_visit ?>',
65
            			patient_num : <?= $patient_num ?>
66
            		});
67
    	       <?php
68
				}
69
			}
70
    
71
			// If corrective action is asked, display the corrective action form for investigator (or monitor)
72
			if ($visitObject->stateQualityControl == Visit::QC_CORRECTIVE_ACTION_ASKED && ($role == User::INVESTIGATOR || $role == User::MONITOR)) {
73
				?>
74
            		$("#correctiveAction").load('/corrective_action', {
75
            			id_visit : <?=$id_visit?>,
76
            			type_visit : '<?=$type_visit?>',
77
            			patient_num : <?=$patient_num?>
78
            		});
79
            	
80
            		$("#controlerForm").load('/controller_form', {
81
            			id_visit : <?=$id_visit?>,
82
            			type_visit : '<?=$type_visit?>',
83
            			patient_num : <?=$patient_num?>
84
            		});
85
        
86
            	<?php
87
			}
88
			if ($role == User::REVIEWER ||  ($role == User::INVESTIGATOR  && $visitObject->uploadStatus==Visit::DONE) || ($role == User::CONTROLLER && ($visitObject->stateQualityControl == Visit::QC_NOT_DONE || $visitObject->stateQualityControl == Visit::QC_WAIT_DEFINITVE_CONCLUSION))) {
89
				?>
90
            		$("#reviewerDownloadDicomBtn").on('click', function() {
91
            			$("#downloadForm").submit();
92
            		});
93
            		
94
            		$("#OHIFViewer").on('click', function() {
95
            			var win = window.open('/ohif/viewer/<?=$visitObject->getStudyDicomDetails()->studyUID ?>', '_blank');
96
                        if (win) {
97
                            //Browser has allowed it to be opened
98
                            win.focus();
99
                        } else {
100
                            //Browser has blocked it
101
                            alert('Please allow popups for this website');
102
                        }
103
            		});
104
        	    <?php
105
			}
106
			?>
107
108
	});
109
	
110
	function refreshDivContenu(){
111
		$('#contenu').load('/visit_interface', {
112
				id_visit : <?=$id_visit?>,
113
				type_visit : '<?=$type_visit?>',
114
				patient_num : <?=$patient_num?>
115
		});
116
		$('#containerTree').jstree(true).refresh();
117
	};
118
119
	<?php if ($visitObject->uploadStatus == Visit::UPLOAD_PROCESSING) {
120
		
121
		?>
122
	    function refreshUploadStatus(){
123
	        $.ajax({
124
	            type: "POST",
125
	            url: '/scripts/get_upload_status.php',
126
				dataType: 'json',
127
				//Do not trigger event to avoid conflit with dicomupload listener in parallel
128
				global: false,
129
	            data: {id_visit:<?=$id_visit?>},
130
				success: function(data) {
131
		           //Update the span of the upload status
132
					var spinner=$('#spinnerUploadDiv<?=$visitObject->id_visit?>');
133
					var uploadStatusLabel=$('#uploadStatusLabel<?=$visitObject->id_visit?>');
134
					var checkIcon=$('#checkIconDiv<?=$visitObject->id_visit?>');
135
					
136
					uploadStatusLabel.html(data);
137
					
138
		        	if(data == "<?=Visit::UPLOAD_PROCESSING?>"){
139
		        		spinner.show();
140
		        		setTimeout(refreshUploadStatus, 5000);
141
		        	}else if(data=="<?= Visit::DONE ?>"){
142
		        		checkIcon.show();
143
		        		uploadStatusLabel.css("color", "green");
144
		        		spinner.hide();
145
		        		<?php if($visitObject->stateInvestigatorForm==Visit::DONE){
146
							?>
147
		        			refreshDivContenu();
148
		        			<?php
149
						}?>
150
		        	}else{
151
		        		spinner.hide();
152
		        		uploadStatusLabel.css("color", "red");
153
		        		checkIcon.hide();
154
		        	}
155
	           },
156
	           error : function(){
157
		           console.log('error');
158
	           }
159
			});		
160
161
		}
162
163
	    $( document ).ready(function() {
164
	    	refreshUploadStatus();
165
	    });
166
	
167
168
	<?php 
169
	    
170
	}?>
171
172
    	
173
    </script>
174
175
<?php
176
// Status reminder
177
if ($role != User::REVIEWER) {
178
	?>
179
    <div class="bloc_bordures text-center mt-3 mb-3">
180
		<label><b>Upload Status:</b> <span id="uploadStatusLabel<?=$visitObject->id_visit?>"><?=$visitObject->uploadStatus?> </span> </label>
181
    	<span id="spinnerUploadDiv<?=$visitObject->id_visit?>" class="spinner-border text-primary" role="status" style="display: none;">
182
			<span class="sr-only">Loading...</span>
183
		</span>
184
		<span id="checkIconDiv<?=$visitObject->id_visit?>" style="display: none;">
185
			<svg xmlns="http://www.w3.org/2000/svg" width="12" height="16" viewBox="0 0 12 16">
186
				<path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5L12 5z"/>
187
			</svg>
188
		</span>
189
		<br>
190
		<label><b>Quality Control Status:</b> <?=$visitObject->stateQualityControl?></label>
191
    </div>
192
    <?php
193
}
194
// If reviewer or controler with awaiting QC action add an invisible form and a button to make dicom zip dowload
195
if ($role == User::REVIEWER || ($role == User::INVESTIGATOR  && $visitObject->uploadStatus==Visit::DONE) || ($role == User::CONTROLLER && ($visitObject->stateQualityControl == Visit::QC_WAIT_DEFINITVE_CONCLUSION || $visitObject->stateQualityControl == Visit::QC_NOT_DONE))) {
196
	?>
197
    <div class="text-center mt-3 mb-3">
198
    	<input class="btn btn-primary" type="button"
199
    		id="reviewerDownloadDicomBtn" value="Download DICOM">
200
		<input class="btn btn-primary" type="button"
201
    		id="OHIFViewer" value="OHIF Viewer">
202
    </div>
203
    <form id="downloadForm" method="post"
204
    	action="scripts/download_dicom.php">
205
    	<input type="hidden" name="id_visit" value="<?=$id_visit?>">
206
    
207
    </form>
208
209
<?php
210
}
211
// If upload validated display the detailed tables
212
if ($visitObject->uploadStatus == Visit::DONE && $role != User::REVIEWER) {
213
	build_patient_visit_table($patientObject);
214
	build_visit_details_table(array($visitObject), $_SESSION['role']);
215
	build_table_series($role, $visitObject);
216
}
217
?>
218
219
<div id="uploadDicom" class="mt-3"></div>
220
<div id="correctiveAction"></div>
221
<div id="controlerForm"></div>
222
<div id="formInvestigator"></div>
223
224
<?php
225
function replaceEmpty($data){
226
    if (empty($data)){
227
        return ('/');
228
    } else{
229
        return (htmlspecialchars($data));
230
    }
231
}
232
/**
233
 * Generate Table of series details of a given visit for visit investigator interface
234
 */
235
function build_table_series($role, $visitObject)
236
{
237
    // Get Series Object Array with details
238
    $data_series = $visitObject->getSeriesDetails();
239
    
240
    $series_number = count($data_series);
241
    
242
    if ($series_number == 0) {
243
    	return;
244
    }
245
    
246
    $colspan = $series_number + 1;
247
    ?>
248
	<div style="overflow-x:auto;"> 
249
		<table id="tab_series" class="table table-striped">
250
			<tr>
251
				<th colspan=<?=$colspan ?>>Series information</th>
252
			</tr>
253
			<tr>
254
				<td>Series Number</td>
255
    			<?php 
256
                for ($i = 0; $i < $series_number; $i ++) {
257
                    if (empty($data_series[$i]->seriesNumber)) {
258
                                            ?>
259
                        <td> 
260
                        	<?=replaceEmpty($data_series[$i]->seriesNumber)?>
261
                        </td>
262
            	<?php 
263
                }?>
264
    		</tr>
265
			<tr>
266
    			<td>Manufacturer</td>
267
    			<?php 
268
                for ($i = 0;
269
                    }
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected '}', expecting ';' on line 269 at column 20
Loading history...
270
                    $i < $series_number; $i ++) {
271
                    ?>
272
                    <td>
273
                    	<?=replaceEmpty($data_series[$i]->manufacturer)?>
274
                	</td>
275
               <?php 
276
                }?>
277
   			</tr>
278
			<tr>
279
				<td>Series Description</td>
280
				<?php 
281
                for ($i=0; $i < $series_number; $i++) {
282
                    ?>
283
                    <td>
284
                    	<?=replaceEmpty($data_series[$i]->seriesDescription)?>
285
                	</td>
286
               <?php 
287
                }
288
                ?>
289
			</tr>
290
			<tr>
291
				<td>Modality</td>
292
				<?php 
293
                for ($i=0; $i < $series_number; $i++) {
294
                    ?>
295
                    <td>
296
                    	<?=replaceEmpty($data_series[$i]->modality)?>
297
                	</td>
298
               <?php 
299
                }
300
                ?>
301
			</tr>
302
			<tr>
303
				<td>Acquisition Date Time</td>
304
				<?php 
305
                for ($i=0; $i < $series_number; $i++) {
306
                    ?>
307
                    <td>
308
                    	<?=replaceEmpty($data_series[$i]->acquisitionDateTime)?>
309
                	</td>
310
               <?php 
311
                }
312
                ?>
313
   			</tr>
314
			<tr>
315
				<td>Total Dose (MBq)</td>
316
				<?php 
317
                for ($i = 0; $i < $series_number; $i ++) {
318
                    ?>
319
                    <td>
320
                    <?php if (empty($data_series[$i]->injectedDose)){
321
                        echo('/');
322
                    } else{
323
                        echo(htmlspecialchars($data_series[$i]->injectedDose / 10 ** 6));
324
                    }
325
                    ?>
326
                    </td>
327
                <?php
328
				}
329
                ?>
330
			</tr>
331
			<tr>
332
				<td>Radiopharmaceutical</td>
333
				<?php 
334
                for ($i=0; $i < $series_number; $i++) {
335
                    ?>
336
                    <td>
337
                    	<?=replaceEmpty($data_series[$i]->radiopharmaceutical)?>
338
                	</td>
339
               <?php 
340
                }
341
                ?>
342
			</tr>
343
			<tr>
344
				<td>Injection Date Time</td>
345
				<?php 
346
                for ($i=0; $i < $series_number; $i++) {
347
                    ?>
348
                    <td>
349
                    	<?=replaceEmpty($data_series[$i]->injectedDateTime)?>
350
                	</td>
351
               <?php 
352
                }
353
                ?>
354
			</tr>
355
			<tr>
356
				<td>Radiopharm. Specific Activity (MBq)</td>
357
				<?php 
358
                for ($i = 0; $i < $series_number; $i ++) {
359
                    ?>
360
                    <td>
361
                    <?php if (empty($data_series[$i]->injectedActivity)){
362
                        echo('/');
363
                    } else{
364
                        echo(htmlspecialchars($data_series[$i]->injectedActivity / 10 ** 6));
365
                    }
366
                    ?>
367
                    </td>
368
                <?php
369
				}
370
                ?>
371
			</tr>
372
			<tr>
373
				<td>Half Life (s)</td>
374
				<?php 
375
                for ($i=0; $i < $series_number; $i++) {
376
                    ?>
377
                    <td>
378
                    	<?=replaceEmpty($data_series[$i]->halfLife)?>
379
                	</td>
380
				<?php 
381
                }
382
                ?>
383
			</tr>
384
			<tr>
385
				<td>Patient's Weight (kg)</td>
386
				<?php 
387
                for ($i=0; $i < $series_number; $i++) {
388
                    ?>
389
                    <td>
390
                    	<?=replaceEmpty($data_series[$i]->patientWeight)?>
391
                	</td>
392
				<?php 
393
                }
394
                ?>
395
			</tr>
396
			<tr>
397
				<td>Slice Count</td>
398
				<?php 
399
                for ($i=0; $i < $series_number; $i++) {
400
                    ?>
401
                    <td>
402
                    	<?=replaceEmpty($data_series[$i]->numberInstances)?>
403
                	</td>
404
				<?php 
405
                }
406
                ?>
407
			</tr>
408
			<tr>
409
				<td>Upload Date</td>
410
				<?php 
411
                for ($i=0; $i < $series_number; $i++) {
412
                    ?>
413
                    <td>
414
                    	<?=replaceEmpty($data_series[$i]->studyDetailsObject->uploadDate)?>
415
                	</td>
416
				<?php 
417
                }
418
                ?>
419
			</tr>
420
			<?php 
421
            if (($role == User::INVESTIGATOR || $role == User::CONTROLLER) && ($visitObject->stateQualityControl != Visit::QC_ACCEPTED && $visitObject->stateQualityControl != Visit::QC_REFUSED)) {
422
            ?><tr>
423
    	        <td>Delete</td>
424
            <?php 
425
            for ($i=0; $i < $series_number; $i++) {
426
                ?>
427
                <td>
428
                	<a href=scripts/change_series_deletion.php?action=delete&Series_Orthanc_Id=<?=htmlspecialchars($data_series[$i]->seriesOrthancID)?> class="ajaxLinkConfirm" ><input class="btn btn-danger" type="button" value="Delete Series"></a>
429
            	</td>
430
        	<?php 
431
            }
432
            ?>
433
           	</tr>
434
            <tr>
435
            	<td colspan="<?=$colspan?>">
436
            		<a href=scripts/change_series_deletion.php?action=delete&Series_Orthanc_Id=allVisit<?=$visitObject->id_visit?> class="ajaxLinkConfirm" ><input class="btn btn-danger" type="button" value="Delete All (Reset Upload)"></a>
437
        		</td>
438
    		</tr>
439
    	<?php 
440
		}?>
441
        </table> 
442
    </div>
443
<?php 
444
}
445
?>