Skip to content

Commit

Permalink
Merge pull request #701 from Pixilib/GaelO2-dev
Browse files Browse the repository at this point in the history
Gael o2 dev
  • Loading branch information
salimkanoun committed Nov 1, 2023
2 parents 9793eee + 5ab745f commit 2f744e4
Show file tree
Hide file tree
Showing 146 changed files with 4,733 additions and 1,386 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- GaelO2
- GaelO2-dev
- tmtv-inference
tags:
- '*'

Expand All @@ -22,6 +23,7 @@ jobs:
with:
images: ghcr.io/pixilib/gaelo
tags: |
type=ref,event=branch
type=ref,event=tag
v2-latest
Expand Down
24 changes: 12 additions & 12 deletions GaelO2/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

TUS_URL = 'http://localhost:1080'
TUS_URL='http://localhost:1080'

ORTHANC_TEMPORARY_URL = 'http://localhost:8042'
ORTHANC_TEMPORARY_LOGIN = 'login'
ORTHANC_TEMPORARY_PASSWORD = 'password'
ORTHANC_TEMPORARY_URL='http://localhost:8042'
ORTHANC_TEMPORARY_LOGIN='login'
ORTHANC_TEMPORARY_PASSWORD='password'

ORTHANC_STORAGE_URL = 'http://localhost:8043'
ORTHANC_STORAGE_LOGIN = 'login'
ORTHANC_STORAGE_PASSWORD = 'password'
ORTHANC_STORAGE_URL='http://localhost:8043'
ORTHANC_STORAGE_LOGIN='login'
ORTHANC_STORAGE_PASSWORD='password'

GAELO_PROCESSING_PROTOCOL='http://'
GAELO_PROCESSING_HOST = 'gaeloprocessing'
GAELO_PROCESSING_PORT= '8000'
GAELO_PROCESSING_URL='http://gaeloprocessing:8000'
GAELO_PROCESSING_LOGIN='login'
GAELO_PROCESSING_PASSWORD='password'

AZURE_CLIENT_ID =''
AZURE_DIRECTORY_ID =''
AZURE_CLIENT_ID=''
AZURE_DIRECTORY_ID=''
AZURE_CLIENT_SECRET=''
AZURE_SUBSCRIPTION_ID=''
AZURE_CONTAINER_GROUP=''
Expand Down
2 changes: 1 addition & 1 deletion GaelO2/app/GaelO/Adapters/FrameworkAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function sendRegisteredEventForEmailVerification(int $userId): voi
public static function sendResetPasswordLink(string $email): bool
{
$status = Password::sendResetLink(
['email' => $email]
['email' => strtolower($email)]
);

return $status === Password::RESET_LINK_SENT;
Expand Down
28 changes: 24 additions & 4 deletions GaelO2/app/GaelO/Adapters/HttpClientAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ public function setBasicAuthentication(string $login, string $password): void
$this->password = $password;
}

public function uploadFile(string $method, string $uri, string $filename): Psr7ResponseInterface
{
$fileHandler = fopen($filename, 'rb');
$headers = [
'auth' => [$this->login, $this->password],
'content-type' => 'application/zip',
'body' => $fileHandler
];

$response = $this->client->request($method, $this->address . $uri, $headers);
return new Psr7ResponseAdapter($response);
}

public function requestUploadArrayDicom(string $method, string $uri, array $files): array
{

Expand All @@ -71,15 +84,15 @@ public function requestUploadArrayDicom(string $method, string $uri, array $file
},
'rejected' => function (RequestException $exception, $index) {
$reason = "Error sending dicom to orthanc";

if ($exception->hasResponse()) {
$reason = $exception->getResponse()->getStatusCode();
Log::error($exception->getResponse()->getBody()->getContents());
} else {
$reason = $exception->getMessage();
}
// this is delivered each failed request
Log::error('DICOM Import Failed in Orthanc Temporary: '.$reason. ' index: '.$index);
Log::error('DICOM Import Failed in Orthanc Temporary: ' . $reason . ' index: ' . $index);
},
]);

Expand All @@ -95,7 +108,14 @@ public function requestUploadArrayDicom(string $method, string $uri, array $file

public function requestJson(string $method, string $uri, array $body = []): Psr7ResponseInterface
{
$authenticationOption = ['auth' => [$this->login, $this->password]];
if ($this->login !== '' && $this->password !== '') {
$authenticationOption['auth'] = [$this->login, $this->password];
}

if ($this->authorizationToken != null) {
$authenticationOption['headers']['Authorization'] = 'Bearer ' . $this->authorizationToken;
}

$bodyOption = ['json' => $body];
$options = array_merge($authenticationOption, $bodyOption);
$response = $this->client->request($method, $this->address . $uri, $options);
Expand Down Expand Up @@ -135,7 +155,7 @@ public function requestStreamResponseToFile(string $method, string $uri, $ressou
return new Psr7ResponseAdapter($response);
}

public function rowRequest(string $method, string $uri, $body, ?array $headers, $ressourceDestination = null, $httpErrors = true): Psr7ResponseInterface
public function rawRequest(string $method, string $uri, $body, ?array $headers, $ressourceDestination = null, $httpErrors = true): Psr7ResponseInterface
{
$options = [];

Expand Down
6 changes: 6 additions & 0 deletions GaelO2/app/GaelO/Adapters/JobAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@

use App\GaelO\Interfaces\Adapters\JobInterface;
use App\Jobs\JobQcReport;
use App\Jobs\JobRadiomicsReport;

class JobAdapter implements JobInterface
{
public function sendQcReportJob(int $visitId): void
{
JobQcReport::dispatch($visitId);
}

public function sendRadiomicsReport(int $visitId, int $behalfUserId): void
{
JobRadiomicsReport::dispatch($visitId, $behalfUserId);
}
}
8 changes: 8 additions & 0 deletions GaelO2/app/GaelO/Adapters/MailerAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
use App\GaelO\Interfaces\Adapters\MailerInterface;
use App\Mail\QcReport;
use App\Mail\ImportPatient;
use App\Mail\JobFailure;
use App\Mail\MagicLink;
use App\Mail\RadiomicsReport;
use App\Mail\RequestPatientCreation;
use App\Mail\UserCreated;
use Illuminate\Mail\Mailable;
Expand Down Expand Up @@ -158,6 +160,12 @@ private function getModel(int $model): Mailable
case MailConstants::EMAIL_REQUEST_PATIENT_CREATION:
$model = new RequestPatientCreation($this->parameters);
break;
case MailConstants::EMAIL_RADIOMICS_REPORT:
$model = new RadiomicsReport($this->parameters);
break;
case MailConstants::EMAIL_JOB_FAILURE:
$model = new JobFailure($this->parameters);
break;
default:
throw new GaelOException("Unkown Mail Type");
break;
Expand Down
14 changes: 8 additions & 6 deletions GaelO2/app/GaelO/Adapters/MimeAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
namespace App\GaelO\Adapters;

use App\GaelO\Interfaces\Adapters\MimeInterface;
use Mimey\MimeTypes;
use Illuminate\Support\Facades\Log;
use League\MimeTypeDetection\ExtensionMimeTypeDetector;
use League\MimeTypeDetection\GeneratedExtensionToMimeTypeMap;

class MimeAdapter implements MimeInterface
{

public static function getExtensionsFromMime(string $mime): array
{
$mimes = new MimeTypes();
return $mimes->getAllExtensions($mime);
$mimes = new ExtensionMimeTypeDetector();
return $mimes->lookupAllExtensions($mime);
}

public static function getMimesFromExtension(string $extension): array
public static function getMimeFromExtension(string $extension): string
{
$mimes = new MimeTypes();
return $mimes->getAllMimeTypes($extension);
$mimes = new GeneratedExtensionToMimeTypeMap();
return $mimes->lookupMimeType($extension);
}
}
16 changes: 16 additions & 0 deletions GaelO2/app/GaelO/Adapters/PdfAdapter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\GaelO\Adapters;

use App\GaelO\Interfaces\Adapters\PdfInterface;
use Barryvdh\DomPDF\Facade\Pdf;

class PdfAdapter implements PdfInterface
{

public function saveViewToPdf(string $view, array $parameters, string $filename): void
{
$pdf = Pdf::loadView('mails.mail_radiomics_report', $parameters)->setOption('defaultFont', 'sans-serif');
$pdf->save($filename);
}
}
6 changes: 6 additions & 0 deletions GaelO2/app/GaelO/Adapters/Psr7ResponseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\GaelO\Interfaces\Adapters\Psr7ResponseInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;

class Psr7ResponseAdapter implements Psr7ResponseInterface
{
Expand All @@ -20,6 +21,11 @@ public function getStatusCode(): int
return $this->response->getStatusCode();
}

public function getStream(): StreamInterface
{
return $this->response->getBody();
}

public function getBody(): string
{
return $this->response->getBody()->getContents();
Expand Down
1 change: 1 addition & 0 deletions GaelO2/app/GaelO/Constants/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Constants
const TRACKER_CREATE_VISIT = "Create Visit";
const TRACKER_UPLOAD_SERIES = "Upload Series";
const TRACKER_UPDATE_VISIT_DATE = "Update Visit Date";
const TRACKER_UPDATE_VISIT_FILE = "Update Visit File";
const TRACKER_UPLOAD_VALIDATION_FAILED = "Upload Failed";
const TRACKER_ASK_UNLOCK = "Ask Unlock Form";
const TRACKER_UNLOCK_INVESTIGATOR_FORM = "Unlock Investigator Form";
Expand Down
2 changes: 2 additions & 0 deletions GaelO2/app/GaelO/Constants/MailConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ class MailConstants {
const EMAIL_UNLOCK_QC_REQUEST=22;
const EMAIL_QC_REPORT = 23;
const EMAIL_REQUEST_PATIENT_CREATION = 24;
const EMAIL_RADIOMICS_REPORT = 25;
const EMAIL_JOB_FAILURE = 26;
}
6 changes: 3 additions & 3 deletions GaelO2/app/GaelO/Constants/SettingsConstants.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class SettingsConstants {
const ORTHANC_STORAGE_LOGIN = 'orthanc_storage_login';
const ORTHANC_STORAGE_PASSWORD = 'orthanc_storage_password';

const GAELO_PROCESSING_PROTOCOL='gaelo_processing_protocol';
const GAELO_PROCESSING_HOST = 'gaelo_processing_host';
const GAELO_PROCESSING_PORT= 'gaelo_processing_port';
const GAELO_PROCESSING_URL='gaelo_processing_url';
const GAELO_PROCESSING_LOGIN='gaelo_processing_login';
const GAELO_PROCESSING_PASSWORD='gaelo_processing_password';

const AZURE_CLIENT_ID ='azure_client_id';
const AZURE_DIRECTORY_ID ='azure_directory_id';
Expand Down
4 changes: 2 additions & 2 deletions GaelO2/app/GaelO/Entities/ReviewEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public static function fillFromDBReponseArray(array $array): ReviewEntity
$reviewEntity = new ReviewEntity();
$reviewEntity->local = $array['local'];
$reviewEntity->id = $array['id'];
$reviewEntity->study_name = $array['study_name'];
$reviewEntity->studyName = $array['study_name'];
$reviewEntity->userId = $array['user_id'];
$reviewEntity->date = $array['review_date'];
$reviewEntity->visitId = $array['visit_id'];
$reviewEntity->validated = $array['validated'];
$reviewEntity->data = $array['review_data'];
$reviewEntity->files = $array['sent_files'];
$reviewEntity->files = $array['sent_files'] ?? [];
$reviewEntity->adjudication = $array['adjudication'];
return $reviewEntity;
}
Expand Down
2 changes: 2 additions & 0 deletions GaelO2/app/GaelO/Entities/StudyEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class StudyEntity
public bool $monitorShowAll;
public bool $documentationMandatory;
public bool $deleted;
public bool $creatablePatientsInvestigator;
public ?string $ancillaryOf;

//Array of VisitGroupEntities
Expand All @@ -29,6 +30,7 @@ public static function fillFromDBReponseArray(array $array) : StudyEntity
$studyEntity->monitorShowAll = $array['monitor_show_all'];
$studyEntity->ancillaryOf = $array['ancillary_of'];
$studyEntity->documentationMandatory = $array['documentation_mandatory'];
$studyEntity->creatablePatientsInvestigator = $array['creatable_patients_investigator'];
$studyEntity->deleted = $array['deleted_at'] !== null;

return $studyEntity;
Expand Down
2 changes: 2 additions & 0 deletions GaelO2/app/GaelO/Entities/VisitEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class VisitEntity
public ?bool $correctiveActionInvestigatorForm;
public ?string $correctiveActionOther;
public ?bool $correctiveActionDecision;
public array $files;
public ?string $deletedAt;

public VisitGroupEntity $visitGroup;
Expand Down Expand Up @@ -70,6 +71,7 @@ public static function fillFromDBReponseArray(array $array): VisitEntity
$visitEntity->correctiveActionInvestigatorForm = $array['corrective_action_investigator_form'];
$visitEntity->correctiveActionOther = $array['corrective_action_comment'];
$visitEntity->correctiveActionDecision = $array['corrective_action_applied'];
$visitEntity->files = $array['sent_files'] ?? [];
$visitEntity->deletedAt = $array['deleted_at'];
return $visitEntity;
}
Expand Down
3 changes: 2 additions & 1 deletion GaelO2/app/GaelO/Interfaces/Adapters/HttpClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ public function setAuthorizationToken(string $authorizationToken): void;

public function setBasicAuthentication(string $login, string $password): void;

public function rowRequest(string $method, string $uri, $body, ?array $headers, $ressourceDestination = null, $httpErrors = true): Psr7ResponseInterface;
public function rawRequest(string $method, string $uri, $body, ?array $headers, $ressourceDestination = null, $httpErrors = true): Psr7ResponseInterface;

public function uploadFile(string $method, string $uri, string $filename) : Psr7ResponseInterface;
/**
* Return array of PSR7 response adapter of multiple request, used to sent multiple files to an endpoint
*/
Expand Down
1 change: 1 addition & 0 deletions GaelO2/app/GaelO/Interfaces/Adapters/JobInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
interface JobInterface
{
public function sendQcReportJob(int $visitId) : void;
public function sendRadiomicsReport(int $visitId, int $behalfUserId) :void;
}
2 changes: 1 addition & 1 deletion GaelO2/app/GaelO/Interfaces/Adapters/MimeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

Interface MimeInterface{
public static function getExtensionsFromMime(string $mime) : array;
public static function getMimesFromExtension(string $extension) : array;
public static function getMimeFromExtension(string $extension) : string;
}
8 changes: 8 additions & 0 deletions GaelO2/app/GaelO/Interfaces/Adapters/PdfInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace App\GaelO\Interfaces\Adapters;

interface PdfInterface
{
public function saveViewToPdf(string $view, array $parameters, string $filename): void;
}
16 changes: 10 additions & 6 deletions GaelO2/app/GaelO/Interfaces/Adapters/Psr7ResponseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

namespace App\GaelO\Interfaces\Adapters;

Interface Psr7ResponseInterface {
public function getStatusCode() : int ;
public function getBody() : string ;
public function getReasonPhrase() :string ;
public function getHeaders() : array ;
public function getJsonBody() : array ;
use Psr\Http\Message\StreamInterface;

interface Psr7ResponseInterface
{
public function getStatusCode(): int;
public function getBody(): string;
public function getStream(): StreamInterface;
public function getReasonPhrase(): string;
public function getHeaders(): array;
public function getJsonBody(): array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function find($name): StudyEntity;

public function delete($name): void;

public function addStudy(String $name, string $code, int $patientCodeLength, string $contactEmail, bool $controllerShowAll, bool $monitorShowAll, bool $documentationMandatory, ?string $ancillaryOf): void;
public function addStudy(String $name, string $code, int $patientCodeLength, string $contactEmail, bool $controllerShowAll, bool $monitorShowAll, bool $documentationMandatory, ?string $ancillaryOf, bool $creatablePatientsInvestigator): void;

public function isExistingStudyName(string $name): bool;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,6 @@ public function getVisitsInVisitType(int $visitTypeId, bool $withReviewStatus =

public function getVisitContextByVisitIdArray(array $visitIdArray): array;

public function updateVisitFile(int $visitId, array $associatedFile): void;

}
3 changes: 2 additions & 1 deletion GaelO2/app/GaelO/Repositories/StudyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function delete($name): void
$this->studyModel->findOrFail($name)->delete();
}

public function addStudy(String $name, string $code, int $patientCodeLength, string $contactEmail, bool $controllerShowAll, bool $monitorShowAll, bool $documentationMandatory, ?string $ancillaryOf): void
public function addStudy(String $name, string $code, int $patientCodeLength, string $contactEmail, bool $controllerShowAll, bool $monitorShowAll, bool $documentationMandatory, ?string $ancillaryOf, bool $creatablePatientsInvestigator): void
{
$study = new Study();
$study->name = $name;
Expand All @@ -38,6 +38,7 @@ public function addStudy(String $name, string $code, int $patientCodeLength, str
$study->monitor_show_all = $monitorShowAll;
$study->documentation_mandatory = $documentationMandatory;
$study->ancillary_of = $ancillaryOf;
$study->creatable_patients_investigator = $creatablePatientsInvestigator;
$study->save();
}

Expand Down
Loading

0 comments on commit 2f744e4

Please sign in to comment.