Skip to content

Commit 6594921

Browse files
alistairewjgithub-actions[bot]
authored andcommitted
chore: regenerate postgres/duckdb concepts from BigQuery sources
1 parent d20b49a commit 6594921

113 files changed

Lines changed: 1144 additions & 149 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎mimic-iii/concepts_postgres/code_status.sql‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
22
DROP TABLE IF EXISTS mimiciii_derived.code_status; CREATE TABLE mimiciii_derived.code_status AS
3-
/* This query extracts: */ /* i) a patient's first code status */ /* ii) a patient's last code status */ /* iii) the time of the first entry of DNR or CMO */
3+
/* This query extracts: */
4+
/* i) a patient's first code status */
5+
/* ii) a patient's last code status */
6+
/* iii) the time of the first entry of DNR or CMO */
47
WITH t1 AS (
58
SELECT
69
icustay_id,

‎mimic-iii/concepts_postgres/comorbidity/elixhauser_ahrq_v37.sql‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,8 @@ WITH eliflg AS (
10191019
GROUP BY
10201020
d.hadm_id
10211021
)
1022-
/* now merge these flags together to define elixhauser */ /* most are straightforward.. but hypertension flags are a bit more complicated */
1022+
/* now merge these flags together to define elixhauser */
1023+
/* most are straightforward.. but hypertension flags are a bit more complicated */
10231024
SELECT
10241025
adm.subject_id,
10251026
adm.hadm_id,

‎mimic-iii/concepts_postgres/comorbidity/elixhauser_ahrq_v37_no_drg.sql‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
22
DROP TABLE IF EXISTS mimiciii_derived.elixhauser_ahrq_v37_no_drg; CREATE TABLE mimiciii_derived.elixhauser_ahrq_v37_no_drg AS
3-
/* This code uses the latest version of Elixhauser provided by AHRQ */ /* However, it does *not* filter based on diagnosis related groups (DRGs) */ /* As such, "comorbidities" identified are more likely to be associated with the primary reason for their hospital stay */ /* The code: */ /* removes "primary" ICD9_CODE (seq_num != 1) */ /* uses AHRQ published rules to define comorbidities */
3+
/* This code uses the latest version of Elixhauser provided by AHRQ */
4+
/* However, it does *not* filter based on diagnosis related groups (DRGs) */
5+
/* As such, "comorbidities" identified are more likely to be associated with the primary reason for their hospital stay */
6+
/* The code: */
7+
/* removes "primary" ICD9_CODE (seq_num != 1) */
8+
/* uses AHRQ published rules to define comorbidities */
49
WITH eliflg AS (
510
SELECT
611
hadm_id,
@@ -613,7 +618,8 @@ WITH eliflg AS (
613618
GROUP BY
614619
hadm_id
615620
)
616-
/* now merge these flags together to define elixhauser */ /* most are straightforward.. but hypertension flags are a bit more complicated */
621+
/* now merge these flags together to define elixhauser */
622+
/* most are straightforward.. but hypertension flags are a bit more complicated */
617623
SELECT
618624
adm.subject_id,
619625
adm.hadm_id,

‎mimic-iii/concepts_postgres/comorbidity/elixhauser_quan.sql‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
22
DROP TABLE IF EXISTS mimiciii_derived.elixhauser_quan; CREATE TABLE mimiciii_derived.elixhauser_quan AS
3-
/* This code calculates the Elixhauser comorbidities as defined in Quan et. al 2009: */ /* Quan, Hude, et al. "Coding algorithms for defining comorbidities in */ /* ICD-9-CM and ICD-10 administrative data." Medical care (2005): 1130-1139. */ /* https://www.ncbi.nlm.nih.gov/pubmed/16224307 */ /* Quan defined an "Enhanced ICD-9" coding scheme for deriving Elixhauser */ /* comorbidities from ICD-9 billing codes. This script implements that calculation. */ /* The logic of the code is roughly that, if the comorbidity lists a length 3 */ /* ICD-9 code (e.g. 585), then we only require a match on the first 3 characters. */ /* This code derives each comorbidity as follows: */ /* 1) ICD9_CODE is directly compared to 5 character codes */ /* 2) The first 4 characters of ICD9_CODE are compared to 4 character codes */ /* 3) The first 3 characters of ICD9_CODE are compared to 3 character codes */
3+
/* This code calculates the Elixhauser comorbidities as defined in Quan et. al 2009: */
4+
/* Quan, Hude, et al. "Coding algorithms for defining comorbidities in */
5+
/* ICD-9-CM and ICD-10 administrative data." Medical care (2005): 1130-1139. */
6+
/* https://www.ncbi.nlm.nih.gov/pubmed/16224307 */
7+
/* Quan defined an "Enhanced ICD-9" coding scheme for deriving Elixhauser */
8+
/* comorbidities from ICD-9 billing codes. This script implements that calculation. */
9+
/* The logic of the code is roughly that, if the comorbidity lists a length 3 */
10+
/* ICD-9 code (e.g. 585), then we only require a match on the first 3 characters. */
11+
/* This code derives each comorbidity as follows: */
12+
/* 1) ICD9_CODE is directly compared to 5 character codes */
13+
/* 2) The first 4 characters of ICD9_CODE are compared to 4 character codes */
14+
/* 3) The first 3 characters of ICD9_CODE are compared to 3 character codes */
415
WITH eliflg AS (
516
SELECT
617
hadm_id,
@@ -388,7 +399,8 @@ WITH eliflg AS (
388399
GROUP BY
389400
hadm_id
390401
)
391-
/* now merge these flags together to define elixhauser */ /* most are straightforward.. but hypertension flags are a bit more complicated */
402+
/* now merge these flags together to define elixhauser */
403+
/* most are straightforward.. but hypertension flags are a bit more complicated */
392404
SELECT
393405
adm.hadm_id,
394406
chf AS congestive_heart_failure,

‎mimic-iii/concepts_postgres/comorbidity/elixhauser_score_ahrq.sql‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
22
DROP TABLE IF EXISTS mimiciii_derived.elixhauser_score_ahrq; CREATE TABLE mimiciii_derived.elixhauser_score_ahrq AS
3-
/* This query provides various methods of combining the Elixhauser components into a single score */ /* The methods are called "vanWalRaven" and "SID30", and "SID29" */
3+
/* This query provides various methods of combining the Elixhauser components into a single score */
4+
/* The methods are called "vanWalRaven" and "SID30", and "SID29" */
45
SELECT
56
subject_id,
67
hadm_id, /* Below is the van Walraven score */

‎mimic-iii/concepts_postgres/comorbidity/elixhauser_score_quan.sql‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
22
DROP TABLE IF EXISTS mimiciii_derived.elixhauser_score_quan; CREATE TABLE mimiciii_derived.elixhauser_score_quan AS
3-
/* This query provides various methods of combining the Elixhauser components into a single score */ /* The methods are called "vanWalRaven" and "SID30", and "SID29" */
3+
/* This query provides various methods of combining the Elixhauser components into a single score */
4+
/* The methods are called "vanWalRaven" and "SID30", and "SID29" */
45
SELECT
56
hadm_id, /* Below is the van Walraven score */
67
0 * aids + 0 * alcohol_abuse + -2 * blood_loss_anemia + 7 * congestive_heart_failure + 3 /* Cardiac arrhythmias are not included in van Walraven based on Quan 2007 */ * chronic_pulmonary + 3 * coagulopathy + -2 * deficiency_anemias + -3 * depression + 0 * diabetes_complicated + 0 * diabetes_uncomplicated + -7 * drug_abuse + 5 * fluid_electrolyte + 0 * hypertension + 0 * hypothyroidism + 11 * liver_disease + 9 * lymphoma + 12 * metastatic_cancer + 6 * other_neurological + -4 * obesity + 7 * paralysis + 2 * peripheral_vascular + 0 * peptic_ulcer + 0 * psychoses + 4 * pulmonary_circulation + 0 * rheumatoid_arthritis + 5 * renal_failure + 4 * solid_tumor + -1 * valvular_disease + 6 * weight_loss AS elixhauser_vanwalraven, /* Below is the 29 component SID score */

‎mimic-iii/concepts_postgres/demographics/heightweight.sql‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
22
DROP TABLE IF EXISTS mimiciii_derived.heightweight; CREATE TABLE mimiciii_derived.heightweight AS
3-
/* ------------------------------------------------------------------ */ /* Title: Extract height and weight for ICUSTAY_IDs */ /* Description: This query gets the first, minimum, and maximum weight and height */ /* for a single ICUSTAY_ID. It extracts data from the CHARTEVENTS table. */ /* MIMIC version: MIMIC-III v1.4 */ /* ------------------------------------------------------------------ */ /* prep height */
3+
/* ------------------------------------------------------------------ */
4+
/* Title: Extract height and weight for ICUSTAY_IDs */
5+
/* Description: This query gets the first, minimum, and maximum weight and height */
6+
/* for a single ICUSTAY_ID. It extracts data from the CHARTEVENTS table. */
7+
/* MIMIC version: MIMIC-III v1.4 */
8+
/* ------------------------------------------------------------------ */
9+
/* prep height */
410
WITH ht_stg AS (
511
SELECT
612
c.subject_id,

‎mimic-iii/concepts_postgres/demographics/icustay_detail.sql‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
22
DROP TABLE IF EXISTS mimiciii_derived.icustay_detail; CREATE TABLE mimiciii_derived.icustay_detail AS
3-
/* ------------------------------------------------------------------ */ /* Title: Detailed information on ICUSTAY_ID */ /* Description: This query provides a useful set of information regarding patient */ /* ICU stays. The information is combined from the admissions, patients, and */ /* icustays tables. It includes age, length of stay, sequence, and expiry flags. */ /* MIMIC version: MIMIC-III v1.3 */ /* ------------------------------------------------------------------ */ /* This query extracts useful demographic/administrative information for patient ICU stays */
3+
/* ------------------------------------------------------------------ */
4+
/* Title: Detailed information on ICUSTAY_ID */
5+
/* Description: This query provides a useful set of information regarding patient */
6+
/* ICU stays. The information is combined from the admissions, patients, and */
7+
/* icustays tables. It includes age, length of stay, sequence, and expiry flags. */
8+
/* MIMIC version: MIMIC-III v1.3 */
9+
/* ------------------------------------------------------------------ */
10+
/* This query extracts useful demographic/administrative information for patient ICU stays */
411
SELECT
512
ie.subject_id,
613
ie.hadm_id,

‎mimic-iii/concepts_postgres/demographics/icustay_hours.sql‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
22
DROP TABLE IF EXISTS mimiciii_derived.icustay_hours; CREATE TABLE mimiciii_derived.icustay_hours AS
3-
/* This query generates a row for every hour the patient is in the ICU. */ /* The hours are based on clock-hours (i.e. 02:00, 03:00). */ /* The hour clock starts 24 hours before the first heart rate measurement. */ /* Note that the time of the first heart rate measurement is ceilinged to the hour. */ /* this query extracts the cohort and every possible hour they were in the ICU */ /* this table can be to other tables on ICUSTAY_ID and (ENDTIME - 1 hour,ENDTIME] */ /* get first/last measurement time */
3+
/* This query generates a row for every hour the patient is in the ICU. */
4+
/* The hours are based on clock-hours (i.e. 02:00, 03:00). */
5+
/* The hour clock starts 24 hours before the first heart rate measurement. */
6+
/* Note that the time of the first heart rate measurement is ceilinged to the hour. */
7+
/* this query extracts the cohort and every possible hour they were in the ICU */
8+
/* this table can be to other tables on ICUSTAY_ID and (ENDTIME - 1 hour,ENDTIME] */
9+
/* get first/last measurement time */
410
WITH all_hours AS (
511
SELECT
612
it.icustay_id, /* ceiling the intime to the nearest hour by adding 59 minutes then truncating */ /* note thart we truncate by parsing as string, rather than using DATETIME_TRUNC */ /* this is done to enable compatibility with psql */

‎mimic-iii/concepts_postgres/demographics/icustay_times.sql‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- THIS SCRIPT IS AUTOMATICALLY GENERATED. DO NOT EDIT IT DIRECTLY.
22
DROP TABLE IF EXISTS mimiciii_derived.icustay_times; CREATE TABLE mimiciii_derived.icustay_times AS
3-
/* create a table which has fuzzy boundaries on hospital admission */ /* involves first creating a lag/lead version of disch/admit time */
3+
/* create a table which has fuzzy boundaries on hospital admission */
4+
/* involves first creating a lag/lead version of disch/admit time */
45
WITH h AS (
56
SELECT
67
subject_id,

0 commit comments

Comments
 (0)