Skip to content

Commit

Permalink
Add allow_upload_supervisor in study table and apis
Browse files Browse the repository at this point in the history
  • Loading branch information
salimkanoun committed Jun 11, 2024
1 parent 3b21f4a commit af0db63
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 6 deletions.
2 changes: 2 additions & 0 deletions GaelO2/app/GaelO/Entities/StudyEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class StudyEntity
public bool $documentationMandatory;
public bool $deleted;
public bool $creatablePatientsInvestigator;
public bool $allowSupervisorUploadDicom;
public ?string $ancillaryOf;

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

return $studyEntity;
Expand Down
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, bool $creatablePatientsInvestigator): void;
public function addStudy(String $name, string $code, int $patientCodeLength, string $contactEmail, bool $controllerShowAll, bool $monitorShowAll, bool $documentationMandatory, ?string $ancillaryOf, bool $creatablePatientsInvestigator, bool $allowSupervisorUploadDicom): void;

public function isExistingStudyName(string $name): bool;

Expand Down
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, bool $creatablePatientsInvestigator): void
public function addStudy(String $name, string $code, int $patientCodeLength, string $contactEmail, bool $controllerShowAll, bool $monitorShowAll, bool $documentationMandatory, ?string $ancillaryOf, bool $creatablePatientsInvestigator, bool $allowSupervisorUploadDicom): void
{
$study = new Study();
$study->name = $name;
Expand All @@ -39,6 +39,7 @@ public function addStudy(String $name, string $code, int $patientCodeLength, str
$study->documentation_mandatory = $documentationMandatory;
$study->ancillary_of = $ancillaryOf;
$study->creatable_patients_investigator = $creatablePatientsInvestigator;
$study->allow_supervisor_upload_dicom = $allowSupervisorUploadDicom;
$study->save();
}

Expand Down
7 changes: 6 additions & 1 deletion GaelO2/app/GaelO/UseCases/CreateStudy/CreateStudy.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function execute(CreateStudyRequest $createStudyRequest, CreateStudyRespo
$contactEmail = $createStudyRequest->contactEmail;
$ancillaryOf = $createStudyRequest->ancillaryOf;
$creatablePatientsInvestigator = $createStudyRequest->creatablePatientsInvestigator;
$allowSupervisorUploadDicom = $createStudyRequest->allowSupervisorUploadDicom;

if (preg_match('/[^A-Z0-9]/', $studyName)) {
throw new GaelOBadRequestException('Only uppercase alphanumerical name allowed, no space or special characters');
Expand Down Expand Up @@ -75,7 +76,11 @@ public function execute(CreateStudyRequest $createStudyRequest, CreateStudyRespo
throw new GaelOBadRequestException('Missing Creatable Patient Investigator');
}

$this->studyRepositoryInterface->addStudy($studyName, $studyCode, $patientCodeLength, $contactEmail, $controllerShowAll, $monitorShowAll, $documentationMandatory, $ancillaryOf, $creatablePatientsInvestigator);
if(!isset($allowSupervisorUploadDicom)){
throw new GaelOBadRequestException('Missing Allow Upload Dicom Supervisor');
}

$this->studyRepositoryInterface->addStudy($studyName, $studyCode, $patientCodeLength, $contactEmail, $controllerShowAll, $monitorShowAll, $documentationMandatory, $ancillaryOf, $creatablePatientsInvestigator, $allowSupervisorUploadDicom);

$currentUserId = $createStudyRequest->currentUserId;
$actionDetails = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ class CreateStudyRequest
public bool $documentationMandatory;
public ?string $ancillaryOf = null;
public bool $creatablePatientsInvestigator;
public bool $allowSupervisorUploadDicom;
}
10 changes: 10 additions & 0 deletions GaelO2/database/factories/StudyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function definition()
'documentation_mandatory' => false,
'ancillary_of' => null,
'creatable_patients_investigator' => false,
'allow_supervisor_upload_dicom' => false
];
}

Expand Down Expand Up @@ -93,4 +94,13 @@ public function creatablePatientsInvestigator()
];
});
}

public function allowSupervisorUploadDicom()
{
return $this->state(function (array $attributes) {
return [
'allow_supervisor_upload_dicom' => true,
];
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('studies', function (Blueprint $table) {
$table->boolean('allow_supervisor_upload_dicom')->default(false);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('studies', function (Blueprint $table) {
$table->dropColumn('allow_supervisor_upload_dicom');
});
}
};
3 changes: 2 additions & 1 deletion GaelO2/tests/Feature/TestStudy/CreateStudyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ protected function setUp(): void
'monitorShowAll' => false,
'documentationMandatory' => false,
'contactEmail' => '[email protected]',
'creatablePatientsInvestigator' => false
'creatablePatientsInvestigator' => false,
'allowSupervisorUploadDicom' => false,
];
}

Expand Down
2 changes: 2 additions & 0 deletions GaelO2/tests/Unit/TestRepositories/StudyRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public function testCreateStudy()
$this->assertFalse((bool) $studyEntity->documentation_mandatory);
$this->assertEquals(null, $studyEntity->ancillary_of);
$this->assertFalse((bool) $studyEntity->creatable_patients_investigator);
$this->assertFalse((bool) $studyEntity->allow_supervisor_upload_dicom);

}

public function testIsExistingStudy()
Expand Down
4 changes: 2 additions & 2 deletions GaelO2/tests/Unit/TestServices/VisitTreeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ protected function setUp(): void
'documentation_mandatory' => false,
'ancillary_of' => null,
'deleted_at' => null,
'creatable_patients_investigator' => false

'creatable_patients_investigator' => false,
'allow_supervisor_upload_dicom' => false
]));


Expand Down

0 comments on commit af0db63

Please sign in to comment.