Skip to content

Commit b43d8ff

Browse files
authored
Merge pull request #741 from Pixilib/GaelO2-dev
Gael o2 dev
2 parents 8f1fbcb + 0c08cc8 commit b43d8ff

File tree

11 files changed

+378
-92
lines changed

11 files changed

+378
-92
lines changed

GaelO2/app/GaelO/Services/OrthancService.php

-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ private function removeSC(string $orthancStudyID)
332332
foreach ($seriesObjects as $serie) {
333333
if ($serie->isSecondaryCapture()) {
334334
$this->deleteFromOrthanc("series", $serie->serieOrthancID);
335-
error_log("Deleted SC");
336335
}
337336
}
338337
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
Copyright (C) 2018-2020 KANOUN Salim
45
This program is free software; you can redistribute it and/or modify
@@ -18,11 +19,12 @@
1819
use App\GaelO\Constants\Constants;
1920
use App\GaelO\Services\OrthancService;
2021

21-
Class OrthancSeries {
22+
class OrthancSeries
23+
{
2224

23-
private OrthancService $orthancService;
25+
private OrthancService $orthancService;
2426

25-
public string $seriesOrthancID;
27+
public string $seriesOrthancID;
2628

2729
public string $parentStudyOrthancID;
2830
public ?string $manufacturer;
@@ -40,99 +42,104 @@
4042
public int $diskSizeMb;
4143
public int $uncompressedSizeMb;
4244
public $patientWeight;
43-
public $injectedDose;
44-
public $injectedTime;
45+
public $injectedDose;
46+
public $injectedTime;
4547
public $injectedDateTime;
4648
public $radiopharmaceutical;
4749
public $halfLife;
4850
public string $sopClassUid;
4951

50-
public function __construct(OrthancService $orthancService) {
51-
$this->orthancService=$orthancService;
52-
}
52+
public function __construct(OrthancService $orthancService)
53+
{
54+
$this->orthancService = $orthancService;
55+
}
5356

54-
public function setSeriesOrthancID(string $seriesOrthancID){
55-
$this->seriesOrthancID=$seriesOrthancID;
56-
}
57+
public function setSeriesOrthancID(string $seriesOrthancID)
58+
{
59+
$this->seriesOrthancID = $seriesOrthancID;
60+
}
5761

5862
/**
5963
*Get Series related data and store them in this object
6064
*/
61-
public function retrieveSeriesData() {
62-
$seriesDetails=$this->orthancService->getOrthancRessourcesDetails(Constants::ORTHANC_SERIES_LEVEL, $this->seriesOrthancID);
65+
public function retrieveSeriesData()
66+
{
67+
$seriesDetails = $this->orthancService->getOrthancRessourcesDetails(Constants::ORTHANC_SERIES_LEVEL, $this->seriesOrthancID);
6368

6469
//add needed informations in the current object
65-
$this->manufacturer=$seriesDetails['MainDicomTags']['Manufacturer'] ?? null;
66-
$this->modality=$seriesDetails['MainDicomTags']['Modality'] ?? null;
67-
$this->seriesDate=$seriesDetails['MainDicomTags']['SeriesDate'] ?? null;
68-
$this->seriesTime=$seriesDetails['MainDicomTags']['SeriesTime'] ?? null;
69-
$this->seriesDescription=$seriesDetails['MainDicomTags']['SeriesDescription'] ?? null;
70-
$this->seriesInstanceUID=$seriesDetails['MainDicomTags']['SeriesInstanceUID'];
71-
$this->seriesNumber=$seriesDetails['MainDicomTags']['SeriesNumber'] ?? null;
72-
$this->seriesIsStable=$seriesDetails['IsStable'];
73-
$this->parentStudyOrthancID=$seriesDetails['ParentStudy'];
74-
$this->seriesInstances=$seriesDetails['Instances'];
75-
$this->numberOfInstanceInOrthanc=sizeof($seriesDetails['Instances']);
76-
$this->lastUpdate=$seriesDetails['LastUpdate'];
70+
$this->manufacturer = $seriesDetails['MainDicomTags']['Manufacturer'] ?? null;
71+
$this->modality = $seriesDetails['MainDicomTags']['Modality'] ?? null;
72+
$this->seriesDate = $seriesDetails['MainDicomTags']['SeriesDate'] ?? null;
73+
$this->seriesTime = $seriesDetails['MainDicomTags']['SeriesTime'] ?? null;
74+
$this->seriesDescription = $seriesDetails['MainDicomTags']['SeriesDescription'] ?? null;
75+
$this->seriesInstanceUID = $seriesDetails['MainDicomTags']['SeriesInstanceUID'];
76+
$this->seriesNumber = $seriesDetails['MainDicomTags']['SeriesNumber'] ?? null;
77+
$this->seriesIsStable = $seriesDetails['IsStable'];
78+
$this->parentStudyOrthancID = $seriesDetails['ParentStudy'];
79+
$this->seriesInstances = $seriesDetails['Instances'];
80+
$this->numberOfInstanceInOrthanc = sizeof($seriesDetails['Instances']);
81+
$this->lastUpdate = $seriesDetails['LastUpdate'];
7782

7883
//add instance data using the first Instance Orthanc ID
7984
$this->retrieveInstancesData($seriesDetails['Instances'][0]);
8085

8186
//add statistics data
8287
$this->retrieveSeriesStatistics();
83-
8488
}
8589

8690
/**
8791
* Get statistics of the series (size in MB)
8892
*/
89-
private function retrieveSeriesStatistics() {
90-
$statistics=$this->orthancService->getOrthancRessourcesStatistics(Constants::ORTHANC_SERIES_LEVEL, $this->seriesOrthancID);
91-
$this->diskSizeMb=$statistics['DiskSizeMB'];
92-
$this->uncompressedSizeMb=$statistics['UncompressedSizeMB'];
93+
private function retrieveSeriesStatistics()
94+
{
95+
$statistics = $this->orthancService->getOrthancRessourcesStatistics(Constants::ORTHANC_SERIES_LEVEL, $this->seriesOrthancID);
96+
$this->diskSizeMb = $statistics['DiskSizeMB'];
97+
$this->uncompressedSizeMb = $statistics['UncompressedSizeMB'];
9398
}
9499

95100
/**
96101
* Store some data only available in the Instance level
97102
* @param $instanceID
98103
*/
99-
private function retrieveInstancesData($instanceOrthancID) {
104+
private function retrieveInstancesData($instanceOrthancID)
105+
{
100106
$instanceTags = $this->orthancService->getInstanceTags($instanceOrthancID);
101-
$this->patientWeight=is_numeric($instanceTags->getPatientWeight()) ? $instanceTags->getPatientWeight() : null;
107+
$this->patientWeight = is_numeric($instanceTags->getPatientWeight()) ? $instanceTags->getPatientWeight() : null;
102108
$this->modelName = $instanceTags->getModelName();
103109
$this->injectedDose = is_numeric($instanceTags->getInjectedDose()) ? $instanceTags->getInjectedDose() : null;
104-
$this->injectedTime = $instanceTags->getInjectedTime();
105-
$this->injectedDateTime = $instanceTags->getInjectedDateTime();
110+
$this->injectedTime = $instanceTags->getInjectedTime();
111+
$this->injectedDateTime = $instanceTags->getInjectedDateTime();
106112
$this->radiopharmaceutical = $instanceTags->getRadiopharmaceutical();
107-
$this->halfLife=is_numeric($instanceTags->getHalfLife())? $instanceTags->getHalfLife() : null;
108-
$this->sopClassUid= $instanceTags->getSOPClassUID();
113+
$this->halfLife = is_numeric($instanceTags->getHalfLife()) ? $instanceTags->getHalfLife() : null;
114+
$this->sopClassUid = $instanceTags->getSOPClassUID();
109115
}
110116

111117
/**
112118
* Return if this serie in a secondary capture type
113119
* @return boolean
114120
*/
115-
public function isSecondaryCapture() {
116-
$scUids[]="1.2.840.10008.5.1.4.1.1.7";
117-
$scUids[]="1.2.840.10008.5.1.4.1.1.7.1";
118-
$scUids[]="1.2.840.10008.5.1.4.1.1.7.2";
119-
$scUids[]="1.2.840.10008.5.1.4.1.1.7.3";
120-
$scUids[]="1.2.840.10008.5.1.4.1.1.7.4";
121-
$scUids[]="1.2.840.10008.5.1.4.1.1.88.11";
122-
$scUids[]="1.2.840.10008.5.1.4.1.1.88.22";
123-
$scUids[]="1.2.840.10008.5.1.4.1.1.88.33";
124-
$scUids[]="1.2.840.10008.5.1.4.1.1.88.40";
125-
$scUids[]="1.2.840.10008.5.1.4.1.1.88.50";
126-
$scUids[]="1.2.840.10008.5.1.4.1.1.88.59";
127-
$scUids[]="1.2.840.10008.5.1.4.1.1.88.65";
128-
$scUids[]="1.2.840.10008.5.1.4.1.1.88.67";
121+
public function isSecondaryCapture()
122+
{
123+
$scUids = [
124+
"1.2.840.10008.5.1.4.1.1.7",
125+
"1.2.840.10008.5.1.4.1.1.7.1",
126+
"1.2.840.10008.5.1.4.1.1.7.2",
127+
"1.2.840.10008.5.1.4.1.1.7.3",
128+
"1.2.840.10008.5.1.4.1.1.7.4",
129+
"1.2.840.10008.5.1.4.1.1.88.11",
130+
"1.2.840.10008.5.1.4.1.1.88.22",
131+
"1.2.840.10008.5.1.4.1.1.88.33",
132+
"1.2.840.10008.5.1.4.1.1.88.40",
133+
"1.2.840.10008.5.1.4.1.1.88.50",
134+
"1.2.840.10008.5.1.4.1.1.88.59",
135+
"1.2.840.10008.5.1.4.1.1.88.65",
136+
"1.2.840.10008.5.1.4.1.1.88.67"
137+
];
129138

130139
if (in_array($this->sopClassUid, $scUids)) {
131140
return true;
132141
} else {
133142
return false;
134143
}
135-
136144
}
137-
138145
}

GaelO2/app/Jobs/JobQcReport.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class JobQcReport implements ShouldQueue, ShouldBeUnique
2828
private int $visitId;
2929

3030
public $failOnTimeout = true;
31-
public $timeout = 300;
31+
public $timeout = 1200;
3232
public $tries = 1;
3333

3434
/**

GaelO2/tests/Feature/ReverseProxyTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ protected function setUp() : void{
3131

3232
$this->studyName = $this->orthancStudy->visit->patient->study->name;
3333

34-
$this->markTestSkipped('all tests in this file are invactive, this is only to check orthanc communication');
34+
$this->markTestSkipped('Needs Orthanc To Be Tested');
3535

3636
}
3737

GaelO2/tests/Feature/TestDicoms/ValidateDicomTest.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\GaelO\Constants\Constants;
66
use App\GaelO\Repositories\TrackerRepository;
7+
use App\GaelO\Services\OrthancService;
78
use App\GaelO\Services\TusService;
89
use App\Models\ReviewStatus;
910
use Illuminate\Foundation\Testing\RefreshDatabase;
@@ -18,6 +19,7 @@ class ValidateDicomTest extends TestCase
1819
use RefreshDatabase;
1920

2021
private MockInterface $trackerSpy;
22+
private MockInterface $orthancServiceSpy;
2123
private ReviewStatus $reviewStatus;
2224
private string $studyName;
2325
private int $visitId;
@@ -49,6 +51,9 @@ protected function setUp() : void{
4951
$this->numberOfInstances = 22;
5052
$this->trackerSpy = $this->spy(TrackerRepository::class);
5153
app()->instance(TrackerRepository::class, $this->trackerSpy);
54+
55+
$this->orthancServiceSpy = $this->spy(OrthancService::class);
56+
app()->instance(OrthancService::class, $this->orthancServiceSpy);
5257
}
5358

5459

@@ -65,7 +70,7 @@ public function testValidateDicom()
6570
$response = $this->json('POST', 'api/visits/'.$this->visitId.'/validate-dicom', $payload);
6671
$response->assertStatus(200);
6772
$this->trackerSpy->shouldHaveReceived('writeAction')->once()->with($currentUserId, Constants::ROLE_INVESTIGATOR, Mockery::any(), Mockery::any(), Constants::TRACKER_UPLOAD_SERIES, Mockery::any());
68-
73+
$this->orthancServiceSpy->shouldHaveReceived('anonymize')->once();
6974
}
7075

7176
public function testValidateDicomShouldBeForbidden()

GaelO2/tests/Feature/TestExportDb/ExportDbTest.php

+17-2
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,45 @@
22

33
namespace Tests\Feature\TestExportDb;
44

5+
use App\GaelO\Adapters\DatabaseDumperAdapter;
56
use Tests\TestCase;
67
use Illuminate\Foundation\Testing\RefreshDatabase;
8+
use Illuminate\Support\Facades\Storage;
9+
use Mockery\MockInterface;
710
use Tests\AuthorizationTools;
811

912
class ExportDbTest extends TestCase
1013
{
1114
use RefreshDatabase;
15+
private MockInterface $dbDumperSpy;
1216

1317
protected function setUp() : void {
1418
parent::setUp();
1519
$this->artisan('db:seed');
20+
$this->dbDumperSpy = $this->spy(DatabaseDumperAdapter::class);
21+
app()->instance(DatabaseDumperAdapter::class, $this->dbDumperSpy);
1622
}
1723

1824
public function testExportDb()
1925
{
26+
Storage::fake();
27+
Storage::spy();
28+
Storage::shouldReceive('allFiles')
29+
->once()
30+
->andReturn([]);
2031
AuthorizationTools::actAsAdmin(true);
21-
$response = $this->get('/api/export-db', []);
32+
$response = $this->get('/api/export-db');
2233
$response->assertStatus(200);
34+
ob_start();
35+
$response->sendContent();
36+
ob_get_clean();
37+
$this->dbDumperSpy->shouldHaveReceived('createDatabaseDumpFile')->once();
2338
}
2439

2540
public function testExportDbShouldBeForbiddenNotAdmin()
2641
{
2742
AuthorizationTools::actAsAdmin(false);
28-
$response = $this->get('/api/export-db', []);
43+
$response = $this->get('/api/export-db');
2944
$response->assertStatus(403);
3045
}
3146
}

0 commit comments

Comments
 (0)