Новые таблицы миса

This commit is contained in:
brusnitsyn
2026-01-16 17:30:41 +09:00
parent a649eaf7c5
commit 62d7e9efd4
11 changed files with 217 additions and 39 deletions

View File

@@ -7,6 +7,7 @@ use App\Http\Resources\Mis\FormattedPatientResource;
use App\Models\MetrikaGroup;
use App\Models\MetrikaResult;
use App\Models\MisMedicalHistory;
use App\Models\MisStationarBranch;
use App\Models\ObservationPatient;
use App\Models\Report;
use Illuminate\Http\Request;
@@ -102,30 +103,51 @@ class ReportController extends Controller
$status = $data['status'];
$startDate = Carbon::now()->addDays(-1)->format('Y-m-d');
$endDate = Carbon::now()->format('Y-m-d');
$model = new MisMedicalHistory();
$misDepartmentId = $request->user()->department->rf_mis_department_id;
$misStationarBranchId = MisStationarBranch::where('rf_DepartmentID', $misDepartmentId)->first()->StationarBranchID;
if ($status === 'plan') {
$patients = MisMedicalHistory::select(
[
...$model->getFillable(),
DB::raw('ROW_NUMBER() OVER (ORDER BY "DateRecipient" DESC) as num')
])
->where('rf_EmerSignID', 1)
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d'))
->plan()
->inDepartment($misDepartmentId, $startDate, $endDate)
->orderBy('DateRecipient', 'DESC')
->get();
->get()
->map(function ($item, $index) {
$item->num = $index + 1;
return $item;
});;
} else if ($status === 'emergency') {
$patients = MisMedicalHistory::select(
[
...$model->getFillable(),
DB::raw('ROW_NUMBER() OVER (ORDER BY "DateRecipient" DESC) as num')
])
->where('rf_EmerSignID', 2)
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d'))
->emergency()
->inDepartment($misDepartmentId, $startDate, $endDate)
->orderBy('DateRecipient', 'DESC')
->limit(20)
->get();
->get()
->map(function ($item, $index) {
$item->num = $index + 1;
return $item;
});;
} else if ($status === 'deceased') {
}
$patients->load(['migrations' => function ($query) use ($startDate, $endDate, $misStationarBranchId) {
$query->whereHas('diagnosis', function ($query) {
$query->where('rf_DiagnosTypeID', 3);
})->with('diagnosis.mkb')
->where('rf_StationarBranchID', $misStationarBranchId);
}]);
return response()->json(FormattedPatientResource::collection($patients));
}
@@ -137,17 +159,21 @@ class ReportController extends Controller
$status = $data['status'];
$startDate = Carbon::now()->addDays(-1)->format('Y-m-d');
$endDate = Carbon::now()->format('Y-m-d');
$model = new MisMedicalHistory();
$misDepartmentId = $request->user()->department->rf_mis_department_id;
if ($status === 'plan') {
$count = MisMedicalHistory::select($model->getFillable())
->where('rf_EmerSignID', 1)
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d'))
->plan()
->inDepartment($misDepartmentId, $startDate, $endDate)
->orderBy('DateRecipient', 'DESC')
->count();
} else if ($status === 'emergency') {
$count = MisMedicalHistory::select($model->getFillable())
->where('rf_EmerSignID', 2)
->whereDate('DateRecipient', '>=', Carbon::now()->format('Y-m-d'))
->emergency()
->inDepartment($misDepartmentId, $startDate, $endDate)
->orderBy('DateRecipient', 'DESC')
->count();
}