Commit e8e121c5 by luoqi

docs(extraction): 修正冷静期字典 + 补认领取数口径(plan_event_logs)

- 关闭原因冷静期:inaccurate / treated 由 14 天改永久
- 品牌患者数更新:瑞尔 351,024 / 瑞泰 64,883(瑞泰必须排除)
- 新增「三之二、认领怎么捞」:快照与账本的分工、plan_event_logs 字段字典、
  三条常用查询(处理过哪些患者 / 接手后放弃 / 认领时长分布)
- 表关系图补 plan_event_logs
- 坑表补两条:assignee_user_id 是快照、按 plan_id 聚合会因升版本重复计数

SQL 均已在生产库执行验证。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
parent d9fb836e
Pipeline #3439 failed in 0 seconds
--- ---
title: 取数说明 title: 取数说明
description: 瑞尔召回数据自助取数 —— 涉及哪些表、召回池怎么筛、关闭操作落在哪、数据范围怎么过滤。 description: 瑞尔召回数据自助取数 —— 涉及哪些表、召回池怎么筛、认领与关闭操作落在哪、数据范围怎么过滤。
icon: Database icon: Database
--- ---
...@@ -25,6 +25,7 @@ tenant_id = 'ruier-grp' ...@@ -25,6 +25,7 @@ tenant_id = 'ruier-grp'
followup_plans 召回工单(一行 = 一个患者的一次召回任务) followup_plans 召回工单(一行 = 一个患者的一次召回任务)
├─ plan_reasons 1:N 召回理由(命中了哪些临床信号) ├─ plan_reasons 1:N 召回理由(命中了哪些临床信号)
├─ plan_executions 1:N 执行记录(客服每次操作一行,关闭也在这) ├─ plan_executions 1:N 执行记录(客服每次操作一行,关闭也在这)
├─ plan_event_logs 1:N 归属/反馈账本(认领、返池、召回反馈)
└─ patients N:1 患者主数据 └─ patients N:1 患者主数据
└─ patient_profiles 1:1 合规标记(勿打扰 / 已故) └─ patient_profiles 1:1 合规标记(勿打扰 / 已故)
``` ```
...@@ -42,8 +43,8 @@ followup_plans 召回工单(一行 = 一个患者的一次召回任务) ...@@ -42,8 +43,8 @@ followup_plans 召回工单(一行 = 一个患者的一次召回任务)
| 值 | 患者数 | 说明 | | 值 | 患者数 | 说明 |
|---|---|---| |---|---|---|
| `瑞尔` | 349,385 | **PAC 业务实际服务的范围** | | `瑞尔` | 351,024 | **PAC 业务实际服务的范围** |
| `瑞泰` | 57,707 | 历史带入的少量数据,分析时建议排除 | | `瑞泰` | 64,883 | 不在业务范围内,**必须排除** |
```sql ```sql
join patients pt on pt.id = p.patient_id and pt.source_unit = '瑞尔' join patients pt on pt.id = p.patient_id and pt.source_unit = '瑞尔'
...@@ -102,6 +103,67 @@ order by p.priority_score desc; ...@@ -102,6 +103,67 @@ order by p.priority_score desc;
--- ---
## 三之二、认领怎么捞
「认领」= 客服把工单收到自己名下,认领后才能操作(提交结果 / 关闭 / 生成话术 / 打反馈)。
两个数据源:
| 源 | 是什么 | 用途 |
|---|---|---|
| `followup_plans.assignee_user_id` / `assigned_at` | 当前快照,返池即置 `NULL` | 现在谁手里有多少单 |
| `plan_event_logs` | 历史账本,append-only | 谁处理过哪些患者 |
⚠️ **统计"处理过"用 `plan_event_logs`,不要用 `assignee_user_id`** —— 后者返池后被清空。
账本 **2026-07-24 起**才有数据。
### plan_event_logs
| 字段 | 说明 |
|---|---|
| `event` | `claim` 认领 / `assign` 指派他人 / `release` 返池 / `feedback` 召回反馈 |
| `assignee_user_id` | 变更后的归属人;`release` 为 `NULL` |
| `actor_user_id` | 操作人。`claim` 时 = `assignee_user_id` |
| `held_seconds` | 本次归属持续秒数,仅 `release` 有值 |
| `reason` | `feedback` = `up` / `down` |
| `details` | JSON,事件补充(如反馈文字) |
| `plan_id` / `patient_id` | **按患者聚合用 `patient_id`** |
**某客服处理过哪些患者**
```sql
select l.actor_user_id as 客服, count(distinct l.patient_id) as 处理患者数
from plan_event_logs l
where l.host_id = '902b9698-0b38-4521-95a2-6e56f8d9efbc'
and l.event in ('claim', 'assign', 'feedback')
and l.created_at >= '2026-07-24'
group by 1 order by 处理患者数 desc;
```
**接手后放弃**(认领了但没提交任何执行)
```sql
select count(distinct l.patient_id)
from plan_event_logs l
where l.host_id = '902b9698-0b38-4521-95a2-6e56f8d9efbc'
and l.event = 'claim'
and not exists (
select 1 from plan_executions e where e.plan_id = l.plan_id
);
```
**认领时长分布**
```sql
select width_bucket(held_seconds, 0, 86400, 12) as 桶, count(*),
min(held_seconds), max(held_seconds)
from plan_event_logs
where event = 'release' and held_seconds is not null
group by 1 order by 1;
```
---
## 四、关闭操作怎么捞 ## 四、关闭操作怎么捞
回访在你们系统里做,PAC 只提供「关闭机会」做闭环。一次关闭在一个事务里写两处: 回访在你们系统里做,PAC 只提供「关闭机会」做闭环。一次关闭在一个事务里写两处:
...@@ -118,10 +180,10 @@ order by p.priority_score desc; ...@@ -118,10 +180,10 @@ order by p.priority_score desc;
| 值 | 中文 | 冷静期 | | 值 | 中文 | 冷静期 |
|---|---|---| |---|---|---|
| `no_intent` | 客户无意愿 | 60 天 | | `no_intent` | 客户无意愿 | 60 天 |
| `inaccurate` | 机会识别不准确 | 14 天 | | `inaccurate` | 机会识别不准确 | **永久** |
| `competitor` | 选择竞品机构 | 永久 | | `competitor` | 选择竞品机构 | 永久 |
| `price` | 价格因素 | 60 天 | | `price` | 价格因素 | 60 天 |
| `treated` | 已完成治疗 | 14 天 | | `treated` | 已完成治疗 | **永久** |
| `unreachable` | 无法联系客户 | 30 天 | | `unreachable` | 无法联系客户 | 30 天 |
| `other` | 其他(说明写在 `notes`) | 60 天 | | `other` | 其他(说明写在 `notes`) | 60 天 |
...@@ -197,7 +259,7 @@ group by 1, 2 order by 被判不准 desc; ...@@ -197,7 +259,7 @@ group by 1, 2 order by 被判不准 desc;
| `status` | `active` 待处理 / `assigned` 处理中 / `completed` 完成 / `abandoned` 放弃(含关闭)/ `superseded` 已被新版取代 | | `status` | `active` 待处理 / `assigned` 处理中 / `completed` 完成 / `abandoned` 放弃(含关闭)/ `superseded` 已被新版取代 |
| `contact_attempts` | 累计触达次数(患者级) | | `contact_attempts` | 累计触达次数(患者级) |
| `snoozed_until` | 冷静期截止,未到期不进池 | | `snoozed_until` | 冷静期截止,未到期不进池 |
| `assignee_user_id` / `assigned_at` | 经办人 / 认领时间 | | `assignee_user_id` / `assigned_at` | 经办人 / 认领时间。**当前快照**,返池即置 `NULL`;历史见 `plan_event_logs` |
| `recall_feedback` | 客服对"这条召回准不准"的反馈(`up`/`down`),独立于关闭操作 | | `recall_feedback` | 客服对"这条召回准不准"的反馈(`up`/`down`),独立于关闭操作 |
| `superseded_at` | 被新版取代的时间;当前版为 `NULL` | | `superseded_at` | 被新版取代的时间;当前版为 `NULL` |
| `created_at` | 工单生成时间 | | `created_at` | 工单生成时间 |
...@@ -246,6 +308,9 @@ group by 1, 2 order by 被判不准 desc; ...@@ -246,6 +308,9 @@ group by 1, 2 order by 被判不准 desc;
| 忘了 `superseded_at is null` | 查当前态一律加,否则同一患者多版工单重复计数 | | 忘了 `superseded_at is null` | 查当前态一律加,否则同一患者多版工单重复计数 |
| 用 `target_clinic_id in (...)` | 会漏掉集团池,要 `or target_clinic_id is null` | | 用 `target_clinic_id in (...)` | 会漏掉集团池,要 `or target_clinic_id is null` |
| 拿 `followup_plans` 数关闭量 | 关闭数查 `plan_executions`,一个工单可能有多次操作 | | 拿 `followup_plans` 数关闭量 | 关闭数查 `plan_executions`,一个工单可能有多次操作 |
| 用 `assignee_user_id` 数"处理过多少患者" | 那是快照,返池即清空;用 `plan_event_logs` |
| 按 `plan_id` 聚合认领 / 执行 | 升版本会换新 `plan_id`,同一次认领被算多次;**按 `patient_id` 聚合** |
| 用 `external_id` 对号 | 用 `medical_record_number` | | 用 `external_id` 对号 | 用 `medical_record_number` |
| 按 `created_at` 直接当北京时间 | 差 8 小时,要 `at time zone 'Asia/Shanghai'` | | 按 `created_at` 直接当北京时间 | 差 8 小时,要 `at time zone 'Asia/Shanghai'` |
| 把 36500 天后的 `snoozed_until` 当脏数据 | 那是"永久"哨兵值 | | 把 36500 天后的 `snoozed_until` 当脏数据 | 那是"永久"哨兵值 |
| 忘了排除 `source_unit='瑞泰'` | 不在业务范围 |
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment