Hosp Code
Overview
Use this skill to turn research code into a hospital-ready handoff package that can run outside the developer's machine, explain exactly what the hospital must edit, protect sensitive row-level data, and produce reproducible clinical AI outputs.
For detailed acceptance criteria, read references/hospital-code-delivery-checklist.md when auditing a package, designing a new package, or investigating hospital feedback.
Workflow
- Identify the task mode:
- Package or retrofit: modify code/docs so the bundle can run at the hospital.
- Audit: compare an existing package against the checklist and report gaps by severity.
- Debug feedback: triage a hospital error from logs, preflight output, and used config.
- Inspect the current bundle before editing. Locate the entrypoint, README, requirements, config template, input templates, experiment inventory, output folders, and any local absolute paths.
- Keep the handoff contract narrow: one documented entrypoint, config-driven paths, no developer-machine assumptions, and clear boundaries between local sensitive inputs and returnable de-identified results.
- Implement the smallest changes needed to satisfy the contract. Preserve existing scientific logic unless the user explicitly asks to redesign experiments.
- Validate with compilation, preflight or dry-run where available, README/config consistency checks, and sensitive-output checks.
- Report exactly what changed, what command the hospital should run, what version string should appear in logs, and any remaining limitations.
Non-Negotiables
- Provide a single main entrypoint such as
run_all.py.
- Route all hospital-specific paths through config files such as
config_template.json and config_hospital.json.
- Put the hospital's required edits at the top of the README: what to fill, environment setup, and run command.
- Print a package version at startup and write the same version into
used_config.json.
- Run preflight before real experiments and write
preflight_check.txt plus used_config.json.
- Make long runs observable with
[INFO], [RUN], [DONE], [WARN], and [ERROR] logs, including heartbeat messages for slow steps and a clear final completion signal.
- Write
FAILED_STEP_README.txt on fatal failure when practical.
- Treat
To_hospital/ as a sensitive local sandbox and keep returnable result folders de-identified by default.
- Treat
To_hospital_sensitive_do_not_return/ as a hospital-internal retention and verification directory that must not be sent back with result folders.
- Default to
retain_sensitive_row_level_outputs=false unless the hospital explicitly enables local debugging output.
- Avoid Python 3.9+ assumptions and fragile dependency choices when the hospital may run Python 3.8 or older pandas/sklearn.
README Requirements
Put these as the first three README sections:
- What the hospital must fill in or modify.
- Environment setup.
- Run command.
Include the exact clinical info file name, required columns, optional/recommended columns, fields the hospital should not edit, config keys to change, and the shortest command, for example:
python run_all.py --config config_hospital.json
If the package starts from de-identified feature tables rather than raw audio, ASR, or feature extraction, say so explicitly near the top.
Package Structure
Prefer a handoff package containing:
README_医院交接说明.md or an equivalent README.
run_all.py or one documented main entrypoint.
requirements.txt.
config_template.json.
config_hospital.json if safe to include without real secrets or paths.
- An input template such as
ID_info.xlsx.
hospital_code_experiment_inventory.md or an equivalent code/experiment inventory.
- The project SOP or a pointer to it when useful.
Do not include local test outputs, __pycache__, result folders, or sensitive hospital data in the zip.
Preflight And Logging
Before modeling or analysis, preflight must check Python version, key dependency versions, required input files, required columns, sample ID columns, non-empty target columns, and missing recommended fields.
Error messages should tell the hospital which file or field is missing, which log to read first, and which artifacts to send back for debugging.
For each major step:
- Print
[RUN] step name before it starts.
- Print
[DONE] step name (xxs) after it succeeds, where xxs is elapsed time.
- If a step runs longer than 60 seconds, print
[INFO] Still running: step name (xxs elapsed) every 60 seconds until it finishes.
- After all analyses finish, print
[DONE] ALL ANALYSES COMPLETED as a highly visible final success signal.
- Print
[INFO] package version at startup.
- Emit JSON summaries from child scripts when practical.
Sensitive Output Rules
Separate local sensitive data from returnable results:
To_hospital/ may contain hospital-local ID_info and merged feature/clinical tables.
To_hospital_sensitive_do_not_return/ is for hospital-local retention and verification only. It must not be bundled with returnable result directories.
- If present,
To_hospital_sensitive_do_not_return/ should contain task_feature_info_merged_for_hospital_internal_use.csv, README_DO_NOT_RETURN.txt, and internal_archive_manifest.json.
- Result directories must not retain raw IDs, names, clinical details, or identifiable row-level tables by default.
- Per-subject predictions should use IDs such as
anon_subject_id.
- Returnable row-level files should include
no_id in filenames when applicable.
- Clean intermediate files that include ID fields before finishing unless local debugging output was explicitly requested.
In the README, state which directories can be sent back and which must stay inside the hospital. Explicitly mark To_hospital_sensitive_do_not_return/ as non-returnable.
Medical AI Experiment Scope
When the goal is a publishable medical AI analysis, make the experiment inventory distinguish:
- Cohort definitions and inclusion/exclusion rules.
- Internal CV, nested CV, temporal/site/device split, and external validation.
- Exploratory feature selection versus locked validation performance.
- Clinical baselines, traditional task scores, AI features, and combined models.
- Classification metrics, regression metrics, calibration, clinical utility, interpretability, subgroup fairness, missingness, and reproducibility artifacts.
Do not let optional modules such as SHAP, large visual reports, or long sensitivity analyses block the main run. They should write status files when unavailable.
Validation Before Handoff
Run the strongest checks available in the repo:
python -m py_compile path/to/script.py
python run_all.py --config config_hospital.json
If full execution is too expensive or needs real hospital data, prefer a --dry-run or preflight-only mode when it exists. Also inspect the final zip or folder for the latest version string, required templates, README order, requirements, config files, and absence of sensitive outputs.
Hospital Error Triage
When the hospital reports a failure, ask first for:
- Complete run log.
- First log line showing package version.
preflight_check.txt.
used_config.json.
FAILED_STEP_README.txt.
Triage in this order: stale package version, path quoting or spaces, old Python/pandas/sklearn, missing fields or empty target columns, renamed or moved input files, missing optional dependencies, then sensitive files accidentally written into returnable results.
1---2name: hosp-code3description: Prepare, audit, or debug hospital-facing reproducible code handoff packages for medical AI analyses. Use when packaging code for an external hospital or collaborator, especially AVLT, Cookie, Picnic, speech/cognition, or similar clinical AI projects that need README-first instructions, config templates, input templates, preflight checks, versioned run_all.py entrypoints, heartbeat/progress logging, de-identified returnable results, sensitive local sandboxes, do-not-return hospital-internal archives, reproducible experiment inventories, or hospital error triage. Also use for Chinese requests such as 医院代码交付, 医院交接代码, 医院交付包, 对外交付code, 对外交付代码, 医院可复现代码, or 医院运行报错排查.4---56# Hosp Code78## Overview910Use this skill to turn research code into a hospital-ready handoff package that can run outside the developer's machine, explain exactly what the hospital must edit, protect sensitive row-level data, and produce reproducible clinical AI outputs.1112For detailed acceptance criteria, read `references/hospital-code-delivery-checklist.md` when auditing a package, designing a new package, or investigating hospital feedback.1314## Workflow15161. Identify the task mode:17 - **Package or retrofit**: modify code/docs so the bundle can run at the hospital.18 - **Audit**: compare an existing package against the checklist and report gaps by severity.19 - **Debug feedback**: triage a hospital error from logs, preflight output, and used config.202. Inspect the current bundle before editing. Locate the entrypoint, README, requirements, config template, input templates, experiment inventory, output folders, and any local absolute paths.213. Keep the handoff contract narrow: one documented entrypoint, config-driven paths, no developer-machine assumptions, and clear boundaries between local sensitive inputs and returnable de-identified results.224. Implement the smallest changes needed to satisfy the contract. Preserve existing scientific logic unless the user explicitly asks to redesign experiments.235. Validate with compilation, preflight or dry-run where available, README/config consistency checks, and sensitive-output checks.246. Report exactly what changed, what command the hospital should run, what version string should appear in logs, and any remaining limitations.2526## Non-Negotiables2728- Provide a single main entrypoint such as `run_all.py`.29- Route all hospital-specific paths through config files such as `config_template.json` and `config_hospital.json`.30- Put the hospital's required edits at the top of the README: what to fill, environment setup, and run command.31- Print a package version at startup and write the same version into `used_config.json`.32- Run preflight before real experiments and write `preflight_check.txt` plus `used_config.json`.33- Make long runs observable with `[INFO]`, `[RUN]`, `[DONE]`, `[WARN]`, and `[ERROR]` logs, including heartbeat messages for slow steps and a clear final completion signal.34- Write `FAILED_STEP_README.txt` on fatal failure when practical.35- Treat `To_hospital/` as a sensitive local sandbox and keep returnable result folders de-identified by default.36- Treat `To_hospital_sensitive_do_not_return/` as a hospital-internal retention and verification directory that must not be sent back with result folders.37- Default to `retain_sensitive_row_level_outputs=false` unless the hospital explicitly enables local debugging output.38- Avoid Python 3.9+ assumptions and fragile dependency choices when the hospital may run Python 3.8 or older pandas/sklearn.3940## README Requirements4142Put these as the first three README sections:43441. What the hospital must fill in or modify.452. Environment setup.463. Run command.4748Include the exact clinical info file name, required columns, optional/recommended columns, fields the hospital should not edit, config keys to change, and the shortest command, for example:4950```bash51python run_all.py --config config_hospital.json52```5354If the package starts from de-identified feature tables rather than raw audio, ASR, or feature extraction, say so explicitly near the top.5556## Package Structure5758Prefer a handoff package containing:5960- `README_医院交接说明.md` or an equivalent README.61- `run_all.py` or one documented main entrypoint.62- `requirements.txt`.63- `config_template.json`.64- `config_hospital.json` if safe to include without real secrets or paths.65- An input template such as `ID_info.xlsx`.66- `hospital_code_experiment_inventory.md` or an equivalent code/experiment inventory.67- The project SOP or a pointer to it when useful.6869Do not include local test outputs, `__pycache__`, result folders, or sensitive hospital data in the zip.7071## Preflight And Logging7273Before modeling or analysis, preflight must check Python version, key dependency versions, required input files, required columns, sample ID columns, non-empty target columns, and missing recommended fields.7475Error messages should tell the hospital which file or field is missing, which log to read first, and which artifacts to send back for debugging.7677For each major step:7879- Print `[RUN] step name` before it starts.80- Print `[DONE] step name (xxs)` after it succeeds, where `xxs` is elapsed time.81- If a step runs longer than 60 seconds, print `[INFO] Still running: step name (xxs elapsed)` every 60 seconds until it finishes.82- After all analyses finish, print `[DONE] ALL ANALYSES COMPLETED` as a highly visible final success signal.83- Print `[INFO] package version` at startup.84- Emit JSON summaries from child scripts when practical.8586## Sensitive Output Rules8788Separate local sensitive data from returnable results:8990- `To_hospital/` may contain hospital-local `ID_info` and merged feature/clinical tables.91- `To_hospital_sensitive_do_not_return/` is for hospital-local retention and verification only. It must not be bundled with returnable result directories.92- If present, `To_hospital_sensitive_do_not_return/` should contain `task_feature_info_merged_for_hospital_internal_use.csv`, `README_DO_NOT_RETURN.txt`, and `internal_archive_manifest.json`.93- Result directories must not retain raw IDs, names, clinical details, or identifiable row-level tables by default.94- Per-subject predictions should use IDs such as `anon_subject_id`.95- Returnable row-level files should include `no_id` in filenames when applicable.96- Clean intermediate files that include ID fields before finishing unless local debugging output was explicitly requested.9798In the README, state which directories can be sent back and which must stay inside the hospital. Explicitly mark `To_hospital_sensitive_do_not_return/` as non-returnable.99100## Medical AI Experiment Scope101102When the goal is a publishable medical AI analysis, make the experiment inventory distinguish:103104- Cohort definitions and inclusion/exclusion rules.105- Internal CV, nested CV, temporal/site/device split, and external validation.106- Exploratory feature selection versus locked validation performance.107- Clinical baselines, traditional task scores, AI features, and combined models.108- Classification metrics, regression metrics, calibration, clinical utility, interpretability, subgroup fairness, missingness, and reproducibility artifacts.109110Do not let optional modules such as SHAP, large visual reports, or long sensitivity analyses block the main run. They should write status files when unavailable.111112## Validation Before Handoff113114Run the strongest checks available in the repo:115116```bash117python -m py_compile path/to/script.py118python run_all.py --config config_hospital.json119```120121If full execution is too expensive or needs real hospital data, prefer a `--dry-run` or preflight-only mode when it exists. Also inspect the final zip or folder for the latest version string, required templates, README order, requirements, config files, and absence of sensitive outputs.122123## Hospital Error Triage124125When the hospital reports a failure, ask first for:126127- Complete run log.128- First log line showing package version.129- `preflight_check.txt`.130- `used_config.json`.131- `FAILED_STEP_README.txt`.132133Triage in this order: stale package version, path quoting or spaces, old Python/pandas/sklearn, missing fields or empty target columns, renamed or moved input files, missing optional dependencies, then sensitive files accidentally written into returnable results.