From 717641e4bb1b4c756a5ade43ad8304b059d717ef Mon Sep 17 00:00:00 2001 From: brusnitsyn Date: Tue, 5 May 2026 17:06:15 +0900 Subject: [PATCH] =?UTF-8?q?*=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=B4=D0=B8=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D0=B9?= =?UTF-8?q?=20=D0=B4=D0=B2=D0=B8=D0=B6=D0=B5=D0=BD=D0=B8=D0=B9=20*=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=B0=D0=B2=D1=82?= =?UTF-8?q?=D0=BE=D0=BC=D0=B0=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=BE?= =?UTF-8?q?=D0=B5=20=D1=81=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=B4=D0=B2=D0=B8=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B8=20*=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=BE?= =?UTF-8?q?=D0=BD=D0=B0=D0=BB=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=BE=D1=85?= =?UTF-8?q?=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=D1=82=D1=87?= =?UTF-8?q?=D0=B5=D1=82=D0=B0=20=D0=B8=20=D0=BF=D0=B0=D1=86=D0=B8=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=BE=D0=B2=20*=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=BB=20=D1=84=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=B0=D1=82=20*?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20=D1=87=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D0=B8=D1=87=D0=BD=D1=83=D1=8E=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D1=83=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/NurseController.php | 34 ++++- .../Controllers/Web/NurseReportController.php | 14 +- app/Models/MigrationPatient.php | 22 ++- app/Models/MigrationPatientCorrection.php | 31 ++++ app/Models/MigrationPatientNurse.php | 25 +++ app/Models/ReportNurse.php | 19 ++- app/Models/ReportNursePatient.php | 34 +++++ app/Models/UnifiedMedicalHistory.php | 12 +- app/Models/UnifiedMigrationPatient.php | 110 ++++++++++++++ app/Services/DateRangeService.php | 24 +-- app/Services/NurseReportService.php | 143 ++++++++++++++++++ ...830_create_report_nurse_patients_table.php | 44 ++++++ ...te_migration_patient_corrections_table.php | 43 ++++++ ..._create_migration_patient_nurses_table.php | 41 +++++ database/seeders/ReportStatusSeeder.php | 23 +++ .../Components/AddMedicalHistoryModal.vue | 72 +++++++-- .../Components/EditMedicalHistoryModal.vue | 72 +++++++-- resources/js/Pages/Nurse/Report/Index.vue | 9 +- 18 files changed, 712 insertions(+), 60 deletions(-) create mode 100644 app/Models/MigrationPatientCorrection.php create mode 100644 app/Models/MigrationPatientNurse.php create mode 100644 app/Models/ReportNursePatient.php create mode 100644 app/Models/UnifiedMigrationPatient.php create mode 100644 app/Services/NurseReportService.php create mode 100644 database/migrations/2026_05_05_093830_create_report_nurse_patients_table.php create mode 100644 database/migrations/2026_05_05_143417_create_migration_patient_corrections_table.php create mode 100644 database/migrations/2026_05_05_152746_create_migration_patient_nurses_table.php create mode 100644 database/seeders/ReportStatusSeeder.php diff --git a/app/Http/Controllers/Api/NurseController.php b/app/Http/Controllers/Api/NurseController.php index c42ecc8..23d4cdf 100644 --- a/app/Http/Controllers/Api/NurseController.php +++ b/app/Http/Controllers/Api/NurseController.php @@ -6,8 +6,11 @@ use App\Http\Controllers\Controller; use App\Models\MedicalHistory; use App\Models\MedicalHistoryCorrection; use App\Models\MedicalHistoryNurse; +use App\Models\MigrationPatient; +use App\Models\MigrationPatientCorrection; use App\Models\UnifiedMedicalHistory; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; class NurseController extends Controller { @@ -77,10 +80,33 @@ class NurseController extends Controller $data['medical_history_id'] = $id; $data['user_id'] = auth()->user()->id; - $result = MedicalHistoryCorrection::create($data); + $currentMigration = MigrationPatient::currentMigration($id); - return response()->json([ - 'data' => $result, - ], 201); + $migrationData = [ + 'migration_patient_id' => $currentMigration->id, + 'medical_history_id' => $id, + 'ingoing_date' => $data['recipient_date'], + 'out_date' => $data['extract_date'], + 'visit_result_id' => $data['visit_result_id'], + 'user_id' => $data['user_id'], + ]; + + DB::beginTransaction(); + + $historyCorrection = MedicalHistoryCorrection::create($data); + $migrationCorrection = MigrationPatientCorrection::create($migrationData); + + if ($historyCorrection && $migrationCorrection) { + DB::commit(); + + return response()->json([ + 'data' => $historyCorrection, + ], 201); + } else { + DB::rollBack(); + return response()->json([ + 'data' => 'Something went wrong', + ], 400); + } } } diff --git a/app/Http/Controllers/Web/NurseReportController.php b/app/Http/Controllers/Web/NurseReportController.php index b5f0716..fa38798 100644 --- a/app/Http/Controllers/Web/NurseReportController.php +++ b/app/Http/Controllers/Web/NurseReportController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Web; use App\Http\Controllers\Controller; use App\Models\Department; use App\Services\DateRangeService; +use App\Services\NurseReportService; use App\Services\UnifiedMedicalHistoryService; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -14,7 +15,8 @@ class NurseReportController extends Controller { public function __construct( protected DateRangeService $dateRangeService, - protected UnifiedMedicalHistoryService $unifiedMedicalHistoryService + protected UnifiedMedicalHistoryService $unifiedMedicalHistoryService, + protected NurseReportService $nurseReportService, ) {} @@ -51,10 +53,16 @@ class NurseReportController extends Controller /** * Сохранение отчета от роли мед. сестра - * @return void + * @return \Illuminate\Http\RedirectResponse */ - public function store() + public function store(Request $request) { + $user = auth()->user(); + $dateRange = $this->dateRangeService->getDateRangeFromRequest($request, $user); + $report = $this->nurseReportService->saveReport($dateRange); + $this->nurseReportService->saveSnapshot($dateRange, $report); + + return redirect()->back(); } } diff --git a/app/Models/MigrationPatient.php b/app/Models/MigrationPatient.php index b59bdfc..e0374e8 100644 --- a/app/Models/MigrationPatient.php +++ b/app/Models/MigrationPatient.php @@ -69,7 +69,7 @@ class MigrationPatient extends MaterializedViewModel { return $query->where('out_date', '>', $from) ->where('out_date', '<=', $to) - ->whereNotIn('stat_cure_result_id', [3, 4, 7]) + ->whereNotIn('visit_result_id', [3, 4, 5, 6]) ->whereNull('death_date'); // умершие не считаются "выбывшими домой" } @@ -77,7 +77,7 @@ class MigrationPatient extends MaterializedViewModel { return $query->where('out_date', '>', $from) ->where('out_date', '<=', $to) - ->whereIn('stat_cure_result_id', [3, 4, 7]); + ->whereIn('visit_result_id', [3, 4]); } public function scopeDeceased($query, string $from, string $to) @@ -89,17 +89,13 @@ class MigrationPatient extends MaterializedViewModel public function scopeCurrent($query, DateRange $dateRange) { -// return $query->where('ingoing_date', '<', $dateRange->startSql()) -// ->where(function ($q) use ($dateRange) { -// $q->whereNull('out_date')->orWhere('out_date', '>', $dateRange->endSql()); -// }); -// return $query->where('ingoing_date', '<=', $dateRange->endSql()) -// ->has('medicalHistory') -// ->where(function ($q) use ($dateRange) { -// $q->whereNull('out_date') -// ->orWhere('out_date', '>=', $dateRange->startSql()) -// ->where('out_date', '<=', $dateRange->endSql()); -// }); return $query->where('is_actually_current', true); } + + public function scopeCurrentMigration($query, $historyId) + { + return $query->where('medical_history_id', $historyId) + ->orderBy('ingoing_date', 'desc') + ->limit(1)->first(); + } } diff --git a/app/Models/MigrationPatientCorrection.php b/app/Models/MigrationPatientCorrection.php new file mode 100644 index 0000000..72b0448 --- /dev/null +++ b/app/Models/MigrationPatientCorrection.php @@ -0,0 +1,31 @@ + 'datetime:UTC', + 'out_date' => 'datetime:UTC', + ]; +} diff --git a/app/Models/MigrationPatientNurse.php b/app/Models/MigrationPatientNurse.php new file mode 100644 index 0000000..81f421b --- /dev/null +++ b/app/Models/MigrationPatientNurse.php @@ -0,0 +1,25 @@ + 'date:Y-m-d', + 'sent_at' => 'datetime:Y-m-d H:i:s', + 'period_start' => 'datetime:Y-m-d H:i:s', + 'period_end' => 'datetime:Y-m-d H:i:s', + ]; + + public function department() + { + return $this->belongsTo(Department::class, 'rf_department_id', 'department_id'); + } + public function patients() { return $this->hasMany(ReportNursePatient::class, 'report_nurse_id'); diff --git a/app/Models/ReportNursePatient.php b/app/Models/ReportNursePatient.php new file mode 100644 index 0000000..3abe62f --- /dev/null +++ b/app/Models/ReportNursePatient.php @@ -0,0 +1,34 @@ + 'date', + 'recipient_date' => 'datetime', + 'extract_date' => 'datetime', + 'death_date' => 'datetime', + 'male' => 'boolean', + ]; +} diff --git a/app/Models/UnifiedMedicalHistory.php b/app/Models/UnifiedMedicalHistory.php index 52dc683..cf038e7 100644 --- a/app/Models/UnifiedMedicalHistory.php +++ b/app/Models/UnifiedMedicalHistory.php @@ -10,16 +10,16 @@ class UnifiedMedicalHistory extends MaterializedViewModel protected $primaryKey = 'id'; protected $casts = [ - 'birth_date' => 'date', - 'recipient_date' => 'datetime', - 'extract_date' => 'datetime', - 'death_date' => 'datetime', + 'birth_date' => 'date:Y-m-d', + 'recipient_date' => 'datetime:Y-m-d H:i:s', + 'extract_date' => 'datetime:Y-m-d H:i:s', + 'death_date' => 'datetime:Y-m-d H:i:s', 'male' => 'boolean', ]; public function migrations(): \Illuminate\Database\Eloquent\Relations\HasMany|MedicalHistory { - return $this->hasMany(MigrationPatient::class, 'medical_history_id', 'id'); + return $this->hasMany(UnifiedMigrationPatient::class, 'medical_history_id', 'id'); } public function operations(): \Illuminate\Database\Eloquent\Relations\HasMany|MedicalHistory @@ -29,7 +29,7 @@ class UnifiedMedicalHistory extends MaterializedViewModel public function latestMigration() { - return $this->hasOne(MigrationPatient::class, 'medical_history_id', 'id') + return $this->hasOne(UnifiedMigrationPatient::class, 'medical_history_id', 'id') ->latest('ingoing_date'); } diff --git a/app/Models/UnifiedMigrationPatient.php b/app/Models/UnifiedMigrationPatient.php new file mode 100644 index 0000000..458817a --- /dev/null +++ b/app/Models/UnifiedMigrationPatient.php @@ -0,0 +1,110 @@ + 'datetime:Y-m-d H:i:s', + 'out_date' => 'datetime:Y-m-d H:i:s', + ]; + + public function medicalHistory() + { + return $this->belongsTo(UnifiedMedicalHistory::class, 'medical_history_id', 'id'); + } + + public function operations() + { + return $this->hasMany(SurgicalOperation::class, 'migration_patient_id', 'id'); + } + + // Пересечение с отчетным периодом + public function scopeDateRange($query, string $from, string $to) + { + return $query->where('ingoing_date', '<=', $to) + ->where(function ($q) use ($from) { + $q->whereNull('out_date')->orWhere('out_date', '>=', $from); + }); + } + + // Фильтр по подразделению (получает ID отделений) + public function scopeDepartment($query, int $departmentId) + { + $branchIds = DB::table('stt_stationarbranch') + ->where('rf_DepartmentID', $departmentId) + ->pluck('StationarBranchID'); + + return $query->whereIn('stationar_branch_id', $branchIds); + } + + // Добавляет вычисляемый столбец `category` (только для отображения) + public function scopeWithCategory($query, string $from, string $to) + { + $sql = "CASE + WHEN ingoing_date BETWEEN ? AND ? THEN 'admitted' + WHEN out_date BETWEEN ? AND ? THEN + CASE + WHEN death_date IS NOT NULL AND death_date BETWEEN ? AND ? THEN 'deceased' + WHEN stat_cure_result_id IN (3,4,7) THEN 'transferred' + ELSE 'discharged' + END + WHEN ingoing_date < ? AND (out_date IS NULL OR out_date > ?) THEN 'current' + ELSE 'historical' + END as category"; + + return $query->selectRaw($sql, [$from, $to, $from, $to, $from, $to, $to, $to]); + } + + // Быстрые фильтры по статусам (используют индексы MV, а не computed column) + public function scopeAdmitted($query, string $from, string $to) + { + return $query->where('ingoing_date', '>', $from) + ->where('ingoing_date', '<=', $to); + } + + public function scopeDischarged($query, string $from, string $to) + { + return $query->where('out_date', '>', $from) + ->where('out_date', '<=', $to) + ->whereNotIn('visit_result_id', [3, 4, 5, 6]) + ->whereNull('death_date'); // умершие не считаются "выбывшими домой" + } + + public function scopeTransferred($query, string $from, string $to) + { + return $query->where('out_date', '>', $from) + ->where('out_date', '<=', $to) + ->whereIn('visit_result_id', [3, 4]); + } + + public function scopeDeceased($query, string $from, string $to) + { + return $query->whereNotNull('death_date') + ->where('death_date', '>', $from) + ->where('death_date', '<=', $to); + } + + public function scopeCurrent($query, DateRange $dateRange) + { + return $query->whereNull('out_date') + ->whereNotNull('medical_history_id') + ->whereHas('medicalHistory', function ($q) use ($dateRange) { + $q->whereNull('extract_date'); + }); + } + + public function scopeCurrentMigration($query, $historyId) + { + return $query->where('medical_history_id', $historyId) + ->orderBy('ingoing_date', 'desc') + ->limit(1)->first(); + } +} diff --git a/app/Services/DateRangeService.php b/app/Services/DateRangeService.php index 83c43d4..396d187 100644 --- a/app/Services/DateRangeService.php +++ b/app/Services/DateRangeService.php @@ -55,8 +55,8 @@ class DateRangeService ? $this->parseDate($startAtInput) : Carbon::now('Asia/Yakutsk'); - $endDate = $endDate->copy()->setTime(7, 0); - $startDate = $startDate->copy()->subDay()->setTime(7, 0); + $endDate = $endDate->copy()->setTime(9, 0); + $startDate = $startDate->copy()->subDay()->setTime(9, 0); return new DateRange( startDate: $startDate, @@ -85,10 +85,10 @@ class DateRangeService $startDate = Carbon::now('Asia/Yakutsk') ->startOfYear() // 1 января текущего года ->subDay() - ->setTime(7, 0); + ->setTime(9, 0); $endDate = Carbon::now('Asia/Yakutsk') - ->setTime(7, 0); + ->setTime(9, 0); return [ $startDate->format('Y-m-d H:i:s'), @@ -123,11 +123,11 @@ class DateRangeService $endDate = $this->parseDate($endAt); if ($startDate->isSameDay($endDate)) { - $startDate = $startDate->subDay()->setTime(7, 0); - $endDate = $endDate->setTime(7, 0); + $startDate = $startDate->subDay()->setTime(9, 0); + $endDate = $endDate->setTime(9, 0); } else { - $startDate = $startDate->setTime(7, 0); - $endDate = $endDate->setTime(7, 0); + $startDate = $startDate->setTime(9, 0); + $endDate = $endDate->setTime(9, 0); } return [ @@ -140,10 +140,10 @@ class DateRangeService { $startDate = Carbon::now('Asia/Yakutsk') ->subDay() - ->setTime(7, 0); + ->setTime(9, 0); $endDate = Carbon::now('Asia/Yakutsk') - ->setTime(7, 0); + ->setTime(9, 0); return [ $startDate->format('Y-m-d H:i:s'), @@ -197,8 +197,8 @@ class DateRangeService { // Для автоматического заполнения используем логику как для врача // (вчера 07:00 - сегодня 07:00) - $startDate = $date->copy()->subDay()->setTime(7, 0); - $endDate = $date->copy()->setTime(7, 0); + $startDate = $date->copy()->subDay()->setTime(9, 0); + $endDate = $date->copy()->setTime(9, 0); return new DateRange( startDate: $startDate, diff --git a/app/Services/NurseReportService.php b/app/Services/NurseReportService.php new file mode 100644 index 0000000..ce0eeb9 --- /dev/null +++ b/app/Services/NurseReportService.php @@ -0,0 +1,143 @@ +whereHas('migrations', function ($q) use ($departmentId, $dateRange) { + $q->department($departmentId)->dateRange($dateRange->startSql(), $dateRange->endSql()); + }) + ->with(['latestMigration' => function ($q) use ($departmentId, $dateRange) { + $q->department($departmentId)->dateRange($dateRange->startSql(), $dateRange->endSql()); + }]); + } + + /** + * Сохранить отчет + */ + public function saveReport(DateRange $dateRange, ?int $userId = null, ?int $lpuDoctorId = null, ?int $departmentId = null) + { + $user = $userId ? User::find($userId) : auth()->user(); + + $lpuDoctorId = $lpuDoctorId ?? $user->rf_lpudoctor_id; + $departmentId = $departmentId ?? $user->rf_department_id; + + $data = [ + 'report_date' => Carbon::now()->format('Y-m-d'), + 'sent_at' => Carbon::now()->format('Y-m-d H:i:s'), + 'period_type' => 'day', + 'period_start' => $dateRange->startSql(), + 'period_end' => $dateRange->endSql(), + 'status_id' => 2, // опубликован + 'rf_lpudoctor_id' => $lpuDoctorId, + 'rf_department_id' => $departmentId, + 'rf_user_id' => $user->id, + ]; + + $report = ReportNurse::create($data); + + return $report; + } + + /** + * Сохранить снимок пациентов за период + */ + public function saveSnapshot(DateRange $dateRange, ReportNurse $reportNurse, ?int $departmentId = null, ?int $userId = null): array + { + $departmentId = $departmentId ?? $reportNurse->department->rf_mis_department_id; + $userId = $userId ?? $reportNurse->rf_user_id; + $startYear = Carbon::now()->startOfYear()->format('Y-m-d'); + + $query = UnifiedMedicalHistory::query() + // Фильтруем движения по отделению + пересечение дат + ->whereHas('migrations', function ($q) use ($departmentId, $dateRange, $startYear) { + $q->where('department_id', $departmentId) + // пребывание пересекается с отчётным периодом + ->where('ingoing_date', '<=', $dateRange->endSql()) + ->where('ingoing_date', '>=', $startYear) + ->where(function ($sub) use ($dateRange) { + $sub->whereNull('out_date') + ->orWhere('out_date', '>=', $dateRange->startSql()) + ->where('out_date', '<=', $dateRange->endSql()); + }) + ->where(function ($sub) use ($dateRange) { + $sub->whereNull('out_date') + ->orWhere('out_date', '>=', $dateRange->startSql()) + ->where('out_date', '<=', $dateRange->endSql()); + }); + }) + // Подгружаем последнее движение для денормализации + ->with(['latestMigration' => function ($q) use ($departmentId, $dateRange, $startYear) { + $q->where('department_id', $departmentId) + ->where('ingoing_date', '<=', $dateRange->endSql()) + ->where('ingoing_date', '>=', $startYear) + ->where(function ($sub) use ($dateRange) { + $sub->whereNull('out_date') + ->orWhere('out_date', '>=', $dateRange->startSql()) + ->where('out_date', '<=', $dateRange->endSql()); + }) + ->latest('ingoing_date'); // если несколько, берём последнее + }]); + + $rawSql = $query->toRawSql(); + + // Получаем данные (chunk для памяти, если пациентов > 1000) + $patients = $query->cursor(); + + $savedCount = 0; + $reportData = []; + + foreach ($patients as $patient) { + // Подготовка данных для сохранения (денормализация) + $data = [ + 'report_nurse_id' => $reportNurse->id, + 'source_type' => $patient->source_type, + 'original_id' => $patient->original_id, + 'medical_card_number' => $patient->medical_card_number, + 'full_name' => $patient->full_name, + 'birth_date' => $patient->birth_date, + 'recipient_date' => $patient->recipient_date, + 'extract_date' => $patient->extract_date, + 'death_date' => $patient->death_date, + 'male' => $patient->male, + 'urgency_id' => $patient->urgency_id, + 'hospital_result_id' => $patient->hospital_result_id, + 'visit_result_id' => $patient->visit_result_id, + 'comment' => $patient->comment, + 'user_id' => $userId, + ]; + + // UPSERT: обновляем если запись с таким ключом уже есть, иначе вставляем + \DB::table('report_nurse_patients')->upsert( + [$data], + ['report_nurse_id', 'source_type', 'original_id'], // уникальные ключи + [ + 'medical_card_number', 'full_name', 'birth_date', 'recipient_date', 'extract_date', 'death_date', + 'male', 'urgency_id', 'hospital_result_id', 'visit_result_id', 'comment', 'user_id' + ] // обновляемые поля + ); + + $savedCount++; + $reportData[] = $data; + } + + return [ + 'saved_count' => $savedCount, + 'report_date' => $dateRange->startSql(), + 'department_id' => $departmentId, + ]; + } +} diff --git a/database/migrations/2026_05_05_093830_create_report_nurse_patients_table.php b/database/migrations/2026_05_05_093830_create_report_nurse_patients_table.php new file mode 100644 index 0000000..6f904e6 --- /dev/null +++ b/database/migrations/2026_05_05_093830_create_report_nurse_patients_table.php @@ -0,0 +1,44 @@ +id(); + $table->foreignIdFor(ReportNurse::class, 'report_nurse_id'); + $table->string('source_type'); + $table->bigInteger('original_id'); + $table->string('medical_card_number')->nullable(); + $table->string('full_name'); + $table->date('birth_date')->nullable(); + $table->dateTime('recipient_date'); + $table->dateTime('extract_date')->nullable(); + $table->dateTime('death_date')->nullable(); + $table->boolean('male')->default(true); + $table->integer('urgency_id')->nullable(); + $table->integer('hospital_result_id')->nullable(); + $table->integer('visit_result_id')->nullable(); + $table->text('comment')->nullable(); + $table->foreignIdFor(\App\Models\User::class, 'user_id'); + $table->unique(['report_nurse_id', 'source_type', 'original_id']); // защита от дублей + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('report_nurse_patients'); + } +}; diff --git a/database/migrations/2026_05_05_143417_create_migration_patient_corrections_table.php b/database/migrations/2026_05_05_143417_create_migration_patient_corrections_table.php new file mode 100644 index 0000000..1ea5f4d --- /dev/null +++ b/database/migrations/2026_05_05_143417_create_migration_patient_corrections_table.php @@ -0,0 +1,43 @@ +id(); + $table->integer('migration_patient_id'); + $table->integer('medical_history_id'); + $table->dateTime('ingoing_date')->nullable(); + $table->dateTime('out_date')->nullable(); + $table->integer('diagnosis_id')->nullable(); + $table->string('diagnosis_code')->nullable(); + $table->string('diagnosis_name')->nullable(); + $table->integer('interrupted_event_id')->nullable(); + $table->integer('stationar_branch_id')->nullable(); + $table->integer('department_id')->nullable(); + $table->integer('visit_result_id')->nullable(); + $table->integer('stat_cure_result_id')->nullable(); + + $table->foreignIdFor(\App\Models\User::class, 'user_id'); + $table->integer('mis_user_id')->nullable(); + $table->text('comment')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('migration_patient_corrections'); + } +}; diff --git a/database/migrations/2026_05_05_152746_create_migration_patient_nurses_table.php b/database/migrations/2026_05_05_152746_create_migration_patient_nurses_table.php new file mode 100644 index 0000000..a962cb9 --- /dev/null +++ b/database/migrations/2026_05_05_152746_create_migration_patient_nurses_table.php @@ -0,0 +1,41 @@ +id(); + $table->foreignIdFor( \App\Models\MedicalHistoryNurse::class, 'medical_history_id'); + $table->dateTime('ingoing_date')->nullable(); + $table->dateTime('out_date')->nullable(); + $table->integer('diagnosis_id')->nullable(); + $table->string('diagnosis_code')->nullable(); + $table->string('diagnosis_name')->nullable(); + $table->integer('interrupted_event_id')->nullable(); + $table->integer('stationar_branch_id')->nullable(); + $table->integer('department_id')->nullable(); + $table->integer('visit_result_id')->nullable(); + $table->integer('stat_cure_result_id')->nullable(); + $table->foreignIdFor(\App\Models\User::class, 'user_id')->nullable(); + $table->integer('mis_user_id')->nullable(); + $table->text('comment')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('migration_patient_nurses'); + } +}; diff --git a/database/seeders/ReportStatusSeeder.php b/database/seeders/ReportStatusSeeder.php new file mode 100644 index 0000000..0b1fe52 --- /dev/null +++ b/database/seeders/ReportStatusSeeder.php @@ -0,0 +1,23 @@ + 'Черновик' + ]); + ReportStatus::create([ + 'name' => 'Опубликован' + ]); + } +} diff --git a/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue b/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue index a35aa9c..1b3d689 100644 --- a/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue +++ b/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue @@ -4,12 +4,13 @@ import {computed, ref, watch} from "vue"; import AppRadio from "../../../Components/AppRadio.vue"; import {useDebounceFn} from "@vueuse/core"; import {format} from "date-fns"; +import {router} from "@inertiajs/vue3"; const show = defineModel('show', { default: false }) const currentStep = ref(1) const currentStatus = ref('process') const isFinallyStep = computed(() => currentStep.value === 2) -const disableFillable = ref(false) +const buttonLoading = ref(false) const form = ref({ patient_source: 'mis', @@ -61,7 +62,43 @@ const visitResultOptions = [ { label: '1 - Выписан', value: 1 - } + }, + { + label: '2 - Переведён в др. ЛПУ', + value: 2 + }, + { + label: '3 - Переведён в дневной стационар', + value: 2 + }, + { + label: '4 - Переведён на другой профиль коек', + value: 4 + }, + { + label: '5 - Умер', + value: 5 + }, + { + label: '6 - Умер в приёмном покое', + value: 6 + }, + { + label: '7 - Лечение прервано по инициативе пациента', + value: 7 + }, + { + label: '8 - Лечение прервано по инициативе ЛПУ', + value: 8 + }, + { + label: '9 - Лечение продолжено', + value: 9 + }, + { + label: '10 - Самовольно прерванное лечение', + value: 10 + }, ] const prev = () => { @@ -77,10 +114,25 @@ const next = () => { } const submit = () => { + buttonLoading.value = true axios.post('/api/nurse/patients', { ...form.value }).then(res => { - console.log(res) + router.reload({ + only: [ + 'inDepartmentHistories', + 'recipientHistories', + 'dischargedHistories', + 'deceasedHistories', + 'transferredHistories' + ], + onSuccess: () => { + show.value = false + }, + onFinish: () => { + buttonLoading.value = false + } + }) }) } @@ -125,6 +177,8 @@ watch(() => currentStep.value, (val) => { title="Добавление пациента" class="max-w-xl min-h-[500px]" draggable + :close-on-esc="!buttonLoading" + :closable="!buttonLoading" > @@ -163,16 +217,16 @@ watch(() => currentStep.value, (val) => { - + - + - + - + @@ -180,13 +234,13 @@ watch(() => currentStep.value, (val) => {