Skip to content

Instantly share code, notes, and snippets.

@louismullie
Created August 1, 2020 19:18
Show Gist options
  • Save louismullie/5c034109d7da18e4eba76855752cb6b7 to your computer and use it in GitHub Desktop.
Save louismullie/5c034109d7da18e4eba76855752cb6b7 to your computer and use it in GitHub Desktop.
# Lab data
query = "SELECT lab_data.patient_site_uid, lab_name, lab_sample_time, lab_result_value, lab_sample_type from lab_data " + \
" INNER JOIN patient_data ON " + \
" lab_data.patient_site_uid = patient_data.patient_site_uid WHERE " + \
" (lab_data.lab_sample_type = 'venous_blood' OR " + \
" lab_data.lab_sample_type = 'arterial_blood' OR " + \
" lab_data.lab_sample_type = 'unspecified_blood') AND " + \
" lab_data.lab_result_status = 'resulted' " + \
inclusion_flag
res1 = sql_fetch_all(conn, query)
# Vitals data
query = "SELECT observation_data.patient_site_uid, observation_name, observation_time, observation_value from observation_data " + \
" INNER JOIN patient_data ON " + \
" observation_data.patient_site_uid = patient_data.patient_site_uid WHERE " + \
" observation_data.observation_value IS NOT NULL " + \
inclusion_flag
res2 = sql_fetch_all(conn, query)
# Selected vitals and labs
include_variables = ['alanine_aminotransferase', 'albumin','alkaline_phosphatase',
'anion_gap', 'ast', 'base_excess', 'basophil_count',
'bicarbonate', 'c_reactive_protein', 'chloride',
'corrected_total_calcium','creatine_kinase', 'creatinine',
'd_dimer', 'diastolic_blood_pressure', 'eosinophil_count',
'ferritin', 'fibrinogen', 'fraction_inspired_oxygen', 'gamma_glutamyl_transferase',
'glucose', 'heart_rate', 'hs_troponin_t', 'indirect_bilirubin',
'ionized_calcium', 'lactate_dehydrogenase', 'lactic_acid',
'lipase', 'lymphocyte_count', 'magnesium',
'mean_corpuscular_hemoglobin', 'mean_corpuscular_hemoglobin_concentration',
'mean_corpuscular_volume', 'mean_platelet_volume',
'monocyte_count', 'myelocyte_count', 'neutrophil_count',
'o2_sat', 'oxygen_flow_rate', 'oxygen_saturation',
'partial_thromboplastin_time', 'pco2', 'phosphate', 'platelet_count',
'po2', 'potassium', 'procalcitonin',
'red_blood_cell_count', 'respiratory_rate', 'sodium',
'systolic_blood_pressure', 'temperature',
'total_bilirubin', 'urea', 'weight', 'white_blood_cell_count']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment