Commit f608db9a by luoqi

feat(sync/friday): 默认联系号关系语义 — preferences.contactPhone(本人号/代接号判定)

customer_contacts.relationship(13.3 万行,57.6% 填充,host sys_dict 编码 1-9)随 phone
lookup 同源带出 → patient canonical passthrough → preferences.contactPhone
{relationshipCode, isSelf: 码=='1'}。零 schema 迁移(preferences Json 收纳,同 dedicatedCs)。

编码语义用本地数据统计自证(年龄分桶):1=本人(成人 78.7%/儿童仅 51.4%——儿童过半
代接号,触达该打家长);3/2 儿童特异=父母类;8 老人特异=子女类;9 全人群恒定≈其他。
完整标签待测试库恢复读 sys_dict 后在 patient.yaml enum_mapping 补解码,管道零改动。
jvs-dw 不映射 phoneRelationshipCode → 行为分毫不变。

落库验证:107,227 患者 upsert,contactPhone 44,293(本人 40,059/代接 6,234... 按码分布
与统计一致);儿童样例(2015/2018 生)代接码 2/3 符合预期。
消费端(guardian/话术标注)待字典解码后一并接,避免半吊子 UX。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
parent c57b0806
...@@ -11,6 +11,10 @@ field_mapping: ...@@ -11,6 +11,10 @@ field_mapping:
externalId: id # customer_basic_info 主键 = host 内部患者唯一 id(→ String 化) externalId: id # customer_basic_info 主键 = host 内部患者唯一 id(→ String 化)
name: name name: name
phone: phone # 由 transforms.lookup 从 customer_contacts 挑默认号附加 phone: phone # 由 transforms.lookup 从 customer_contacts 挑默认号附加
# 该号关系码(lookup 同源带出;canonical passthrough → mergePatientPreferences 收进
# preferences.contactPhone{relationshipCode,isSelf})。1=本人(统计自证 78.7% 成人);
# 完整标签(3/2=父母类,8=子女类,9=其他)待 host sys_dict 可读后在此加 enum_mapping 解码。
phoneRelationshipCode: phone_relationship
gender: sex # tinyint 1/2 → enum_mapping 归一;0/空 → 空 gender: sex # tinyint 1/2 → enum_mapping 归一;0/空 → 空
birthDate: birthday # date;空值入库为 null birthDate: birthday # date;空值入库为 null
medicalRecordNumber: file_number # 档案号(病历号,客服沟通用) medicalRecordNumber: file_number # 档案号(病历号,客服沟通用)
......
...@@ -61,6 +61,9 @@ transforms: ...@@ -61,6 +61,9 @@ transforms:
- { field: id, dir: asc } - { field: id, dir: asc }
select: select:
phone: contacts_tel # patient.phone ← 选中候选的 contacts_tel phone: contacts_tel # patient.phone ← 选中候选的 contacts_tel
# 该号与患者的关系码(host sys_dict 编码;实测 1=本人 78.7%(成人),儿童过半非本人号)。
# 先落原码(preferences.contactPhone,isSelf=码=='1');完整标签字典待 sys_dict 可读后补。
phone_relationship: relationship
# ── 预约:丢草稿 → 全部预约(拼 scheduledAt)+ 已到诊拆成接诊事件(→ encounter)── # ── 预约:丢草稿 → 全部预约(拼 scheduledAt)+ 已到诊拆成接诊事件(→ encounter)──
# 与 jvs-dw 同款设计:一个预约源喂两张 canonical(appointment / encounter)。 # 与 jvs-dw 同款设计:一个预约源喂两张 canonical(appointment / encounter)。
......
...@@ -6,6 +6,10 @@ import type { Prisma } from '@prisma/client'; ...@@ -6,6 +6,10 @@ import type { Prisma } from '@prisma/client';
* 当前承载: * 当前承载:
* - dedicatedCs 专属客服(current_task_director):路由/指派属性,非画像特征。 * - dedicatedCs 专属客服(current_task_director):路由/指派属性,非画像特征。
* "当前"会换 → upsert 覆盖(存当前值)。用于详情页展示 + 推送人匹配。 * "当前"会换 → upsert 覆盖(存当前值)。用于详情页展示 + 推送人匹配。
* - contactPhone 默认联系号的关系语义(FRIDAY customer_contacts.relationship):
* { relationshipCode: host 原码, isSelf: 码=='1'(统计自证:成人 78.7%=本人) }。
* 触达场景先能区分"本人号 vs 代接号"(儿童过半非本人号);完整关系标签待 host
* sys_dict 字典解码后由 assembler enum_mapping 补,此处零改动。
* *
* 返回 undefined 表示"无可写偏好"(让 prisma upsert 不动该列)。 * 返回 undefined 表示"无可写偏好"(让 prisma upsert 不动该列)。
*/ */
...@@ -24,5 +28,10 @@ export function mergePatientPreferences( ...@@ -24,5 +28,10 @@ export function mergePatientPreferences(
base.dedicatedCs = { id: csId, name: csName }; base.dedicatedCs = { id: csId, name: csName };
} }
const relCode = c.phoneRelationshipCode == null ? '' : String(c.phoneRelationshipCode).trim();
if (relCode) {
base.contactPhone = { relationshipCode: relCode, isSelf: relCode === '1' };
}
return Object.keys(base).length ? (base as Prisma.InputJsonValue) : undefined; return Object.keys(base).length ? (base as Prisma.InputJsonValue) : undefined;
} }
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