opensafely-core / ehrql

ehrQL: the electronic health record query language for OpenSAFELY
https://docs.opensafely.org/ehrql/
Other
7 stars 3 forks source link

Update example data with properties useful for tutorial #2215

Closed inglesp closed 4 days ago

inglesp commented 1 week ago

For the tutorial, we plan to help users work through writing ehrQL queries related to the following QOF rules for diabetes:

For this, we'll need example data with the following properties:

For now, we should use arbitrary numbers to be the code for each kind of event/prescription:

Here's some example code that could be adapted to create diabetes events.

if random.random() < 0.75:
    # patient has a diabetes diagnosis code and no diabetes resolved code
    yield "clinical_events", {"date": date, "dmd_code": 111}
elif random.random() < 0.05:
    # patient has a diabetes diagnosis code followed by a diabetes resolved code
    yield "clinical_events", {"date": date1, "dmd_code": 111}
    yield "clinical_events", {"date": date2, "dmd_code": 222}
elif random.random() < 0.05:
    # patient has a diabetes diagnosis code followed by a diabetes resolved code, followed by another diagnosis code
    yield "clinical_events", {"date": date1, "dmd_code": 111}
    yield "clinical_events", {"date": date2, "dmd_code": 222}
    yield "clinical_events", {"date": date3, "dmd_code": 111}