Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/data-sources/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
- [Airmid (PROMPT)](../ehrql/reference/schemas/tpp.md#open_prompt)
- [Covid-19 test results](./sgsscovid.md)
- [Covid-19 therapeutics](./therapeutics.md)
- [HealthCareWorker](/ehrql/reference/schemas/tpp/#occupation_on_covid_vaccine_record)
- [HealthCareWorker](../ehrql/reference/schemas/tpp.md#occupation_on_covid_vaccine_record)
- [High Cost Drugs](./hcd.md)
- [In-hospital deaths (Covid-19 only)](./cpns.md)
- [Intensive care admissions (Covid-19 only)](./icnarc.md)
Expand Down
15 changes: 4 additions & 11 deletions docs/data-sources/systmone.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

It captures symptoms, investigations, test results, diagnoses, prescriptions, demographic and social characteristics, etc. Essentially this is everything about a patient that is electronically recorded or accessed by GPs.

Records for patients who have registered a [National Data Opt-out](https://docs.opensafely.org/national-data-opt-outs/) will be included or excluded according to the [project's approvals](https://www.opensafely.org/approved-projects/).
!!! note "What patient data is made available in OpenSAFELY-TPP?"
A very detailed description of the patient data is available on the [OpenSAFELY Data page](../opensafely-data/index.md).

## The OpenSAFELY-TPP database

The SystmOne database contains various tables for events, medications, registrations, and so on, which have been processed, pseudonymised, and made available within the OpenSAFELY-TPP database. Some additional custom tables are also created, for instance to make administrative and geographic grouping information available (like household membership) without disclosing of identifiable patient data (like addresses).

Clinical and consultation events are coded in SystmOne using an augmented version of CTV3 Read codes, and also available using SNOMED CT codes. These are available in the OpenSAFELY-TPP database in the `CodedEvent` table. Each row is made up of a patient identifier, an event code, an event date, and an additional interaction identifier linking the event to a specific patient–service interaction, such as a GP consultation, getting bloods, receiving test results, updating contact details, and so on (perhaps confusingly, this is called the "consultation" identifier). There may also be an additional numeric value stored, for instance if the code relates to a physiological measurement.

Medications are coded using DM+D codes, and are available in the `MedicationIssue` table which is structured similarly to `CodedEvent`.
Medications are coded using dm+d codes, and are available in the `MedicationIssue` table which is structured similarly to `CodedEvent`.

The `Vaccination` table contains information on administered vaccinations, identified using either the target disease (e.g., influenza), or the vaccine product (e.g., Optaflu).

Expand Down Expand Up @@ -111,22 +112,14 @@ When TPP receive data from external data sources (eg ONS), the tables are comple
## OpenSAFELY-TPP database builds

The OpenSAFELY-TPP database is typically built every four weeks.
In essence, this involves refreshing the database records so that the following groups are available for analysis:

1. All patients currently registered[^1] at a TPP practice
2. All patients registered at any time from 2009-01-01 onwards, but having since de-registered
3. All patients registered at any time from 2009-01-01 onwards, but having since died.

These three groups constitute the patient population available for analysis within the OpenSAFELY-TPP database.
Note that any primary care events occurring in de-registered patients after the de-registration date will not be available in the TPP patient record, though any events recorded in external linked datasets (such as hospitals admissions or deaths) will be visible.

Every time the database is re-built there will differences, either due to new registrations or changes to patient records that include/exclude them from the study cohort.
Old database builds cannot be recovered, and due to the differences between successive database builds, old study populations are unlikely to be re-extracted exactly as before.

For those with access to the OpenSAFELY database, the latest database build time is available in the `LatestBuildTime` table, and the history of builds for each dataset is available in the `BuildInfo` table.

## OpenSAFELY-TPP database coverage and metadata

- [What patient data is made available in OpenSAFELY-TPP?](../opensafely-data/index.md)
- [Most recent coverage of records in SystmOne and external datasets](https://reports.opensafely.org/reports/opensafely-tpp-database-builds/)
- [Historical coverage of records in SystmOne and external datasets](https://reports.opensafely.org/reports/opensafely-tpp-database-history/)
- [OpenSAFELY-TPP database schema](https://reports.opensafely.org/reports/opensafely-tpp-database-schema/)
Expand Down
Binary file added docs/images/flowchart_users_GP_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/memory-efficient-working.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ Before you get to your scripted actions, you can try the following tips for ehrQ
* Carry out initial testing on a small sample population (e.g. short time period). This allows you to check your variables are working as expected in the real data without a large load on the server.
* If you're developing complex new variables create a separate dataset definition and test script rather than embedding in the main file.
* Limit to the period and fields you really need - remove any that are no longer needed after initial testing.
* Use separate dataset definitions or use [parameters](../ehrql/how-to/parameterise-ehrql/) to help to create your flow chart, subsets of the population or run specific tests, rather than returning all variables for all groups where these are not necessary.
* Consider using [measures](../ehrql/explanation/measures/) for basic counts/rates. But note that these can also be slow for large queries.
* Use separate dataset definitions or use [parameters](ehrql/how-to/parameterise-ehrql.md) to help to create your flow chart, subsets of the population or run specific tests, rather than returning all variables for all groups where these are not necessary.
* Consider using [measures](ehrql/explanation/measures.md) for basic counts/rates. But note that these can also be slow for large queries.

## Dataset management

Expand Down
Loading