Skip to content

Commit

Permalink
Merge pull request #669 from Pixilib/GaelO2-dev
Browse files Browse the repository at this point in the history
Gael o2 dev
  • Loading branch information
salimkanoun authored Jul 2, 2023
2 parents 16d088e + 5aaa69a commit dabd27c
Show file tree
Hide file tree
Showing 13 changed files with 644 additions and 523 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: 'publish'
on:
push:
branches:
- Gaelo2
- Gaelo2-dev
- GaelO2
- GaelO2-dev
tags:
- '*'

Expand Down
7 changes: 7 additions & 0 deletions GaelO2/app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\GaelO\CronJobs\GaelOScheduler;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Illuminate\Support\Facades\Log;

class Kernel extends ConsoleKernel
{
Expand All @@ -29,6 +30,12 @@ protected function schedule(Schedule $schedule)
$schedule->command('cache:prune-stale-tags')->hourly();
//Register custom jobs
GaelOScheduler::registerScheduledJobs($schedule);
//Scheduler Probe for monitoring
$schedule->call(function () {
Log::info("Scheduler Probe");
})
->hourly()
->sentryMonitor('gaelo-scheduler');
}

/**
Expand Down
8 changes: 8 additions & 0 deletions GaelO2/app/GaelO/Services/OrthancService.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ public function getJobDetails(String $jobId)
return $this->httpClientInterface->requestJson('GET', '/jobs/' . $jobId)->getJsonBody();
}

/**
* Get System api (check liviness)
*/
public function getSystem()
{
return $this->httpClientInterface->requestJson('GET', '/system')->getJsonBody();
}

public function getStudyOrthancDetails(string $orthancStudyID)
{
$studyOrthanc = new OrthancStudy($this);
Expand Down
12 changes: 11 additions & 1 deletion GaelO2/app/GaelO/UseCases/DeleteSeries/DeleteSeries.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

use App\GaelO\Constants\Constants;
use App\GaelO\Constants\Enums\QualityControlStateEnum;
use App\GaelO\Constants\Enums\ReviewStatusEnum;
use App\GaelO\Exceptions\AbstractGaelOException;
use App\GaelO\Exceptions\GaelOBadRequestException;
use App\GaelO\Exceptions\GaelOForbiddenException;
use App\GaelO\Interfaces\Repositories\DicomSeriesRepositoryInterface;
use App\GaelO\Interfaces\Repositories\ReviewStatusRepositoryInterface;
use App\GaelO\Interfaces\Repositories\TrackerRepositoryInterface;
use App\GaelO\Interfaces\Repositories\VisitRepositoryInterface;
use App\GaelO\Services\AuthorizationService\AuthorizationVisitService;
use App\GaelO\Services\DicomService;
use Exception;

class DeleteSeries
{
Expand All @@ -22,11 +23,13 @@ class DeleteSeries
private TrackerRepositoryInterface $trackerRepositoryInterface;
private AuthorizationVisitService $authorizationVisitService;
private DicomSeriesRepositoryInterface $dicomSeriesRepositoryInterface;
private ReviewStatusRepositoryInterface $reviewStatusRepositoryInterface;


public function __construct(
VisitRepositoryInterface $visitRepositoryInterface,
DicomSeriesRepositoryInterface $dicomSeriesRepositoryInterface,
ReviewStatusRepositoryInterface $reviewStatusRepositoryInterface,
DicomService $dicomService,
AuthorizationVisitService $authorizationVisitService,
TrackerRepositoryInterface $trackerRepositoryInterface
Expand All @@ -36,6 +39,7 @@ public function __construct(
$this->dicomService = $dicomService;
$this->trackerRepositoryInterface = $trackerRepositoryInterface;
$this->visitRepositoryInterface = $visitRepositoryInterface;
$this->reviewStatusRepositoryInterface = $reviewStatusRepositoryInterface;
}

public function execute(DeleteSeriesRequest $deleteSeriesRequest, DeleteSeriesResponse $deleteSeriesResponse)
Expand Down Expand Up @@ -111,6 +115,12 @@ public function checkAuthorization(int $userId, int $visitId, string $role, stri
throw new GaelOForbiddenException();
}

//If review started can't remove series
$reviewStatusEntity = $this->reviewStatusRepositoryInterface->getReviewStatus($visitId, $studyName);
if (!in_array($reviewStatusEntity['review_status'], array(ReviewStatusEnum::NOT_DONE->value, ReviewStatusEnum::NOT_NEEDED->value))) {
throw new GaelOForbiddenException("Delete Review first to remove series");
}

$this->authorizationVisitService->setUserId($userId);
$this->authorizationVisitService->setVisitId($visitId);
$this->authorizationVisitService->setStudyName($studyName);
Expand Down
49 changes: 49 additions & 0 deletions GaelO2/app/GaelO/UseCases/GetReadiness/GetReadiness.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace App\GaelO\UseCases\GetReadiness;

use App\GaelO\Exceptions\AbstractGaelOException;
use App\GaelO\Interfaces\Repositories\CountryRepositoryInterface;
use App\GaelO\Services\OrthancService;
use Exception;

class GetReadiness
{

private OrthancService $orthancService;
private CountryRepositoryInterface $countryRepositoryInterface;

public function __construct(OrthancService $orthancService, CountryRepositoryInterface $countryRepositoryInterface)
{
$this->orthancService = $orthancService;
$this->countryRepositoryInterface = $countryRepositoryInterface;
}

public function execute(GetReadinessRequest $getReadinessRequest, GetReadinessResponse $getReadinessResponse)
{
try {

$countries = $this->countryRepositoryInterface->getAllCountries();

if(sizeof($countries) === 0){
throw new Exception("Missing countries record");
}

$this->orthancService->setOrthancServer(true);
$this->orthancService->getSystem();

$this->orthancService->setOrthancServer(false);
$this->orthancService->getSystem();

$getReadinessResponse->status = '200';
$getReadinessResponse->statusText = 'OK';

} catch (AbstractGaelOException $e) {
$getReadinessResponse->body = $e->getErrorBody();
$getReadinessResponse->status = $e->statusCode;
$getReadinessResponse->statusText = $e->statusText;
} catch (Exception $e) {
throw $e;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace App\GaelO\UseCases\GetReadiness;

class GetReadinessRequest
{
}
10 changes: 10 additions & 0 deletions GaelO2/app/GaelO/UseCases/GetReadiness/GetReadinessResponse.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\GaelO\UseCases\GetReadiness;

class GetReadinessResponse
{
public $body = null;
public int $status;
public string $statusText;
}
9 changes: 9 additions & 0 deletions GaelO2/app/Http/Controllers/ToolsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
use App\GaelO\UseCases\FindUser\FindUser;
use App\GaelO\UseCases\FindUser\FindUserRequest;
use App\GaelO\UseCases\FindUser\FindUserResponse;
use App\GaelO\UseCases\GetReadiness\GetReadiness;
use App\GaelO\UseCases\GetReadiness\GetReadinessRequest;
use App\GaelO\UseCases\GetReadiness\GetReadinessResponse;
use App\GaelO\Util;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
Expand Down Expand Up @@ -64,4 +67,10 @@ public function findUser(Request $request,
return $this->getJsonResponse($findUserResponse->body, $findUserResponse->status, $findUserResponse->statusText);

}

public function readiness(GetReadiness $getReadiness, GetReadinessRequest $getReadinessRequest, GetReadinessResponse $getReadinessResponse)
{
$getReadiness->execute($getReadinessRequest, $getReadinessResponse);
return $this->getJsonResponse($getReadinessResponse->body, $getReadinessResponse->status, $getReadinessResponse->statusText);
}
}
Loading

0 comments on commit dabd27c

Please sign in to comment.