Commit f26f0dde by luoqi

merge: main → test(反向合)

parents bac5db09 aa23e1c8
Pipeline #3639 failed in 0 seconds
......@@ -313,8 +313,34 @@ async function bootstrap(): Promise<number> {
if (!entries.length) throw new Error(`--sub=${args.sub} 不是已知子场景`);
for (const t of tenants) {
const scope: ScenarioScope = { hostId: host.id, tenantId: t.tenantId, now };
out(`▶ host=${args.host} tenant=${t.tenantId} 子场景=${entries.length} 个`);
// --subset=N:把对拍收窄到 N 位患者。生产 113 万患者全量差分要几小时,还会跟
// 2 小时批次抢 RDS;收窄后几分钟就能在**生产真实数据**上拿到零差异证据。
// ⚠️ 收窄降低的是**覆盖**不是可信度:差异一旦出现仍然是真差异。
// 但"子集零差异"≠"全量零差异" —— 报告时必须写清跑的是多少患者。
let subsetIds: string[] | undefined;
if (args.subset > 0) {
const rows = await prisma.$queryRaw<{ id: string }[]>(Prisma.sql`
SELECT p.id FROM patients p
WHERE p.host_id = ${host.id}::uuid AND p.tenant_id = ${t.tenantId} AND p.active = true
AND EXISTS (
SELECT 1 FROM patient_facts f
WHERE f.patient_id = p.id AND f.status = 'active'
AND f.type IN ('diagnosis_record','recommendation_record')
)
ORDER BY p.id LIMIT ${args.subset}`);
subsetIds = rows.map((r) => r.id);
out(` 收窄到 ${subsetIds.length} 位**有 active 诊断/建议信号**的患者(--subset)`);
}
const scope: ScenarioScope = {
hostId: host.id,
tenantId: t.tenantId,
now,
...(subsetIds ? { patientIds: subsetIds } : {}),
};
out(
`▶ host=${args.host} tenant=${t.tenantId} 子场景=${entries.length} 个 ` +
`患者域=${args.subset > 0 ? `${args.subset} 位子集` : '全量'}`,
);
for (const [subKey, cfg] of entries) {
const rule = lookupDxTreatment(cfg.primaryCode);
......
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