Chinastark/bird_dataset huggingface dataset:
Database: synthea
Note: how long = SUBTRACT(julianday(medications.stop, julianday(medications.start))); Amoxicillin 250 MG / Clavulanate 125 MG [Augmentin] refers to medications.description = 'Amoxicillin 250 MG / Clavulanate 125 MG [Augmentin]';
Question: How long was Mr. Major D'Amore prescribed with Amoxicillin 250 MG / Clavulanate 125 MG [Augmentin]?
SQL: SELECT strftime('%J', medications.stop) - strftime('%J', medications.start) AS days FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE medications.description = ' Amoxicillin 250 MG / Clavulanate 125 MG [Augmentin]' AND patients.first = 'Major' AND patients.last = 'D''Amore'
Database: synthea
Note: types of medications refers to medications.description;
Question: How many types of medication have been prescribed to Mr. Major D'Amore since his visit to the hospital?
SQL: SELECT count(DISTINCT medications.description) FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE patients.first = 'Major' AND patients.last = 'D''Amore'
Database: synthea
Note: observation information refers to observations.description AND observations.value AND observations.units;
Question: List out all the observation information collected for the patient named Bella Rolfson.
SQL: SELECT DISTINCT observations.description, observations.value, observations.units FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE patients.first = 'Bella' AND patients.last = 'Rolfson'
Database: synthea
Note: patient names = first, last; calcium deficiency refers to observations.description = 'Calcium' and observations.value < 8.6;
Question: List out patient names with calcium deficiency.
SQL: SELECT DISTINCT patients.first, patients.last FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE observations.description = 'Calcium' AND observations.value < 8.6
Database: synthea
Note: most common condition refers to MAX(COUNT(conditions.description)); underweight patient refers to MIN(observations.value WHERE observations.description = 'Body Mass Index');
Question: List out 5 most common conditions for underweight patient.
SQL: SELECT DISTINCT observations.description, observations.value, observations.units FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE observations.description = 'Body Mass Index' GROUP BY observations.value ORDER BY count(observations.value) LIMIT 5
Database: synthea
Note: expecting mothers can be attributed to encounters.reasondescription = 'Normal pregnancy';
Question: How many mothers have taken immunization during prenatal visit?
SQL: SELECT count(DISTINCT immunizations.patient) FROM encounters INNER JOIN immunizations ON encounters.patient = immunizations.patient WHERE encounters.reasondescription = 'Normal pregnancy' AND encounters.date = immunizations.date
Database: synthea
Note: during year 1970 refers to substr(careplans.start, 1, 4) = '1970' and substr(careplans.stop, 1, 4) = '1970';
Question: What care plans have been received by Mrs. Elly Koss during year 1970?
SQL: SELECT careplans.description FROM patients INNER JOIN careplans ON patients.patient = careplans.patient WHERE patients.first = 'Elly' AND patients.last = 'Koss' AND strftime('%Y', careplans.start) = '2013'
Database: synthea
Note: car plan refers to careplans.description; procedure refers to procedures.description; medication refers to medications.description; full name = first, last; encounter refers to encounters.id; encounters.id = '6f2e3935-b203-493e-a9c0-f23e847b9798';
Question: What is the care plan, procedure, medication and the patient's full name for encounter 6f2e3935-b203-493e-a9c0-f23e847b9798?
SQL: SELECT DISTINCT careplans.description, procedures.description, medications.description, patients.first, patients.last FROM patients INNER JOIN encounters ON patients.patient = encounters.patient INNER JOIN careplans ON patients.patient = careplans.patient INNER JOIN procedures ON patients.patient = procedures.patient INNER JOIN medications ON patients.patient = medications.patient WHERE encounters.id = '6f2e3935-b203-493e-a9c0-f23e847b9798'
Database: synthea
Note: male refers to gender = 'M'; diagnosed with hypertension refers to conditions.description = 'Hypertension'; female refers to gender = 'F'; number of male patients with hypertension = count(patient WHERE gender = 'M' AND conditions.description = 'Hypertension'); number of female patients with hypertension = count(patient WHERE gender = 'F' AND conditions.description = 'Hypertension');
Question: How many male patients are diagnosed with hypertension as compared to female patients?
SQL: SELECT count(DISTINCT CASE WHEN patients.gender = 'M' THEN patients.patient END) AS male , count(DISTINCT CASE WHEN patients.gender = 'F' THEN patients.patient END) AS female FROM conditions INNER JOIN patients ON conditions.patient = patients.patient WHERE conditions.description = 'Hypertension'
Database: synthea
Note: unmarried refers to marital = 'S'; women refers to gender = 'F'; normal pregnancy refers to conditions.description = 'normal pregnancy';
Question: How many unmarried women were checked for normal pregnancy?
SQL: SELECT count(DISTINCT patients.patient) FROM conditions INNER JOIN patients ON conditions.patient = patients.patient WHERE conditions.description = 'Normal pregnancy' AND patients.gender = 'F' AND patients.marital = 'S'
Database: synthea
Note: procedure refers to procedures.description; medicine prescribed refers to medications.description; drug overdose refers to encounters.reasondescription = 'Drug overdose';
Question: List out the procedure and medicine prescribed for drug overdose patients.
SQL: SELECT DISTINCT procedures.description, medications.description FROM encounters INNER JOIN procedures ON encounters.patient = procedures.patient INNER JOIN medications ON encounters.patient = medications.patient WHERE encounters.reasondescription = 'Drug overdose'
Database: synthea
Note: average body mass index = DIVidE(SUM(observations.value), COUNT(patient) WHERE observations.description = 'Body Mass Index'); body mass index refers to observations.description = 'Body Mass Index'; higher total cholesterol refers to observations.description = 'total Cholesterol' and observations.value >= 200;
Question: What is the average body mass index for patients with higher total cholesterol?
SQL: SELECT sum(observations.value) / count(observations.patient) FROM observations INNER JOIN ( SELECT DISTINCT patient FROM observations WHERE description = 'Total Cholesterol' AND value > 200 ) AS t2 ON observations.patient = t2.patient WHERE observations.description = 'Body Mass Index'
Database: synthea
Note: sum(case when t2.date-t1.birthdate between 20 and 29 then t2.value else 0 end)/count(case when t2.date-t1.birthdate between 20 and 29 then t2.patient else null end)-sum(case when t2.date-t1.birthdate between 50 and 59 then t2.value else 0 end)/count(case when t2.date-t1.birthdate between 50 and 59 then t2.patient else null end);
Question: What is the difference between average glucose reading for patients in the 20s and 50s?
SQL: SELECT sum(CASE WHEN round((strftime('%J', observations.date) - strftime('%J', patients.birthdate)) / 365) BETWEEN 20 AND 30 THEN observations.value ELSE 0 END) / count(CASE WHEN round((strftime('%J', observations.date) - strftime('%J', patients.birthdate)) / 365) BETWEEN 20 AND 30 THEN observations.patient END) - sum(CASE WHEN round((strftime('%J', observations.date) - strftime('%J', patients.birthdate)) / 365) BETWEEN 50 AND 60 THEN observations.value ELSE 0 END) / count(CASE WHEN round((strftime('%J', observations.date) - strftime('%J', patients.birthdate)) / 365) BETWEEN 50 AND 60 THEN observations.patient END) AS difference FROM patients INNER JOIN observations ON patients.patient = observations.patient WHERE observations.description = 'Glucose'
Database: synthea
Note: most common condition refers to MAX(COUNT(conditions.description)); age 60 and above refers to SUBTRACT(conditions.start, birthdate) > 60; percentage = MULTIPLY(DIVidE(SUM(patients.patient WHERE MAX(COUNT(conditions.description)) AND SUBTRACT(conditions.start, birthdate) > 60))), COUNT(patients.patient WHERE MAX(COUNT(conditions.description)), 10);
Question: What is the percentage of the most common conditions for patients age 60 and above?
SQL: SELECT cast(sum(CASE WHEN conditions.description = t3.description THEN 1 ELSE 0 END) AS REAL) * 100 / count(t3.patient) FROM ( SELECT conditions.description, patients.patient FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE round((strftime('%J', conditions.start) - strftime('%J', patients.birthdate)) / 365) > 60 GROUP BY conditions.description ORDER BY count(conditions.description) DESC LIMIT 1 ) AS t3 INNER JOIN patients ON t3.patient = patients.patient INNER JOIN conditions ON patients.patient = conditions.patient WHERE round((strftime('%J', conditions.start) - strftime('%J', patients.birthdate)) / 365) > 60
Database: synthea
Note: reason for visiting medical professionals refers to encounters.reasondescription;  in July 2009 refers to  substr(encounters.date, 1, 7) = '2009-07' ;
Question: Name the reason Walter Bahringer visited medical professionals in July 2009.
SQL: SELECT encounters.reasondescription FROM patients INNER JOIN encounters ON patients.patient = encounters.patient WHERE patients.first = 'Walter' AND patients.last = 'Bahringer' AND encounters.date LIKE '2009-07%'
Database: synthea
Note: how old = SUBTRACT(MIN(encounters.date), patients.birthdate); his first emergency room admission refers to MIN(encounters.date); drug overdose refers to encounters.reasondescription = 'Drug overdose' ;
Question: How old was Mr. Stacy Morar at the time of his first emergency room admission due to a drug overdose?
SQL: SELECT encounters.date - patients.birthdate AS age FROM patients INNER JOIN encounters ON patients.patient = encounters.patient WHERE patients.first = 'Stacy' AND patients.last = 'Morar' AND encounters.description = 'Emergency Room Admission' AND encounters.reasondescription = 'Drug overdose' ORDER BY encounters.date LIMIT 1
Database: synthea
Note: drug that was administered refers to medications.description; child attention deficit disorder refers to medications.reasondescription = 'Child attention deficit disorder';
Question: What drug is administered more often to treat child attention deficit disorder?
SQL: SELECT description FROM medications WHERE reasondescription = 'Child attention deficit disorder' GROUP BY description ORDER BY count(description) DESC LIMIT 1
Database: synthea
Note: full name = first, last; lung transplant refers to procedures.description = 'Transplant of lung (procedure)';
Question: Please include the full name of the patient who received a lung transplant.
SQL: SELECT patients.first, patients.last FROM procedures INNER JOIN patients ON procedures.patient = patients.patient WHERE procedures.description = 'Transplant of lung (procedure)'
Database: synthea
Note: average = DIVidE(COUNT(procedures.patient), COUNT(substr(procedures.date, 1, 4))); combined chemotherapy and radiation therapy refers to procedures.description = 'Combined chemotherapy and radiation therapy (procedure)';
Question: How many patients on average receive combined chemotherapy and radiation therapy procedures each year?
SQL: SELECT cast(count(patient) AS REAL) / count(DISTINCT strftime('%Y', DATE)) FROM procedures WHERE description = 'Combined chemotherapy and radiation therapy (procedure)'
Database: synthea
Note: time frame = SUBTRACT(JULIANDAY(careplans.stop), JULIANDAY(careplans.start)); details of care plan refers to careplans.description; most recent care plan refers to MIN(careplans.STAR);
Question: Indicate the time frame and details of the most recent care plan suggested to Jacquelyn Shanahan.
SQL: SELECT strftime('%J', careplans.stop) - strftime('%J', careplans.start) AS timeframe , careplans.description FROM patients INNER JOIN careplans ON patients.patient = careplans.patient WHERE patients.first = 'Jacquelyn' AND patients.last = 'Shanahan' ORDER BY careplans.start DESC LIMIT 1
Database: synthea
Note: allergy period = SUBTRACT(allergies.start, allergies.stop); what triggered the allergy refers to allergies.description;
Question: Identify the allergy period for Isadora Moen and what triggered it.
SQL: SELECT allergies.start, allergies.stop, allergies.description FROM patients INNER JOIN allergies ON patients.patient = allergies.patient WHERE patients.first = 'Isadora' AND patients.last = 'Moen'
Database: synthea
Note: how old = SUBTRACT(MIN(encounters.date), patients.birthdate); most recent medical encounter refers to MIN(encounters.date);
Question: How old was Mrs. Laronda Bernier at the time of her most recent medical encounter?
SQL: SELECT encounters.date - patients.birthdate AS age FROM patients INNER JOIN encounters ON patients.patient = encounters.patient WHERE patients.first = 'Laronda' AND patients.last = 'Bernier' ORDER BY encounters.date DESC LIMIT 1
Database: synthea
Note: condition refers to conditions.description; in 2017 refers to substr(conditions.start, 1, 4) = '2017';
Question: What condition forced Mrs. Joye Homenick to seek medical attention in 2017?
SQL: SELECT conditions.description FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE patients.first = 'Joye' AND patients.last = 'Homenick' AND strftime('%Y', conditions.start) = '2017'
Database: synthea
Note: when a patient received her most recent vaccine refers to MAX(immunications.date); influenza seasonal vaccine refers to immunizations.description = 'Influenza seasonal injectable preservative free';
Question: When did Mrs. Joye Homenick receive her most recent influenza seasonal vaccine?
SQL: SELECT immunizations.date FROM patients INNER JOIN immunizations ON patients.patient = immunizations.patient WHERE immunizations.description = 'Influenza  seasonal  injectable  preservative free' AND patients.first = 'Joye' AND patients.last = 'Homenick' ORDER BY immunizations.date DESC LIMIT 1
Database: synthea
Note: how long = SUBTRACT(julianday(medications.stop), julianday(medications.start)); Acetaminophen 160 MG refers to medications.description = 'Acetaminophen 160 MG';
Question: How long did Elly Koss have to take Acetaminophen 160 MG?
SQL: SELECT strftime('%J', medications.stop) - strftime('%J', medications.start) AS days FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE patients.first = 'Elly' AND LAST = 'Koss' AND medications.description = 'Acetaminophen 160 MG'
Database: synthea
Note: second-degree burn refers to encounters.reasondescription = 'Second degree burn'; ;
Question: How many patients sought medical attention due to a second-degree burn? Describe the care plan recommended to them.
SQL: SELECT count(DISTINCT careplans.patient), careplans.description FROM encounters INNER JOIN careplans ON encounters.patient = careplans.patient WHERE careplans.reasondescription = 'Second degree burn'
Database: synthea
Note: in 2010 refers to substr(encounters.date, 1, 4) = '2010'; contact dermatitis refers to encounters.reasondescription = 'Contact dermatitis'; percentage = MULTIPLY(DIVidE(COUNT(encounters.patient WHERE gender = 'F'), count(encounters.patient) WHERE encounters.reasondescription = 'Contact dermatitis'), 1.0) females refers to gender = 'F';
Question: Among all patients who sought medical attention in 2010 due to contact dermatitis, identify the percentage of females.
SQL: SELECT cast(sum(CASE WHEN patients.gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / count(encounters.patient) FROM encounters INNER JOIN patients ON encounters.patient = patients.patient WHERE strftime('%Y', encounters.date) = '2010' AND encounters.reasondescription = 'Contact dermatitis'
Database: synthea
Note: between 2010 and 2017 refers to substr(encounters.date, 1, 4) between '2010' and '2017'; percentage = MULTIPLY(DIVidE(COUNT(encounters.id WHERE description = 'Prenatal visit'), count(encounters.id)), 1.0); prenatal visits refers to encounters.description = 'Prenatal visit';
Question: How many interactions did Lorri Simons have with medical professionals between 2010 and 2017? What percentage of encounters are attributed to prenatal visits?
SQL: SELECT count(patients.patient) , cast(sum(CASE WHEN encounters.description = 'Prenatal visit' THEN 1 ELSE 0 END) AS REAL) * 100 / count(patients.patient) FROM patients INNER JOIN encounters ON patients.patient = encounters.patient WHERE patients.first = 'Lorri' AND patients.last = 'Simonis' AND strftime('%Y', encounters.date) BETWEEN '2010' AND '2017'
Database: synthea
Note: description of medication refers to medications.description;
Question: State description of medication taken by Joe Homenick.
SQL: SELECT medications.description FROM medications INNER JOIN patients ON medications.patient = patients.patient WHERE patients.first = 'Joye' AND patients.last = 'Homenick'
Database: synthea
Note: start date of the care plan refers to careplans.start;
Question: What is the start date of the care plan of the patient whose maiden name is Adams?
SQL: SELECT DISTINCT careplans.start FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.maiden = 'Adams'
Database: synthea
Note: male patients refers to gender = 'M'; earliest starting date of the care plan refers to MIN(careplans.start);
Question: Among the male patients, who has the earliest starting date of the care plan?
SQL: SELECT patients.first, patients.last FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.gender = 'M' ORDER BY careplans.start LIMIT 1
Database: synthea
Note: Hispanic patients refers to ethnicity = 'hispanic'; percentage = MULTIPLY(DIVidE(COUNT(careplans.patient WHERE ethnicity = 'hispanic'), COUNT(careplans.patient)), 1.0); stopped their care plan in 2011 refers to substr(careplans.stop, 1, 4) = '2011';
Question: What is the percentage of Hispanic patients who stopped their care plan in 2011?
SQL: SELECT cast(sum(CASE WHEN patients.race = 'hispanic' THEN 1 ELSE 0 END) AS REAL) * 100 / count(careplans.patient) FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE strftime('%Y', careplans.stop) = '2011'
Database: synthea
Note: description of the reason of the care plan refers to careplans.reasondescription;
Question: State the description of the reason why Angelo Buckridge needs the care plan.
SQL: SELECT DISTINCT careplans.reasondescription FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.first = 'Angelo' AND patients.last = 'Buckridge'
Database: synthea
Note: American refers to ethnicity = 'american';
Question: Mention the description of the care plan of American patients.
SQL: SELECT DISTINCT careplans.description FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.ethnicity = 'american'
Database: synthea
Note: medical encounter ids careplans.id; born in Pembroke MA US refers to birthplace = 'Pembroke MA US';
Question: What are the medical encounter ids of patients who were born in Pembroke MA US?
SQL: SELECT DISTINCT careplans.encounter FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.birthplace = 'Pembroke MA US'
Database: synthea
Note: start of the care plan refers to careplans.start; alive patients refers to deathdate is null;
Question: List out the start date of the care plan of alive patients.
SQL: SELECT DISTINCT careplans.start FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.deathdate IS NULL
Database: synthea
Note: white refers to race = 'white'; reason code of 10509002 refers to careplans.reasoncode = '10509002';
Question: How many white patients have the reason code of 10509002?
SQL: SELECT count(DISTINCT careplans.patient) FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.race = 'white' AND careplans.reasoncode = '10509002'
Database: synthea
Note: full name = first, last; Diabetic diet refers to careplans.description = 'Diabetic diet';
Question: List out full name of patients who have "Diabetic diet" in the description of the care plan.
SQL: SELECT DISTINCT patients.first, patients.last FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE careplans.description = 'Diabetic diet'
Database: synthea
Note: stop date of the care plan refers to careplans.stop; dead patients refers to deathdate is not null;
Question: List out the stop date of the care plan of dead patients.
SQL: SELECT DISTINCT careplans.stop FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.deathdate IS NOT NULL AND careplans.stop IS NOT NULL
Database: synthea
Note: Italian patients refers to ethnicity = 'italian';
Question: How many Italian patients have the care plan code of 304510005?
SQL: SELECT count(DISTINCT patients.patient) FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.ethnicity = 'italian' AND careplans.code = '304510005'
Database: synthea
Note: female patients refers to gender = 'F'; started the care plan in 2010 refers to substr(careplans.start, 1, 4) = '2010'; percentage = MULTIPLY(DIVidE(COUNT(patients.patient WHERE patients.gender = 'F'), COUNT(patients.patient) WHERE substr(careplans.start, 1, 4) = '2010'), 100);
Question: What is the percentage of female patients who started the care plan in 2010?
SQL: SELECT cast(sum(CASE WHEN patients.gender = 'F' THEN 1 ELSE 0 END) AS REAL) * 100 / count(careplans.patient) AS percentage FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE strftime('%Y', careplans.start) = '2010'
Database: synthea
Note: black refers to race = 'black'; stopped their care plan in 2017 refers to substr(careplans.stop, 1, 4) = '2017';
Question: How many black patients stopped their care plan in 2017?
SQL: SELECT count(DISTINCT patients.patient) FROM careplans INNER JOIN patients ON careplans.patient = patients.patient WHERE patients.race = 'black' AND strftime('%Y', careplans.stop) = '2017'
Database: synthea
Note: male refers to gender = 'M'; prediabetes condition refers to conditions.description = 'Prediabetes';
Question: How many male patients have prediabetes condition?
SQL: SELECT count(DISTINCT patients.patient) FROM patients INNER JOIN conditions WHERE conditions.description = 'Prediabetes' AND patients.gender = 'M'
Database: synthea
Note: full names = first, last; nut allergy refers to allergies.description = 'Allergy to nut';
Question: List the full names of patients with nut allergy.
SQL: SELECT DISTINCT patients.first, patients.last FROM patients INNER JOIN allergies ON patients.patient = allergies.patient WHERE allergies.description = 'Allergy to nut'
Database: synthea
Question: Describe the condition of patient Wilmer Koepp.
SQL: SELECT conditions.description FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE patients.first = 'Wilmer' AND patients.last = 'Koepp'
Database: synthea
Note: viral sinusitis condition refers to conditions.description = 'Viral sinusitis (disorder)'; gender that is most affected refers to MAX(COUNT(gender WHERE conditions.description = 'Viral sinusitis (disorder)'));
Question: Among the patients with viral sinusitis condition, which patient's gender is most affected? Provide the number for each respectively.
SQL: SELECT sum(CASE WHEN patients.gender = 'F' THEN 1 ELSE 0 END), sum(CASE WHEN patients.gender = 'M' THEN 1 ELSE 0 END) FROM patients INNER JOIN conditions ON patients.patient = conditions.patient WHERE conditions.description = 'Viral sinusitis (disorder)'
Database: synthea
Note: full names = first, last; Penicillin V Potassium 250 MG refers to medications.description = 'Penicillin V Potassium 250 MG'; since 1948 refers to substr(medications.start, 1, 4) >= '1948';
Question: Provide the full names of patients who have been taking Penicillin V Potassium 250 MG since 1948.
SQL: SELECT DISTINCT patients.first, patients.last FROM patients INNER JOIN medications ON patients.patient = medications.patient WHERE medications.description = 'Penicillin V Potassium 250 MG' AND strftime('%Y', medications.start) >= '1948'