Commit c888729e by luoqi

Merge Meyer manual operation ownership guard into test

parents d1c30148 4c15d765
Pipeline #3846 failed in 0 seconds
......@@ -8,7 +8,7 @@ import { loadMeyerScopes, loadMeyerScopeResults } from '../integrations/meyer/or
import { ConfigSchema, InputConfigSchema, hash, imageKey } from '../integrations/meyer/contracts';
import { MeyerClient } from '../integrations/meyer/client';
import { collectMeyer } from '../integrations/meyer/collector';
import { prepareClinicStates } from '../integrations/meyer/clinic-state';
import { prepareClinicStates, clinicStateStore } from '../integrations/meyer/clinic-state';
import { backfillMeyerFileRefs } from '../integrations/meyer/backfill-file-refs';
import { PrismaClient } from '@prisma/client';
import { loadDiagnosisCodes } from '../integrations/meyer/mapper';
......@@ -84,6 +84,13 @@ export async function runMeyerCli(argv: string[], isolateWatchFailures = false):
await validateTarget();
const previous = await store.read<{ target: string }>('database');
if (!previous) await store.write('database', { target });
// 手动固定窗口、补引用和取址也保留原诊所归属闸;tick 在逐诊所执行时单独隔离。
if (!args.tick) for (const scope of config.scopes) {
const state = clinicStateStore(store, scope);
const previousScope = await state.read('scope');
if (previousScope && hash(previousScope) !== hash(scope)) throw new Error('clinic ownership mapping changed');
if (!previousScope) await state.write('scope', scope);
}
if (args.backfillFileRefs) {
const db = new PrismaClient();
try {
......
......@@ -19,6 +19,7 @@ import { codes } from './meyer-imaging-fixtures';
import { meyerBundle } from './meyer-imaging-fixtures';
import { meyerConfig, meyerImage, meyerSymptom } from './meyer-imaging-fixtures';
import { runMeyerCli } from '../src/cli/meyer-imaging.cli';
import { clinicStateStore } from '../src/integrations/meyer/clinic-state';
import { backfillMeyerFileRefs } from '../src/integrations/meyer/backfill-file-refs';
import { mkdtemp, writeFile, rm } from 'node:fs/promises';
import { join } from 'node:path';
......@@ -367,6 +368,10 @@ describePg('Meyer | isolated PostgreSQL + actual minimal CLI module', () => {
expect(await prisma.followupPlan.count()).toBe(0);
expect(await prisma.persona.count()).toBe(0);
const scopedState = clinicStateStore(new MeyerStore(join(directory, 'state')), meyerConfig().scopes[0]!);
await scopedState.write('scope', { ...meyerConfig().scopes[0], sourceUnit: 'changed-brand' });
await expect(runMeyerCli(args)).rejects.toThrow('ownership mapping changed');
await scopedState.write('scope', meyerConfig().scopes[0]);
await hostRecord(otherPatientId);
await expect(runMeyerCli([...args, '--tick'])).rejects.toThrow('conflicting');
expect(await prisma.patientFact.count({ where: { hostId, patientId } })).toBe(4);
......
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