Skip to content

No patients after 2019 in sepsis3 table #2170

Description

@mer13-de

I noticed a likely mistake in sepsis 3 table
TableID: physionet-data.mimiciv_3_1_derived.sepsis3

It seems that this table doesn't contain patients after year 2019:
SELECT p.anchor_year_group, COUNT(*) AS n
FROM physionet-data.mimiciv_3_1_derived.sepsis3 s
JOIN physionet-data.mimiciv_3_1_icu.icustays i ON s.stay_id = i.stay_id
JOIN physionet-data.mimiciv_3_1_hosp.patients p ON i.subject_id = p.subject_id
GROUP BY 1 ORDER BY 1;

shows

Image

I changed code for querying sepsis table that was uploaded to GitHub

_WITH sofa AS (
SELECT stay_id
, starttime, endtime
, respiration_24hours AS respiration
, coagulation_24hours AS coagulation
, liver_24hours AS liver
, cardiovascular_24hours AS cardiovascular
, cns_24hours AS cns
, renal_24hours AS renal
, sofa_24hours AS sofa_score
FROM physionet-data.mimiciv_3_1_derived.sofa
WHERE sofa_24hours >= 2
)

, s1 AS (
SELECT
soi.subject_id
, soi.stay_id
-- suspicion columns
, soi.ab_id
, soi.antibiotic
, soi.antibiotic_time
, soi.culture_time
, soi.suspected_infection
, soi.suspected_infection_time
, soi.specimen
, soi.positive_culture
-- sofa columns
, starttime, endtime
, respiration, coagulation, liver, cardiovascular, cns, renal
, sofa_score

    , sofa_score >= 2 AND suspected_infection = 1 AS sepsis3
    
    , ROW_NUMBER() OVER
    (
        PARTITION BY soi.stay_id
        ORDER BY
            suspected_infection_time, antibiotic_time, culture_time, endtime
    ) AS rn_sus
FROM `physionet-data.mimiciv_3_1_derived.suspicion_of_infection` AS soi
INNER JOIN sofa
    ON soi.stay_id = sofa.stay_id
        AND sofa.endtime >= DATETIME_SUB(
            soi.suspected_infection_time, INTERVAL '48' HOUR
        )
        AND sofa.endtime <= DATETIME_ADD(
            soi.suspected_infection_time, INTERVAL '24' HOUR
        )
-- only include in-ICU rows
WHERE soi.stay_id IS NOT NULL

)

SELECT
subject_id, stay_id
-- note: there may be more than one antibiotic given at this time
, antibiotic_time
-- culture times may be dates, rather than times
, culture_time
, suspected_infection_time
-- endtime is latest time at which the SOFA score is valid
, endtime AS sofa_time
, sofa_score
, respiration, coagulation, liver, cardiovascular, cns, renal
, sepsis3
FROM s1
WHERE rn_sus = 1_

The new table has 41295 rows and shows patients after year 2019

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions