From fe2264dfce233bc65a107d5870d2465aad3e084b Mon Sep 17 00:00:00 2001 From: brusnitsyn Date: Tue, 5 May 2026 21:03:14 +0900 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BF=D0=B0=D1=86=D0=B8=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=B0=20=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=B8=D0=BD=D0=BA=D1=80=D0=B5=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B8=D0=B4=D0=B5=D0=BD?= =?UTF-8?q?=D1=82=D0=B8=D1=84=D0=B8=D0=BA=D0=B0=D1=82=D0=BE=D1=80=D0=BE?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/NurseController.php | 38 +++++++++++++++++-- app/Models/MedicalHistoryNurse.php | 1 + ...column_in_medical_history_nurses_table.php | 28 ++++++++++++++ .../Components/AddMedicalHistoryModal.vue | 14 ++++--- 4 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 database/migrations/2026_05_05_203152_add_latest_migration_id_column_in_medical_history_nurses_table.php diff --git a/app/Http/Controllers/Api/NurseController.php b/app/Http/Controllers/Api/NurseController.php index 23d4cdf..9cfb750 100644 --- a/app/Http/Controllers/Api/NurseController.php +++ b/app/Http/Controllers/Api/NurseController.php @@ -8,6 +8,8 @@ use App\Models\MedicalHistoryCorrection; use App\Models\MedicalHistoryNurse; use App\Models\MigrationPatient; use App\Models\MigrationPatientCorrection; +use App\Models\MigrationPatientNurse; +use App\Models\MisStationarBranch; use App\Models\UnifiedMedicalHistory; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; @@ -35,6 +37,10 @@ class NurseController extends Controller public function storePatient(Request $request) { + $user = auth()->user(); + $department = auth()->user()->department; + $misUserId = $user->rf_lpudoctor_id; + $data = $request->validate([ 'source_type' => 'nullable', 'medical_card_number' => 'nullable', @@ -51,12 +57,38 @@ class NurseController extends Controller 'comment' => 'nullable', ]); - $data['user_id'] = auth()->user()->id; + $data['user_id'] = $user->id; - $result = MedicalHistoryNurse::create($data); + $branch = MisStationarBranch::where('rf_DepartmentID', $department->rf_mis_department_id) + ->first(); + + $migrationData = [ + 'ingoing_date' => $data['recipient_date'], + 'out_date' => $data['extract_date'], + 'department_id' => $department->rf_mis_department_id, + 'stationar_branch_id' => $branch->StationarBranchID, + 'visit_result_id' => $data['visit_result_id'], + 'user_id' => $data['user_id'], + 'mis_user_id' => $misUserId + ]; + + DB::beginTransaction(); + + $historyNurse = MedicalHistoryNurse::create($data); + $migrationData['medical_history_id'] = $historyNurse->id; + $migrationNurse = MigrationPatientNurse::create($migrationData); + $historyNurse->update([ + 'latest_migration_id' => $migrationNurse->id + ]); + + if ($historyNurse && $migrationNurse) { + DB::commit(); + } else { + DB::rollBack(); + } return response()->json([ - 'data' => $result, + 'data' => $historyNurse, ], 201); } diff --git a/app/Models/MedicalHistoryNurse.php b/app/Models/MedicalHistoryNurse.php index 615be32..7733e2f 100644 --- a/app/Models/MedicalHistoryNurse.php +++ b/app/Models/MedicalHistoryNurse.php @@ -21,6 +21,7 @@ class MedicalHistoryNurse extends Model 'user_id', 'mis_user_id', 'comment', + 'latest_migration_id' ]; public function user() diff --git a/database/migrations/2026_05_05_203152_add_latest_migration_id_column_in_medical_history_nurses_table.php b/database/migrations/2026_05_05_203152_add_latest_migration_id_column_in_medical_history_nurses_table.php new file mode 100644 index 0000000..d463578 --- /dev/null +++ b/database/migrations/2026_05_05_203152_add_latest_migration_id_column_in_medical_history_nurses_table.php @@ -0,0 +1,28 @@ +bigInteger('latest_migration_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('medical_history_nurses', function (Blueprint $table) { + $table->dropColumn('latest_migration_id'); + }); + } +}; diff --git a/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue b/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue index 1b3d689..0db3c5b 100644 --- a/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue +++ b/resources/js/Pages/Nurse/Components/AddMedicalHistoryModal.vue @@ -20,7 +20,7 @@ const form = ref({ urgency_id: 1, visit_result_id: 0, birth_date: null, - recipient_date: new Date(), + recipient_date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'), death_date: null, extract_date: null }) @@ -34,7 +34,7 @@ const resetForm = () => { urgency_id: 1, visit_result_id: 0, birth_date: null, - recipient_date: new Date(), + recipient_date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'), death_date: null, extract_date: null } @@ -133,6 +133,8 @@ const submit = () => { buttonLoading.value = false } }) + }).catch((e) => { + buttonLoading.value = false }) } @@ -217,16 +219,16 @@ watch(() => currentStep.value, (val) => { - + - + - + - +