Upload data.jsonl with huggingface_hub
Browse files- data.jsonl +2 -2
data.jsonl
CHANGED
|
@@ -100,8 +100,8 @@
|
|
| 100 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(10), address text, phone_number character varying(20), email character varying(128) UNIQUE, emergency_contact_name character varying(200), emergency_contact_phone character varying(20), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (patient_id) )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id.text, record_id.text, patient_id.text, doctor_id.text, medication_id.text, dosage.text, frequency.text, route.text, start_date.date, end_date.date, quantity_dispensed.numeric, refills_allowed.integer, prescription_date.timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, plan_id character varying(64) NOT NULL, policy_number character varying(100) NOT NULL, group_number character varying(100), subscriber_name character varying(200), effective_date date NOT NULL, expiration_date date, is_primary boolean NOT NULL DEFAULT true, PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) )\n", "conversations": [{"role": "user", "content": "List each patient's first and last name along with the insurance plan name they are enrolled in, including only primary policies. Return patient_id, first_name, last_name, and plan_name."}, {"role": "assistant", "content": "SELECT p.patient_id,\n p.first_name,\n p.last_name,\n ip.plan_name\nFROM healthcare.patients AS p\nJOIN healthcare.patient_insurance AS pi\n ON p.patient_id = pi.patient_id AND pi.is_primary = true\nJOIN healthcare.insurance_plans AS ip ON pi.plan_id = ip.plan_id;"}, {"role": "user", "content": "Now limit to plans with plan_type 'EPO' and sort by patient last name ascending."}, {"role": "assistant", "content": "SELECT p.patient_id,\n p.first_name,\n p.last_name,\n ip.plan_name\nFROM healthcare.patients AS p\nJOIN healthcare.patient_insurance AS pi\n ON p.patient_id = pi.patient_id AND pi.is_primary = true\nJOIN healthcare.insurance_plans AS ip ON pi.plan_id = ip.plan_id\nWHERE ip.plan_type = 'EPO'\nORDER BY p.last_name ASC;"}]}
|
| 101 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, specialty character varying(100) NOT NULL, license_number character varying(50) UNIQUE NOT NULL, phone_number character varying(20), email character varying(128) UNIQUE, hospital_affiliation_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (doctor_id) )\nCREATE TABLE healthcare.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\n", "conversations": [{"role": "user", "content": "Show a list of diagnoses along with the chief complaint noted in the corresponding medical record. Display diagnosis description, diagnosis date, and the chief complaint."}, {"role": "assistant", "content": "SELECT T1.description, T1.diagnosis_date, T2.chief_complaint FROM healthcare.diagnoses AS T1 JOIN healthcare.medical_records AS T2 ON T1.record_id = T2.record_id;"}]}
|
| 102 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.diagnoses ( diagnosis_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, diagnosis_code character varying(20) NOT NULL, code_type character varying(10) NOT NULL DEFAULT 'ICD-10', description text, diagnosis_date date NOT NULL, status character varying(32) NOT NULL, is_chronic boolean DEFAULT false, PRIMARY KEY (diagnosis_id) )\nCREATE TABLE healthcare.prescriptions ( prescription_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, medication_id character varying(64) NOT NULL, dosage character varying(100) NOT NULL, frequency character varying(100) NOT NULL, route character varying(50), start_date date NOT NULL, end_date date, quantity_dispensed numeric(10,2), refills_allowed integer NOT NULL DEFAULT 0, prescription_date timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (prescription_id) )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, plan_id character varying(64) NOT NULL, policy_number character varying(100) NOT NULL, group_number character varying(100), subscriber_name character varying(200), effective_date date NOT NULL, expiration_date date, is_primary boolean NOT NULL DEFAULT true, PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) )\n", "conversations": [{"role": "user", "content": "Show each patient's policy number, the associated insurance plan ID, and any medications they have been prescribed, including the medication ID and prescription date."}, {"role": "assistant", "content": "SELECT pi.patient_id, pi.policy_number, pi.plan_id, pr.medication_id, pr.prescription_date\nFROM healthcare.patient_insurance pi\nJOIN healthcare.prescriptions pr ON pi.patient_id = pr.patient_id;"}, {"role": "user", "content": "Only include prescriptions that were made after the insurance policy's effective date."}, {"role": "assistant", "content": "SELECT pi.patient_id, pi.policy_number, pi.plan_id, pr.medication_id, pr.prescription_date\nFROM healthcare.patient_insurance pi\nJOIN healthcare.prescriptions pr ON pi.patient_id = pr.patient_id\nWHERE pr.prescription_date >= pi.effective_date;"}, {"role": "user", "content": "Add the expiration date of the insurance policy and only show records where the prescription was made before the policy expired."}, {"role": "assistant", "content": "SELECT pi.patient_id, pi.policy_number, pi.plan_id, pi.expiration_date, pr.medication_id, pr.prescription_date\nFROM healthcare.patient_insurance pi\nJOIN healthcare.prescriptions pr ON pi.patient_id = pr.patient_id\nWHERE pr.prescription_date >= pi.effective_date\n AND (pi.expiration_date IS NULL OR pr.prescription_date < pi.expiration_date);"}]}
|
| 103 |
-
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medical_records ( record_id text PRIMARY KEY, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List all medical records along with the chief complaint and record date for patients who had their medical record created after March 1, 2023 and whose record was created by doctor with ID 'doctor_123'."}, {"role": "assistant", "content": "SELECT record_id, patient_id, chief_complaint, record_date FROM healthcare.medical_records WHERE doctor_id = 'doctor_123' AND record_date > '2023-03-01';"}, {"role": "user", "content": "Can you also include the treatment plan for each record in the result?"}, {"role": "assistant", "content": "SELECT record_id, patient_id, chief_complaint, record_date, treatment_plan FROM healthcare.medical_records WHERE doctor_id = 'doctor_123' AND record_date > '2023-03-01';"}, {"role": "user", "content": "Actually, I only want records where the assessment field is not null."}, {"role": "assistant", "content": "SELECT record_id, patient_id, chief_complaint, record_date, treatment_plan FROM healthcare.medical_records WHERE doctor_id = 'doctor_123' AND record_date > '2023-03-01' AND assessment IS NOT NULL;"}, {"role": "user", "content": "Now, restrict the results to records where the chief complaint contains the word 'cough'."}, {"role": "assistant", "content": "SELECT record_id, patient_id, chief_complaint, record_date, treatment_plan FROM healthcare.medical_records WHERE doctor_id = 'doctor_123' AND record_date > '2023-03-01' AND assessment IS NOT NULL AND chief_complaint ILIKE '%cough%';"}]}
|
| 104 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "Show me all primary insurance policies along with their policy numbers and effective dates for patient with ID 'patient_555'."}, {"role": "assistant", "content": "SELECT patient_insurance_id, policy_number, effective_date FROM healthcare.patient_insurance WHERE patient_id = 'patient_555' AND is_primary = TRUE;"}, {"role": "user", "content": "Can you also show the group number for each policy?"}, {"role": "assistant", "content": "SELECT patient_insurance_id, policy_number, effective_date, group_number FROM healthcare.patient_insurance WHERE patient_id = 'patient_555' AND is_primary = TRUE;"}, {"role": "user", "content": "I only want to see those policies that are still active."}, {"role": "assistant", "content": "SELECT patient_insurance_id, policy_number, effective_date, group_number FROM healthcare.patient_insurance WHERE patient_id = 'patient_555' AND is_primary = TRUE AND expiration_date > CURRENT_DATE;"}, {"role": "user", "content": "Actually, can you order the results by expiration_date, with the soonest expiration first?"}, {"role": "assistant", "content": "SELECT patient_insurance_id, policy_number, effective_date, group_number FROM healthcare.patient_insurance WHERE patient_id = 'patient_555' AND is_primary = TRUE AND expiration_date > CURRENT_DATE ORDER BY expiration_date ASC;"}]}
|
|
|
|
| 105 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List all medical records created by doctor 'doctor_001' for patients who had their last medical record on or after '2024-01-01', including record_id, patient_id, record_date, chief_complaint, and doctor_id."}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.record_date, mr.chief_complaint, mr.doctor_id\nFROM healthcare.medical_records mr\nJOIN (\n SELECT patient_id, MAX(record_date) AS last_record_date\n FROM healthcare.medical_records\n GROUP BY patient_id\n) last_rec ON mr.patient_id = last_rec.patient_id\nWHERE mr.doctor_id = 'doctor_001' AND last_rec.last_record_date >= '2024-01-01';"}, {"role": "user", "content": "Please refine the results to only include records where the 'assessment' field is not null."}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.record_date, mr.chief_complaint, mr.doctor_id\nFROM healthcare.medical_records mr\nJOIN (\n SELECT patient_id, MAX(record_date) AS last_record_date\n FROM healthcare.medical_records\n GROUP BY patient_id\n) last_rec ON mr.patient_id = last_rec.patient_id\nWHERE mr.doctor_id = 'doctor_001' AND last_rec.last_record_date >= '2024-01-01' AND mr.assessment IS NOT NULL;"}, {"role": "user", "content": "I received too many results. Can you only show records where 'treatment_plan' is also not null?"}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.record_date, mr.chief_complaint, mr.doctor_id\nFROM healthcare.medical_records mr\nJOIN (\n SELECT patient_id, MAX(record_date) AS last_record_date\n FROM healthcare.medical_records\n GROUP BY patient_id\n) last_rec ON mr.patient_id = last_rec.patient_id\nWHERE mr.doctor_id = 'doctor_001' AND last_rec.last_record_date >= '2024-01-01' AND mr.assessment IS NOT NULL AND mr.treatment_plan IS NOT NULL;"}]}
|
| 106 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medications ( medication_id text PRIMARY KEY, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\n", "conversations": [{"role": "user", "content": "List the medication IDs and names for all entries where the description is missing or empty."}, {"role": "assistant", "content": "SELECT medication_id, medication_name FROM healthcare.medications WHERE description IS NULL OR description = '';"}, {"role": "user", "content": "For those medications, please also show the manufacturer and sort the results by medication name in ascending order."}, {"role": "assistant", "content": "SELECT medication_id, medication_name, manufacturer FROM healthcare.medications WHERE description IS NULL OR description = '' ORDER BY medication_name ASC;"}]}
|
| 107 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "I need to find patients who received prescriptions within 7 days after their latest appointment. Show patient_id, first and last name, appointment_time, prescription_date, and medication_name."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id"}, {"role": "user", "content": "Actually, restrict it to prescriptions where dosage contains 'mg'."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\n AND pr.dosage LIKE '%mg%'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id"}, {"role": "user", "content": "Also, sort the results by prescription_date descending and limit to 5."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\n AND pr.dosage LIKE '%mg%'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id\nORDER BY pr.prescription_date DESC\nLIMIT 5"}]}
|
|
@@ -247,4 +247,4 @@
|
|
| 247 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(10), address text, phone_number character varying(20), email character varying(128) UNIQUE, emergency_contact_name character varying(200), emergency_contact_phone character varying(20), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (patient_id) )\nCREATE TABLE healthcare.doctors ( doctor_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, specialty character varying(100) NOT NULL, license_number character varying(50) UNIQUE NOT NULL, phone_number character varying(20), email character varying(128) UNIQUE, hospital_affiliation_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (doctor_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, diagnosis_code character varying(20) NOT NULL, code_type character varying(10) NOT NULL DEFAULT 'ICD-10', description text, diagnosis_date date NOT NULL, status character varying(32) NOT NULL, is_chronic boolean DEFAULT false, PRIMARY KEY (diagnosis_id) )\nCREATE TABLE healthcare.medications ( medication_id character varying(64) NOT NULL, medication_name character varying(255) NOT NULL, generic_name character varying(255), manufacturer character varying(100), ndc_code character varying(20) UNIQUE, description text, PRIMARY KEY (medication_id) )\nCREATE TABLE healthcare.insurance_plans ( plan_id character varying(64) NOT NULL, plan_name character varying(200) NOT NULL, insurance_provider character varying(100) NOT NULL, plan_type character varying(50), contact_phone character varying(20), website character varying(255), PRIMARY KEY (plan_id) )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, plan_id character varying(64) NOT NULL, policy_number character varying(100) NOT NULL, group_number character varying(100), subscriber_name character varying(200), effective_date date NOT NULL, expiration_date date, is_primary boolean NOT NULL DEFAULT true, PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) )\n", "conversations": [{"role": "user", "content": "Which patients have a primary insurance policy and are subscribed to a plan provided by 'Cigna'? List patient ID, full name, policy number, plan ID, and insurance provider."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna';"}, {"role": "user", "content": "Additionally, only show results where the policy has not expired yet."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna' AND (pi.expiration_date IS NULL OR pi.expiration_date >= CURRENT_DATE);"}]}
|
| 248 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text, first_name text, last_name text, company_name text, email text, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.lawyers ( lawyer_id text, first_name text, last_name text, bar_number text, firm_id text, email text, phone text, specialization text, hire_date timestamp, is_partner boolean )\nCREATE TABLE legal_services.law_firms ( firm_id text, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.documents ( document_id text, case_id text, document_name text, document_type text, storage_path text, uploaded_by_lawyer_id text, upload_timestamp timestamp, version integer, description text )\nCREATE TABLE legal_services.time_entries ( entry_id text, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable boolean, is_billed boolean, invoice_id text, created_at timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id text, client_id text, lawyer_id text, case_id text, start_time timestamp, end_time timestamp, location text, subject text, notes text, status text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "I need a list showing the name of each law firm and the full name of every lawyer employed by that firm."}, {"role": "assistant", "content": "SELECT T1.firm_name, T2.first_name, T2.last_name FROM law_firms AS T1 JOIN lawyers AS T2 ON T1.firm_id = T2.firm_id;"}]}
|
| 249 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )\n", "conversations": [{"role": "user", "content": "Show me all customers (customer_id, first_name, last_name, email) who were born after 1985 (date_of_birth > '1985-12-31') and have an email address ending with '@yahoo.com', along with their city and state information."}, {"role": "assistant", "content": "SELECT customer_id, first_name, last_name, email, city, state FROM financial_services.customers WHERE date_of_birth > '1985-12-31' AND email LIKE '%@yahoo.com';"}]}
|
| 250 |
-
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE
|
|
|
|
| 100 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(10), address text, phone_number character varying(20), email character varying(128) UNIQUE, emergency_contact_name character varying(200), emergency_contact_phone character varying(20), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (patient_id) )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id.text, record_id.text, patient_id.text, doctor_id.text, medication_id.text, dosage.text, frequency.text, route.text, start_date.date, end_date.date, quantity_dispensed.numeric, refills_allowed.integer, prescription_date.timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, plan_id character varying(64) NOT NULL, policy_number character varying(100) NOT NULL, group_number character varying(100), subscriber_name character varying(200), effective_date date NOT NULL, expiration_date date, is_primary boolean NOT NULL DEFAULT true, PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) )\n", "conversations": [{"role": "user", "content": "List each patient's first and last name along with the insurance plan name they are enrolled in, including only primary policies. Return patient_id, first_name, last_name, and plan_name."}, {"role": "assistant", "content": "SELECT p.patient_id,\n p.first_name,\n p.last_name,\n ip.plan_name\nFROM healthcare.patients AS p\nJOIN healthcare.patient_insurance AS pi\n ON p.patient_id = pi.patient_id AND pi.is_primary = true\nJOIN healthcare.insurance_plans AS ip ON pi.plan_id = ip.plan_id;"}, {"role": "user", "content": "Now limit to plans with plan_type 'EPO' and sort by patient last name ascending."}, {"role": "assistant", "content": "SELECT p.patient_id,\n p.first_name,\n p.last_name,\n ip.plan_name\nFROM healthcare.patients AS p\nJOIN healthcare.patient_insurance AS pi\n ON p.patient_id = pi.patient_id AND pi.is_primary = true\nJOIN healthcare.insurance_plans AS ip ON pi.plan_id = ip.plan_id\nWHERE ip.plan_type = 'EPO'\nORDER BY p.last_name ASC;"}]}
|
| 101 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, specialty character varying(100) NOT NULL, license_number character varying(50) UNIQUE NOT NULL, phone_number character varying(20), email character varying(128) UNIQUE, hospital_affiliation_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (doctor_id) )\nCREATE TABLE healthcare.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\n", "conversations": [{"role": "user", "content": "Show a list of diagnoses along with the chief complaint noted in the corresponding medical record. Display diagnosis description, diagnosis date, and the chief complaint."}, {"role": "assistant", "content": "SELECT T1.description, T1.diagnosis_date, T2.chief_complaint FROM healthcare.diagnoses AS T1 JOIN healthcare.medical_records AS T2 ON T1.record_id = T2.record_id;"}]}
|
| 102 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.diagnoses ( diagnosis_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, diagnosis_code character varying(20) NOT NULL, code_type character varying(10) NOT NULL DEFAULT 'ICD-10', description text, diagnosis_date date NOT NULL, status character varying(32) NOT NULL, is_chronic boolean DEFAULT false, PRIMARY KEY (diagnosis_id) )\nCREATE TABLE healthcare.prescriptions ( prescription_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, medication_id character varying(64) NOT NULL, dosage character varying(100) NOT NULL, frequency character varying(100) NOT NULL, route character varying(50), start_date date NOT NULL, end_date date, quantity_dispensed numeric(10,2), refills_allowed integer NOT NULL DEFAULT 0, prescription_date timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (prescription_id) )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, plan_id character varying(64) NOT NULL, policy_number character varying(100) NOT NULL, group_number character varying(100), subscriber_name character varying(200), effective_date date NOT NULL, expiration_date date, is_primary boolean NOT NULL DEFAULT true, PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) )\n", "conversations": [{"role": "user", "content": "Show each patient's policy number, the associated insurance plan ID, and any medications they have been prescribed, including the medication ID and prescription date."}, {"role": "assistant", "content": "SELECT pi.patient_id, pi.policy_number, pi.plan_id, pr.medication_id, pr.prescription_date\nFROM healthcare.patient_insurance pi\nJOIN healthcare.prescriptions pr ON pi.patient_id = pr.patient_id;"}, {"role": "user", "content": "Only include prescriptions that were made after the insurance policy's effective date."}, {"role": "assistant", "content": "SELECT pi.patient_id, pi.policy_number, pi.plan_id, pr.medication_id, pr.prescription_date\nFROM healthcare.patient_insurance pi\nJOIN healthcare.prescriptions pr ON pi.patient_id = pr.patient_id\nWHERE pr.prescription_date >= pi.effective_date;"}, {"role": "user", "content": "Add the expiration date of the insurance policy and only show records where the prescription was made before the policy expired."}, {"role": "assistant", "content": "SELECT pi.patient_id, pi.policy_number, pi.plan_id, pi.expiration_date, pr.medication_id, pr.prescription_date\nFROM healthcare.patient_insurance pi\nJOIN healthcare.prescriptions pr ON pi.patient_id = pr.patient_id\nWHERE pr.prescription_date >= pi.effective_date\n AND (pi.expiration_date IS NULL OR pr.prescription_date < pi.expiration_date);"}]}
|
|
|
|
| 103 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "Show me all primary insurance policies along with their policy numbers and effective dates for patient with ID 'patient_555'."}, {"role": "assistant", "content": "SELECT patient_insurance_id, policy_number, effective_date FROM healthcare.patient_insurance WHERE patient_id = 'patient_555' AND is_primary = TRUE;"}, {"role": "user", "content": "Can you also show the group number for each policy?"}, {"role": "assistant", "content": "SELECT patient_insurance_id, policy_number, effective_date, group_number FROM healthcare.patient_insurance WHERE patient_id = 'patient_555' AND is_primary = TRUE;"}, {"role": "user", "content": "I only want to see those policies that are still active."}, {"role": "assistant", "content": "SELECT patient_insurance_id, policy_number, effective_date, group_number FROM healthcare.patient_insurance WHERE patient_id = 'patient_555' AND is_primary = TRUE AND expiration_date > CURRENT_DATE;"}, {"role": "user", "content": "Actually, can you order the results by expiration_date, with the soonest expiration first?"}, {"role": "assistant", "content": "SELECT patient_insurance_id, policy_number, effective_date, group_number FROM healthcare.patient_insurance WHERE patient_id = 'patient_555' AND is_primary = TRUE AND expiration_date > CURRENT_DATE ORDER BY expiration_date ASC;"}]}
|
| 104 |
+
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.diagnoses ( diagnosis_id.text, record_id.text, patient_id.text, doctor_id.text, diagnosis_code.text, code_type.text, description.text, diagnosis_date.date, status.text, is_chronic.boolean )\n", "conversations": [{"role": "user", "content": "Can you show me the total number of diagnosis records for each doctor, along with the doctor's ID? Please include only those diagnoses marked as 'chronic'."}, {"role": "assistant", "content": "SELECT doctor_id, COUNT(*) AS total_chronic_diagnoses FROM healthcare.diagnoses WHERE is_chronic = TRUE GROUP BY doctor_id;"}, {"role": "user", "content": "Now, can you also include the average number of chronic diagnoses per patient for each doctor in the results?"}, {"role": "assistant", "content": "SELECT doctor_id, COUNT(*) AS total_chronic_diagnoses, COUNT(*)::FLOAT / COUNT(DISTINCT patient_id) AS avg_chronic_per_patient FROM healthcare.diagnoses WHERE is_chronic = TRUE GROUP BY doctor_id;"}, {"role": "user", "content": "Please filter the results to only include doctors with at least 5 chronic diagnoses."}, {"role": "assistant", "content": "SELECT doctor_id, COUNT(*) AS total_chronic_diagnoses, COUNT(*)::FLOAT / COUNT(DISTINCT patient_id) AS avg_chronic_per_patient FROM healthcare.diagnoses WHERE is_chronic = TRUE GROUP BY doctor_id HAVING COUNT(*) >= 5;"}]}
|
| 105 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "List all medical records created by doctor 'doctor_001' for patients who had their last medical record on or after '2024-01-01', including record_id, patient_id, record_date, chief_complaint, and doctor_id."}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.record_date, mr.chief_complaint, mr.doctor_id\nFROM healthcare.medical_records mr\nJOIN (\n SELECT patient_id, MAX(record_date) AS last_record_date\n FROM healthcare.medical_records\n GROUP BY patient_id\n) last_rec ON mr.patient_id = last_rec.patient_id\nWHERE mr.doctor_id = 'doctor_001' AND last_rec.last_record_date >= '2024-01-01';"}, {"role": "user", "content": "Please refine the results to only include records where the 'assessment' field is not null."}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.record_date, mr.chief_complaint, mr.doctor_id\nFROM healthcare.medical_records mr\nJOIN (\n SELECT patient_id, MAX(record_date) AS last_record_date\n FROM healthcare.medical_records\n GROUP BY patient_id\n) last_rec ON mr.patient_id = last_rec.patient_id\nWHERE mr.doctor_id = 'doctor_001' AND last_rec.last_record_date >= '2024-01-01' AND mr.assessment IS NOT NULL;"}, {"role": "user", "content": "I received too many results. Can you only show records where 'treatment_plan' is also not null?"}, {"role": "assistant", "content": "SELECT mr.record_id, mr.patient_id, mr.record_date, mr.chief_complaint, mr.doctor_id\nFROM healthcare.medical_records mr\nJOIN (\n SELECT patient_id, MAX(record_date) AS last_record_date\n FROM healthcare.medical_records\n GROUP BY patient_id\n) last_rec ON mr.patient_id = last_rec.patient_id\nWHERE mr.doctor_id = 'doctor_001' AND last_rec.last_record_date >= '2024-01-01' AND mr.assessment IS NOT NULL AND mr.treatment_plan IS NOT NULL;"}]}
|
| 106 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.medications ( medication_id text PRIMARY KEY, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\n", "conversations": [{"role": "user", "content": "List the medication IDs and names for all entries where the description is missing or empty."}, {"role": "assistant", "content": "SELECT medication_id, medication_name FROM healthcare.medications WHERE description IS NULL OR description = '';"}, {"role": "user", "content": "For those medications, please also show the manufacturer and sort the results by medication name in ascending order."}, {"role": "assistant", "content": "SELECT medication_id, medication_name, manufacturer FROM healthcare.medications WHERE description IS NULL OR description = '' ORDER BY medication_name ASC;"}]}
|
| 107 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id text, first_name text, last_name text, date_of_birth date, gender text, address text, phone_number text, email text, emergency_contact_name text, emergency_contact_phone text, created_at timestamp, updated_at timestamp )\nCREATE TABLE healthcare.appointments ( appointment_id text, patient_id text, doctor_id text, appointment_time timestamp, duration_minutes integer, reason text, status text, location_id text, notes text, created_at timestamp )\nCREATE TABLE healthcare.medical_records ( record_id text, patient_id text, appointment_id text, doctor_id text, record_date timestamp, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals text, created_at timestamp )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.prescriptions ( prescription_id text, record_id text, patient_id text, doctor_id text, medication_id text, dosage text, frequency text, route text, start_date date, end_date date, quantity_dispensed numeric, refills_allowed integer, prescription_date timestamp )\nCREATE TABLE healthcare.insurance_plans ( plan_id text, plan_name text, insurance_provider text, plan_type text, contact_phone text, website text )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id text, patient_id text, plan_id text, policy_number text, group_number text, subscriber_name text, effective_date date, expiration_date date, is_primary boolean )\n", "conversations": [{"role": "user", "content": "I need to find patients who received prescriptions within 7 days after their latest appointment. Show patient_id, first and last name, appointment_time, prescription_date, and medication_name."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id"}, {"role": "user", "content": "Actually, restrict it to prescriptions where dosage contains 'mg'."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\n AND pr.dosage LIKE '%mg%'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id"}, {"role": "user", "content": "Also, sort the results by prescription_date descending and limit to 5."}, {"role": "assistant", "content": "WITH latest_appt AS (\n SELECT patient_id, MAX(appointment_time) AS latest_time\n FROM healthcare.appointments\n GROUP BY patient_id\n)\nSELECT p.patient_id,\n p.first_name,\n p.last_name,\n la.latest_time AS appointment_time,\n pr.prescription_date,\n m.medication_name\nFROM latest_appt la\nJOIN healthcare.patients p\n ON p.patient_id = la.patient_id\nJOIN healthcare.prescriptions pr\n ON pr.patient_id = la.patient_id\n AND pr.prescription_date BETWEEN la.latest_time AND la.latest_time + INTERVAL '7 days'\n AND pr.dosage LIKE '%mg%'\nJOIN healthcare.medications m\n ON m.medication_id = pr.medication_id\nORDER BY pr.prescription_date DESC\nLIMIT 5"}]}
|
|
|
|
| 247 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.patients ( patient_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, date_of_birth date NOT NULL, gender character varying(10), address text, phone_number character varying(20), email character varying(128) UNIQUE, emergency_contact_name character varying(200), emergency_contact_phone character varying(20), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (patient_id) )\nCREATE TABLE healthcare.doctors ( doctor_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, specialty character varying(100) NOT NULL, license_number character varying(50) UNIQUE NOT NULL, phone_number character varying(20), email character varying(128) UNIQUE, hospital_affiliation_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (doctor_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id character varying(64) NOT NULL, record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, doctor_id character varying(64) NOT NULL, diagnosis_code character varying(20) NOT NULL, code_type character varying(10) NOT NULL DEFAULT 'ICD-10', description text, diagnosis_date date NOT NULL, status character varying(32) NOT NULL, is_chronic boolean DEFAULT false, PRIMARY KEY (diagnosis_id) )\nCREATE TABLE healthcare.medications ( medication_id character varying(64) NOT NULL, medication_name character varying(255) NOT NULL, generic_name character varying(255), manufacturer character varying(100), ndc_code character varying(20) UNIQUE, description text, PRIMARY KEY (medication_id) )\nCREATE TABLE healthcare.insurance_plans ( plan_id character varying(64) NOT NULL, plan_name character varying(200) NOT NULL, insurance_provider character varying(100) NOT NULL, plan_type character varying(50), contact_phone character varying(20), website character varying(255), PRIMARY KEY (plan_id) )\nCREATE TABLE healthcare.patient_insurance ( patient_insurance_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, plan_id character varying(64) NOT NULL, policy_number character varying(100) NOT NULL, group_number character varying(100), subscriber_name character varying(200), effective_date date NOT NULL, expiration_date date, is_primary boolean NOT NULL DEFAULT true, PRIMARY KEY (patient_insurance_id), UNIQUE (patient_id, plan_id, policy_number) )\n", "conversations": [{"role": "user", "content": "Which patients have a primary insurance policy and are subscribed to a plan provided by 'Cigna'? List patient ID, full name, policy number, plan ID, and insurance provider."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna';"}, {"role": "user", "content": "Additionally, only show results where the policy has not expired yet."}, {"role": "assistant", "content": "SELECT p.patient_id, p.first_name, p.last_name, pi.policy_number, pi.plan_id, ip.insurance_provider\nFROM healthcare.patient_insurance pi\nJOIN healthcare.patients p ON pi.patient_id = p.patient_id\nJOIN healthcare.insurance_plans ip ON pi.plan_id = ip.plan_id\nWHERE pi.is_primary = true AND ip.insurance_provider = 'Cigna' AND (pi.expiration_date IS NULL OR pi.expiration_date >= CURRENT_DATE);"}]}
|
| 248 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE legal_services.clients ( client_id text, first_name text, last_name text, company_name text, email text, phone text, address text, date_registered timestamp, status text )\nCREATE TABLE legal_services.lawyers ( lawyer_id text, first_name text, last_name text, bar_number text, firm_id text, email text, phone text, specialization text, hire_date timestamp, is_partner boolean )\nCREATE TABLE legal_services.law_firms ( firm_id text, firm_name text, address text, phone text, website text, founded_date date, managing_partner_id text )\nCREATE TABLE legal_services.documents ( document_id text, case_id text, document_name text, document_type text, storage_path text, uploaded_by_lawyer_id text, upload_timestamp timestamp, version integer, description text )\nCREATE TABLE legal_services.time_entries ( entry_id text, case_id text, lawyer_id text, date_worked date, hours_spent numeric, billing_rate numeric, description text, is_billable boolean, is_billed boolean, invoice_id text, created_at timestamp )\nCREATE TABLE legal_services.appointments ( appointment_id text, client_id text, lawyer_id text, case_id text, start_time timestamp, end_time timestamp, location text, subject text, notes text, status text, created_at timestamp )\n", "conversations": [{"role": "user", "content": "I need a list showing the name of each law firm and the full name of every lawyer employed by that firm."}, {"role": "assistant", "content": "SELECT T1.firm_name, T2.first_name, T2.last_name FROM law_firms AS T1 JOIN lawyers AS T2 ON T1.firm_id = T2.firm_id;"}]}
|
| 249 |
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE financial_services.customers ( customer_id text, first_name text, last_name text, date_of_birth date, ssn_hash text, address text, city text, state text, zip_code text, country text, email text, phone_number text, created_at timestamp, status text, risk_profile text )\n", "conversations": [{"role": "user", "content": "Show me all customers (customer_id, first_name, last_name, email) who were born after 1985 (date_of_birth > '1985-12-31') and have an email address ending with '@yahoo.com', along with their city and state information."}, {"role": "assistant", "content": "SELECT customer_id, first_name, last_name, email, city, state FROM financial_services.customers WHERE date_of_birth > '1985-12-31' AND email LIKE '%@yahoo.com';"}]}
|
| 250 |
+
{"system": "You are an expert in writing database language. You can write a corresponding database language query to answer the user's question based on the table structure described by the table creation statement. \n##Table Structure\nCREATE TABLE healthcare.doctors ( doctor_id character varying(64) NOT NULL, first_name character varying(100) NOT NULL, last_name character varying(100) NOT NULL, specialty character varying(100) NOT NULL, license_number character varying(50) UNIQUE NOT NULL, phone_number character varying(20), email character varying(128) UNIQUE, hospital_affiliation_id character varying(64), created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, updated_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (doctor_id) )\nCREATE TABLE healthcare.medical_records ( record_id character varying(64) NOT NULL, patient_id character varying(64) NOT NULL, appointment_id character varying(64) UNIQUE, doctor_id character varying(64) NOT NULL, record_date timestamp with time zone NOT NULL, chief_complaint text, present_illness_history text, past_medical_history text, physical_examination_notes text, assessment text, treatment_plan text, vitals jsonb, created_at timestamp with time zone NOT NULL DEFAULT current_timestamp, PRIMARY KEY (record_id) )\nCREATE TABLE healthcare.diagnoses ( diagnosis_id text PRIMARY KEY, record_id text, patient_id text, doctor_id text, diagnosis_code text, code_type text, description text, diagnosis_date date, status text, is_chronic boolean )\nCREATE TABLE healthcare.medications ( medication_id text, medication_name text, generic_name text, manufacturer text, ndc_code text, description text )\nCREATE TABLE healthcare.insurance_plans ( plan_id.text, plan_name.text, insurance_provider.text, plan_type.text, contact_phone.text, website.text )\n", "conversations": [{"role": "user", "content": "List each doctor's full name and the total number of medical records they have created."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, COUNT(T2.record_id) FROM healthcare.doctors AS T1 JOIN healthcare.medical_records AS T2 ON T1.doctor_id = T2.doctor_id GROUP BY T1.doctor_id, T1.first_name, T1.last_name;"}, {"role": "user", "content": "Refine the previous request: I only want to see doctors whose specialty is 'Cardiology', and for these doctors, show their record count. Make sure to include Cardiology doctors even if they have created no records."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, COUNT(T2.record_id) FROM healthcare.doctors AS T1 LEFT JOIN healthcare.medical_records AS T2 ON T1.doctor_id = T2.doctor_id WHERE T1.specialty = 'Cardiology' GROUP BY T1.doctor_id, T1.first_name, T1.last_name;"}, {"role": "user", "content": "Sort the results by the record count in descending order."}, {"role": "assistant", "content": "SELECT T1.first_name, T1.last_name, COUNT(T2.record_id) AS record_count FROM healthcare.doctors AS T1 LEFT JOIN healthcare.medical_records AS T2 ON T1.doctor_id = T2.doctor_id WHERE T1.specialty = 'Cardiology' GROUP BY T1.doctor_id, T1.first_name, T1.last_name ORDER BY record_count DESC;"}]}
|