Skip to content

Create inclusion/exclusion flowcharts


cohort-extractor is now deprecated. All new projects should use ehrQL to extract data from an OpenSAFELY database.

Flowcharts (temporary workaround)🔗

Many studies will require a flowchart to show inclusion/exclusion of patients in the study. Eventually the numbers of patients excluded/included will be summarised automatically following cohort extract, but for now, a slightly manual approach is required:

  • Make a copy of the study definition (called The population=patients.satisfying() function should be replaced with population=patients.all(). Then all variables except for those that appeared in the population definition logic should be removed (this will mean that it runs much faster than the main study definition). An example of such a study definition can be seen in this repository on NSAIDS use and COVID-related outcomes.
  • Then write a script that reads the input_flow_chart.csv and then sequentially drops each of the variables and counts the remaining population, in whatever order you'd like to report them; Stata example.