This repo contains common variables or variable patterns defined in ehrQL that may be used in multiple OpenSAFELY studies.
The repo is a experiment at collecting commonly used variables in a single place, and will hopefully inform features required for a more formal OpenSAFELY variables library in future.
Please use the following pattern to add a new variable or set of variables:
- Choose a meaningful identifying
{NAME}
for your variable or set of variables, and use this name consistently. - Create a new working branch from
main
. - Create a dataset definition
./analysis/{NAME}/dataset_definition.py
in the./analysis/
directory. This dataset definition will contain the new variable(s). You may wish to add further scripts inside the./analysis/{NAME}/
directory which define additional functions or other code snippets, if this replicates how the variables should be specified in practice. - Any new codelists will need to be added directly to the
./codelists/codelist.txt
- specifying codelists in the variable-specific directories does not work neatly with theopensafely codelists update
operation. Use a large separator, as below, to clearly distinguish groups of codelists belong to each variable(s).####################################################### # {NAME} #######################################################
- Add a new action in the
./project.yaml
file, titledgenerate_dataset_{NAME}
, to run the dataset definition. - Check everything works as intended then submit a PR for review.
Where ever these variables are used in actual research repos, please link back to this repo.
The OpenSAFELY framework is a Trusted Research Environment (TRE) for electronic health records research in the NHS, with a focus on public accountability and research quality.
Read more at OpenSAFELY.org.
As standard, research projects have a MIT license.