1sf/bird-sql-train-with-schema huggingface dataset:
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: List down the first name of patients who have cystitis condition.
Evidence: cystitis refers to conditions where DESCRIPTION = 'Cystitis';
SQL: SELECT DISTINCT T1.first FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Cystitis'
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: How many stroke patients have married?
Evidence: stroke refers to conditions where DESCRIPTION = 'Stroke'; married refers to the marital status of the patient in which marital = 'M';
SQL: SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN conditions AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Stroke' AND T1.marital = 'M'
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: List down the address of patients who have billable period in 2010.
SQL: SELECT DISTINCT T1.address FROM patients AS T1 INNER JOIN claims AS T2 ON T1.patient = T2.PATIENT WHERE T2.BILLABLEPERIOD LIKE '2010%'
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: List down the last name of patients who are allergic to dairy products.
Evidence: allergic to dairy products refers to allergies where DESCRIPTION = 'Allergy to dairy product';
SQL: SELECT DISTINCT T1.last FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Allergy to dairy product'
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: When the allergy starts for Angelo Buckridge.
SQL: SELECT T2.START FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.first = 'Adolfo' AND T1.last = 'Schmitt' AND T2.STOP IS NOT NULL
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: How many of the male patients are allergic to house dust mites?
Evidence: male patients refer to PATIENT where gender = 'M'; allergic to house dust mites refers to allergies where DESCRIPTION = 'House dust mite allergy';
SQL: SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'House dust mite allergy' AND T1.gender = 'M'
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: What kind of allergy is most common among white people?
Evidence: kind of allergy is most common refers to MAX(COUNT(DESCRIPTION)) from allergies; white refers to race = 'white';
SQL: SELECT T2.DESCRIPTION FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.race = 'white' GROUP BY T2.DESCRIPTION ORDER BY COUNT(T2.DESCRIPTION) DESC LIMIT 1
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: List down the first name of patients who received "Influenza seasonal injectable preservative free" immunization.
Evidence: "Influenza seasonal injectable preservative free" immunization refers to immunizations where DESCRIPTION = 'Influenza seasonal injectable preservative free';
SQL: SELECT DISTINCT T1.first, T1.last FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Influenza  seasonal  injectable  preservative free'
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: Calculate the number of female patients who accepted "HPV quadrivalent" immunization.
Evidence: female refers to gender = 'F'; "HPV quadrivalent" immunization refers to immunizations where DESCRIPTION = 'HPV quadrivalent';
SQL: SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN immunizations AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'HPV  quadrivalent' AND T1.gender = 'F'
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: List down the encounter descriptions of patients who were born in Pittsfield MA US.
Evidence: born in Pittsfield MA US refers to birthplace = 'Pittsfield MA US';
SQL: SELECT DISTINCT T2.DESCRIPTION FROM patients AS T1 INNER JOIN encounters AS T2 ON T1.patient = T2.PATIENT WHERE T1.birthplace = 'Pittsfield MA US'
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: Calculate the total type of allergies for German people.
Evidence: type of allergies refers to DESCRIPTION from allergies; German people refer to PATIENT where ethnicity = 'german';
SQL: SELECT COUNT(DISTINCT T2.DESCRIPTION) FROM patients AS T1 INNER JOIN allergies AS T2 ON T1.patient = T2.PATIENT WHERE T1.ethnicity = 'german'
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: Calculate the average age of patients with prediabetes care plan.
Evidence: SUBTRACT(SUM(deathdate), SUM(birthdate)), COUNT(patient) where REASONDESCRIPTION = 'Prediabetes' from careplans;
SQL: SELECT CAST(SUM(CASE WHEN T1.deathdate IS NULL THEN strftime('%Y', T2.STOP) - strftime('%Y', T1.birthdate) ELSE strftime('%Y', T1.deathdate) - strftime('%Y', T1.birthdate) END) AS REAL) / COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN careplans AS T2 ON T1.patient = T2.PATIENT WHERE T2.REASONDESCRIPTION = 'Prediabetes'
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: How many of the patients who have stopped taking medication for 'coronary heart disease' are still alive?
Evidence: patients who have stopped taking medication for 'coronary heart disease' refer to PATIENT where REASONDESCRIPTION = 'Coronary Heart Disease' and STOP is not null from medications; if deathdate is null, it means this patient is still alive;
SQL: SELECT COUNT(DISTINCT T2.patient) FROM medications AS T1 INNER JOIN patients AS T2 ON T1.PATIENT = T2.patient WHERE T1.REASONDESCRIPTION = 'Coronary Heart Disease' AND T1.STOP IS NOT NULL AND T2.deathdate IS NULL
Database: synthea
Tables: all_prevalences, patients, encounters, allergies, careplans, conditions, immunizations, medications, observations, procedures, claims
Columns (table index, column name): -1, *, 0, ITEM, 0, POPULATION TYPE, 0, OCCURRENCES, 0, POPULATION COUNT, 0, PREVALENCE RATE, 0, PREVALENCE PERCENTAGE, 1, patient, 1, birthdate, 1, deathdate, 1, ssn, 1, drivers, 1, passport, 1, prefix, 1, first, 1, last, 1, suffix, 1, maiden, 1, marital, 1, race, 1, ethnicity, 1, gender, 1, birthplace, 1, address, 2, ID, 2, DATE, 2, PATIENT, 2, CODE, 2, DESCRIPTION, 2, REASONCODE, 2, REASONDESCRIPTION, 3, START, 3, STOP, 3, PATIENT, 3, ENCOUNTER, 3, CODE, 3, DESCRIPTION, 4, ID, 4, START, 4, STOP, 4, PATIENT, 4, ENCOUNTER, 4, CODE, 4, DESCRIPTION, 4, REASONCODE, 4, REASONDESCRIPTION, 5, START, 5, STOP, 5, PATIENT, 5, ENCOUNTER, 5, CODE, 5, DESCRIPTION, 6, DATE, 6, PATIENT, 6, ENCOUNTER, 6, CODE, 6, DESCRIPTION, 7, START, 7, STOP, 7, PATIENT, 7, ENCOUNTER, 7, CODE, 7, DESCRIPTION, 7, REASONCODE, 7, REASONDESCRIPTION, 8, DATE, 8, PATIENT, 8, ENCOUNTER, 8, CODE, 8, DESCRIPTION, 8, VALUE, 8, UNITS, 9, DATE, 9, PATIENT, 9, ENCOUNTER, 9, CODE, 9, DESCRIPTION, 9, REASONCODE, 9, REASONDESCRIPTION, 10, ID, 10, PATIENT, 10, BILLABLEPERIOD, 10, ORGANIZATION, 10, ENCOUNTER, 10, DIAGNOSIS, 10, TOTAL
Question: How many of the patients who underwent a 'bone immobilization' procedure have a driver's license?
Evidence: patients who underwent a 'bone immobilization' procedure refer to PATIENT from procedures where DESCRIPTION = 'Bone immobilization'; have a driver's license refers to drivers is not null;
SQL: SELECT COUNT(DISTINCT T1.patient) FROM patients AS T1 INNER JOIN procedures AS T2 ON T1.patient = T2.PATIENT WHERE T2.DESCRIPTION = 'Bone immobilization' AND T1.drivers IS NOT NULL