question
stringlengths 28
136
| goldSQL
stringlengths 65
557
| predSQL
stringlengths 8.07k
11.9k
|
---|---|---|
whats the sex of patient 24517? | select patients.gender from patients where patients.subject_id = 24517 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
Table 'MICROBIOLOGYEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), CHARTDATE (VARCHAR), CHARTTIME (VARCHAR), SPEC_ITEMID (INTEGER), SPEC_TYPE_DESC (VARCHAR), ORG_ITEMID (INTEGER), ORG_NAME (VARCHAR), ISOLATE_NUM (INTEGER), AB_ITEMID (INTEGER), AB_NAME (VARCHAR), DILUTION_TEXT (VARCHAR), DILUTION_COMPARISON (VARCHAR), DILUTION_VALUE (INTEGER), INTERPRETATION (VARCHAR), . The table is: Table containing various medical event labels and their corresponding item IDs.{'ROW_ID': 744, 'SUBJECT_ID': 96, 'HADM_ID': 170324, 'CHARTDATE': '2156-04-13 00:00:00', 'CHARTTIME': '2156-04-13 14:18:00', 'SPEC_ITEMID': 70021, 'SPEC_TYPE_DESC': 'BRONCHOALVEOLAR LAVAGE', 'ORG_ITEMID': 80026, 'ORG_NAME': 'PSEUDOMONAS AERUGINOSA', 'ISOLATE_NUM': 1, 'AB_ITEMID': None, 'AB_NAME': None, 'DILUTION_TEXT': None, 'DILUTION_COMPARISON': None, 'DILUTION_VALUE': None, 'INTERPRETATION': None}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
# Question: whats the sex of patient 24517?
# SQLQuery:
|
tell me the sex of patient 26549. | select patients.gender from patients where patients.subject_id = 26549 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
# Question: tell me the sex of patient 26549.
# SQLQuery:
|
what are patient 59916's genders? | select patients.gender from patients where patients.subject_id = 59916 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'CAREGIVER' has columns: ROW_ID (INTEGER), CGID (INTEGER), LABEL (VARCHAR), DESCRIPTION (VARCHAR), . The table is: This table contains information about caregivers, including their roles and descriptions.{'ROW_ID': 2228, 'CGID': 16174, 'LABEL': 'RO', 'DESCRIPTION': 'READ ONLY'}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'D_ICD_PROCEDURES' has columns: ROW_ID (INTEGER), ICD9_CODE (INTEGER), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: ICD9 procedure codes with short and long titles{'ROW_ID': 264, 'ICD9_CODE': 851, 'SHORT_TITLE': 'CANTHOTOMY', 'LONG_TITLE': 'CANTHOTOMY'}
# Question: what are patient 59916's genders?
# SQLQuery:
|
does patient 5905 have a male or female gender? | select patients.gender from patients where patients.subject_id = 5905 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
Table 'CAREGIVER' has columns: ROW_ID (INTEGER), CGID (INTEGER), LABEL (VARCHAR), DESCRIPTION (VARCHAR), . The table is: This table contains information about caregivers, including their roles and descriptions.{'ROW_ID': 2228, 'CGID': 16174, 'LABEL': 'RO', 'DESCRIPTION': 'READ ONLY'}
# Question: does patient 5905 have a male or female gender?
# SQLQuery:
|
whats the sex of patient 1862? | select patients.gender from patients where patients.subject_id = 1862 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'MICROBIOLOGYEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), CHARTDATE (VARCHAR), CHARTTIME (VARCHAR), SPEC_ITEMID (INTEGER), SPEC_TYPE_DESC (VARCHAR), ORG_ITEMID (INTEGER), ORG_NAME (VARCHAR), ISOLATE_NUM (INTEGER), AB_ITEMID (INTEGER), AB_NAME (VARCHAR), DILUTION_TEXT (VARCHAR), DILUTION_COMPARISON (VARCHAR), DILUTION_VALUE (INTEGER), INTERPRETATION (VARCHAR), . The table is: Table containing various medical event labels and their corresponding item IDs.{'ROW_ID': 744, 'SUBJECT_ID': 96, 'HADM_ID': 170324, 'CHARTDATE': '2156-04-13 00:00:00', 'CHARTTIME': '2156-04-13 14:18:00', 'SPEC_ITEMID': 70021, 'SPEC_TYPE_DESC': 'BRONCHOALVEOLAR LAVAGE', 'ORG_ITEMID': 80026, 'ORG_NAME': 'PSEUDOMONAS AERUGINOSA', 'ISOLATE_NUM': 1, 'AB_ITEMID': None, 'AB_NAME': None, 'DILUTION_TEXT': None, 'DILUTION_COMPARISON': None, 'DILUTION_VALUE': None, 'INTERPRETATION': None}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
# Question: whats the sex of patient 1862?
# SQLQuery:
|
whats the sex of patient 53176? | select patients.gender from patients where patients.subject_id = 53176 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
# Question: whats the sex of patient 53176?
# SQLQuery:
|
what are patient 12775's genders? | select patients.gender from patients where patients.subject_id = 12775 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'CAREGIVER' has columns: ROW_ID (INTEGER), CGID (INTEGER), LABEL (VARCHAR), DESCRIPTION (VARCHAR), . The table is: This table contains information about caregivers, including their roles and descriptions.{'ROW_ID': 2228, 'CGID': 16174, 'LABEL': 'RO', 'DESCRIPTION': 'READ ONLY'}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
# Question: what are patient 12775's genders?
# SQLQuery:
|
what are patient 655's genders? | select patients.gender from patients where patients.subject_id = 655 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'CAREGIVER' has columns: ROW_ID (INTEGER), CGID (INTEGER), LABEL (VARCHAR), DESCRIPTION (VARCHAR), . The table is: This table contains information about caregivers, including their roles and descriptions.{'ROW_ID': 2228, 'CGID': 16174, 'LABEL': 'RO', 'DESCRIPTION': 'READ ONLY'}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
# Question: what are patient 655's genders?
# SQLQuery:
|
whats the sex of patient 43779? | select patients.gender from patients where patients.subject_id = 43779 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
# Question: whats the sex of patient 43779?
# SQLQuery:
|
does patient 45612 have a male or female gender? | select patients.gender from patients where patients.subject_id = 45612 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'CAREGIVER' has columns: ROW_ID (INTEGER), CGID (INTEGER), LABEL (VARCHAR), DESCRIPTION (VARCHAR), . The table is: This table contains information about caregivers, including their roles and descriptions.{'ROW_ID': 2228, 'CGID': 16174, 'LABEL': 'RO', 'DESCRIPTION': 'READ ONLY'}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
# Question: does patient 45612 have a male or female gender?
# SQLQuery:
|
tell me the sex of patient 55027. | select patients.gender from patients where patients.subject_id = 55027 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
# Question: tell me the sex of patient 55027.
# SQLQuery:
|
whats the sex of patient 14749? | select patients.gender from patients where patients.subject_id = 14749 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
Table 'D_LABITEMS' has columns: ROW_ID (INTEGER), ITEMID (INTEGER), LABEL (VARCHAR), FLUID (VARCHAR), CATEGORY (VARCHAR), LOINC_CODE (VARCHAR), . The table is: This table contains information about various laboratory items, including their fluid, category and loinc code.{'ROW_ID': 546, 'ITEMID': 51346, 'LABEL': 'BLASTS', 'FLUID': 'CEREBROSPINAL FLUID (CSF)', 'CATEGORY': 'HEMATOLOGY', 'LOINC_CODE': '26447-3'}
Table 'MICROBIOLOGYEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), CHARTDATE (VARCHAR), CHARTTIME (VARCHAR), SPEC_ITEMID (INTEGER), SPEC_TYPE_DESC (VARCHAR), ORG_ITEMID (INTEGER), ORG_NAME (VARCHAR), ISOLATE_NUM (INTEGER), AB_ITEMID (INTEGER), AB_NAME (VARCHAR), DILUTION_TEXT (VARCHAR), DILUTION_COMPARISON (VARCHAR), DILUTION_VALUE (INTEGER), INTERPRETATION (VARCHAR), . The table is: Table containing various medical event labels and their corresponding item IDs.{'ROW_ID': 744, 'SUBJECT_ID': 96, 'HADM_ID': 170324, 'CHARTDATE': '2156-04-13 00:00:00', 'CHARTTIME': '2156-04-13 14:18:00', 'SPEC_ITEMID': 70021, 'SPEC_TYPE_DESC': 'BRONCHOALVEOLAR LAVAGE', 'ORG_ITEMID': 80026, 'ORG_NAME': 'PSEUDOMONAS AERUGINOSA', 'ISOLATE_NUM': 1, 'AB_ITEMID': None, 'AB_NAME': None, 'DILUTION_TEXT': None, 'DILUTION_COMPARISON': None, 'DILUTION_VALUE': None, 'INTERPRETATION': None}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
# Question: whats the sex of patient 14749?
# SQLQuery:
|
tell me the sex of patient 3712. | select patients.gender from patients where patients.subject_id = 3712 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'PROCEDURES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (INTEGER), . The table is: ICD-9 procedure codes with short and long titles{'ROW_ID': 944, 'SUBJECT_ID': 62641, 'HADM_ID': 154460, 'SEQ_NUM': 3, 'ICD9_CODE': 3404}
# Question: tell me the sex of patient 3712.
# SQLQuery:
|
tell me the sex of patient 43052. | select patients.gender from patients where patients.subject_id = 43052 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'CAREGIVER' has columns: ROW_ID (INTEGER), CGID (INTEGER), LABEL (VARCHAR), DESCRIPTION (VARCHAR), . The table is: This table contains information about caregivers, including their roles and descriptions.{'ROW_ID': 2228, 'CGID': 16174, 'LABEL': 'RO', 'DESCRIPTION': 'READ ONLY'}
# Question: tell me the sex of patient 43052.
# SQLQuery:
|
does patient 23930 have a male or female gender? | select patients.gender from patients where patients.subject_id = 23930 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'D_LABITEMS' has columns: ROW_ID (INTEGER), ITEMID (INTEGER), LABEL (VARCHAR), FLUID (VARCHAR), CATEGORY (VARCHAR), LOINC_CODE (VARCHAR), . The table is: This table contains information about various laboratory items, including their fluid, category and loinc code.{'ROW_ID': 546, 'ITEMID': 51346, 'LABEL': 'BLASTS', 'FLUID': 'CEREBROSPINAL FLUID (CSF)', 'CATEGORY': 'HEMATOLOGY', 'LOINC_CODE': '26447-3'}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
# Question: does patient 23930 have a male or female gender?
# SQLQuery:
|
does patient 87733 have a male or female gender? | select patients.gender from patients where patients.subject_id = 87733 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
Table 'CAREGIVER' has columns: ROW_ID (INTEGER), CGID (INTEGER), LABEL (VARCHAR), DESCRIPTION (VARCHAR), . The table is: This table contains information about caregivers, including their roles and descriptions.{'ROW_ID': 2228, 'CGID': 16174, 'LABEL': 'RO', 'DESCRIPTION': 'READ ONLY'}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
# Question: does patient 87733 have a male or female gender?
# SQLQuery:
|
tell me the sex of patient 57899. | select patients.gender from patients where patients.subject_id = 57899 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
# Question: tell me the sex of patient 57899.
# SQLQuery:
|
what are patient 61751's genders? | select patients.gender from patients where patients.subject_id = 61751 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'CAREGIVER' has columns: ROW_ID (INTEGER), CGID (INTEGER), LABEL (VARCHAR), DESCRIPTION (VARCHAR), . The table is: This table contains information about caregivers, including their roles and descriptions.{'ROW_ID': 2228, 'CGID': 16174, 'LABEL': 'RO', 'DESCRIPTION': 'READ ONLY'}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
# Question: what are patient 61751's genders?
# SQLQuery:
|
does patient 23475 have a male or female gender? | select patients.gender from patients where patients.subject_id = 23475 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'CALLOUT' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SUBMIT_WARDID (INTEGER), SUBMIT_CAREUNIT (VARCHAR), CURR_WARDID (INTEGER), CURR_CAREUNIT (VARCHAR), CALLOUT_WARDID (INTEGER), CALLOUT_SERVICE (VARCHAR), REQUEST_TELE (INTEGER), REQUEST_RESP (INTEGER), REQUEST_CDIFF (INTEGER), REQUEST_MRSA (INTEGER), REQUEST_VRE (INTEGER), CALLOUT_STATUS (VARCHAR), CALLOUT_OUTCOME (VARCHAR), DISCHARGE_WARDID (INTEGER), ACKNOWLEDGE_STATUS (VARCHAR), CREATETIME (VARCHAR), UPDATETIME (VARCHAR), ACKNOWLEDGETIME (VARCHAR), OUTCOMETIME (VARCHAR), FIRSTRESERVATIONTIME (VARCHAR), CURRENTRESERVATIONTIME (VARCHAR), . The table is: This table contains information about callouts, including the ward and care unit, callout status, and outcome.{'ROW_ID': 402, 'SUBJECT_ID': 854, 'HADM_ID': 175684, 'SUBMIT_WARDID': 52, 'SUBMIT_CAREUNIT': None, 'CURR_WARDID': 29, 'CURR_CAREUNIT': 'MICU', 'CALLOUT_WARDID': 1, 'CALLOUT_SERVICE': 'MED', 'REQUEST_TELE': 0, 'REQUEST_RESP': 0, 'REQUEST_CDIFF': 0, 'REQUEST_MRSA': 0, 'REQUEST_VRE': 0, 'CALLOUT_STATUS': 'INACTIVE', 'CALLOUT_OUTCOME': 'DISCHARGED', 'DISCHARGE_WARDID': 29, 'ACKNOWLEDGE_STATUS': 'ACKNOWLEDGED', 'CREATETIME': '2146-10-05 13:16:55', 'UPDATETIME': '2146-10-05 13:16:55', 'ACKNOWLEDGETIME': '2146-10-05 13:24:00', 'OUTCOMETIME': '2146-10-05 18:55:22', 'FIRSTRESERVATIONTIME': '2146-10-05 15:27:44', 'CURRENTRESERVATIONTIME': None}
Table 'CAREGIVER' has columns: ROW_ID (INTEGER), CGID (INTEGER), LABEL (VARCHAR), DESCRIPTION (VARCHAR), . The table is: This table contains information about caregivers, including their roles and descriptions.{'ROW_ID': 2228, 'CGID': 16174, 'LABEL': 'RO', 'DESCRIPTION': 'READ ONLY'}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
# Question: does patient 23475 have a male or female gender?
# SQLQuery:
|
what are patient 25869's genders? | select patients.gender from patients where patients.subject_id = 25869 | Given an input question, first create a syntactically correct sqlite query that directly answers the question, ensuring any necessary calculations are included in the SQL syntax. If the question is about whether a patient has ever done something (e.g., "Has the patient ever…"), use SELECT COUNT(*) > 0 to return a Boolean-like result. Then review the query output to determine the answer. Order the results by a relevant column if it helps provide the most informative data.
Instructions:
1. Direct Calculation Requirements: If the question involves a calculation (addition, subtraction, multiplication, or division) between columns, explicitly include the calculation within the SQL SELECT statement to return the computed value.
2. Time-Related Calculations: For questions that require time-based calculations, perform these directly within the SQL query. And keep the results as int type.
3. Boolean Check for Existence: For questions asking if a patient has ever done or had something, use SELECT COUNT(*) to determine existence as a Boolean outcome.
4. Entity and Admission IDs: Include hadm_id and the full entity name in the SQL query if the question specifies.
5. Schema Adherence: Use only the column names visible in the provided schema, qualifying columns with their table name if needed to avoid ambiguity.
Here are some samples:
QUESTION: count the number of times that patient 32154 since 11/19/2101 had a urine out foley output.
SQL: select count(*) from outputevents where outputevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 32154 ) ) and outputevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'urine out foley' and d_items.linksto = 'outputevents' ) and strftime('%y-%m-%d',outputevents.charttime) >= '2101-11-19'
QUESTION: calculate the length of stay of patient 2753's first hospital stay.
SQL: select strftime('%j',admissions.dischtime) - strftime('%j',admissions.admittime) from admissions where admissions.subject_id = 2753 and admissions.dischtime is not null order by admissions.admittime asc limit 1
QUESTION: during the current hospital encounter, was patient 20898's respiratory rate ever less than 19.0?
SQL: select count(*)>0 from chartevents where chartevents.icustay_id in ( select icustays.icustay_id from icustays where icustays.hadm_id in ( select admissions.hadm_id from admissions where admissions.subject_id = 20898 and admissions.dischtime is null ) ) and chartevents.itemid in ( select d_items.itemid from d_items where d_items.label = 'respiratory rate' and d_items.linksto = 'chartevents' ) and chartevents.valuenum < 19.0
# For the current question, only use tables listed below.
# Table 'PATIENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), GENDER (VARCHAR), DOB (VARCHAR), DOD (VARCHAR), DOD_HOSP (VARCHAR), DOD_SSN (VARCHAR), EXPIRE_FLAG (INTEGER), . The table is: Information about patients including demographics and dates of birth and death.{'ROW_ID': 234, 'SUBJECT_ID': 249, 'GENDER': 'F', 'DOB': '2075-03-13 00:00:00', 'DOD': None, 'DOD_HOSP': None, 'DOD_SSN': None, 'EXPIRE_FLAG': 0}
Table 'ADMISSIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ADMITTIME (VARCHAR), DISCHTIME (VARCHAR), DEATHTIME (VARCHAR), ADMISSION_TYPE (VARCHAR), ADMISSION_LOCATION (VARCHAR), DISCHARGE_LOCATION (VARCHAR), INSURANCE (VARCHAR), LANGUAGE (VARCHAR), RELIGION (VARCHAR), MARITAL_STATUS (VARCHAR), ETHNICITY (VARCHAR), EDREGTIME (VARCHAR), EDOUTTIME (VARCHAR), DIAGNOSIS (VARCHAR), HOSPITAL_EXPIRE_FLAG (INTEGER), HAS_CHARTEVENTS_DATA (INTEGER), . The table is: Table containing patient admission information, including demographic details and dates of birth and death.{'ROW_ID': 21, 'SUBJECT_ID': 22, 'HADM_ID': 165315, 'ADMITTIME': '2196-04-09 12:26:00', 'DISCHTIME': '2196-04-10 15:54:00', 'DEATHTIME': None, 'ADMISSION_TYPE': 'EMERGENCY', 'ADMISSION_LOCATION': 'EMERGENCY ROOM ADMIT', 'DISCHARGE_LOCATION': 'DISC-TRAN CANCER/CHLDRN H', 'INSURANCE': 'PRIVATE', 'LANGUAGE': None, 'RELIGION': 'UNOBTAINABLE', 'MARITAL_STATUS': 'MARRIED', 'ETHNICITY': 'WHITE', 'EDREGTIME': '2196-04-09 10:06:00', 'EDOUTTIME': '2196-04-09 13:24:00', 'DIAGNOSIS': 'BENZODIAZEPINE OVERDOSE', 'HOSPITAL_EXPIRE_FLAG': 0, 'HAS_CHARTEVENTS_DATA': 1}
Table 'TRANSFERS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), EVENTTYPE (VARCHAR), PREV_CAREUNIT (VARCHAR), CURR_CAREUNIT (VARCHAR), PREV_WARDID (INTEGER), CURR_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: Table containing patient transfer information, including care unit and ward ID changes, along with timestamps for admission, transfer, and discharge events.{'ROW_ID': 657, 'SUBJECT_ID': 111, 'HADM_ID': 192123, 'ICUSTAY_ID': 254245, 'DBSOURCE': 'CAREVUE', 'EVENTTYPE': 'TRANSFER', 'PREV_CAREUNIT': 'CCU', 'CURR_CAREUNIT': 'MICU', 'PREV_WARDID': 7, 'CURR_WARDID': 23, 'INTIME': '2142-04-29 15:27:11', 'OUTTIME': '2142-05-04 20:38:33', 'LOS': 125.19}
Table 'D_ICD_DIAGNOSES' has columns: ROW_ID (INTEGER), ICD9_CODE (VARCHAR), SHORT_TITLE (VARCHAR), LONG_TITLE (VARCHAR), . The table is: Table containing ICD-9 diagnosis codes for patients{'ROW_ID': 174, 'ICD9_CODE': '01166', 'SHORT_TITLE': 'TB PNEUMONIA-OTH TEST', 'LONG_TITLE': 'TUBERCULOUS PNEUMONIA [ANY FORM], TUBERCLE BACILLI NOT FOUND BY BACTERIOLOGICAL OR HISTOLOGICAL EXAMINATION, BUT TUBERCULOSIS CONFIRMED BY OTHER METHODS [INOCULATION OF ANIMALS]'}
Table 'ICUSTAYS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), DBSOURCE (VARCHAR), FIRST_CAREUNIT (VARCHAR), LAST_CAREUNIT (VARCHAR), FIRST_WARDID (INTEGER), LAST_WARDID (INTEGER), INTIME (VARCHAR), OUTTIME (VARCHAR), LOS (INTEGER), . The table is: This table contains information about ICU stays, including admission and discharge times, patient demographics, and hospital information.{'ROW_ID': 365, 'SUBJECT_ID': 268, 'HADM_ID': 110404, 'ICUSTAY_ID': 280836, 'DBSOURCE': 'CAREVUE', 'FIRST_CAREUNIT': 'MICU', 'LAST_CAREUNIT': 'MICU', 'FIRST_WARDID': 52, 'LAST_WARDID': 52, 'INTIME': '2198-02-14 23:27:38', 'OUTTIME': '2198-02-18 05:26:11', 'LOS': 3.249}
Table 'DRGCODES' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), DRG_TYPE (VARCHAR), DRG_CODE (INTEGER), DESCRIPTION (VARCHAR), DRG_SEVERITY (INTEGER), DRG_MORTALITY (INTEGER), . The table is: Table containing diagnosis-related group (DRG) codes and corresponding information{'ROW_ID': 342, 'SUBJECT_ID': 2491, 'HADM_ID': 144486, 'DRG_TYPE': 'HCFA', 'DRG_CODE': 28, 'DESCRIPTION': 'TRAUMATIC STUPOR & COMA, COMA <1 HR AGE >17 WITH COMPLICATIONS, COMORBIDITIES', 'DRG_SEVERITY': None, 'DRG_MORTALITY': None}
Table 'DIAGNOSES_ICD' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), SEQ_NUM (INTEGER), ICD9_CODE (VARCHAR), . The table is: This table contains diagnoses information with ICD9 codes.{'ROW_ID': 1297, 'SUBJECT_ID': 109, 'HADM_ID': 172335, 'SEQ_NUM': 1, 'ICD9_CODE': '40301'}
Table 'LABEVENTS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ITEMID (INTEGER), CHARTTIME (VARCHAR), VALUE (VARCHAR), VALUENUM (INTEGER), VALUEUOM (VARCHAR), FLAG (VARCHAR), . The table is: Table containing laboratory test results for patients, including values, units, and flags.{'ROW_ID': 281, 'SUBJECT_ID': 3, 'HADM_ID': None, 'ITEMID': 50820, 'CHARTTIME': '2101-10-12 16:07:00', 'VALUE': '7.39', 'VALUENUM': 7.39, 'VALUEUOM': 'UNITS', 'FLAG': None}
Table 'PRESCRIPTIONS' has columns: ROW_ID (INTEGER), SUBJECT_ID (INTEGER), HADM_ID (INTEGER), ICUSTAY_ID (INTEGER), STARTDATE (VARCHAR), ENDDATE (VARCHAR), DRUG_TYPE (VARCHAR), DRUG (VARCHAR), DRUG_NAME_POE (VARCHAR), DRUG_NAME_GENERIC (VARCHAR), FORMULARY_DRUG_CD (VARCHAR), GSN (VARCHAR), NDC (INTEGER), PROD_STRENGTH (VARCHAR), DOSE_VAL_RX (VARCHAR), DOSE_UNIT_RX (VARCHAR), FORM_VAL_DISP (VARCHAR), FORM_UNIT_DISP (VARCHAR), ROUTE (VARCHAR), . The table is: This table contains information about prescriptions, including the drug type, name, dosage, and route of administration.{'ROW_ID': 2214776, 'SUBJECT_ID': 6, 'HADM_ID': 107064, 'ICUSTAY_ID': None, 'STARTDATE': '2175-06-11 00:00:00', 'ENDDATE': '2175-06-12 00:00:00', 'DRUG_TYPE': 'MAIN', 'DRUG': 'TACROLIMUS', 'DRUG_NAME_POE': 'TACROLIMUS', 'DRUG_NAME_GENERIC': 'TACROLIMUS', 'FORMULARY_DRUG_CD': 'TACR1', 'GSN': '021796', 'NDC': 469061711, 'PROD_STRENGTH': '1MG CAPSULE', 'DOSE_VAL_RX': '2', 'DOSE_UNIT_RX': 'MG', 'FORM_VAL_DISP': '2', 'FORM_UNIT_DISP': 'CAP', 'ROUTE': 'PO'}
Table 'CAREGIVER' has columns: ROW_ID (INTEGER), CGID (INTEGER), LABEL (VARCHAR), DESCRIPTION (VARCHAR), . The table is: This table contains information about caregivers, including their roles and descriptions.{'ROW_ID': 2228, 'CGID': 16174, 'LABEL': 'RO', 'DESCRIPTION': 'READ ONLY'}
# Question: what are patient 25869's genders?
# SQLQuery:
|
End of preview. Expand
in Dataset Viewer.
No dataset card yet
New: Create and edit this dataset card directly on the website!
Contribute a Dataset Card- Downloads last month
- 6