|
|
Line 7: |
Line 7: |
|
| |
|
| [[File:Dataset algorithm.jpg|600x600px|The algorithm followed to generate datasets]] | | [[File:Dataset algorithm.jpg|600x600px|The algorithm followed to generate datasets]] |
| <div class="toc" id="toc"><span class="mw-headline" id="Creating_the_Patient_Cohort.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D"><span class="mw-headline" id="Creating_the_Patient_Cohort.5Bedit.5D.5B.5B.5B.7Cedit.5D.5D.5D.5Bedit.5D"><span class="mw-headline" id="Creating_the_Patient_Cohort.5Bedit.5D.5Bedit.5D"><span class="mw-headline" id="Creating_the_Patient_Cohort.5Bedit.5D"><span class="mw-headline" id="Creating_the_Patient_Cohort">Creating the Patient Cohort</span><span class="mw-editsection"><span class="mw-editsection-bra">[</span>[[Edit|edit]]<span class="mw-editsection-bra">]</span></span></span><span class="mw-editsection"><span class="mw-editsection-bra">[</span>[[Edit|edit]]<span class="mw-editsection-bra">]</span></span></span><span class="mw-editsection"><span class="mw-editsection-bra">[</span>[[Edit|edit]]<span class="mw-editsection-bra">]</span></span></span><span class="mw-editsection"><span class="mw-editsection-bra">[</span>[[Edit|edit]]<span class="mw-editsection-bra">]</span></span></span><span class="mw-editsection"><span class="mw-editsection-bra">[</span>[[edit]]<span class="mw-editsection-bra">]</span></span></div>
| | |
| The first step, when a list of patients marked for observational study is received, is to create a patient cohort. Patient data usually comes into the DDS in the form of pseudonymised personal data. Additional information about the patient can be obtained from the Discovery database using the pseudo identifier or the pseudo NHS identifier. | | The first step, when a list of patients marked for observational study is received, is to create a patient cohort. Patient data usually comes into the DDS in the form of pseudonymised personal data. Additional information about the patient can be obtained from the Discovery database using the pseudo identifier or the pseudo NHS identifier. |
| <div class="toc" id="toc"><input class="toctogglecheckbox" id="toctogglecheckbox" role="button" style="display:none" type="checkbox"></input> <div class="toctitle" dir="ltr" lang="en-GB">
| |
| == Contents ==
| |
| </div>
| |
| *[[#General_patient_cohort.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">1</span> <span class="toctext"><span><span><span><span><span>General patient cohort</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| *[[#Building_a_patient_cohort_using_pseudo_NHS_numbers.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">2</span> <span class="toctext"><span><span><span><span><span>Building a patient cohort using pseudo NHS numbers</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| *[[#Cohorts_with_filtered_observations.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">3</span> <span class="toctext"><span><span><span><span><span>Cohorts with filtered observations</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| *[[#Building_patient_cohort_SQL_with_filtered_observations.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">4</span> <span class="toctext"><span><span><span><span><span>Building patient cohort SQL with filtered observations</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| *[[#Creating_the_observation_cohort.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">5</span> <span class="toctext"><span><span><span><span><span>Creating the observation cohort</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| **[[#Building_the_observation_cohort_SQL_.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">5.1</span> <span class="toctext"><span><span><span><span><span>Building the observation cohort SQL </span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| *[[#Creating_the_medications_cohort.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">6</span> <span class="toctext"><span><span><span><span><span>Creating the medications cohort</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| **[[#Building_the_medication_cohort_SQL.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">6.1</span> <span class="toctext"><span><span><span><span><span>Building the medication cohort SQL</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| *[[#Creating_other_cohorts.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">7</span> <span class="toctext"><span><span><span><span><span>Creating other cohorts</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| **[[#Building_the_encounter_raw_cohort_SQL.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">7.1</span> <span class="toctext"><span><span><span><span><span>Building the encounter raw cohort SQL</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| *[[#Building_datasets.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">8</span> <span class="toctext"><span><span><span><span><span>Building datasets</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| **[[#Patient_demographic_dataset.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">8.1</span> <span class="toctext"><span><span><span><span><span>Patient demographic dataset</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| **[[#Create_table_script_for_a_patient_demographic_dataset_table.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D|<span class="tocnumber">8.2</span> <span class="toctext"><span><span><span><span><span>Create table script for a patient demographic dataset table</span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span><span><span>[</span>edit<span>]</span></span></span>]]
| |
| </div>
| |
| == <span class="mw-headline" id="General_patient_cohort.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D"><span class="mw-headline" id="General_patient_cohort.5Bedit.5D.5Bedit.5D.5Bedit.5D.5Bedit.5D"><span class="mw-headline" id="General_patient_cohort.5Bedit.5D.5B.5B.5B.7Cedit.5D.5D.5D.5Bedit.5D"><span class="mw-headline" id="General_patient_cohort.5Bedit.5D.5Bedit.5D"><span class="mw-headline" id="General_patient_cohort.5Bedit.5D"><span class="mw-headline" id="General_patient_cohort">General patient cohort</span><span class="mw-editsection"><span class="mw-editsection-bra">[</span>[[Edit|edit]]<span class="mw-editsection-bra">]</span></span></span><span class="mw-editsection"><span class="mw-editsection-bra">[</span>[[Edit|edit]]<span class="mw-editsection-bra">]</span></span></span><span class="mw-editsection"><span class="mw-editsection-bra">[</span>[[Edit|edit]]<span class="mw-editsection-bra">]</span></span></span><span class="mw-editsection"><span class="mw-editsection-bra">[</span>[[Edit|edit]]<span class="mw-editsection-bra">]</span></span></span><span class="mw-editsection"><span class="mw-editsection-bra">[</span>[[edit]]<span class="mw-editsection-bra">]</span></span></span><span class="mw-editsection"><span class="mw-editsection-bra">[</span>[[Remote_Subscriber_Database_(RSD)_SQL_guide|edit]]<span class="mw-editsection-bra">]</span></span> ==
| |
|
| |
|
| The following entity diagram shows the relationships between patient and organisation: | | The following entity diagram shows the relationships between patient and organisation: |
Revision as of 10:09, 14 May 2020
This article describes the steps needed to create, and analyse, patient data selections from the Discovery database.
Datasets are needed to add patient data to a report. Each dataset represents the results gained from running a combination of SQL commands and stored procedures on a data source.
The following diagram shows the algorithm that is followed to generate these datasets:
The first step, when a list of patients marked for observational study is received, is to create a patient cohort. Patient data usually comes into the DDS in the form of pseudonymised personal data. Additional information about the patient can be obtained from the Discovery database using the pseudo identifier or the pseudo NHS identifier.
The following entity diagram shows the relationships between patient and organisation:
Patients are linked to the Discovery database using pseudo patient identifiers. However, if only pseudo NHS numbers are provided, the corresponding pseudo identifiers can be derived from the link distributor table. Patients are filtered by organisation ODS codes to ensure that only the patients of the required GP practices are selected.
Building a patient cohort using pseudo NHS numbers[edit][edit][edit][edit][edit][edit]
The following example SQL shows how a patient cohort is built using pseudo NHS numbers:
Sometimes, the cohort is created with filtered observations.
The example below filters patients who are registered, alive, and have had diabetes. They belong to the age 12 years and over. Two additional tables are introduced for the query: observation(patients who have had diabetes) and episode of care (patients who are registered and have the appropriate registration type for this study).
Patients can be selected with a specific set of observations using a lookup table of relevant SNOMED codes.
Some patients prefer to withhold consent and are therefore are excluded from the cohort; the relevant SNOMED consent code can be checked in the observation table.
Patients are usually only select if they have registration type 2 (Regular/GMS).
Sometimes patients are also based on their age in years.
Building patient cohort SQL with filtered observations[edit][edit][edit][edit][edit][edit]
Observation cohort are created to improve query performance; instead of scanning through the entire observation table, a sub-set of the observation table is created, based on the patient cohort.
Medications cohort are created to improve query performance; instead of scanning through the entire observation table, a sub-set of the medication statement table is created, based on the patient cohort.
This step can apply to any large tables to support improved query performance. For example, the encounter_raw table is a good candidate to create a separate cohort for SQL query; you can query this table if you want information such as the number of face to face encounters, or the number of home visits.
Building the encounter raw cohort SQL[edit][edit][edit][edit][edit][edit]
This involves creating a number of tables in the database.
A typical patient demographic dataset includes the following information:
This information is translated into a 'create table' script, which is then run to create the dataset table in the database.
Create table script for a patient demographic dataset table[edit][edit][edit][edit][edit][edit]
In this example, the age and LSOA code are derived from the patient table. The demographic dataset table is updated with those values when there is a match on the pseudo identifier.
If the update is large, it might be possible to optimise the update process by using batches as shown in the following example: