Identifying individual health events #262
-
Our study requires counting the number of events satisfying a given codelist (e.g. codelist for RTIs). For example, if patient X attends their GP on two different occasions during the study period, and are coded as having an RTI both times, we need to count both events for that patient. However, the study_definition.py template is set up for patient-level data. Is there a way to derive counts of events rather than patients by either
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Currently there isn't a straightforward way to return all the individual events themselves. We hope to add this functionality eventually. However, if you only need to count the individual events, you can return the count of recorded events within a given time period by using the Does that fulfil your use case? |
Beta Was this translation helpful? Give feedback.
-
Option 1 is not currently possible -- see this issue and the issues linked therein for more info about how we're working to resolve this. Option 2 is possible with a bit of guile. See section Extracting a series of consecutive events in this issue. WARNING I wouldn't recommend this approach if you want to return a large number of events. This would mean you need to create lots of variables (columns) which means more queries and slower extraction time. It might be useful for you to talk through your use-case in a bit more detail first. |
Beta Was this translation helpful? Give feedback.
Currently there isn't a straightforward way to return all the individual events themselves. We hope to add this functionality eventually.
However, if you only need to count the individual events, you can return the count of recorded events within a given time period by using the
returning="number_of_matches_in_period"
option, which will return an integer count, as documented here:https://docs.opensafely.org/study-def-variables/#cohortextractor.patients.with_these_clinical_events
Does that fulfil your use case?