* блокировка изменения отчета для врача
* вывод данных из отчетов для ролей адм и зав * поправил ширину стобцов ввода * добавил календарь на страницу статистики * переделал календарь у заведующего на странице отчета * добавил и привязал метрики в статистику
This commit is contained in:
@@ -15,6 +15,18 @@ class DateRangeService
|
||||
return $this->getDefaultDateRange($user);
|
||||
}
|
||||
|
||||
public function isRangeOneDay($startAt = null, $endAt = null): bool
|
||||
{
|
||||
if (!$startAt || !$endAt) return false;
|
||||
|
||||
$startDate = $this->parseDate($startAt);
|
||||
$endDate = $this->parseDate($endAt);
|
||||
|
||||
if ($startDate->diffInDays($endDate) === 1.0) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function getCustomDateRange($startAt, $endAt, $user): array
|
||||
{
|
||||
$startDate = $this->parseDate($startAt);
|
||||
@@ -36,21 +48,12 @@ class DateRangeService
|
||||
|
||||
private function getDefaultDateRange($user): array
|
||||
{
|
||||
if ($user->isHeadOfDepartment() || $user->isAdmin()) {
|
||||
$startDate = Carbon::now('Asia/Yakutsk')
|
||||
->firstOfMonth()
|
||||
->setTime(6, 0);
|
||||
$startDate = Carbon::now('Asia/Yakutsk')
|
||||
->subDay()
|
||||
->setTime(6, 0);
|
||||
|
||||
$endDate = Carbon::now('Asia/Yakutsk')
|
||||
->setTime(6, 0);
|
||||
} else {
|
||||
$startDate = Carbon::now('Asia/Yakutsk')
|
||||
->subDay()
|
||||
->setTime(6, 0);
|
||||
|
||||
$endDate = Carbon::now('Asia/Yakutsk')
|
||||
->setTime(6, 0);
|
||||
}
|
||||
$endDate = Carbon::now('Asia/Yakutsk')
|
||||
->setTime(6, 0);
|
||||
|
||||
return [
|
||||
$startDate->format('Y-m-d H:i:s'),
|
||||
@@ -58,7 +61,7 @@ class DateRangeService
|
||||
];
|
||||
}
|
||||
|
||||
private function parseDate($dateInput): Carbon
|
||||
public function parseDate($dateInput): Carbon
|
||||
{
|
||||
if (is_numeric($dateInput)) {
|
||||
return Carbon::createFromTimestampMs($dateInput)
|
||||
|
||||
100
app/Services/MisPatientService.php
Normal file
100
app/Services/MisPatientService.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Models\MisMedicalHistory;
|
||||
use App\Models\MisMigrationPatient;
|
||||
|
||||
class MisPatientService
|
||||
{
|
||||
public function getPatientByType(string $type, int $branchId, array $dateRange)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'plan':
|
||||
$query = $this->getPlanPatientsQuery($branchId, $dateRange);
|
||||
break;
|
||||
case 'emergency':
|
||||
$query = $this->getEmergencyPatientsQuery($branchId, $dateRange);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение текущих пациентов по MigrationPatient
|
||||
*/
|
||||
public function getInStationarPatients(string $status, $branchId, string|array $dateRange)
|
||||
{
|
||||
$emerSign = $status === 'plan' ? 1 : [2,4];
|
||||
$query = MisMedicalHistory::query();
|
||||
$query->when(isset($branchId), function ($query) use ($branchId, $dateRange) {
|
||||
$query->with(['migrations', 'surgicalOperations'])
|
||||
->whereHas('migrations', function ($q) use ($branchId, $dateRange) {
|
||||
$q->where('rf_StationarBranchID', $branchId)
|
||||
->whereDate('DateRecipient', '<', is_array($dateRange) ? $dateRange[1] : $dateRange)
|
||||
->whereDate('DateOut', '=', '2222-01-01 00:00:00.000')
|
||||
->where('rf_kl_StatCureResultID', 0)
|
||||
->where('rf_kl_VisitResultID', 0);
|
||||
});
|
||||
})
|
||||
->where('rf_EmerSignID', $emerSign)
|
||||
->where('MedicalHistoryID', '<>', 0);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение запроса плановых пациентов по MigrationPatient
|
||||
*/
|
||||
public function getPlanPatientsQuery($branchId, $dateRange)
|
||||
{
|
||||
$query = MisMedicalHistory::query();
|
||||
$query->when(isset($branchId), function ($query) use ($branchId, $dateRange) {
|
||||
$query->with('migrations')
|
||||
->whereHas('migrations', function ($q) use ($branchId, $dateRange) {
|
||||
$q->where('rf_StationarBranchID', $branchId)
|
||||
->whereDate('DateRecipient', '<', $dateRange[1]);
|
||||
});
|
||||
})
|
||||
->where('rf_EmerSignID', 1)
|
||||
->where('MedicalHistoryID', '<>', 0);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение запроса экстренных + неотложных пациентов по MedicalHistory
|
||||
*/
|
||||
public function getEmergencyPatientsQuery($branchId, $dateRange)
|
||||
{
|
||||
$query = MisMedicalHistory::query();
|
||||
$query->when(isset($branchId), function ($query) use ($branchId, $dateRange) {
|
||||
$query->with('migrations')
|
||||
->whereHas('migrations', function ($q) use ($branchId, $dateRange) {
|
||||
$q->where('rf_StationarBranchID', $branchId)
|
||||
->whereBetween('DateIngoing', $dateRange);
|
||||
});
|
||||
})
|
||||
->whereIn('rf_EmerSignID', [2, 4])
|
||||
->where('MedicalHistoryID', '<>', 0);
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение запроса пациентов которые попали в отделение в определенную дату
|
||||
* @param int $branchId Индентификатор ветки стационара
|
||||
* @param array $dateRange Массив дат (0 - начальная дата, 1 - конечная дата)
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function getRecipientPatientsQuery(int $branchId, array $dateRange): \Illuminate\Database\Eloquent\Builder
|
||||
{
|
||||
$query = MisMedicalHistory::query();
|
||||
$query->with('migrations')
|
||||
->whereHas('migrations', function ($q) use ($branchId, $dateRange) {
|
||||
$q->where('rf_StationarBranchID', $branchId)
|
||||
->whereBetween('DateIngoing', $dateRange);
|
||||
})->where('MedicalHistoryID', '<>', 0);
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user