Skip to main content

date-validity

Validate date values in a QUIQ-format table. Checks Event_date column and Mapping_info_1='date' rows using standard format parsing, Korean date formats, and optional LLM fallback. Use for data quality assessment of temporal data.

Source facts

Repository
28sungmin/m4-add-skills
Last source activity
June 19, 2026 at 00:33
Detected SKILL.md language
Mixed languages
Stars
0
Forks
0

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

File Explorer
4 files

Showing SKILL.md

SKILL.md
Source instructions ยท Read-only preview
name
date-validity
description
Validate date values in a QUIQ-format table. Checks Event_date column and Mapping_info_1='date' rows using standard format parsing, Korean date formats, and optional LLM fallback. Use for data quality assessment of temporal data.
tier
community
category
lydus
parameters
{"quiq_path":{"description":"Path to QUIQ-format CSV file (output of quiq skill).","type":"string"},"save_path":{"description":"Directory path to save output files.","type":"string"},"use_llm":{"description":"If true (default), uses Claude CLI for ambiguous date fallback. Set false to skip LLM and use rule-based only.","type":"boolean"}}
# Date Validity Validates date values in a QUIQ-format table. For each date-related value, determines whether it represents a valid date using standard format parsing, Korean date format regex, and (optionally) an LLM fallback for ambiguous strings. ## When to Use This Skill - After QUIQ conversion, to assess quality of temporal data - To identify records with invalid or malformed date strings - As part of LYDUS quality management assessment ## Data Sources in QUIQ ๋‘ ์ข…๋ฅ˜์˜ ๋‚ ์งœ ๋ฐ์ดํ„ฐ๋ฅผ ๋Œ€์ƒ์œผ๋กœ ํ•จ: | ์†Œ์Šค | ์กฐ๊ฑด | Variable_name | |------|------|--------------| | `Event_date` ์ปฌ๋Ÿผ | non-null | `Event_date` | | `Value` ์ปฌ๋Ÿผ | `Mapping_info_1` contains `date` | ์›๋ณธ Variable_name | ## Validation Pipeline ๊ฐ ๋‚ ์งœ ๋ฌธ์ž์—ด์— ๋Œ€ํ•ด ์ˆœ์„œ๋Œ€๋กœ ๊ฒ€์ฆ: ``` 1. dateutil.parse() โ†’ ํ‘œ์ค€ ๋‚ ์งœ ํ˜•์‹ (ISO, US, EU ๋“ฑ) 2. _valid_date_custom() โ†’ ํ•œ๊ตญ์–ด ๋‚ ์งœ (e.g. "2024๋…„ 3์›” 15์ผ") 3. LLM fallback (์„ ํƒ) โ†’ ์œ„ ๋‘ ๋ฐฉ๋ฒ• ์‹คํŒจ ์‹œ Claude CLI์— yes/no ์งˆ์˜ ``` **SQL ๋ฒ„์ „** (`duckdb.sql`) ์€ 1๋ฒˆ(TRY_STRPTIME 7์ข…) + 2๋ฒˆ(regex) ๋งŒ ์ง€์›. LLM fallback ์—†์Œ. ## Output | File | Description | |------|-------------| | `date_validity_total.txt` | Overall Date Validity (%), Total/Invalid dates | | `date_validity_summary.csv` | Per-variable: Total_date, Invalid_date, Date_Validity_(%) | | `date_validity_detail.csv` | Per-row: Date_value, Is_valid (Python ๋ฒ„์ „๋งŒ) | ## How to Run ### SQL ๋ฒ„์ „ (๋น ๋ฆ„, LLM ์—†์Œ) ```python import os import duckdb skill_dir = os.path.dirname(os.path.abspath(__file__)) with open(os.path.join(skill_dir, "scripts/duckdb.sql")) as f: sql = f.read() quiq_csv = "/path/to/quiq_3patients.csv" sql = sql.replace("{quiq_csv}", quiq_csv) df = duckdb.sql(sql).df() total_date = df["Total_date"].sum() invalid_date = df["Invalid_date"].sum() date_validity = round((total_date - invalid_date) / total_date * 100, 2) print(f"Date Validity (%) = {date_validity}") save_path = "/path/to/output" os.makedirs(save_path, exist_ok=True) df.to_csv(f"{save_path}/date_validity_summary.csv", index=False, encoding="utf-8-sig") with open(f"{save_path}/date_validity_total.txt", "w") as f: f.write(f"Date Validity (%) = {date_validity}\n") f.write(f"Total dates = {total_date}\n") f.write(f"Invalid dates = {invalid_date}\n") print(f"Saved {len(df):,} rows โ†’ {save_path}") ``` ### Python ๋ฒ„์ „ (LLM fallback ํฌํ•จ) ```python import pandas as pd import sys, os skill_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, skill_dir) from scripts.date_validity import get_date_validity quiq = pd.read_csv("/path/to/quiq.csv") valid_results_df, summary_df = get_date_validity( quiq=quiq, use_llm=True # False ๋กœ ์„ค์ •ํ•˜๋ฉด LLM fallback ๋น„ํ™œ์„ฑํ™” ) ``` ### As a script with config ```yaml # config.yaml quiq_path: /path/to/quiq.csv save_path: /path/to/output use_llm: true # false ๋กœ ์„ค์ •ํ•˜๋ฉด LLM fallback ์—†์Œ ``` ```bash python scripts/date_validity.py --config config.yaml ``` ## Critical Notes 1. **SQL vs Python ์„ ํƒ** โ€” MIMIC-IV ์ฒ˜๋Ÿผ ISO ํ˜•์‹ ๋‚ ์งœ๋งŒ ์žˆ์œผ๋ฉด SQL ๋ฒ„์ „์œผ๋กœ ์ถฉ๋ถ„. ํฌ๊ท€ ํ˜•์‹์ด๋‚˜ ์ž์—ฐ์–ด ๋‚ ์งœ๊ฐ€ ์„ž์ธ ๋ฐ์ดํ„ฐ๋Š” Python + LLM fallback ๊ถŒ์žฅ. 2. **์›๋ณธ ์ฝ”๋“œ ๋ฒ„๊ทธ ์ˆ˜์ •** โ€” `_gpt_chat` ๋ฐ˜ํ™˜๊ฐ’์ด `list`์ธ๋ฐ `if "no" in result`๋กœ list ์ „์ฒด๋ฅผ ๊ฒ€์ƒ‰ํ–ˆ์Œ โ†’ `result[0]`๋กœ ์ˆ˜์ •. 3. **LLM ํ˜ธ์ถœ ๋ฐฉ์‹** โ€” LLM fallback์€ ํ‘œ์ค€ ํŒŒ์‹ฑ ์‹คํŒจ ์‹œ์—๋งŒ Claude CLI(`claude -p`)๋ฅผ ํ†ตํ•ด ํ˜ธ์ถœ๋จ. MIMIC-IV์—์„œ๋Š” ๊ฑฐ์˜ ํ˜ธ์ถœ๋˜์ง€ ์•Š์Œ. 4. **use_llm=False** โ€” Python ๋ฒ„์ „์—์„œ `use_llm=False` ๋กœ ์„ค์ •ํ•˜๋ฉด LLM fallback ์—†์ด ๊ทœ์น™ ๊ธฐ๋ฐ˜์œผ๋กœ๋งŒ ์‹คํ–‰ ๊ฐ€๋Šฅ. ## References - LYDUS ํ’ˆ์งˆ๊ด€๋ฆฌ ํ”„๋กœ๊ทธ๋žจ ํ™œ์šฉ ๊ฐ€์ด๋“œ๋ผ์ธ (๋น„๊ณต๊ฐœ ๋‚ด๋ถ€ ๋ฌธ์„œ) - Original Python implementation: LYDUS_Date_Validity.py (์ด์„ฑ๋ฏผ ์ž‘์„ฑ)
View on GitHub