Chuyển đến nội dung
Skillpedia
Phân tích và bảng tính5.8k · #14735

shifting-clinical-dates

Skill này làm gì

Skill này dạy agent cách che ngày dương lịch thật trong văn bản y khoa, nhưng vẫn giữ khoảng thời gian giữa các sự kiện. Dành cho nhà nghiên cứu cần các khoảng thời gian, như số ngày đến tái nhập viện, sau khi ngày đã được che.

Khi nào nên dùng

  • ✓Khi nhà nghiên cứu cần khoảng thời gian giữa các sự kiện, như số ngày đến tái nhập viện, sau khi ngày đã bị che.
  • ✓Khi người dùng cần dời ngày theo từng bệnh nhân để cùng một độ lệch được dùng cho mỗi người.
  • ✓Khi người dùng cần giới hạn tuổi trên 89 và rút gọn ngày theo mức Safe Harbor cho phép.

Liên kết skill

https://github.com/maziyarpanahi/openmed/blob/master/skills/shifting-clinical-dates/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/maziyarpanahi/openmed/blob/master/skills/shifting-clinical-dates/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Bạn có thể che các ngày thật trong ghi chú bệnh nhân của tôi nhưng giữ số ngày giữa mỗi lượt khám không?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent chọn một độ lệch cho mỗi bệnh nhân và cộng nó vào mọi ngày trong hồ sơ đó. Các ngày thật bị mất, nhưng khoảng cách giữa chúng vẫn giữ nguyên.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Shifting clinical dates

HIPAA Safe Harbor forbids keeping dates more specific than the year. But naively deleting dates destroys the temporal structure research depends on — time to event, length of stay, intervals between visits. Date shifting is the compromise: move every date by a single random offset so the absolute dates become meaningless while the intervals between them are preserved exactly. OpenMed does this on-device with deidentify(method="shift_dates", ...).

When to use this skill

Use it when downstream analysis needs temporal relationships (survival curves, sepsis-to-antibiotic time, readmission gaps) but the calendar dates must be de-identified. If you can throw dates away entirely, plain method="mask" is simpler — reach for shifting only when intervals matter.

Quick start

import openmed

note = (
    "Admitted 2024-03-02, started antibiotics 2024-03-04, discharged 2024-03-09. "
    "Follow-up scheduled 2024-04-02."
)

# Shift every date by the SAME offset -> intervals preserved, dates obscured.
result = openmed.deidentify(
    note,
    method="shift_dates",
    consistent=True,        # one stable offset for this run
    seed=20240519,          # reproducible per-patient offset (use a per-patient key)
    keep_year=False,        # do NOT retain the year (Safe Harbor: year-only is the max)
)
print(result.deidentified_text)
# Admit -> antibiotics is still 2 days; admit -> discharge still 7 days; etc.

How interval preservation works

All dates in the document are moved by one offset (auto-selected as a random non-zero value in roughly ±1 year, or fixed with date_shift_days=). Because the offset is identical for every date, the difference between any two dates is unchanged:

real:    Mar 2  ──2d──▶ Mar 4  ──5d──▶ Mar 9
shifted: Jul 18 ──2d──▶ Jul 20 ──5d──▶ Jul 25     (offset = +138 days, intervals intact)

That is why survival time, length of stay, and visit gaps survive de-identification while the actual calendar is destroyed.

Per-patient consistent offsets

Each patient should get their own offset, and that offset should be stable across documents and reproducible across runs. Derive a per-patient seed (e.g. from a secret keyed hash of the patient ID — never the raw MRN) and pass it as seed=:

def patient_offset_seed(patient_key: str) -> int:
    import hashlib, hmac
    # keyed so the mapping from patient -> offset is itself a secret
    digest = hmac.new(b"<vault-secret>", patient_key.encode(), hashlib.sha256).digest()
    return int.from_bytes(digest[:8], "big")

for doc in patient_documents:
    openmed.deidentify(
        doc, method="shift_dates",
        consistent=True, seed=patient_offset_seed(patient_id),
        keep_year=False,
    )

Same patient → same offset everywhere (their notes stay internally consistent); different patients → different offsets (cross-patient dates cannot be aligned).

Workflow

  1. Decide the offset policy. Per-patient is standard for clinical research. Use consistent=True + a per-patient seed. Use a fixed date_shift_days= only when a deterministic, externally-managed offset is required.
  2. Set keep_year=False for Safe Harbor. (keep_year=True retains the year, which is permissible only if dates aren't tied to an individual's care.)
  3. Cap ages over 89 separately. Date shifting moves dates; it does not aggregate ages. Safe Harbor requires ages >89 and any date implying age >89 to collapse to a single "90+" — handle AGE spans explicitly (auditing-safe-harbor-checklist).
  4. Keep names/IDs handled too. shift_dates only touches dates. Run a normal redaction pass (or a policy) for PERSON, ID_NUM, etc.
  5. Verify intervals are preserved and no calendar leaked via audit=True.

Hand-off to / from OpenMed

  • Core de-id: deidentifying-clinical-text — combine date shifting with a policy= so names/IDs are redacted in the same pipeline.
  • Safe Harbor checklist: auditing-safe-harbor-checklist — the date rule and the age-90 cap are categories C in the 18.
  • Audit: auditing-deidentification-runs records the method and per-span actions (offsets/hashes, not raw dates).
  • Other surfaces: MCP openmed_deidentify / REST POST /pii/deidentify accept the same method and parameters.

Edge cases & gotchas

  • Offset 0 is forbidden. An auto-selected offset is always non-zero — a zero shift would si
Câu hỏi thường gặp

Khi nào xóa đơn giản thì dễ hơn?

Skill nói nếu ngày không quan trọng, phương pháp che đơn giản dễ hơn việc dời ngày.

Tại sao dùng độ lệch theo từng bệnh nhân?

Nó giữ dòng thời gian của mỗi bệnh nhân nhất quán trong khi che ngày thật.

Độ lệch có thể lặp lại được không?

Có. Skill đặt seed cố định để cùng một bệnh nhân nhận cùng độ lệch mỗi lần.

Chi tiết

Mô tả gốc của tác giả

Apply consistent per-patient date shifting in OpenMed that preserves intervals between events while satisfying HIPAA Safe Harbor's date rule. Use when the user needs to de-identify dates but keep temporal structure for research, shift all dates by the same offset per patient, preserve days-between-events for survival or longitudinal analysis, cap ages over 89, or strip everything but the year. Covers deidentify(method=\"shift_dates\", date_shift_days=..., keep_year=...) and per-patient reproducible offsets via consistent=True, seed=.... Pairs with OpenMed deidentifying-clinical-text and auditi

repo: maziyarpanahi/openmed

Độ phổ biến

Sao GitHub
5.8k
Vị trí xếp hạng
#14735
Giấy phép
Apache-2.0
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự