Обновление отчета

This commit is contained in:
brusnitsyn
2026-01-20 09:26:47 +09:00
parent 62d7e9efd4
commit 8a0fdf9470
12 changed files with 83 additions and 41 deletions

View File

@@ -136,9 +136,20 @@ class ReportController extends Controller
->map(function ($item, $index) {
$item->num = $index + 1;
return $item;
});;
});
} else if ($status === 'observation') {
$patients = ObservationPatient::with(['history'])
->where('rf_department_id', $misDepartmentId)
->history;
} else if ($status === 'deceased') {
$patients = MisMedicalHistory::select(...$model->getFillable())
->deceased()
->inDepartment($misDepartmentId, $startDate, $endDate)
->get()
->map(function ($item, $index) {
$item->num = $index + 1;
return $item;
});
}
$patients->load(['migrations' => function ($query) use ($startDate, $endDate, $misStationarBranchId) {

View File

@@ -26,7 +26,8 @@ class StatisticController extends Controller
$data = [];
$departments = Department::select('department_id', 'name_short')->get();
$departments = Department::select('department_id', 'name_short')
->orderBy('name_short')->get();
foreach ($departments as $department) {
$allCount = MetrikaResult::whereHas('report', function ($query) use ($userDepartment, $department) {

View File

@@ -21,8 +21,8 @@ class FormattedPatientResource extends JsonResource
'num' => $this->num,
'mkb' => $this->whenLoaded('migrations', function () {
return [
'ds' => $this->migrations()->first()->diagnosis()->first()->mkb()->first()->DS ?? null,
'name' => $this->migrations()->first()->diagnosis()->first()->mkb()->first()->NAME ?? null,
'ds' => $this->migrations()->first()->diagnosis()->first()?->mkb()->first()->DS ?? null,
'name' => $this->migrations()->first()->diagnosis()->first()?->mkb()->first()->NAME ?? null,
];
}),
'fullname' => Str::ucwords(Str::lower("$this->FAMILY $this->Name $this->OT")),

View File

@@ -40,6 +40,14 @@ class MisMedicalHistory extends Model
return $this->where('rf_EmerSignID', 2);
}
/*
* Истории с результатом - Умер
*/
public function scopeDeceased()
{
return $this->where('rf_kl_VisitResultID', 5);
}
/*
* Движения истории
*/

View File

@@ -15,4 +15,9 @@ class ObservationPatient extends Model
'rf_department_id',
'rf_report_id',
];
public function history()
{
return $this->belongsTo(MisMedicalHistory::class, 'rf_medicalhistory_id', 'MedicalHistoryID');
}
}