-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatientCodeStatus
14 lines (12 loc) · 932 Bytes
/
patientCodeStatus
1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- author: Joseph Park
-- NOT SUPPORTED: autogenerated from careplan_getpatientcode.Rmd by using show_query()
DROP MATERIALIZED VIEW IF EXISTS patientCodeStatus;
CREATE MATERIALIZED VIEW patientCodeStatus AS
SELECT "patientunitstayid", "cplitemoffset", string_agg("cplitemvalue", ', ') AS "cplitemvalue"
FROM (SELECT *
FROM (SELECT "patientunitstayid" AS "patientunitstayid", "cplitemoffset" AS "cplitemoffset", "cplgroup" AS "cplgroup", "cplitemvalue" AS "cplitemvalue"
FROM (SELECT *
FROM "careplangeneral"
WHERE ("cplitemvalue" IN ('Full therapy', 'Do not resuscitate', 'No CPR', 'No intubation', 'Comfort measures only', 'No cardioversion', 'No vasopressors/inotropes', 'No augmentation of care', 'End of life', 'No blood products', 'No blood draws', 'Advance directives'))) "ivtmaaxwzk") "oytldaespk"
ORDER BY "patientunitstayid", "cplitemoffset", "cplitemvalue") "vrxthajevr"
GROUP BY "patientunitstayid", "cplitemoffset";