============================================================ 宠物医院管理系统 - 实体关系图 ============================================================ ┌─────────────┐ ┌─────────────┐ │ User │◄────────┤ Pet │ │─────────────│ │─────────────│ │ id (PK) │ │ id (PK) │ │ username │ │ owner_id (FK)│ │ phone │ │ name │ │ email │ │ species │ │ password │ │ breed │ │ role │ │ gender │ │ status │ │ birthday │ │ ... │ │ ... │ └─────────────┘ └─────────────┘ │ │ │ │ │ 1 │ 1..* │ │ ▼ ▼ ┌─────────────┐ ┌─────────────┐ │ Appointment │◄────────┤ Visit │ │─────────────│ │─────────────│ │ id (PK) │ │ id (PK) │ │ customer_id │ │ appointment │ │ pet_id (FK) │ │ _id (FK) │ │ doctor_id │ │ customer_id │ │ date │ │ pet_id (FK) │ │ time_slot │ │ doctor_id │ │ status │ │ symptoms │ │ ... │ │ diagnosis │ └─────────────┘ │ ... │ └─────────────┘ │ │ │ 1 │ ▼ ┌─────────────┐ ┌─────────────┐ │ Doctor │ │Prescription │ │─────────────│ │─────────────│ │ id (PK) │◄────────┤ id (PK) │ │ name │ │ visit_id (FK)│ │ department │ │ doctor_id │ │ title │ │ customer_id │ │ ... │ │ total_amount│ └─────────────┘ │ status │ │ ... │ └─────────────┘ │ │ 1 │ ▼ ┌─────────────┐ │Prescription │ │ Item │ │─────────────│ │ id (PK) │ │ prescr_id │ │ (FK) │ │ drug_id (FK)│ │ quantity │ │ ... │ └─────────────┘ │ │ │ 1 │ ▼ ┌─────────────┐ │ Drug │ │─────────────│ │ id (PK) │ │ name │ │ category │ │ price │ │ stock_qty │ │ ... │ └─────────────┘ │ ┌──────────┼──────────┐ │ │ │ ▼ ▼ ▼ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │ Stock In │ │ Stock Out │ │ Order │ │─────────────│ │─────────────│ │─────────────│ │ drug_id (FK)│ │ drug_id (FK)│ │ visit_id │ │ quantity │ │ quantity │ │ (FK) │ │ ... │ │ ... │ │ amount │ └─────────────┘ └─────────────┘ │ status │ │ ... │ └─────────────┘ ============================================================ 关系说明 ============================================================ 1. User (1) ───── (0..*) Pet - 一个用户可以拥有零个或多个宠物 2. User (1) ───── (0..*) Appointment - 一个用户可以创建零个或多个预约 3. Pet (1) ───── (0..*) Appointment - 一个宠物可以有零个或多个预约 4. Doctor (1) ──── (0..*) Appointment - 一个医生可以接收零个或多个预约 5. Appointment (0..1) ──── (0..1) Visit - 一个预约最多对应一个就诊记录 6. Visit (1) ───── (0..*) Prescription - 一个就诊可以开具零个或多个处方 7. Prescription (1) ──── (1..*) PrescriptionItem - 一个处方包含一个或多个处方明细 8. Drug (1) ───── (0..*) PrescriptionItem - 一种药品可以在零个或多个处方中出现 9. Visit (1) ───── (0..*) Order - 一次就诊可以产生零个或多个订单 10. Drug (1) ───── (0..*) StockIn/StockOut - 一种药品可以有零个或多个出入库记录 ============================================================ 业务流程 ============================================================ 顾客 (User) → 预约 (Appointment) → 就诊 (Visit) → 处方 (Prescription) → 订单 (Order) → 支付 医生 (User) → 诊断 (Visit) → 开具处方 (Prescription) → 用药指导 (PrescriptionItem) 药品 (Drug) ←→ 库存管理 (StockIn/StockOut) → 成本控制 (Order) ============================================================