feat: initialize ERP base platform (extracted from HMS)

- Stripped 11 business crates (health, ai, dialysis, plugins)
- Cleaned AppState, AppConfig, main.rs from business coupling
- Reduced migrations from 169 to 53 (base-only)
- Removed health_provider trait from erp-core
- Removed business integration tests
- Removed gateway rate limiting middleware
- Base capabilities: auth, RBAC, JWT, config, workflow, message, plugin, audit, crypto, RLS, multi-tenant

Cargo check: OK
Cargo test: OK
This commit is contained in:
iven
2026-05-31 20:35:57 +08:00
commit 59856ac2fc
639 changed files with 124710 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
// apps/web/e2e/flows/alert-flow.spec.ts
import { test, expect } from '../fixtures/auth.fixture';
import { makeAlertRule } from '../fixtures/test-data';
test.describe('@flow 告警规则链路', () => {
const cleanup: Array<() => Promise<void>> = [];
test.afterEach(async () => {
for (const fn of cleanup.reverse()) {
await fn().catch(() => {});
}
cleanup.length = 0;
});
test('创建告警规则 → 查看列表 → 查看告警页面', async ({ api, authenticatedPage: page }) => {
const rule = await api.createAlertRule(makeAlertRule());
cleanup.push(() => api.deleteAlertRule(rule.id, rule.version));
await page.goto('/#/health/alert-rules');
await page.waitForSelector('.ant-table', { timeout: 10000 });
const tableText = await page.locator('.ant-table-tbody').textContent();
expect(tableText).toBeTruthy();
await page.goto('/#/health/alerts');
await page.waitForSelector('.ant-table, .ant-empty', { timeout: 10000 });
});
});

View File

@@ -0,0 +1,38 @@
// apps/web/e2e/flows/appointment-flow.spec.ts
import { test, expect } from '../fixtures/auth.fixture';
import { AppointmentPage } from '../pages/appointment.page';
import { makePatient, makeDoctor, makeSchedule, makeAppointment } from '../fixtures/test-data';
test.describe('@flow 预约排班链路', () => {
const cleanup: Array<() => Promise<void>> = [];
test.afterEach(async () => {
for (const fn of cleanup.reverse()) {
await fn().catch(() => {});
}
cleanup.length = 0;
});
test('创建医生 → 设置排班 → 创建预约 → 查看列表', async ({ api, authenticatedPage: page }) => {
const doctor = await api.createDoctor(makeDoctor());
cleanup.push(() => api.deleteDoctor(doctor.id, doctor.version));
const patient = await api.createPatient(makePatient());
cleanup.push(() => api.deletePatient(patient.id, patient.version));
const schedule = await api.createSchedule(makeSchedule(doctor.id));
cleanup.push(() => api.deleteSchedule(schedule.id, schedule.version));
const appointmentPage = new AppointmentPage(page);
await appointmentPage.gotoSchedule();
const appointment = await api.createAppointment(
makeAppointment(patient.id, doctor.id, schedule.id),
);
cleanup.push(() => api.deleteAppointment(appointment.id, appointment.version));
await appointmentPage.gotoAppointments();
const tableText = await page.locator('.ant-table-tbody').textContent();
expect(tableText).toBeTruthy();
});
});

View File

@@ -0,0 +1,36 @@
// apps/web/e2e/flows/follow-up-flow.spec.ts
import { test, expect } from '../fixtures/auth.fixture';
import { makePatient, makeFollowUpTemplate, makeFollowUpTask } from '../fixtures/test-data';
test.describe('@flow 随访管理链路', () => {
const cleanup: Array<() => Promise<void>> = [];
test.afterEach(async () => {
for (const fn of cleanup.reverse()) {
await fn().catch(() => {});
}
cleanup.length = 0;
});
test('创建模板 → 创建任务 → 查看任务列表', async ({ api, authenticatedPage: page }) => {
const patient = await api.createPatient(makePatient());
cleanup.push(() => api.deletePatient(patient.id, patient.version));
const template = await api.createFollowUpTemplate(makeFollowUpTemplate());
cleanup.push(() => api.deleteFollowUpTemplate(template.id, template.version));
await page.goto('/#/health/follow-up-tasks');
await page.waitForSelector('.ant-table', { timeout: 10000 });
const task = await api.createFollowUpTask(
makeFollowUpTask(patient.id, template.id),
);
cleanup.push(() => api.deleteFollowUpTask(task.id, task.version));
await page.reload();
await page.waitForSelector('.ant-table');
const rowCount = await page.locator('.ant-table-tbody tr').count();
expect(rowCount).toBeGreaterThanOrEqual(1);
});
});

View File

@@ -0,0 +1,53 @@
// apps/web/e2e/flows/patient-journey.spec.ts
import { test, expect } from '../fixtures/auth.fixture';
import { PatientListPage } from '../pages/patient-list.page';
import { PatientDetailPage } from '../pages/patient-detail.page';
import { makePatient, makeDoctor } from '../fixtures/test-data';
test.describe('@flow 患者全流程', () => {
const cleanup: Array<() => Promise<void>> = [];
test.afterEach(async () => {
for (const fn of cleanup.reverse()) {
await fn().catch(() => {});
}
cleanup.length = 0;
});
test('创建患者 → 查看详情 → 编辑 → 分配医生', async ({ api, authenticatedPage: page }) => {
const doctorData = makeDoctor();
const doctor = await api.createDoctor(doctorData);
cleanup.push(() => api.deleteDoctor(doctor.id, doctor.version));
const listPage = new PatientListPage(page);
await listPage.goto();
const patientData = makePatient();
await listPage.clickCreate();
await listPage.fillCreateForm({
name: patientData.name,
});
await listPage.submitForm();
await expect(async () => {
const found = await listPage.hasPatientInTable(patientData.name);
expect(found).toBeTruthy();
}).toPass({ timeout: 10000 });
const patient = await api.createPatient({ ...patientData, name: `${patientData.name}_detail` });
cleanup.push(() => api.deletePatient(patient.id, patient.version));
const detailPage = new PatientDetailPage(page);
await detailPage.goto(patient.id);
const name = await detailPage.getPatientName();
expect(name.length).toBeGreaterThan(0);
const assignBtn = page.locator('button:has-text("分配医生")');
if (await assignBtn.isVisible().catch(() => false)) {
await detailPage.clickAssignDoctor();
await detailPage.selectDoctor(doctorData.name);
await detailPage.confirmAssign();
}
});
});

View File

@@ -0,0 +1,37 @@
// apps/web/e2e/flows/vital-signs-flow.spec.ts
import { test, expect } from '../fixtures/auth.fixture';
import { PatientDetailPage } from '../pages/patient-detail.page';
import { makePatient, makeVitalSigns } from '../fixtures/test-data';
test.describe('@flow 体征数据链路', () => {
const cleanup: Array<() => Promise<void>> = [];
test.afterEach(async () => {
for (const fn of cleanup.reverse()) {
await fn().catch(() => {});
}
cleanup.length = 0;
});
test('API录入体征 → 患者详情查看体征数据列表', async ({ api, authenticatedPage: page }) => {
const patient = await api.createPatient(makePatient());
cleanup.push(() => api.deletePatient(patient.id, patient.version));
const vitalSigns = await api.createVitalSigns(patient.id, makeVitalSigns({
systolic_bp_morning: 130,
heart_rate: 80,
}));
cleanup.push(() => api.deleteVitalSigns(patient.id, vitalSigns.id, vitalSigns.version));
const detailPage = new PatientDetailPage(page);
await detailPage.goto(patient.id);
await detailPage.clickTab('健康数据');
await page.waitForTimeout(800);
await detailPage.clickTab('体征数据');
await page.waitForSelector('.ant-table', { timeout: 10000 });
const rows = await page.locator('.ant-table-tbody tr').count();
expect(rows).toBeGreaterThanOrEqual(1);
});
});