{
 "use_case": "medical-chronology",
 "title": "Medical chronology: 16 pages of mixed synthetic records for a fictional patient",
 "about": "Dana Whitlock is fictional. After a rear-end collision on 8 March 2024, five providers send records: typed PCP notes (born-digital PDF), a scanned ED note and lab table, a handwritten physical-therapy evaluation and flow sheet, two MRI reports, and an orthopedic file with a scanned operative note. The ED note also arrives as a fax inside the PCP's file, and the lumbar MRI report as a fax inside the orthopedic file. Planted: the rotator cuff repair's date is given differently in the post-procedure note, therapy stops for 138 days, and a 2022 low-back visit comes before the injury. The run must list the events with a page and box on every line, flag the conflict, the gap and the pre-existing low-back condition (as related), merge the faxed copies, and sign a record that verifies and fails when changed. It takes a few minutes: every page is read by the document reader and one model call is made per page.",
 "licence": "Synthetic: the patient, providers, dates and records are invented (decosa_api/verticals/chronology/synth.py; handwriting in the OFL fonts Kalam and Patrick Hand). Part of decosa-api, AGPL-3.0-or-later.",
 "inputs": [
  {"file": "inputs/F1.pdf", "what": "Riverside Family Medicine: typed office notes (2022, 2023, after the injury, follow-up) and a faxed copy of the ED note."},
  {"file": "inputs/F2.pdf", "what": "Mercy County Hospital: the scanned ED note and lab table from the day of the injury."},
  {"file": "inputs/F3.pdf", "what": "Summit Imaging Center: MRI reports of the lumbar spine (scanned) and the right shoulder (typed)."},
  {"file": "inputs/F4.pdf", "what": "Harbor Physical Therapy: a handwritten evaluation, a handwritten flow sheet and a scanned discharge summary."},
  {"file": "inputs/F5.pdf", "what": "Cascade Orthopedics & Spine: the consult, a faxed copy of the lumbar MRI report, the scanned operative note and the post-procedure note."}
 ],
 "steps": [
  {
   "id": "run",
   "method": "POST",
   "path": "/chronology/run",
   "timeout": 1200,
   "body": {
    "synthetic": true,
    "incident_date": "2024-03-08",
    "claimed": ["low back", "right shoulder"],
    "files": [
     {"name": "F1", "title": "Riverside Family Medicine: office records", "file_b64": {"$b64": "inputs/F1.pdf"}},
     {"name": "F2", "title": "Mercy County Hospital: emergency department records", "file_b64": {"$b64": "inputs/F2.pdf"}},
     {"name": "F3", "title": "Summit Imaging Center: imaging reports", "file_b64": {"$b64": "inputs/F3.pdf"}},
     {"name": "F4", "title": "Harbor Physical Therapy: therapy records", "file_b64": {"$b64": "inputs/F4.pdf"}},
     {"name": "F5", "title": "Cascade Orthopedics & Spine: specialist records", "file_b64": {"$b64": "inputs/F5.pdf"}}
    ]
   }
  },
  {"id": "verify", "method": "POST", "path": "/record/verify", "auth": false, "body": {"record": {"$ref": "run.record"}}},
  {"id": "tampered", "method": "POST", "path": "/record/verify", "auth": false, "body": {"record": {"$ref": "run.record"}},
   "tamper": {"at": "record.statement.counts.entries", "set": 0}}
 ],
 "checks": [
  {"says": "every page was read and gave an answer", "path": "run.complete", "equals": true},
  {"says": "the rotator cuff repair is listed and its conflicting date is flagged", "path": "run.entries[type=procedure,label~rotator cuff,flags~conflict]", "count_min": 1},
  {"says": "the 138-day gap in treatment is found", "path": "run.gaps[days=138]", "count": 1},
  {"says": "the 2022 low back pain is flagged before the injury and judged related", "path": "run.preexisting[date=2022-11-15,related=related]", "count": 1},
  {"says": "the faxed ED note inside the PCP's file is merged as a copy", "path": "run.copies[copy.file=F1,copy.page=4]", "count": 1},
  {"says": "at least 25 entries, each located in the retrieval index", "path": "run.counts.entries", "min": 25},
  {"says": "every cite's quote is located in an index chunk", "path": "run.stats.cites_in_index", "min": 25},
  {"says": "each file has a signed document-reader receipt", "path": "run.documents[receipt~dr-]", "count": 5},
  {"says": "the chronology says it is not medical or legal advice", "path": "run.markdown", "contains": "not medical or legal advice"},
  {"says": "the signed record verifies", "path": "verify.ok", "equals": true},
  {"says": "the record fails once its entry count is changed", "path": "tampered.ok", "equals": false},
  {"says": "every model call has a signed receipt", "receipts": "signed", "min": 16}
 ]
}
