Sync new medical exam PDFs into the site's JSON data files. Use when the user runs /process-exams or asks to process, sync, or import new exams. Scans drive/Exams/ for unprocessed files, extracts structured data via subagents, and updates exam.json and examvalues.json.
Detect new exam files in drive/Exams/, extract structured data from each, and append to the site's JSON data files.
5d2a48010f15903e74c855984fc7d3640d33737b/{base}/drive/Exams/{base}/jsonout/exam.json and {base}/jsonout/examvalues.json{base}/sync-state.jsonRead sync-state.json. Structure:
{
"processed": { "filename.pdf": { "processed_at": "ISO", "has_summary": true, "has_values": true } },
"skipped": { "filename.pdf": { "reason": "exam request, not results" } }
}
List all files in . Compare against sync-state (use Unicode NFC normalization for filenames). Report counts and list new files.
drive/Exams/If no new files, stop.
Auto-skip and add to skipped:
.docx files → "unsupported format"Ask user to confirm processing vs skipping for non-PDF image files (.jpg, .jpeg, .png).
Report triage results, confirm before proceeding.
For each file to process, launch a general-purpose subagent using the prompt template in references/extraction-prompts.md. Launch up to 3 subagents in parallel.
For each successful extraction:
exam.json and examvalues.jsonmeta field to each object (copy of all fields except file — legacy compatibility)sample_date ascendingsync-state.jsonIf subagent returns SKIP:reason, add to skipped.
Summary of processed, skipped, and errored files.
meta field for backward compatibility