Новые таблицы миса
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,12 @@ class FormattedPatientResource extends JsonResource
|
||||
return [
|
||||
'id' => $this->MedicalHistoryID,
|
||||
'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,
|
||||
];
|
||||
}),
|
||||
'fullname' => Str::ucwords(Str::lower("$this->FAMILY $this->Name $this->OT")),
|
||||
'age' => Carbon::parse($this->BD)->diff(Carbon::now())->format('%y'),
|
||||
'birth_date' => Carbon::parse($this->BD)->format('d.m.Y'),
|
||||
|
||||
Reference in New Issue
Block a user