opensafely-core / opensafely-core/opencodelists
Categories within codelists
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 60
- Forks
- 16
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 17
Description
Sometimes it would be good to have additional categories within a codelist that you can call upon in study defintion or analysis without creating an extra codelist. We have sort of done this with ethnicity. Here are two more examples to help inform thinking on any future developments
Antidiabetic medications We have a full list of medicines used for diabetes. This is comprehensive but within this there are different classes of medications - in an analysis you will want to further analyse by each class. Currently the only way to do this is to have the complete list plus a separate codelists for each class - (e.g. like Manuj has done here) Having the category in the complete list would be more efficent, reduce time compiling codelists and also I think will be eaiser to maintain in future. Study definition may need to be updated to support analysis with the categories.
Pulse Oximetry - We have started a codelist here and you can clearly see that there are different categories of code finding, procedure etc. Depending on the study you may want to use different ones depending on question - this isn't the most compelling use case but you may want to utilse categories here depending on the study.

Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing the ethnicity and antidiabetic medications codelists, then review the pulse oximetry example to understand how categories are currently represented. Determine which codelist and study-definition entry points would need to support reusable categories; done means a single codelist can expose category selections for analysis without duplicating separate codelists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100