Variables are a complex entity in that they combine Python code used in the study_definition.py
,
creation of the codelist on OpenCodelists and Python code to import
codelists into the study defintion, usually in a file called codelists.py
.
Many OpenSAFELY studies contain the same variables that are implemented within the study
definition. Currently these are either manually written, with guidance from the
documentation or more commonly copied and pasted across
from other studies, and dates changed. When the cohortextractor
API endpoints have changed
or updated, this can mean that sometimes variables are written in an out of date way.
A variable library would aim to address the above problem by having one place for variables to be taken off the shelf from, and pasted into research projects. In the future, we would aim for this to have an interactive GUI or user interface with dropdown menus, and the ability to save and tweak. For now, this repo is a MVP of what the implementation of a Variable Library would look like. It contains issues for different variable options with codeblocks for easy copy and pasting across to your study definition. These have documentation and will act as an easily explainable library of variables.
We will iterate and roadtest the components of this library before implementing a more complicated project with user interface. Please see the discussion for what this project may iterate into.
Researchers can contribute in two ways:
1) Put useful variables into an in issue on this repo with good documentation. At a
minimum, an issue should contain code for the study_definition.py
, code for the
codelists.py
and the relevant codelist link (usually as a codelists.txt
). It will be easier
copy and paste if this is put into code blocks which format it correctly.