更新
This commit is contained in:
@@ -89,18 +89,17 @@ class MyPatientLists extends BaseAdminDataLists implements ListsSearchInterface,
|
||||
$this->applyKeyword($query);
|
||||
|
||||
$statusFilter = $applyStatusFilter ? trim((string) ($this->params['status_filter'] ?? '')) : '';
|
||||
if ($statusFilter === 'unconfirmed') {
|
||||
$viewTable = (new DiagnosisViewRecord())->getTable();
|
||||
$appointmentTable = (new Appointment())->getTable();
|
||||
if ($statusFilter === 'unbooked') {
|
||||
$query->whereNotExists(
|
||||
"SELECT 1 FROM {$viewTable} confirm_row"
|
||||
. ' WHERE confirm_row.diagnosis_id = d.id'
|
||||
. ' AND confirm_row.is_confirmed = 1'
|
||||
. ' AND confirm_row.delete_time IS NULL'
|
||||
"SELECT 1 FROM {$appointmentTable} unbooked_apt"
|
||||
. ' WHERE unbooked_apt.patient_id = d.id'
|
||||
. ' AND unbooked_apt.status IN (' . implode(',', self::EFFECTIVE_APPOINTMENT_STATUSES) . ')'
|
||||
);
|
||||
}
|
||||
|
||||
$appointmentStatuses = self::EFFECTIVE_APPOINTMENT_STATUSES;
|
||||
if ($statusFilter === 'booked') {
|
||||
if (in_array($statusFilter, ['pending_interview', 'booked'], true)) {
|
||||
$appointmentStatuses = [1];
|
||||
} elseif ($statusFilter === 'completed') {
|
||||
$appointmentStatuses = [3];
|
||||
@@ -108,14 +107,17 @@ class MyPatientLists extends BaseAdminDataLists implements ListsSearchInterface,
|
||||
$appointmentStatuses = [4];
|
||||
}
|
||||
|
||||
$needsAppointmentFilter = in_array($statusFilter, ['booked', 'completed', 'missed'], true);
|
||||
$needsAppointmentFilter = in_array(
|
||||
$statusFilter,
|
||||
['pending_interview', 'booked', 'completed', 'missed'],
|
||||
true
|
||||
);
|
||||
[$startDate, $endDate] = $applyDateFilter ? $this->dateRange() : ['', ''];
|
||||
if ($startDate !== '' || $endDate !== '') {
|
||||
$needsAppointmentFilter = true;
|
||||
}
|
||||
|
||||
if ($needsAppointmentFilter) {
|
||||
$appointmentTable = (new Appointment())->getTable();
|
||||
$conditions = [
|
||||
'filter_apt.patient_id = d.id',
|
||||
'filter_apt.status IN (' . implode(',', $appointmentStatuses) . ')',
|
||||
@@ -245,6 +247,7 @@ class MyPatientLists extends BaseAdminDataLists implements ListsSearchInterface,
|
||||
$today = date('Y-m-d');
|
||||
$statusFilter = trim((string) ($this->params['status_filter'] ?? ''));
|
||||
$preferredStatuses = [
|
||||
'pending_interview' => [1],
|
||||
'booked' => [1],
|
||||
'completed' => [3],
|
||||
'missed' => [4],
|
||||
@@ -364,6 +367,6 @@ class MyPatientLists extends BaseAdminDataLists implements ListsSearchInterface,
|
||||
|
||||
private function appointmentStatusText(int $status): string
|
||||
{
|
||||
return [1 => '已挂号', 3 => '已完成', 4 => '已过号'][$status] ?? '未挂号';
|
||||
return [1 => '待面诊', 3 => '已完成', 4 => '已过号'][$status] ?? '未预约';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,9 +65,18 @@ class MyPatientOrderLists extends BaseAdminDataLists implements ListsSearchInter
|
||||
$effectiveAmountQuery = clone $query;
|
||||
YejiStatsLogic::applyPrescriptionOrderEffectiveAmountQuery($effectiveAmountQuery, 'po');
|
||||
|
||||
// 拒收指标保留关键词、审核和日期条件,但不受当前履约状态按钮影响,
|
||||
// 避免点击“拒收订单”后分母被收窄为拒收状态而固定显示 100%。
|
||||
$rejectionScopeQuery = $this->buildQuery(true);
|
||||
$rejectionScopeOrderCount = (int) (clone $rejectionScopeQuery)->count('po.id');
|
||||
$rejectedCount = (int) (clone $rejectionScopeQuery)
|
||||
->where('po.fulfillment_status', 9)
|
||||
->count('po.id');
|
||||
$orderCount = (int) (clone $query)->count('po.id');
|
||||
|
||||
return [
|
||||
'summary' => [
|
||||
'orders' => (int) (clone $query)->count('po.id'),
|
||||
'orders' => $orderCount,
|
||||
'amount' => round((float) $effectiveAmountQuery->sum('po.amount'), 2),
|
||||
'pending' => (int) $pendingQuery
|
||||
->where(function ($q) {
|
||||
@@ -76,12 +85,16 @@ class MyPatientOrderLists extends BaseAdminDataLists implements ListsSearchInter
|
||||
})
|
||||
->count('po.id'),
|
||||
'completed' => (int) (clone $query)->whereIn('po.fulfillment_status', [3, 6])->count('po.id'),
|
||||
'rejected' => $rejectedCount,
|
||||
'rejection_rate' => $rejectionScopeOrderCount > 0
|
||||
? round($rejectedCount / $rejectionScopeOrderCount * 100, 2)
|
||||
: 0.0,
|
||||
],
|
||||
'scope' => MyPatientLogic::scopeMeta($this->adminId, $this->adminInfo),
|
||||
];
|
||||
}
|
||||
|
||||
private function buildQuery(): Query
|
||||
private function buildQuery(bool $ignoreFulfillmentStatus = false): Query
|
||||
{
|
||||
$query = PrescriptionOrder::alias('po')
|
||||
->join('tcm_diagnosis d', 'po.diagnosis_id = d.id')
|
||||
@@ -91,7 +104,7 @@ class MyPatientOrderLists extends BaseAdminDataLists implements ListsSearchInter
|
||||
|
||||
MyPatientLogic::applyScope($query, $this->adminId, $this->adminInfo);
|
||||
$this->applyKeyword($query);
|
||||
$this->applyStatusFilters($query);
|
||||
$this->applyStatusFilters($query, $ignoreFulfillmentStatus);
|
||||
$this->applyDateFilter($query);
|
||||
|
||||
return $query;
|
||||
@@ -122,9 +135,12 @@ class MyPatientOrderLists extends BaseAdminDataLists implements ListsSearchInter
|
||||
});
|
||||
}
|
||||
|
||||
private function applyStatusFilters(Query $query): void
|
||||
private function applyStatusFilters(Query $query, bool $ignoreFulfillmentStatus = false): void
|
||||
{
|
||||
foreach (['prescription_audit_status', 'payment_slip_audit_status', 'fulfillment_status'] as $field) {
|
||||
if ($ignoreFulfillmentStatus && $field === 'fulfillment_status') {
|
||||
continue;
|
||||
}
|
||||
$raw = $this->params[$field] ?? '';
|
||||
if ($raw === '' || $raw === null) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user