         hadm_id
         , CASE WHEN icd_version = 9 THEN icd_code ELSE NULL END AS icd9_code
         , CASE WHEN icd_version = 10 THEN icd_code ELSE NULL END AS icd10_code
-    FROM mimic_hosp.diagnoses_icd diag
+    FROM `physionet-data.mimic_hosp.diagnoses_icd` diag
 )
 , com AS
 (

    2*rd2 + 2*mal2 + 3*ld3 + 6*mst6 + 6*aids6 +
    age_score
    AS charlson
FROM mimic_core.admissions ad
LEFT JOIN com
ON ad.hadm_id = com.hadm_id
LEFT JOIN ag

            SUBSTRING(icd10_code FROM 1 for 3) IN ('B20','B21','B22','B24')
            THEN 1 
            ELSE 0 END) AS aids6 --AIDS/HIV
    FROM `physionet-data.mimic_core.admissions` ad
    LEFT JOIN diag
    ON ad.hadm_id = diag.hadm_id
    GROUP BY ad.hadm_id
