Skip to content
Bits & Flames Fyron Documentation GitHub
DocsCohort reconciliation

Reconcile a document cohort and retry a failed download

Read or download the complete example script. To run the repository copy, install Fyron Beta 6 and execute:

bash
python examples/cohort_reconciliation.py

The example starts with patient strings 001 through 005. A synthetic FHIR DocumentReference search and a simulated PostgreSQL cohort query return the same document index. Both routes run the document extraction and patient summary workflows. Model answers are fixed and all requests stay offline.

PatientRecords foundDocuments expectedDocuments readSummary before retryReason
001111ok
002000no_matching_records
003110incompletedownload_failed
004110incompleteempty_text
005221incompleteempty_text

Start the final table from the original cohort and left-join counts and summaries. Patient 002 had no match in this query. Patient 003 had a matching document that could not be retrieved. Treating either as a negative clinical finding would lose that distinction.

Retry selected results

In the example, inspect answers[answers.reason.eq("download_failed")] and retry only after the synthetic service recovers. Replace answers on the pair (doc_id, prompt_name) and preserve every other row. Rebuild summaries only for patients whose answers changed. Patient 003 now has one readable document and an ok summary. Patients 004 and 005 still need source review or OCR. Inspect the per-source reasons in sources when a group reports multiple_reasons.

The example uses one extraction prompt per document and one attachment per matching record. When using multiple prompts or attachments, count distinct documents independently of answer rows.