A command line interface for the TriNetX query browser
A federated-network query tool gives you a browser and no API. The numbers it returns are real, but the path to them lives in whoever did the clicking. The point of this script is that the path becomes a file you can read, diff and run again.
Why the counts stopped being typed
The output of this tool is the input to everything downstream.
Each run writes a counts file and a folder of query definitions. Those counts are what the master workbook reads, and the workbook is what the cohort figure on this site reads — live, by query name. A number on the prostate cancer page is therefore traceable back through the sheet, through the dump, to the query definition that produced it, without any step in that chain being a person retyping a figure.
The question
If the analysis has to be defensible, can the query layer underneath it be made reproducible when the vendor only offers a web interface?
How it is being done
- The study comes from the working directory. Nothing is hardcoded — the script resolves which study it is operating on from where it was run, so the same command cannot quietly point at the wrong cohort.
- Definitions are dumped, not transcribed. Each query’s full logic — every code, every date window, every include and exclude — is written to text, which is what makes a methods section checkable after the fact.
- Already-dumped queries are skipped before the refresh, so a second run costs nothing and no count is recomputed for the sake of it.
- Bulk edits are a flag, not an afternoon. Appending a suffix to every query name, or find-and-replacing inside the group titles, happens across the whole study at once, with a dry run that lists the changes before any of them are typed.
- It drives a Chrome you already have open over the DevTools protocol rather than launching its own, and deliberately does not steal focus — a long run leaves you working in whatever else you were doing.
What comes next
The same treatment for the parts still done by hand — chiefly turning a dumped definition straight into the methods paragraph that describes it.