-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy patharb.sql
More file actions
31 lines (30 loc) · 961 Bytes
/
arb.sql
File metadata and controls
31 lines (30 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
WITH arb_drug AS (
SELECT DISTINCT
drug
, CASE
WHEN UPPER(drug) LIKE '%AZILSARTAN%' OR UPPER(drug) LIKE '%EDARBI%'
OR UPPER(drug) LIKE '%CANDESARTAN%' OR UPPER(drug) LIKE '%ATACAND%'
OR UPPER(drug) LIKE '%IRBESARTAN%' OR UPPER(drug) LIKE '%AVAPRO%'
OR UPPER(drug) LIKE '%LOSARTAN%' OR UPPER(drug) LIKE '%COZAAR%'
OR UPPER(drug) LIKE '%OLMESARTAN%' OR UPPER(drug) LIKE '%BENICAR%'
OR UPPER(drug) LIKE '%TELMISARTAN%' OR UPPER(drug) LIKE '%MICARDIS%'
OR UPPER(drug) LIKE '%VALSARTAN%' OR UPPER(drug) LIKE '%DIOVAN%'
OR UPPER(drug) LIKE '%SACUBITRIL%' OR UPPER(drug) LIKE '%ENTRESTO%'
THEN 1
ELSE 0
END AS arb
FROM `physionet-data.mimiciv_hosp.prescriptions`
)
SELECT
pr.subject_id
, pr.hadm_id
, pr.drug AS arb
, pr.starttime
, pr.stoptime
FROM
`physionet-data.mimiciv_hosp.prescriptions` pr
INNER JOIN arb_drug
ON pr.drug = arb_drug.drug
WHERE
arb_drug.arb = 1
;