From 2e1b5a3d0eea4309677bed074d73f5a09dd23119 Mon Sep 17 00:00:00 2001 From: brusnitsyn Date: Fri, 5 Dec 2025 18:04:02 +0900 Subject: [PATCH] =?UTF-8?q?*=20=D0=B7=D0=B0=D0=BA=D0=BE=D0=BD=D1=87=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D0=BA=D0=BD=D0=BE=20=D1=80=D0=B5=D0=B4=D0=B0?= =?UTF-8?q?=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=80=D1=82=D1=8B=20=D1=81=20=D0=BD=D0=B0=D0=B7?= =?UTF-8?q?=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=20=D0=BD=D0=BE?= =?UTF-8?q?=D0=BC=D0=B5=D1=80=D0=B0=20=D0=B2=20=D0=B0=D1=80=D1=85=D0=B8?= =?UTF-8?q?=D0=B2=D0=B5=20*=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BE=D0=BA=D0=BD=D0=BE=20=D0=B4=D0=BB=D1=8F=20=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B2=D1=8B=D0=B4=D0=B0=D1=87=D0=B8=20/=20?= =?UTF-8?q?=D0=B2=D0=BE=D0=B7=D0=B2=D1=80=D0=B0=D1=82=D0=B0=20=D0=BA=D0=B0?= =?UTF-8?q?=D1=80=D1=82=D1=8B=20*=20=D1=80=D0=B0=D0=B7=D0=B4=D1=80=D0=BE?= =?UTF-8?q?=D0=B1=D0=B8=D0=BB=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D1=83=20?= =?UTF-8?q?=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=B0?= =?UTF-8?q?=D1=80=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ArchiveHistoryController.php | 21 ++++ .../Controllers/MedicalHistoryController.php | 5 +- app/Http/Controllers/OrgController.php | 16 +++ app/Http/Resources/ArchiveHistoryResource.php | 30 +++++ app/Models/ArchiveHistory.php | 5 + app/Models/ArchiveInfo.php | 21 ++++ app/Models/ArchiveStatus.php | 16 +++ app/Models/Org.php | 1 + app/Models/SI/SttMedicalHistory.php | 6 + ...5_021415_add_code_column_in_orgs_table.php | 28 +++++ ...5_030600_create_archive_statuses_table.php | 29 +++++ ...2_05_030609_create_archive_infos_table.php | 31 +++++ database/seeders/ArchiveStatusSeeder.php | 31 +++++ database/seeders/DatabaseSeeder.php | 7 +- .../Pages/Home/ArchiveHistoryModal/Index.vue | 72 +++++++++-- .../Home/ArchiveHistoryMoveModal/Index.vue | 115 ++++++++++++++++++ routes/api.php | 10 ++ 17 files changed, 431 insertions(+), 13 deletions(-) create mode 100644 app/Http/Controllers/ArchiveHistoryController.php create mode 100644 app/Http/Controllers/OrgController.php create mode 100644 app/Http/Resources/ArchiveHistoryResource.php create mode 100644 app/Models/ArchiveInfo.php create mode 100644 app/Models/ArchiveStatus.php create mode 100644 database/migrations/2025_12_05_021415_add_code_column_in_orgs_table.php create mode 100644 database/migrations/2025_12_05_030600_create_archive_statuses_table.php create mode 100644 database/migrations/2025_12_05_030609_create_archive_infos_table.php create mode 100644 database/seeders/ArchiveStatusSeeder.php create mode 100644 resources/js/Pages/Home/ArchiveHistoryMoveModal/Index.vue diff --git a/app/Http/Controllers/ArchiveHistoryController.php b/app/Http/Controllers/ArchiveHistoryController.php new file mode 100644 index 0000000..07ac590 --- /dev/null +++ b/app/Http/Controllers/ArchiveHistoryController.php @@ -0,0 +1,21 @@ +json($archiveHistory); + } +} diff --git a/app/Http/Controllers/MedicalHistoryController.php b/app/Http/Controllers/MedicalHistoryController.php index a23fced..82512f5 100644 --- a/app/Http/Controllers/MedicalHistoryController.php +++ b/app/Http/Controllers/MedicalHistoryController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Http\Resources\ArchiveHistoryResource; use App\Models\SI\SttMedicalHistory; use Illuminate\Http\Request; @@ -15,11 +16,13 @@ class MedicalHistoryController extends Controller $patientInfo = null; if ($viewType == 'si') { $patient = SttMedicalHistory::where('id', $id)->first(); - $archiveJournal = $patient->archiveHistory; + $archiveJournal = ArchiveHistoryResource::collection($patient->archiveHistory); + $archiveInfo = $patient->archiveInfo; $patientInfo = [ 'info' => $patient, 'journal' => $archiveJournal, + 'archiveInfo' => $archiveInfo, ]; } diff --git a/app/Http/Controllers/OrgController.php b/app/Http/Controllers/OrgController.php new file mode 100644 index 0000000..2ced191 --- /dev/null +++ b/app/Http/Controllers/OrgController.php @@ -0,0 +1,16 @@ +json($orgs); + } +} diff --git a/app/Http/Resources/ArchiveHistoryResource.php b/app/Http/Resources/ArchiveHistoryResource.php new file mode 100644 index 0000000..63c6042 --- /dev/null +++ b/app/Http/Resources/ArchiveHistoryResource.php @@ -0,0 +1,30 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'id' => $this->id, + 'issue_at' => Carbon::parse($this->issue_at)->format('d.m.Y'), + 'return_at' => Carbon::parse($this->return_at)->format('d.m.Y'), + 'comment' => $this->comment, + 'org_id' => $this->org_id, + 'org' => $this->org->name, + 'employee_name' => $this->employee_name, + 'employee_post' => $this->employee_post, + 'has_lost' => $this->has_lost, + ]; + } +} diff --git a/app/Models/ArchiveHistory.php b/app/Models/ArchiveHistory.php index d4aa79d..e08605e 100644 --- a/app/Models/ArchiveHistory.php +++ b/app/Models/ArchiveHistory.php @@ -22,4 +22,9 @@ class ArchiveHistory extends Model { return $this->morphTo(); } + + public function org(): \Illuminate\Database\Eloquent\Relations\BelongsTo + { + return $this->belongsTo(Org::class); + } } diff --git a/app/Models/ArchiveInfo.php b/app/Models/ArchiveInfo.php new file mode 100644 index 0000000..d660e0b --- /dev/null +++ b/app/Models/ArchiveInfo.php @@ -0,0 +1,21 @@ +morphTo(); + } +} diff --git a/app/Models/ArchiveStatus.php b/app/Models/ArchiveStatus.php new file mode 100644 index 0000000..2edf9ee --- /dev/null +++ b/app/Models/ArchiveStatus.php @@ -0,0 +1,16 @@ +morphMany(ArchiveHistory::class, 'historyable'); } + public function archiveInfo() + { + return $this->morphOne(ArchiveInfo::class, 'historyable'); + } + public function scopeSearch($query, $searchText) { return $query->where(function($q) use ($searchText) { diff --git a/database/migrations/2025_12_05_021415_add_code_column_in_orgs_table.php b/database/migrations/2025_12_05_021415_add_code_column_in_orgs_table.php new file mode 100644 index 0000000..3a16b6d --- /dev/null +++ b/database/migrations/2025_12_05_021415_add_code_column_in_orgs_table.php @@ -0,0 +1,28 @@ +string('code')->after('id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('orgs', function (Blueprint $table) { + $table->dropColumn('code'); + }); + } +}; diff --git a/database/migrations/2025_12_05_030600_create_archive_statuses_table.php b/database/migrations/2025_12_05_030600_create_archive_statuses_table.php new file mode 100644 index 0000000..94e3167 --- /dev/null +++ b/database/migrations/2025_12_05_030600_create_archive_statuses_table.php @@ -0,0 +1,29 @@ +id(); + $table->string('text'); + $table->string('variant'); + $table->boolean('has_user_set')->default(false); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('archive_statuses'); + } +}; diff --git a/database/migrations/2025_12_05_030609_create_archive_infos_table.php b/database/migrations/2025_12_05_030609_create_archive_infos_table.php new file mode 100644 index 0000000..71122f0 --- /dev/null +++ b/database/migrations/2025_12_05_030609_create_archive_infos_table.php @@ -0,0 +1,31 @@ +id(); + $table->morphs('historyable'); + $table->string('num'); + $table->date('post_in'); + $table->foreignIdFor(\App\Models\ArchiveStatus::class, 'status_id')->default(1); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('archive_infos'); + } +}; diff --git a/database/seeders/ArchiveStatusSeeder.php b/database/seeders/ArchiveStatusSeeder.php new file mode 100644 index 0000000..9525fb6 --- /dev/null +++ b/database/seeders/ArchiveStatusSeeder.php @@ -0,0 +1,31 @@ + 'Не определен', + 'variant' => 'default' + ]); + + ArchiveStatus::create([ + 'text' => 'В архиве', + 'variant' => 'success' + ]); + + ArchiveStatus::create([ + 'text' => 'Выдана', + 'variant' => 'warning' + ]); + } +} diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 6b901f8..21c4c1d 100644 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -15,11 +15,8 @@ class DatabaseSeeder extends Seeder */ public function run(): void { - // User::factory(10)->create(); - - User::factory()->create([ - 'name' => 'Test User', - 'email' => 'test@example.com', + $this->call([ + ArchiveStatusSeeder::class, ]); } } diff --git a/resources/js/Pages/Home/ArchiveHistoryModal/Index.vue b/resources/js/Pages/Home/ArchiveHistoryModal/Index.vue index a924eaf..db98048 100644 --- a/resources/js/Pages/Home/ArchiveHistoryModal/Index.vue +++ b/resources/js/Pages/Home/ArchiveHistoryModal/Index.vue @@ -1,5 +1,6 @@ + + + + diff --git a/routes/api.php b/routes/api.php index 792eb33..7b87400 100644 --- a/routes/api.php +++ b/routes/api.php @@ -12,4 +12,14 @@ Route::prefix('si')->group(function () { Route::get('{id}', [\App\Http\Controllers\MedicalHistoryController::class, 'patient']); }); }); + +Route::prefix('archive')->group(function () { + Route::prefix('histories')->group(function () { + Route::get('{id}', [\App\Http\Controllers\ArchiveHistoryController::class, 'show']); + }); +}); + +Route::prefix('orgs')->group(function () { + Route::get('/', [\App\Http\Controllers\OrgController::class, 'index']); +}); //Route::get('')