From 2e47c90ccec399c8db073ee5901eb7b75f392c5b Mon Sep 17 00:00:00 2001 From: David Evans Date: Mon, 21 Oct 2024 17:05:45 +0100 Subject: [PATCH] Run `just generate-docs` --- docs/includes/generated_docs/schemas/core.md | 108 ++++++++++++++++++ docs/includes/generated_docs/schemas/emis.md | 112 +++++++++++++++++++ 2 files changed, 220 insertions(+) diff --git a/docs/includes/generated_docs/schemas/core.md b/docs/includes/generated_docs/schemas/core.md index cb4a91758..a3e88da26 100644 --- a/docs/includes/generated_docs/schemas/core.md +++ b/docs/includes/generated_docs/schemas/core.md @@ -12,6 +12,7 @@ from ehrql.tables.core import ( medications, ons_deaths, patients, + practice_registrations, ) ``` @@ -486,3 +487,110 @@ return (date - patients.date_of_birth).years + + +

many rows per patient

+## practice_registrations + +Each record corresponds to a patient's registration with a practice. +
+
Columns
+
+
+
+ start_date + 🔗 + date +
+
+Date patient joined practice. + + * Never `NULL` +
+
+ +
+
+ end_date + 🔗 + date +
+
+Date patient left practice. + +
+
+ +
+
+ practice_pseudo_id + 🔗 + integer +
+
+Pseudonymised practice identifier. + + * Never `NULL` +
+
+ +
+
+
+
Methods
+
+
+
+ for_patient_on(date) + 🔗 + +
+
+Return each patient's practice registration as it was on the supplied date. + +Where a patient is registered with multiple practices we prefer the most recent +registration and then, if there are multiple of these, the one with the longest +duration. If there's stil an exact tie we choose arbitrarily based on the +practice ID. +
+ View method definition +```py +spanning_regs = practice_registrations.where(practice_registrations.start_date <= date).except_where( + practice_registrations.end_date < date +) +ordered_regs = spanning_regs.sort_by( + practice_registrations.start_date, + practice_registrations.end_date, + practice_registrations.practice_pseudo_id, +) +return ordered_regs.last_for_patient() + +``` +
+
+
+ +
+
+ spanning(start_date, end_date) + 🔗 + +
+
+Filter registrations to just those spanning the entire period between +`start_date` and `end_date`. +
+ View method definition +```py +return practice_registrations.where( + practice_registrations.start_date.is_on_or_before(start_date) + & (practice_registrations.end_date.is_after(end_date) | practice_registrations.end_date.is_null()) +) + +``` +
+
+
+ +
+
diff --git a/docs/includes/generated_docs/schemas/emis.md b/docs/includes/generated_docs/schemas/emis.md index b675c80a1..14a41c242 100644 --- a/docs/includes/generated_docs/schemas/emis.md +++ b/docs/includes/generated_docs/schemas/emis.md @@ -12,6 +12,7 @@ from ehrql.tables.emis import ( medications, ons_deaths, patients, + practice_registrations, vaccinations, ) ``` @@ -568,6 +569,117 @@ return patients.registration_start_date.is_on_or_before(start_date) & ( +

many rows per patient

+## practice_registrations + +Each record corresponds to a patient's registration with a practice. + +!!! warning + At present, the EMIS database contains only the patient's current practice + registration and does not include their full registration history. +
+
Columns
+
+
+
+ start_date + 🔗 + date +
+
+Date patient joined practice. + + * Never `NULL` +
+
+ +
+
+ end_date + 🔗 + date +
+
+Date patient left practice. + +
+
+ +
+
+ practice_pseudo_id + 🔗 + integer +
+
+Pseudonymised practice identifier. + + * Never `NULL` +
+
+ +
+
+
+
Methods
+
+
+
+ for_patient_on(date) + 🔗 + +
+
+Return each patient's practice registration as it was on the supplied date. + +Where a patient is registered with multiple practices we prefer the most recent +registration and then, if there are multiple of these, the one with the longest +duration. If there's stil an exact tie we choose arbitrarily based on the +practice ID. +
+ View method definition +```py +spanning_regs = practice_registrations.where(practice_registrations.start_date <= date).except_where( + practice_registrations.end_date < date +) +ordered_regs = spanning_regs.sort_by( + practice_registrations.start_date, + practice_registrations.end_date, + practice_registrations.practice_pseudo_id, +) +return ordered_regs.last_for_patient() + +``` +
+
+
+ +
+
+ spanning(start_date, end_date) + 🔗 + +
+
+Filter registrations to just those spanning the entire period between +`start_date` and `end_date`. +
+ View method definition +```py +return practice_registrations.where( + practice_registrations.start_date.is_on_or_before(start_date) + & (practice_registrations.end_date.is_after(end_date) | practice_registrations.end_date.is_null()) +) + +``` +
+
+
+ +
+
+ +

many rows per patient

## vaccinations