opensafely / tpp-sql-notebook

2 stars 0 forks source link

*Outcome* ICNARC data #72

Open sebbacon opened 4 years ago

sebbacon commented 4 years ago

Field name mappings, i.e. column two are the field names in the table in our database

This is based on the Data Flows ICNARC documentation

There is also a Tech Spec which may or may not be of use...

Fields specification

HelenCEBM commented 4 years ago

ICU

CASE WHEN BasicDays_RespiratorySupport+AdvancedDays_RespiratorySupport >= 1 -- at least one day basic / advanced respiratory support THEN MIN(IcuAdmissionDateTime, OriginalIcuAdmissionDate) -- earliest date of current hospital ITU admission and original ITU admission (if transferred in) ELSE NULL END


- Optional logic for ventilation
`Ventilator = 'TRUE'` -- need to know how this field is coded (y/n, 0/1, true/false)

##  Death
- the discharge fields in the spreadsheet above (from ICU, from hospital) appear to be applicable if patient is alive, according to the data flows document. There don't appear to be any explicit death fields present in the spreadsheet, but there are 4 fields unidentified which may possibly indicate survival but these can't be interpreted from the spec documents (`yhsurv`, `ausurv` etc).
- Assuming we have all the necessary fields we can use the following logic:

- Flag for death:
```sql
SELECT 
CASE WHEN 
StatusOnDischargeFromUnit = "D" -- from DISICU? field (D=dead)
OR UltimateStatusOnDischarge = "D" -- from DIS field (D=dead)
-- note this second clause may include patients who survived Covid but
-- went on to die from something else while still in hospital. 
-- Not including this could exclude patients who are moved 
-- out of ICU to die from Covid (may be unlikely/small numbers). 
THEN 1 ELSE 0 END,