Добавлена возможность сохранения добавленного пациента
Исправлена инкрементация идентификаторов
This commit is contained in:
@@ -8,6 +8,8 @@ use App\Models\MedicalHistoryCorrection;
|
|||||||
use App\Models\MedicalHistoryNurse;
|
use App\Models\MedicalHistoryNurse;
|
||||||
use App\Models\MigrationPatient;
|
use App\Models\MigrationPatient;
|
||||||
use App\Models\MigrationPatientCorrection;
|
use App\Models\MigrationPatientCorrection;
|
||||||
|
use App\Models\MigrationPatientNurse;
|
||||||
|
use App\Models\MisStationarBranch;
|
||||||
use App\Models\UnifiedMedicalHistory;
|
use App\Models\UnifiedMedicalHistory;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
@@ -35,6 +37,10 @@ class NurseController extends Controller
|
|||||||
|
|
||||||
public function storePatient(Request $request)
|
public function storePatient(Request $request)
|
||||||
{
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
$department = auth()->user()->department;
|
||||||
|
$misUserId = $user->rf_lpudoctor_id;
|
||||||
|
|
||||||
$data = $request->validate([
|
$data = $request->validate([
|
||||||
'source_type' => 'nullable',
|
'source_type' => 'nullable',
|
||||||
'medical_card_number' => 'nullable',
|
'medical_card_number' => 'nullable',
|
||||||
@@ -51,12 +57,38 @@ class NurseController extends Controller
|
|||||||
'comment' => 'nullable',
|
'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([
|
return response()->json([
|
||||||
'data' => $result,
|
'data' => $historyNurse,
|
||||||
], 201);
|
], 201);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ class MedicalHistoryNurse extends Model
|
|||||||
'user_id',
|
'user_id',
|
||||||
'mis_user_id',
|
'mis_user_id',
|
||||||
'comment',
|
'comment',
|
||||||
|
'latest_migration_id'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function user()
|
public function user()
|
||||||
|
|||||||
@@ -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('medical_history_nurses', function (Blueprint $table) {
|
||||||
|
$table->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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -20,7 +20,7 @@ const form = ref({
|
|||||||
urgency_id: 1,
|
urgency_id: 1,
|
||||||
visit_result_id: 0,
|
visit_result_id: 0,
|
||||||
birth_date: null,
|
birth_date: null,
|
||||||
recipient_date: new Date(),
|
recipient_date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||||
death_date: null,
|
death_date: null,
|
||||||
extract_date: null
|
extract_date: null
|
||||||
})
|
})
|
||||||
@@ -34,7 +34,7 @@ const resetForm = () => {
|
|||||||
urgency_id: 1,
|
urgency_id: 1,
|
||||||
visit_result_id: 0,
|
visit_result_id: 0,
|
||||||
birth_date: null,
|
birth_date: null,
|
||||||
recipient_date: new Date(),
|
recipient_date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
|
||||||
death_date: null,
|
death_date: null,
|
||||||
extract_date: null
|
extract_date: null
|
||||||
}
|
}
|
||||||
@@ -133,6 +133,8 @@ const submit = () => {
|
|||||||
buttonLoading.value = false
|
buttonLoading.value = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
}).catch((e) => {
|
||||||
|
buttonLoading.value = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,16 +219,16 @@ watch(() => currentStep.value, (val) => {
|
|||||||
<NSelect filterable v-model:value="form.visit_result_id" :options="visitResultOptions" />
|
<NSelect filterable v-model:value="form.visit_result_id" :options="visitResultOptions" />
|
||||||
</NFormItemGi>
|
</NFormItemGi>
|
||||||
<NFormItemGi span="1" label="Дата рождения">
|
<NFormItemGi span="1" label="Дата рождения">
|
||||||
<NDatePicker v-model:value="form.birth_date" class="w-full" format="dd.MM.yyyy" value-format="yyyy-MM-dd" clearable />
|
<NDatePicker v-model:formatted-value="form.birth_date" class="w-full" format="dd.MM.yyyy" value-format="yyyy-MM-dd" clearable />
|
||||||
</NFormItemGi>
|
</NFormItemGi>
|
||||||
<NFormItemGi span="1" label="Дата и время госпитализации">
|
<NFormItemGi span="1" label="Дата и время госпитализации">
|
||||||
<NDatePicker v-model:value="form.recipient_date" type="datetime" class="w-full" format="dd.MM.yyyy HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" clearable />
|
<NDatePicker v-model:formatted-value="form.recipient_date" type="datetime" class="w-full" format="dd.MM.yyyy HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" clearable />
|
||||||
</NFormItemGi>
|
</NFormItemGi>
|
||||||
<NFormItemGi span="1" label="Дата и время выписки">
|
<NFormItemGi span="1" label="Дата и время выписки">
|
||||||
<NDatePicker v-model:value="form.extract_date" type="datetime" class="w-full" format="dd.MM.yyyy HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" clearable />
|
<NDatePicker v-model:formatted-value="form.extract_date" type="datetime" class="w-full" format="dd.MM.yyyy HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" clearable />
|
||||||
</NFormItemGi>
|
</NFormItemGi>
|
||||||
<NFormItemGi span="1" label="Дата и время смерти">
|
<NFormItemGi span="1" label="Дата и время смерти">
|
||||||
<NDatePicker v-model:value="form.death_date" type="datetime" class="w-full" format="dd.MM.yyyy HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" clearable />
|
<NDatePicker v-model:formatted-value="form.death_date" type="datetime" class="w-full" format="dd.MM.yyyy HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" clearable />
|
||||||
</NFormItemGi>
|
</NFormItemGi>
|
||||||
</NGrid>
|
</NGrid>
|
||||||
</NTabPane>
|
</NTabPane>
|
||||||
|
|||||||
Reference in New Issue
Block a user