Skip to content
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

Merged
merged 7 commits into from
Apr 25, 2024
Merged

Conversation

evansd
Copy link
Contributor

@evansd evansd commented Apr 24, 2024

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

Copy link

cloudflare-workers-and-pages bot commented Apr 25, 2024

Deploying databuilder-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9b6801d
Status: ✅  Deploy successful!
Preview URL: https://b3299b55.databuilder.pages.dev
Branch Preview URL: https://evansd-consultation-id.databuilder.pages.dev

View logs

Copy link
Contributor

@rebkwok rebkwok left a 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.

@table
class medications(ehrql.tables.core.medications.__class__):
"""
The medication table provides data about prescribed medications in primary care.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The medication table provides data about prescribed medications in primary care.
The medications table provides data about prescribed medications in primary care.

evansd added 7 commits April 25, 2024 13:27
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose consultation_id column on clinical_events and medications
2 participants