-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose consultation_id
on TPP medications
table
#1993
Conversation
7ee5414
to
2a2da76
Compare
Deploying databuilder-docs with Cloudflare Pages
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I had an attempt at doing the table inheritance a while ago but couldn't figure out how to get it to work. There are probably some other tables that should be updated with it too (I think it was the clinical events table that i wanted to do it for before.
ehrql/tables/tpp.py
Outdated
@table | ||
class medications(ehrql.tables.core.medications.__class__): | ||
""" | ||
The medication table provides data about prescribed medications in primary care. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The medication table provides data about prescribed medications in primary care. | |
The medications table provides data about prescribed medications in primary care. |
This allows us to say: "this table here is just like this other one there but adds some extra columns." Auto-complete continues to work correctly and picks up the inherited columns.
Docstrings are a bit of a wrinkle here: they obviously aren't automatically inherited from the parent; we could set them dynamically by fiddling about with the `__doc__` attribute but that would prevent them showing up in VSCode, and it's quite a nice feature that they display directly in the editor. So instead we require them to be manually copy-pasted but we add a check that they are consistent to avoid drift. We don't require that they are identical because it seems reasonable to allow the child table to extend the parent docstring, but they must share a common prefix.
2a2da76
to
9b6801d
Compare
This requires us to create a TPP specialisation of existing core table. Obviously we can just do this by copy/pasting but I worry that this risks drift in the documentation. (Drift in the table structure itself is less of a worry as the backends will naturally enforce consistency for tables sharing the same name.) So I've made a slight tweak to the
@table
decorator to support table inheritance and added a mechanism to enforce docstring consistency.Closes #1983