← Back to Skills Marketplace
silent404

Family Medical History / 家庭医疗档案

by tbook · GitHub ↗ · v1.5.1 · MIT-0
cross-platform ✓ Security Clean
135
Downloads
0
Stars
0
Active Installs
8
Versions
Install in OpenClaw
/install family-medical-history
Description
Manage and query structured family medical records including profiles, visits, medications, chronic conditions, and vaccination histories stored as Markdown...
README (SKILL.md)

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'] \x3C 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'] \x3C 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
Usage Guidance
This skill appears coherent with its stated purpose: it initializes and manages a local SQLite database and can import/export Markdown records. Before running it, review/accept that it will create medical_records.db and write Markdown/attachments under a medical_records/ directory in the repository parent — these files will contain sensitive personal and health information. Only run the import scripts on directories you trust; do not point them at system or unknown directories. No network exfiltration or credential requests are present, but you should: (1) inspect the scripts yourself or run them in a controlled environment, (2) back up any existing data, (3) protect the created DB/markdown files with appropriate filesystem permissions or encryption, and (4) note minor code quality issues (e.g., a likely bug in get_family_summary) that may cause errors but not indicate malicious behavior.
Capability Assessment
Purpose & Capability
Name/description (local family EHR) match the included scripts: DB initialization, import from Markdown, querying, and optional Markdown sync. No unrelated binaries, env vars, or external services are requested.
Instruction Scope
Runtime instructions and scripts operate on local files (medical_records/ and medical_records.db) and use SQLite; they do not call external network endpoints or read environment credentials. Note: import_md.py will scan a user-specified directory of Markdown files for import, and sync_db.py will write Markdown and attachments back to the repository's medical_records/ tree — these actions will read/write potentially sensitive PII/PHI on the local filesystem and should be run only on directories you expect to process.
Install Mechanism
Instruction-only skill with bundled Python scripts; no installer, no external downloads, and no extraction of remote archives. Behavior occurs when the provided Python scripts are executed locally.
Credentials
No environment variables, credentials, or config paths are required. The scripts do not attempt to access unrelated credentials or services. All data access is local filesystem/SQLite.
Persistence & Privilege
always is false and the skill does not modify other skills or global agent settings. It creates/uses a local medical_records.db and Markdown files under medical_records/, which is expected for this purpose — be aware these files contain sensitive health/identity data and persist on disk.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install family-medical-history
  3. After installation, invoke the skill by name or use /family-medical-history
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.5.1
Fix: removed remaining private data reference (七七 → 小明) in example code. Description already contains Chinese. Name updated to bilingual.
v1.5.0
Bilingual description: English + Chinese in single description field. Includes Chinese trigger words and Chinese use-case summary. Skill name also shows Chinese: 家庭医疗档案.
v1.4.0
Auto-initialization: first database operation automatically calls init_db.py if DB doesn't exist. Zero manual setup required - database is created on first use.
v1.3.0
Mandatory database enforcement: all query functions now check database existence before executing. Without running init_db.py first, every query fails with clear error message directing user to init. SQLite is now truly the unskippable foundation.
v1.2.1
Replaced example member names (daughter/KK) with generic placeholders bob/luna to protect privacy. No real private data in skill examples.
v1.2.0
DB-first architecture: SQLite is now the SINGLE source of truth. All records stored and queried via DB. Markdown layer removed (export-only via sync_db.py). New users start with empty DB via init_db.py. import_md.py now migration-only for existing users.
v1.1.0
Added SQLite database layer: init_db.py, import_md.py, query_db.py, sync_db.py. DB is primary query layer with Markdown as backup. Supports periodic treatment tracking (e.g. ketoconazole weekly schedule). Fixed chronic symptom naming conventions.
v1.0.0
Initial release: comprehensive family medical records management with EHR-Lite V1.1 structure, visit/medication/exam tracking, chronic symptom management, and periodic treatment scheduling.
Metadata
Slug family-medical-history
Version 1.5.1
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 8
Frequently Asked Questions

What is Family Medical History / 家庭医疗档案?

Manage and query structured family medical records including profiles, visits, medications, chronic conditions, and vaccination histories stored as Markdown... It is an AI Agent Skill for Claude Code / OpenClaw, with 135 downloads so far.

How do I install Family Medical History / 家庭医疗档案?

Run "/install family-medical-history" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Family Medical History / 家庭医疗档案 free?

Yes, Family Medical History / 家庭医疗档案 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Family Medical History / 家庭医疗档案 support?

Family Medical History / 家庭医疗档案 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Family Medical History / 家庭医疗档案?

It is built and maintained by tbook (@silent404); the current version is v1.5.1.

💬 Comments