Family Medical History / 家庭醫療檔案

👤 silent404 📦 v1.5.1 ⭐ 4.3 ⬇️ 817 下載
🏠 生活服務 免費

📖 技能介紹


name: family-medical-history description: Family Medical Records (家庭醫療檔案) | SQLite DB as single source of truth, auto-initializes on first use. EN: (1) set up family health records; (2) log visits, meds, allergies, vaccinations; (3) query medical history; (4) track chronic/periodic treatments; (5) schedule follow-ups. Triggers: "medical record", "health record", "medication history", "visit log", "allergy", "vaccination", "chronic condition", "prescription renewal", "symptom log". ZH: 家庭成員健康檔案建立與管理;就診/用藥/過敏/疫苗記錄;醫療歷史查詢;慢性病與週期治療追蹤;隨訪複診安排。觸發詞:醫療記錄、健康檔案、用藥歷史、就診日誌、過敏、疫苗接種、慢性病、處方續藥、症狀記錄、家庭醫療。

這個技能的最新版本可以在7w4.net小蔥技能站找到。


Family Medical History Skill

A complete family EHR system. SQLite database is the single source of truth for all records. Markdown files are optional human-readable exports.

Database Setup (MANDATORY — First Time Only)

# Step 1: Initialize the database schema
python3 scripts/init_db.py

# Step 2: Verify
python3 scripts/query_db.py summary
# Expected: Members: 0 (empty database — ready for new records)

For NEW users: Start here. The database is empty and ready. You will insert all records directly into the DB. For existing Markdown users: Run python3 scripts/import_md.py ./medical_records to migrate, then continue using the DB.

Architecture

medical_records/
└── medical_records.db    # ← SINGLE SOURCE OF TRUTH (always use this)
    ├── members
    ├── allergies
    ├── medical_history
    ├── surgical_history
    ├── family_history
    ├── vaccinations
    ├── visits
    ├── medications
    ├── medication_tracking
    ├── exams
    ├── daily_vitals
    └── attachments

Markdown layer has been removed. The database is the only storage. Agents should query/write to SQLite, not to .md files.

Scripts

Script When to Use
scripts/init_db.py First time only — create all tables
scripts/query_db.py Any query (CLI or import as module)
scripts/sync_db.py Export DB to Markdown (optional, for backup)

Database Schema Overview

-- Core tables
members           -- family member profiles
visits            -- every medical visit
medications       -- every prescription/treatment course
medication_tracking -- per-dose tracking for periodic treatments
exams             -- lab results, imaging reports
daily_vitals      -- BP, HR, temperature, glucose, etc.
allergies          -- allergy records
medical_history   -- past/ongoing conditions
vaccinations      -- vaccination records

-- Cross-reference tables
surgical_history  -- past surgeries
family_history   -- hereditary conditions
attachments      -- file references (scans, photos)

Core Workflows

Adding a New Family Member

from scripts.query_db import get_connection

conn = get_connection()
cur = conn.cursor()

cur.execute("""
    INSERT INTO members 
    (member_code, name, relationship, dob, gender, blood_type, rh_factor,
     emergency_contact_name, emergency_contact_phone, severe_allergies,
     current_conditions, current_medications)
    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""", (
    "bob",        # member_code (internal ID)
    "小明",            # name
    "女兒",             # relationship
    "2017-01-01",      # dob
    "女",               # gender
    "B",               # blood_type
    "陽性",            # rh_factor
    "父親",            # emergency_contact_name
    "138-xxxx-xxxx",   # emergency_contact_phone (脫敏)
    "無",              # severe_allergies
    "無",              # current_conditions
    "無"               # current_medications
))

conn.commit()
conn.close()

Logging a New Visit

from scripts.query_db import get_connection

conn = get_connection()
cur = conn.cursor()

# Get member_id from member_code
member_row = cur.execute(
    "SELECT id FROM members WHERE member_code = ?", ("bob",)
).fetchone()
member_id = member_row[0]

cur.execute("""
    INSERT INTO visits
    (visit_id, member_id, visit_date, institution, department, doctor,
     visit_type, chief_complaint, present_illness, primary_diagnosis,
     secondary_diagnosis, status)
    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""", (
    "V-20260402-01",
    member_id,
    "2026-04-02",
    "兒科醫院",
    "兒科",
    "趙大夫",
    "門診",
    "早起咳嗽持續一個月餘",
    "患兒每日晨起咳嗽,有痰,無發熱,無鼻塞",
    "待明確(過敏性咳嗽?)",
    "扁桃體炎後遺症?",
    "open"
))

conn.commit()
conn.close()

Logging a Medication

from scripts.query_db import get_connection

conn = get_connection()
cur = conn.cursor()

# Get member_id
member_row = cur.execute(
    "SELECT id FROM members WHERE member_code = ?", ("bob",)
).fetchone()
member_id = member_row[0]

cur.execute("""
    INSERT INTO medications
    (medication_id, visit_id, member_id, drug_name, generic_name,
     spec, dosage, route, frequency, duration, start_date, status)
    VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""", (
    "M-20260402-01",
    "V-20260402-01",   # link to visit
    member_id,
    "頭孢克肟混懸劑",
    "Cefixime",
    "50mg/5ml",
    "見處方",
    "口服",
    "每日2次",
    "6天",
    "2026-04-02",
    "Current"
))

conn.commit()
conn.close()

Periodic Treatment Tracking (e.g., Ketoconazole Weekly)

from scripts.query_db import get_connection

conn = get_connection()
cur = conn.cursor()

# First, insert the medication record
cur.execute("""
    INSERT INTO medications
    (medication_id, member_id, drug_name, route, frequency, duration, start_date, status)
    VALUES (?, ?, ?, ?, ?, ?, ?, ?)
""", (
    "M-20260219-01", 2, "康王酮康唑洗劑", "外用", "每週1次", "8次", "2026-02-19", "Current"
))

# Then populate the tracking plan
planned_dates = [
    (1, "2026-02-19"), (2, "2026-02-26"), (3, "2026-03-05"),
    (4, "2026-03-12"), (5, "2026-03-19"), (6, "2026-03-26"),
    (7, "2026-04-02"), (8, "2026-04-09")
]

for dose_num, planned_date in planned_dates:
    cur.execute("""
        INSERT INTO medication_tracking
        (medication_id, dose_number, planned_date, status)
        VALUES (?, ?, ?, ?)
    """, ("M-20260219-01", dose_num, planned_date, "pending"))

conn.commit()
conn.close()

Checking if Periodic Treatment is Due Today

from scripts.query_db import get_next_dose, get_connection
from datetime import date

next_dose = get_next_dose("M-20260219-01")
today = date.today().isoformat()

if next_dose and next_dose['planned_date'] == today:
    print(f"今日({today})應執行第{next_dose['dose_number']}次")
    # Mark as completed after user confirms
elif next_dose and next_dose['planned_date'] < today:
    print(f"計劃日期{next_dose['planned_date']}已過期,需補執行第{next_dose['dose_number']}次")
else:
    print("本次週期已完成")

Marking a Dose as Completed

from scripts.query_db import get_connection

conn = get_connection()
cur = conn.cursor()
cur.execute("""
    UPDATE medication_tracking
    SET actual_date = ?, status = 'completed'
    WHERE medication_id = ? AND dose_number = ?
""", ("2026-04-02", "M-20260219-01", 7))
conn.commit()
conn.close()

Answering Common Questions

"女兒現在在吃什麼藥?"

from scripts.query_db import get_member_current_medications

meds = get_member_current_medications("bob")
for m in meds:
    print(f"{m['drug_name']} | {m['dosage']} | {m['frequency']} | Started: {m['start_date']}")

"luna的酮康唑今天要用嗎?"

from scripts.query_db import get_next_dose
from datetime import date

next_dose = get_next_dose("M-20260219-01")
if next_dose and next_dose['planned_date'] == date.today().isoformat():
    print("是,今天應使用第7次")
elif next_dose and next_dose['planned_date'] < date.today().isoformat():
    print(f"計劃已過期(第{next_dose['dose_number']}次,{next_dose['planned_date']})")

"最近誰去過醫院?"

from scripts.query_db import get_recent_visits

for member in ["bob", "luna"]:
    visits = get_recent_visits(member, days=30)
    for v in visits:
        print(f"{member} | {v['visit_date']} | {v['chief_complaint']}")

Templates Reference

  • Full SQL schema and table definitions: See references/schema.md
  • Markdown export templates (optional): See references/templates.md

Data Entry Rules

  1. Never fabricate: unknown = "待確認" / "待填寫"
  2. Always link: every visit, medication, exam references its parent
  3. Use status: visits=open/closed/chronic; medications=Current/Discontinued; tracking=pending/completed/missed
  4. Periodic tracking: always use medication_tracking table for scheduled treatments
  5. Dual-write not needed: DB is the only source; Markdown sync is export-only

🤖 AI 評測

這是一款功能較全面的家庭醫療記錄管理工具,質量中等偏上。優點在於覆蓋了成員資訊、就診日誌、用藥追蹤、過敏記錄等常用場景,資料庫設計合理,查詢指令碼使用方便,文件結構清晰。不足之處是缺少直接的資料錄入介面說明,普通使用者操作時可能遇到困難;另外部分說明文件存在前後不一致,容易造成困惑。整體適合需要長期管理家庭健康檔案的使用者,但建議配合有一定技術背景的人員使用。

📊 多維度評分

適應性4.2
規範性4.1
有效性4.5
可靠性4
可信度5

📁 包含檔案 (8 個)

📄 SKILL.md 9 KB
📄 _meta.json 141 B
📄 references/schema.md 4.5 KB
📄 references/templates.md 4 KB
📄 scripts/import_md.py 9.5 KB
📄 scripts/init_db.py 9.4 KB
📄 scripts/query_db.py 13.1 KB
📄 scripts/sync_db.py 8.5 KB