instance_id
stringlengths
11
37
selected_database
stringclasses
22 values
query
stringlengths
36
847
normal_query
stringlengths
41
892
preprocess_sql
listlengths
0
2
clean_up_sqls
listlengths
0
2
sol_sql
listlengths
0
0
external_knowledge
listlengths
0
0
test_cases
listlengths
0
0
category
stringclasses
2 values
high_level
bool
2 classes
conditions
dict
virtual_idol_M_2
virtual_idol
To speed up our dashboard reporting, I want you to create a materialized view named Fan_Segment_Analysis. This view should contain our Fan Segments analysis, categorizing users based on their Fan Financial Value (FFV) and Support Load Score (SLS). After creating the view, please also provide the command to refresh it with the latest data.
Create a materialized view named Fan_Segment_Analysis to pre-calculate and store Fan Segments. The view should categorize all fans into a 2x2 grid based on their relative ranking for Fan Financial Value (FFV) and Support Load Score (SLS). After creation, execute a refresh of the view.
[ "DROP MATERIALIZED VIEW IF EXISTS Fan_Segment_Analysis;" ]
[ "DROP MATERIALIZED VIEW IF EXISTS Fan_Segment_Analysis;" ]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
virtual_idol_M_3
virtual_idol
We need to perform some database maintenance to manage our storage. I want you to create a data archival process for old interactions. First, please ensure a table named interactions_archive exists, with the same structure as the main interactions table. Then, you need to move all interaction records older than three years into this archive table, but only for users who meet two specific conditions: they must have an 'Inactive' Fan Status Tier and they must not be a Premium Member. After successfully copying the data to the archive, you must delete those same records from the original interactions table. This entire process, the copy and the delete, must be performed as a single, atomic transaction to ensure data integrity.
Execute a data archival process within a single transaction. This process must first ensure an interactions_archive table exists. Then, it must copy all interaction records older than three years from fans with an 'Inactive' Fan Status Tier who are not Premium Members into the archive table. Finally, it must delete these same records from the primary interactions table.
[ "DROP TABLE IF EXISTS interactions_archive;" ]
[ "DROP TABLE IF EXISTS interactions_archive;" ]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": false }
virtual_idol_M_5
virtual_idol
I need a way to track daily fan activity stats efficiently. Could you set up a summary table called fan_daily_activity? Then, for the fan 'FAN75581', can you run a process that gathers their total messages, gifts, and gift value for today and either adds it as a new line or just adds to their totals if they're already in there for today?
Create a table fan_daily_activity if one does not exist. Then, perform an Upsert Operation for fan 'FAN75581'. The operation must aggregate their total messages, total gifts, and total gift value for the current date from the interactions table. If a record for this fan and date already exists in fan_daily_activity, the new values should be added to the existing ones; otherwise, a new record should be inserted.
[ "DROP TABLE IF EXISTS fan_daily_activity;" ]
[ "DROP TABLE IF EXISTS fan_daily_activity;" ]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": false }
virtual_idol_M_6
virtual_idol
Let's automate our fan promotions. I want you to create a trigger named `on_spending_update_grant_vip`. This trigger should automatically change a fan's `status_tag` to 'VIP' in their profile as soon as their total spending in the `membershipandspending` table hits or goes over the $10,000 mark. This should work for both new purchases and updates to their spending record.
Create a database trigger named on_spending_update_grant_vip and its associated function check_and_grant_vip_status. This trigger must automatically update a fan's status_tag to 'VIP', according to the Fan Status Tiers definition, whenever an INSERT or UPDATE on the membershipandspending table causes their total spend_usd to meet or exceed $10,000.
[ "DROP TRIGGER IF EXISTS on_spending_update_grant_vip ON membershipandspending;", "DROP FUNCTION IF EXISTS check_and_grant_vip_status();" ]
[ "DROP TRIGGER IF EXISTS on_spending_update_grant_vip ON membershipandspending;", "DROP FUNCTION IF EXISTS check_and_grant_vip_status();" ]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": false }
virtual_idol_M_7
virtual_idol
To standardize how we handle money values, please create a custom Monetary Domain named monetary_value. This domain should be a numeric type that cannot be negative. After creating the domain, create a new table called transaction_log that uses this new domain for its transaction_amount column.
Create a custom Monetary Domain named monetary_value which is a NUMERIC(12, 2) type that must be non-negative. Subsequently, create a new table named transaction_log utilizing this domain for the transaction_amount column.
[ "DROP TABLE IF EXISTS transaction_log;", "DROP DOMAIN IF EXISTS monetary_value;" ]
[ "DROP TABLE IF EXISTS transaction_log;", "DROP DOMAIN IF EXISTS monetary_value;" ]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": false }
virtual_idol_M_8
virtual_idol
I've noticed that queries filtering interactions by both an idol and a platform are running slowly. To improve performance, could you create a Composite Index named idx_interactions_idol_platform on the interactions table? It should cover the columns for the idol pivot and the activity platform.
To improve query performance for analyses related to idol and platform activity, create a Composite Index named idx_interactions_idol_platform on the interactions table. This index should be created on the interact_idol_pivot and act_plat columns.
[ "DROP INDEX IF EXISTS idx_interactions_idol_platform;" ]
[ "DROP INDEX IF EXISTS idx_interactions_idol_platform;" ]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
virtual_idol_M_9
virtual_idol
I need a quick, ad-hoc script to check the health of our top user segment. Can you write a server-side script that calculates the total number of Idol Superfans, then shows me a message with that count and what percentage of our total fans they make up? I don't need a table back, just the notice.
Execute an anonymous procedural block that calculates the total number of Idol Superfans. The block must then raise a server notice containing this count and the calculated percentage of Idol Superfans relative to the total fan population. The script should not return a result set.
[]
[]
[]
[]
[]
Management
true
{ "decimal": 2, "distinct": false, "order": false }
virtual_idol_M_10
virtual_idol
To improve our data quality, please add a Data Integrity Constraint to the loyaltyandachievements table. This constraint, named trust_value_is_a_percentage, must ensure that the trust_val column can only contain numbers between 0 and 100, inclusive.
Add a Data Integrity Constraint named trust_value_is_a_percentage to the loyaltyandachievements table. This constraint must ensure that the trust_val column only accepts values within the inclusive range of 0 to 100.
[ "ALTER TABLE loyaltyandachievements DROP CONSTRAINT IF EXISTS trust_value_is_a_percentage;" ]
[ "ALTER TABLE loyaltyandachievements DROP CONSTRAINT IF EXISTS trust_value_is_a_percentage;" ]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_1
organ_transplant
Let's dig into the files of patients who are getting positive crossmatch results. I need a list of these folks. For each one, show me their ID, their PRA score, and whether they have those donor-specific antibodies. Then, based on our official rules for Antibody-Mediated Rejection (AMR) Risk Stratification, tell me if they're considered 'High Risk'. Oh, and I also want to see the date of the last time we tried to find a match for them. Sort the whole thing so the most sensitized patients are at the top.
I want a report on all recipients with a positive crossmatch test to evaluate their risk profile. For each recipient, display their registry ID, their Panel Reactive Antibody (PRA) score, and their donor-specific antibody (DSA) status. Then, classify their risk according to the formal Antibody-Mediated Rejection (AMR) Risk Stratification rules, labeling them 'High Risk' or 'Standard Risk'. Additionally, for context, please include the timestamp of their most recent prior matching attempt if one exists. Order the results to show recipients with the highest PRA scores at the top.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": true }
organ_transplant_2
organ_transplant
I need the pancreas waiting list, sorted exactly how the official Allocation Policy says we should for all the pending matches. Show me the patient's ID, what region they're in, their exact urgency status, the HLA mismatch number, and their final rank in their local area.
Generate a report for transplant coordinators that follows the formal Allocation Policy for all pending pancreas matches. The report should display the recipient's registry ID, their allocation region, their specific medical urgency, their HLA mismatch count, and their final rank within their region.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": true }
organ_transplant_3
organ_transplant
I want to find the lung transplants that were either insanely expensive for the benefit, or a massive bargain. Could you calculate the Cost-Effectiveness Ratio for all the lung transplants we've finished? For the QALY part of the formula, just use the patient's quality-of-life score and multiply it by 5 years. Then, rank all of them and split the list into 20 groups. I want to see all the details—match, donor, and recipient IDs, and the final cost-effectiveness number rounded to two decimals—for only the absolute worst group and the absolute best group.
I need to identify cost-effectiveness outliers. Please calculate the Cost-Effectiveness Ratio (CER) for all 'Completed' lung transplants, assuming a Quality-Adjusted Life Year (QALY) gain of 5 years multiplied by the recipient's quality of life score. Then, using the `NTILE` window function, divide the results into 20 buckets. Display the full details (match ID, donor ID, recipient ID, and the final CER rounded to 2 decimal places) for all transplants that fall into the top and bottom buckets.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 2, "distinct": false, "order": true }
organ_transplant_4
organ_transplant
Let's see how often we find a perfect match within and between different ethnic groups. First, you need to identify every single Optimal Donor-Recipient Match we have. Once you have that list of perfect pairs, I want a table that shows the donor's ethnicity down the side and the recipient's ethnicity across the top, with the cells showing the count of how many times each combination happened.
I want a detailed ethnic compatibility report for all pairings that qualify as an Optimal Donor-Recipient Match. For every such optimal match found, create a cross-tabulation showing the count of matches, with the donor's ethnicity as rows and the recipient's ethnicity as columns.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": true }
organ_transplant_6
organ_transplant
Let's check our CMV exposure risk. I want a list of all current and completed transplants where a CMV-positive donor gave an organ to a CMV-negative patient. For each of these risky cases, show me the match ID and the transplant center. I also want to see the patient's Infection Risk score from their chart and, right next to it, the average infection risk—rounded to four decimals—for all the non-mismatched transplants done at that same hospital. I want to see if the scores reflect the risk. Please order the results by the hospital's ID.
I need to perform a viral mismatch risk analysis for all completed and in-progress transplants. Please produce a report that identifies every donor-recipient pair with a Cytomegalovirus (CMV) mismatch, defined as a CMV-positive donor matched with a CMV-negative recipient. For each identified mismatch, display the match registry ID, the center where the transplant occurred, the pre-calculated Infection Risk, and compare this to the average Infection Risk (rounded to 4 decimal places) for all other transplants at that same center that did not have a CMV mismatch. The final report should be ordered by center ID.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 4, "distinct": false, "order": true }
organ_transplant_7
organ_transplant
I need a list of our absolute sickest patients—the ones on ECMO or a VAD. For each of these patients, show me their ID and what kind of life support they're on. Then, calculate their full Patient Urgency Score. The crucial part is, I want to see their score next to the average score for all the other, more stable patients who are waiting for the same organ, with both scores rounded to four decimals. Let's see how big the gap is. Group the list by organ, and show the sickest patients first within each group.
I need to assess the urgency of recipients currently on advanced life support. Please identify all pending recipients who are on 'ECMO' or 'VAD' life support. For each of these critical recipients, display their registry ID, the specific life support method, their calculated Patient Urgency Score, and compare this score to the average urgency score of other patients waiting for the same organ who are not on life support. Both scores should be rounded to 4 decimal places. Order the results by organ type, then by the critical patient's urgency score.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 4, "distinct": false, "order": true }
organ_transplant_8
organ_transplant
I'm wondering if how we ship organs really makes a difference. Can you run some numbers for me? Let's look at all our finished transplants. Group them by how the organ was transported—you know, ground, helicopter, commercial air, all that. For each of those transport types, I want to see the average Total Ischemia Time rounded to two decimals, and the average Expected Graft Survival Score rounded to four decimals. Sort the results so I can see which transport methods are linked with the best outcomes.
I need a report on the impact of ischemia time on expected graft survival, broken down by the transportation method used. For every completed transplant, determine the Total Ischemia Time and retrieve the Expected Graft Survival (EGS) Score. Group the results by the `trans_method` from the logistics table, and for each method, calculate the average Total Ischemia Time (rounded to 2 decimal places) and the average EGS Score (rounded to 4 decimal places). The report should be sorted by the average EGS Score from highest to lowest.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 4, "distinct": false, "order": true }
organ_transplant_9
organ_transplant
I want to know what the most common health problems our patients have and if those problems make surgery riskier. Can you go through all the patient files, break apart their list of health conditions, and find the top 5 most common ones? Then, for each of those top 5, figure out the average Surgical Risk Score for all patients who have that specific condition. I want to see the condition, how many people have it, and what the average risk score is, rounded to four decimals.
I need to analyze the prevalence of comorbidities and their impact on surgical risk. First, analyze each individual condition listed for all recipients. Then, identify the top 5 most frequently occurring comorbidities across all patients. Finally, for each of these top 5 conditions, calculate the average Surgical Risk Score for the patients who have that comorbidity. Display the comorbidity, its total count, and the calculated average risk score rounded to 4 decimal places.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 4, "distinct": false, "order": true }
organ_transplant_10
organ_transplant
I need to see who's been stuck on our waiting list the longest. Can you pull a special report for me? For each organ, find the 2% of patients who have been waiting longer than everyone else. For this group, I want to see everything that might be making them hard to match: their patient ID, the organ they need, how many days they've been waiting, their PRA score, and a tally of their other health problems. Please group the list by organ and put the longest-waiting patients at the top of each group.
Please generate a profile of our longest-waiting patients. For each organ type, identify the top 2% of pending recipients with the longest wait times using the `PERCENT_RANK` window function. For this elite cohort of long-waiters, display their registry ID, organ type, wait time in days, their Panel Reactive Antibody (PRA) score to assess Immunological Sensitization, and a count of their listed comorbidities. Order the results by organ type and then by wait time descending.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": true }
organ_transplant_11
organ_transplant
I need to find out which of our hospitals are doing the heaviest lifting. I'm talking about the ones that take on the toughest cases, both in terms of travel and patient health. Can you create a ranking? For each hospital, come up with a 'Logistical Challenge Score' based on average distance and organ-on-ice time, and a 'Medical Complexity Score' based on average surgical risk and how many other illnesses the patients have. Then, average those two scores together to get a final 'Workhorse Score'. I just want to see the top 10 hospitals based on that final score, rounded to four decimals.
I want to identify our 'workhorse' transplant centers, defined as those that handle a high volume of logistically and medically complex cases. For each center, calculate a 'Logistical Challenge Score' (average distance * 0.4 + average expected ischemia time * 0.6) and a 'Medical Complexity Score' (average surgical risk * 0.7 + average number of recipient comorbidities * 0.3). Then, combine these into a final 'Workhorse Score' (Logistical Score * 0.5 + Medical Score * 0.5). Display the top 10 centers ranked by this final score, rounded to 4 decimal places.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 4, "distinct": false, "order": true }
organ_transplant_13
organ_transplant
I want to know if our fancy Decision Support System is actually helping us pick better matches. Can you check if its score lines up with the EGS score? Please take all our completed transplants and divide them into 5 groups based on their DSS score. For each of these 5 buckets, tell me how many transplants are in it and what their average Expected Graft Survival Score is, rounded to four decimals. I want to see if the average EGS score goes up as the DSS score bucket goes up.
I need to analyze if our Decision Support System score is aligned with our primary success metric, the Expected Graft Survival score. Using the `WIDTH_BUCKET` function, group all completed transplants into 5 equal buckets based on their Decision Support System score, from the minimum to the maximum score in the dataset. For each bucket, calculate the number of transplants and the average Expected Graft Survival Score, rounded to 4 decimal places. This will show if a higher DSS score correlates with a higher predicted graft survival.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 4, "distinct": false, "order": true }
organ_transplant_14
organ_transplant
I'm curious if some hospitals are more willing to take a chance on a less-than-perfect genetic match. For every transplant center that has performed at least two transplants, can you calculate their average HLA Mismatch Score? Also, for each of those centers, figure out the standard deviation so we can see if their mismatch numbers are all over the place or pretty consistent. Then, just show me the top 10 from that group with the highest average mismatch scores. I'll need to see their total number of transplants, that average mismatch score rounded to four decimals, and the standard deviation, also rounded to four decimals.
I want to identify transplant centers that may have a higher tolerance for immunological risk. Please calculate the average HLA Mismatch Score for all completed transplants at each unique transplant center that has performed two or more transplants. Concurrently, calculate the standard deviation of the mismatch scores for each center to understand the variability in their matches. Display the top 10 centers with the highest average mismatch scores, along with their transplant volume, the average mismatch rounded to 4 decimal places, and the standard deviation rounded to 4 decimal places.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 4, "distinct": false, "order": true }
organ_transplant_16
organ_transplant
I need to see the trade-offs we're making with our less-than-perfect donor organs. Can you pull a list of all matches that fall under our Marginal Donor Acceptance Criteria? That means either the age gap is huge—more than 25 years—or their kidney score is poor, say under 40. For each of those matches, show me the donor and patient IDs, tell me exactly why we're calling the donor 'marginal', and then calculate the patient's standard Patient Urgency Score so I can see just how desperate they are. Round the score to four decimals. Sort it so the most urgent patients are at the top.
Generate a risk-benefit report for transplants using organs from Marginal Donors. First, identify all donors who meet the Marginal Donor Acceptance Criteria, defined as having an age difference greater than 25 years with the recipient OR a Renal Function Score below 40. For each of these marginal donor matches, list the donor ID, the recipient ID, the specific marginal criterion met ('Age Difference' or 'Low Renal Score'), and then calculate the standard Patient Urgency Score for the recipient to assess the necessity of using the marginal organ. The final score should be rounded to 4 decimal places. Sort the results by the calculated urgency score in descending order.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 4, "distinct": false, "order": false }
organ_transplant_17
organ_transplant
I want to figure out which transport method is the most efficient at getting organs delivered quickly relative to the distance they have to travel. Can you come up with a 'Logistical Efficiency Ratio' for every completed transplant? Just divide the total time the organ was on ice by the distance it traveled. Then, for each transport type—ground, air, etc.—I want to see the average, best, and worst efficiency ratio, all rounded to four decimals. Ignore any really short trips, say under 10km. Sort the list by the average efficiency.
I need to analyze the logistical efficiency of different transport methods. For each completed transplant, calculate a 'Logistical Efficiency Ratio', defined as the Total Ischemia Time in minutes divided by the geographic distance in kilometers. A lower ratio indicates better efficiency. Then, for each `trans_method`, calculate the average, minimum, and maximum efficiency ratio, all rounded to 4 decimal places. The report should exclude any trips under 10km as outliers and be sorted by the average efficiency.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 4, "distinct": false, "order": true }
organ_transplant_18
organ_transplant
I want to see how our patients are doing based on how hard they were to match immunologically. Can you sort all the patients who've received a transplant into four groups based on their PRA score? Let's do 'Low' for 0-10, 'Moderate' for 11-79, 'High' for 80-95, and 'Very High' for 96 and up. For each of these four groups, I want to see the total number of patients, the average HLA mismatch they ended up with rounded to two decimals, how long they had to wait on average to the nearest day, and what their average EGS score was, rounded to four decimals.
I need a comprehensive profile of patient outcomes across different levels of Immunological Sensitization. Group all recipients of completed transplants into four Panel Reactive Antibody (PRA) score buckets: 'Low' (0-10), 'Moderate' (11-79), 'High' (80-95), and 'Very High' (96-100). For each bucket, calculate the total number of transplants, the average HLA Mismatch Score of their match (rounded to 2 decimal places), their average wait time in days (rounded to the nearest whole day), and the average Expected Graft Survival (EGS) score (rounded to 4 decimal places) for their transplant.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 4, "distinct": false, "order": true }
organ_transplant_19
organ_transplant
I'm curious about where our single HLA mismatches are happening. Are they usually on the A, the B, or the DR? Can you look at all our completed transplants that had exactly one mismatch? For that group, I want you to figure out which specific HLA type was the one that didn't match. Then, just give me a count: how many were mismatched at 'A', how many at 'B', and how many at 'DR'.
I want to analyze potential HLA mismatch patterns. For all completed matches that have exactly one HLA mismatch, I need to determine on which specific locus (A, B, or DR) the mismatch occurred. Please produce a report that counts the number of mismatches that occurred on the 'A-locus', 'B-locus', and 'DR-locus'.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_20
organ_transplant
I want to create a map of where we're struggling the most to find organs. Can you calculate a 'demand versus supply ratio' for each region and for each blood type, including the +/-? To get 'demand', just count the number of patients waiting in a region for a certain blood type. For 'supply', count all the donors we've ever had from that region with that blood type. Show me a table with the region, the blood type, the number of patients, the number of donors, and the final ratio rounded to four decimals. Put the biggest problem spots at the top.
I need to find geographic and blood type scarcity hotspots. For each allocation region and for each main blood type (A, B, AB, O, and their Rh variations), calculate a 'Demand-to-Supply Ratio'. 'Demand' is the number of pending recipients of that blood type in that region. 'Supply' is the total number of unique donors of that blood type from that region available in the entire dataset. Display the region, blood type, demand count, supply count, and the final ratio rounded to 4 decimal places, sorted to show the highest scarcity ratios first.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 4, "distinct": false, "order": true }
organ_transplant_21
organ_transplant
I need to know if we're getting less bang for our buck on the really urgent transplants. Can you run a cost-effectiveness analysis for me? For every completed transplant, figure out the CER. Let's just assume the quality-adjusted life year gain is 8 years times whatever their quality-of-life score is. Then, I want you to group the results by the patient's medical urgency status. Show me the average CER, rounded to two decimal places, for the Status 1A patients, the Status 1B patients, and so on. Keep them in order of urgency.
I want to find out if transplanting sicker patients is less cost-effective. Calculate the Cost-Effectiveness Ratio (CER) for every completed transplant where cost and quality-of-life data are available. For the QALY gain, use a standard of 8 years multiplied by the patient's quality of life score. Then, group these transplants by the recipient's Medical Urgency Status tier ('Status 1A', 'Status 1B', 'Status 2', etc.) and calculate the average CER for each tier, rounded to 2 decimal places. The results should be ordered by urgency.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 2, "distinct": false, "order": true }
organ_transplant_22
organ_transplant
I'm worried some of our hospitals might be having a rough patch. I want to look for streaks of failed matches. Can you go through the data for each transplant center and find every time they had two or more failed matches in a row, based on when the match was created? I want a list that shows the hospital ID, the ID of the match that continued the streak, and the time it happened. Just show me the second failure in any given streak.
I need a report on consecutive match failures at our transplant centers to identify potential systemic issues. For each transplant center, find every instance where at least two consecutive matches (ordered by creation time) both had a final status of 'Failed'. The report should list the center ID, the registry ID of the second failed match in the sequence, and the timestamp of that failure. Only show the start of sequences of 2 or more failures.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": true }
organ_transplant_M_1
organ_transplant
We keep calculating the Size Compatibility Score over and over. Can we just build a tool for it? I want a function, let's call it `calculate_size_compatibility`, where I can just plug in a donor's ID and a recipient's ID, and it spits out the score. It needs to find the BMI for both the donor and the recipient and then do the math. If it can't find the BMI for either one, it should just return nothing instead of crashing.
Create a reusable PostgreSQL function named `calculate_size_compatibility` that computes the Size Compatibility Score. This function must accept a donor's registry ID and a recipient's registry ID as text inputs. It should retrieve the Body Mass Index for both the donor and the recipient, then apply the standard formula for the Size Compatibility Score. The function must be robust and return NULL if the BMI for either individual is missing or zero to prevent division errors.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_M_2
organ_transplant
Finding a perfect organ match is like looking for a needle in a haystack, and I want a special list that only shows these golden tickets. Can you build a 'live' list, let's call it `v_optimal_matches`, that shows every single donor-recipient pair that qualifies as an Optimal Donor-Recipient Match? I want this list to update itself without locking everything up every time we get a new patient registered in the system.
I need a system to continuously identify every potential match that qualifies as an Optimal Donor-Recipient Match. First, create a materialized view named `v_optimal_matches` that contains the donor and recipient registry IDs for every such pair. Second, create a trigger named `trg_refresh_optimal_matches` that automatically executes a procedure to refresh this materialized view concurrently whenever a new recipient is inserted into the `recipients_demographics` table.
[]
[]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_M_3
organ_transplant
I want to be able to check a donor's kidney health easily. Can you create a function called `get_donor_renal_score` that takes a donor's ID? It should do the math for the Renal Function Score automatically. For the final score, use a weighting of 0.8 for the eGFR part and 0.2 for the creatinine part. I just need it to spit out the single score.
Create a PostgreSQL function called `get_donor_renal_score` that accepts a donor's registry ID as a TEXT input. This function should calculate the donor's Renal Function Score, using weights of 0.8 for the internal eGFR calculation and 0.2 for serum creatinine, and return it as a REAL value.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_M_4
organ_transplant
Let's create a special watchlist for all of our High-Risk Donors so we can track them easily. Can you build a materialized view for this? Call it `v_high_risk_donors`. It should automatically pull in any donor who meets the official definition of high-risk. For each donor on this list, I want to see their ID, their age, and a note on which specific risk factor got them on the list.
I need a dedicated, up-to-date list of all donors who are classified as a High-Risk Donor based on the established criteria. Please create a materialized view named `v_high_risk_donors`. The view should list the donor's registry ID, their age, and the specific high-risk factor that was identified.
[]
[]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_M_5
organ_transplant
We need to keep track whenever a patient's life support status actually changes. Can you set up a log for that? First, make a new table called `life_support_audit` that can store a log entry number, the patient's ID, what the status was before and after the change, and when it happened. Then, create a trigger called `trg_audit_life_support_changes` that automatically adds a new line to this log only if the life support value is modified to something new.
I need an audit trail for changes to a recipient's life support status. Please create a new table called `life_support_audit` with columns for `audit_id`, `recipient_id`, `old_status`, `new_status`, and `change_timestamp`. Then, create a trigger named `trg_audit_life_support_changes` that fires after an update on the `recipients_immunology` table, inserting a new record into the audit table only when the `life_support` value actually changes.
[]
[]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_M_6
organ_transplant
I want a new summary table that tracks how well our transplant centers are doing. Let's call it `transplant_center_performance`. It should show the center's ID, a count of all the transplants they've done, their average EGS score, and a final Center Performance Score. Once the table is made, fill it up by calculating the score for every center. For the score, let's say the number of surgeries they do is the most important part, maybe 70%, and their average graft survival outcome is the other 30%.
Create a new table named `transplant_center_performance` to store analytical data. This table should have columns for the center's identification code, the total number of transplants performed, the average Expected Graft Survival (EGS) score for that center, and a calculated Center Performance Score. After creating the table, populate it by analyzing all relevant transplant records. The Center Performance Score should be calculated with a 70% weight on the center's total transplant volume and a 30% weight on its average EGS score.
[]
[]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_M_7
organ_transplant
I want a list of all the donors who died from Anoxia. Let's make a view for it called `v_anoxia_donor_profile`. Just show me the donor's ID, their age, and their kidney numbers—the creatinine and GFR values. This will help us quickly see if the organs are any good.
Create a view named `v_anoxia_donor_profile` to help assess organ quality for a specific subset of donors. The view should list all donors whose cause of death is recorded as 'Anoxia'. For each such donor, display their registry ID, age, and their key kidney function indicators: serum creatinine and glomerular filtration rate.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_M_8
organ_transplant
We need to track every time a patient's urgency level actually changes. Can you set up an audit trail for that? First, make a table called `urgency_status_log` to store the history—it needs a log number, the patient ID, the date it happened, and what the status changed from and to. Then, build a trigger called `trg_log_urgency_status_change`. It should watch the clinical table and automatically add a new line to our log only when the medical urgency value for a patient is modified.
Create a system for logging changes to a patient's Medical Urgency Status. First, create a new table called `urgency_status_log` with columns to track the log ID, the recipient's registry ID, the date of the change, the old status, and the new status. Second, create a trigger named `trg_log_urgency_status_change` that executes after an update on the `clinical` table. The trigger should fire only if the `med_urgency` column is modified, and it must insert a new record into the log table with the relevant details.
[]
[]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_M_9
organ_transplant
We need to standardize how we calculate our main ranking score. Can you build a function called `calculate_composite_allocation_score` that does all the work? I want to just give it a match ID. It should then go and figure out all the component scores and combine them using the standard Composite Allocation Score formula, and just return the one final number.
Create a reusable function named `calculate_composite_allocation_score` that takes a match ID as input. This function must internally calculate and combine the Patient Urgency Score, Immunological Compatibility Score, and Expected Graft Survival (EGS) Score using the standard Composite Allocation Score formula. The function must return the final calculated score as a single REAL value.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_M_10
organ_transplant
Let's make our center performance stats update in real-time. First, make a simple summary table, call it `center_performance_live`, just to hold the center's ID, a running count of their transplants, and their average EGS score. Then, the magic part: build a trigger called `trg_update_center_performance`. Whenever a match is officially marked as 'Completed', this trigger should automatically update that center's numbers in our new summary table. It needs to be smart enough to add the center if it's their first completed transplant.
I want to automate the updates to our center performance metrics. First, create a summary table called `center_performance_live` with columns for center ID, total transplants, and the running average for their Expected Graft Survival (EGS) Score. Then, create a trigger named `trg_update_center_performance` that fires after an update on `transplant_matching`. When a `match_status` changes to 'Completed', the trigger must find the corresponding transplant center and update its `total_transplants` and `avg_egs_score` in the summary table. If the center isn't in the table yet, it should be inserted.
[]
[]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_M_11
organ_transplant
I need a dedicated, ranked list of all the kids waiting for a heart. Can you create a view called `v_pediatric_heart_candidates`? It should only include patients under 18. The ranking is critical: the sickest kids—Status 1A—go first. If kids have the same urgency status, the one with the higher Recipient Wait Time Ratio should get priority. I need the view to show the kid's ID, their age, their urgency level, and their calculated wait time ratio.
Create a specialized view named `v_pediatric_heart_candidates`. This view should produce a prioritized list of all recipients under the age of 18 who are waiting for a heart transplant. The list should be ordered first by their Medical Urgency Status (Status 1A being highest), and then by their Recipient Wait Time Ratio in descending order for recipients with the same urgency status. The view should display the recipient's ID, age, medical urgency, and the calculated wait time ratio.
[]
[]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": false, "order": true }
organ_transplant_M_12
organ_transplant
We need to prevent silly mistakes in our data entry. People don't get younger. Can you build a trigger called `trg_validate_recipient_age`? It should watch the recipient demographics table. If anyone ever tries to update a patient's age to a number that's lower than what it was before, the trigger must just ignore the change and keep the old age.
To ensure data integrity, create a trigger that prevents illogical updates to a recipient's age. The trigger, named `trg_validate_recipient_age`, should activate before any update on the `recipients_demographics` table. It must check if the new `age_count` is less than the old `age_count`. If a user attempts to decrease a recipient's age, the trigger should silently prevent the change by reverting the age to its original value.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
organ_transplant_M_13
organ_transplant
I need a quick way to pull up all the main risk numbers for a specific transplant match. Can you make a function called `get_match_risk_profile` that takes a match ID? It should just go into the risk data and pull out the five important scores—Immunological, Infection, Rejection, Readmission, and Mortality—and then give them back to me as a single JSON object.
Please create a function that provides a holistic risk profile for a given transplant match. The function, named `get_match_risk_profile`, must accept a match ID. It should retrieve and return a single JSONB object containing the five key risk metrics: Immunological Risk, Infection Risk, Rejection Risk, Readmission Risk, and Mortality Risk.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
mental_health_1
mental_health
Let's find our most vulnerable patients: those who are high-risk, in facilities under severe stress, and who are also not engaging well with their therapy. I need a list with their patient ID, assessment ID, the date of their latest assessment, their average rounded engagement score, and the stress level of their facility. Please sort by the most recent assessment and just show the top 50.
I want to identify High-Risk Patients from facilities experiencing Severe Environmental Stress or Severe Life Impact, who also exhibit low Therapy Engagement Scores (average TES is lower than 2). For each patient, include their patient ID, assessment ID, date of their most recent assessment, their average rounded TES score, and the environmental stress or life impact level of the facility they are associated with. Focus only on the most recent assessments and prioritize patients meeting all these criteria. Sort the results by the assessment date in descending order and limit to the top 50 results.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": true }
mental_health_2
mental_health
Can you help me check how closely a facility's resources relate to how well patients stick to their treatment? I'd like to see the overall resource adequacy score across all facilities and the correlation between each facility's resource score and their treatment adherence rate. Just skip the places where there's no rate for the treatment adherence.
For all facilities, I want to explore the Correlation Between Resource Adequacy and Adherence. Include the overall Facility Resource Adequacy Index as a reference and the correlation coefficient between each facility's resource adequacy score and treatment adherence rate. Exclude facilities with no applicable TAR.
[]
[]
[]
[]
[]
Query
false
{ "decimal": -1, "distinct": false, "order": false }
mental_health_3
mental_health
Show me facilities where patients seem highly engaged in therapy, but their recovery progress is still lagging basically, places with a possible engagement-outcome disconnect. For each of those facilities, I want to see the Facility ID, their average therapy engagement score, and their index of recovery trajectory, both rounded to two decimal places. Sort the list by Facility ID and keep it to the first 100 results.
Identify facilities classified as having a Facility with Potential Engagement-Outcome Disconnect. Display the facility ID, the average TES, and the RTI for these facilities. Round both TES and RTI to 2 decimal places, sort by facility ID, and limit the output to 100 rows.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": true }
mental_health_4
mental_health
Can you show me the top clinicians working in well-supported facilities based on the stability metric of the patients? I want to see each clinician's ID, which facility they work at, their Patient Stability Metric score, and how they rank within their facility (higher PSM means better rank). Just include those in resource-backed facilities, sort by facility and rank, and show only the top 100 results.
I want to identify the top-performing clinicians in Resource-Supported Facilities based on their Patient Stability Metric. For each clinician, provide their ID, the facility ID, their PSM score, and their rank within the facility. The rank should be based on PSM, with higher PSM scores ranked higher. Only include clinicians from facilities classified as Resource-Supported Facilities. Sort the results by facility ID and then by rank within each facility, limiting the output to the top 100 rows.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 2, "distinct": false, "order": true }
mental_health_5
mental_health
Can you show me the patients who seem to have fragile stability? I want to see their ID, how often they miss appointments on average, and what their latest effectiveness score of social support.
I want to find patients who are exhibiting fragile stability. List each patients ID, their average missed appointments, and their most recent SSE score.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": true, "order": false }
mental_health_6
mental_health
Show me the top 100 primary diagnoses where patients have the highest number of crisis interventions. For each diagnosis, include the name of the diagnosis, how many patients had that diagnosis, and the average crisis intervention frequency, rounded to two decimal places. Sort the list by CIF from highest to lowest.
I want to identify which primary diagnoses are associated with the highest Crisis Intervention Frequency (CIF) across all patients. For each diagnosis, list the diagnosis name, the number of patients with that diagnosis, and the CIF value, rounded to two decimal places. Sort the results by CIF in descending order and limit to the top 100 diagnoses.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 2, "distinct": true, "order": true }
mental_health_7
mental_health
Show me the top 100 facilities, grouped into performance quadrants. For each one, list its ID, how well patients stick to their treatments (rate of treatment adherence), how stable the patients are, both rounded to two decimals, and which performance quadrant it falls into. Sort the results by quadrant and then by facility ID.
I want to categorize facilities into performance quadrants. For each facility, list the facility ID, Treatment Adherence Rate (rounded to two decimal places), Patient Stability Metric (rounded to two decimal places), and the performance quadrant. Sort results by performance quadrant and facility ID, limiting to the top 100 facilities.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 2, "distinct": false, "order": true }
mental_health_8
mental_health
I want to see how different kinds of therapy changes—like switching therapy type, therapist, or session frequency—affect how engaged patients are. For each type of change, show how often it happens, what the average engagement score was before and after the change, and how much the score changed overall. Sort the results so that the most common changes appear at the top.
Analyze the impact of therapy changes (modality, therapist, frequency) on the Therapy Engagement Score and calculate the engagement variation for each change type. Show the change type, total occurrences, average scores before (previous encounter of each encounter) and after (current encounter), and average score change from previous score to current score, ordering by total occurrences in descending order.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": true }
mental_health_9
mental_health
Show me the top 100 facilities where suicide risk is very high—over 20%. For each one, list the facility ID, their PFIS score, FRAI score, and the difference in resource demand, sorted from the highest RDD to the lowest. I want to find places where the need for resources is most urgent.
For facilities with high Suicide Risk Prevalence over 20%, calculate the Resource-Demand Differential. List the facility ID, PFIS, FRAI, and RDD scores, ordered by RDD from highest to lowest, showing the top 100 facilities. This helps identify resource gaps in critical environments.
[]
[]
[]
[]
[]
Query
false
{ "decimal": -1, "distinct": false, "order": true }
mental_health_10
mental_health
Find facilities that seem to have an environment that are systemically stressed. For each one, list the facility ID and the differential in resource demand. Just show the top 100 most stressed facilities.
Identify facilities exhibiting characteristics of a Systemically Stressed Facility Environment. For each facility, return its ID and Resource-Demand Differential value, limited to the top 100 facilities.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": true }
mental_health_11
mental_health
Hey, can you pull together a report that shows how care might vary between different ethnic groups? For each patient, I want to see their ethnicity, how severe their symptoms are, and how well they're sticking with their treatment. Also, please include a summary row that combines all ethnicities, so we have a baseline to compare against. And make sure the results are sorted by ethnicity alphabetically. Thanks!
To support our health equity audit, I need a report that assesses potential care disparities across different ethnic groups. Please generate a table showing each patient's ethnicity, their calculated Symptom Severity Index, and their Engagement-Adherence Score. The report must also include a summary row for 'All Ethnicities' to serve as a baseline. Please sort the results alphabetically by patient ethnicity.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": true }
mental_health_12
mental_health
Sarah, our lead case manager, is worried about a pattern she's calling 'the David profile.' These are patients who are constantly in crisis—we're talking about patients that has a low support profile and in high crisis. She wants to find every other patient who looks just like that right now. Can you pull a list for her? She needs to see their ID and age, plus the exact crisis and support scores that got them on the list. For her team to take action, please also show the date they were last in the hospital and their next appointment, but make that appointment date easy to read. And please, put the people with the most crises at the very top so she knows who to call first.
For our weekly clinical review, Sarah needs to generate a Vulnerable Patient Watchlist to proactively identify a specific cohort. The focus is on individuals who fit the Patient with High Crisis & Low Support Profile. To make this list actionable for the meeting, please display each unique patient's identifier, their age, the total count of their crisis interventions, and their calculated Social Support Effectiveness score. For additional context on their recent trajectory and our next point of contact, also include the date of their last hospitalization and format the date of their next scheduled appointment as 'Mon DD, YYYY'.Finally, please sort the list with the patients having the highest number of crisis interventions at the top to prioritize our discussion.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": true, "order": true }
mental_health_13
mental_health
Our director, Dr. Evans, is trying to get more funding for community partnerships, and his whole argument hinges on one idea: that facilities with better resources have patients who are more likely to stick to their treatment plans. He needs a solid number to prove this point. Can you run a statistical analysis to see how strong that connection really is? Basically, do a correlation analysis of the resource's adequacy. Just give me the final correlation score, nice and clean, as a single number.
For a budget proposal, our regional director, Dr. Evans, needs to validate a key hypothesis: that better facility resources improve patient outcomes. He wants to test this by measuring the Correlation Between Resource Adequacy and Adherence. Please calculate this correlation. The final output should be a single numerical value representing this correlation, rounded to four decimal places.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 4, "distinct": false, "order": false }
mental_health_14
mental_health
Our Director, Dr. Sharma, needs help. We have a lot more patients coming in who are in a really bad place—severely depressed or anxious and also at high risk for suicide. She wants to build a list of our 'go-to' experts for these tough cases. Can you figure out, for each diagnosis like 'Depression', 'Anxiety', etc, which of our clinicians has the most hands-on experience with this exact type of high-risk patient? I need a table that shows the diagnosis, the clinician, how many of these patients they have, and then ranks them, so we can see who is number 1, 2, 3 for each category. Please organize the whole thing by diagnosis, then by the rank.
To address a surge in complex cases, the Director of Clinical Services is creating an expert consultation roster. The goal is to identify clinicians with the most experience managing the High Severity, High Risk Patient Group. Please generate a report that, for each primary diagnosis, ranks clinicians based on the number of these specific high-risk patients they manage. The output table should include the primary diagnosis, the clinician's identifier, the count of these high-risk patients for that clinician, and their resulting rank within that diagnosis category. The final roster should be sorted first by the primary diagnosis and then by the clinician's rank to clearly present the top experts for each specialty.
[]
[]
[]
[]
[]
Query
false
{ "decimal": -1, "distinct": false, "order": true }
mental_health_15
mental_health
I'm looking at Patient P871358's file and I'm a bit concerned. He's been diagnosed with Bipolar for about 10 years and has already been in the hospital 3 times. I need to know if we should escalate his care. So, first, can you run that calculation of the patient's risk for annualized hospitalization and tell me if he gets flagged for a immediate coordination of intensive care? If he does, I need to find him a new clinician right away. The new clinician would need to be at the same facility he last visited, be one of our 'High' confidence therapists, and not have their credentials up for review in the next six months or so let's say any time after June 2024. If he's flagged, show me their IDs and where they work. If his risk score is fine, just let me know by reporting as 'Patient does not meet criteria for Intensive Care Coordination'.
I'm assessing Patient 'P871358' and need to determine if an Intensive Care Coordination Flag should be raised. First, please calculate his Annualized Hospitalization Risk, then flag it if the criteria is met. If and only if the patient is flagged, I need a list of suitable clinicians for referral. A suitable clinician must be located at the same facility as the patient's most recent encounter, have a 'High' confidence level, and have a next credential review date after June 1st, 2024. Please return the clinician's identifier and their facility. If the patient is not flagged, just report as 'Patient does not meet criteria for Intensive Care Coordination'
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": false }
mental_health_16
mental_health
I'm doing a review on patient P883117 and need to check a couple of things for her file. First, she's supposed to be getting at least 5 hours of therapy a month in her program. Can you check her latest therapy exp intensity and tell me if she's meeting that target? Second, her insurance gives her $1,200 a year for treatment. Based on her personal cost-effectiveness rate of 0.0509, what's her total expected quality of life gain for the whole year? And finally, is that number over our 'good value' threshold of 50 points? Just give me a quick summary for all the assessment for this patient, including the patient's id, and the answers to those three questions.
I need to perform a case audit for patient 'P883117'. The patient is in a program requiring a minimum therapy intensity of 5 hours per month. Their annual insurance budget for treatment is $1,200, and their current recorded treatment cost-effectiveness is 0.0509 QoL-points per dollar. Please provide a report that answers the following: A boolean value indicating if the patient's current therapy_exp_intensity meets the 5 hours/month target. The calculated Projected Annual QoL Gain, based on their cost-effectiveness rate and the $1,200 budget. A boolean value indicating if this projected gain is greater than 50 points. The output show for all the assessment for this patient with columns for their identifier and these three calculated results.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": false }
mental_health_17
mental_health
I need to run a full audit on patient P425079. His insurance gives him $6,000 a year for treatment, but we charge in pounds—£100 an hour. Assuming an exchange rate of 1.25 dollars to the pound, how many hours of therapy can he actually get for his money? Also, his high-acuity plan says he needs 30 hours of therapy a month, but his chart says he's only getting 29.86. Can you confirm if he's meeting that target? Lastly, given his personal cost-effectiveness rate of 0.1197, what's his total potential quality of life gain if he uses his whole $6,000 budget? And is that number over our 'good value' benchmark of 650?
I am conducting a detailed audit for patient 'P425079'. His insurance plan has a maximum out-of-pocket cost of $6,000 USD per year. Our clinic's therapy rate is £100 GBP per hour, with the current exchange rate at 1.25 USD per GBP. The patient's therapy plan requires a minimum intensity of 30 hours/month, and his last recorded intensity was 29.86 hours/month. His cost-effectiveness rate is 0.1197 QoL-points/dollar. Please provide a report with four calculated fields: The total number of therapy hours his annual budget can afford, rounded to 2 decimal places. A boolean value indicating if his current therapy intensity meets the 30-hour monthly target. The Projected QoL Gain from Max Out-of-Pocket rounded to 2 decimal, using his cost-effectiveness rate and the $6,000 budget. A boolean value indicating if this projected gain exceeds the 'clinically valuable' threshold of 650 points.
[]
[]
[]
[]
[]
Query
true
{ "decimal": 2, "distinct": false, "order": false }
mental_health_18
mental_health
I'm working on a study and need to find a very specific group of patients. I'm looking for people with a Bipolar diagnosis. Once you have that list, I need to check one more thing about their current treatment. Our standard for this group is 15 hours of therapy a month. Can you just show me a table of these patients with their ID, diagnosis duration, and hospitalization count, and then add a true/false column that tells me if they're meeting that 15-hour therapy target?
For my research paper, I need to analyze a Chronic High-Acuity Bipolar Cohort. After identifying this cohort, I need to check their Intensive Therapy Standard Compliance. Please generate a report that lists each patient's identifier, their diagnosis duration in months, their count of previous hospitalizations, and a boolean value indicating if their current therapy intensity is 15 hours per month or more.
[]
[]
[]
[]
[]
Query
false
{ "decimal": -1, "distinct": false, "order": false }
mental_health_19
mental_health
I'm trying to decide where to focus our new goal-setting program. I have a hunch that our PTSD patients are struggling more to make progress than our anxiety patients. Can you check this for me? I want to see a comparison: on average, how many recovery goals would a PTSD patient achieve in a full year versus an anxiety patient? I just need those two numbers side-by-side to see if my hunch is right.
For program development, I need to compare the Annual Goal Achievement between two patient populations. The first population consists of patients with a primary diagnosis of 'PTSD', and the second consists of patients with a primary diagnosis of 'Anxiety'. Please calculate the average Annual Goal Achievement for each group. The final output should be a single row with two columns: one for the PTSD group's average and one for the Anxiety group's average.
[]
[]
[]
[]
[]
Query
false
{ "decimal": -1, "distinct": false, "order": false }
mental_health_20
mental_health
I'm Dr. Hanson, a pharmacist. I need to run a safety check on our Anxiety patients at the F533 facility, but only those who've been diagnosed for more than a year. I'm worried about medication side effects. Can you calculate an side effect score for a 12-month period for each of them with just 2 medications? I need a list of these patients showing their ID, the original density number, this new score, and a true/false if their score is over our new safety limit of 0.1. Please put the patients with the highest scores at the top.
I am conducting a 'Medication Protocol Review' for Anxiety patients at facility F533 who have a diagnosis duration of more than 12 months. I need to calculate their Annualized Side Effect Score, assuming that there are 2 number of medications. Please provide a report that lists the patient identifier, their original med side eff density, their calculated Annualized Side Effect Score, and a boolean flag indicating if this score is over our protocol's threshold of 0.1. The list should be sorted by the highest score first.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": true, "order": true }
mental_health_M_3
mental_health
Hey! Go ahead and clean up the treatmentoutcomes table by deleting any old or stale records, but only for those patients who've been flagged as Non-Compliant. Leave the rest untouched!
Please remove Stale Treatment Outcome Records from the treatmentoutcomes table, but only for patients who have been identified as Non-Compliant Patient.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": true, "order": false }
mental_health_M_4
mental_health
Hey! Can you make a reusable database function called calculate_tes? If it already exists, just replace it. This function should take a treatment key, look up the 'engagement' level from the therapy details tied to that treatment, and return the score for therapy engagements as a number.
Please create (or replace if it exists) a reusable database function named calculate_tes. This function's purpose is to calculate the Therapy Engagement Score for a single treatment record. It should take the treatment key as input, find the corresponding 'engagement' level from the therapy details data, and return the calculated numeric score based on the standard Therapy Engagement Score definition.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
mental_health_M_6
mental_health
Hi team, I'm worried we're missing the chance to help patients who are really struggling until it's too late. I want to build a new 'at-risk' watchlist named vulnerable_patient_watchlist that our care coordinators can check every morning. Let's automatically flag any patient who is both having frequent crises and seems to be socially isolated. When the system flags someone, I need the new watchlist to show the watchlist id, their patient ID, who their clinician is, exactly how many crises they've had, what their support score was, and—most importantly—when their next appointment is, and also the insertion date of the watchlist. Make sure you pull that date from the notes of their last visit so we have the most current one.
As the head of clinical outreach, I am launching a new initiative to reduce critical incidents. To do this, I need to establish a new, permanent data process called 'Vulnerable Patient Watchlist Generation'. This process will create and populate a new table named vulnerable_patient_watchlist. To determine who belongs on this list, we will use our established 'Patient with High Crisis & Low Support Profile'. For every patient who meets these criteria, the new vulnerable_patient_watchlist table must store the following actionable information: a watchlist id, their unique patient ID, the ID of their lead clinician, their total crisis intervention count, their calculated SSE score, and their next scheduled appointment date as recorded during their most recent encounter, and the date of the watchlist's insertion.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
mental_health_M_8
mental_health
This is urgent. My patient, P515871, is at high risk for suicide based on the assessment I just filed. Our protocol says this should immediately flag me for intensive care coordination so we can get them help now. Can you run a script to do this protocol?
I've just finished an emergency assessment for patient P515871, who has been flagged with a 'High' suicide risk. To ensure immediate action, I need to invoke our 'High-Risk Escalation Protocol'. Please execute a script to do this protocol.
[]
[]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": true, "order": false }
mental_health_M_9
mental_health
We nearly missed a serious situation with a patient named John because nobody saw their hospitalization risk score was getting dangerously high. I want to fix this now by doing a review protocol. Please help me flag those patients that is the same as John in our patient files. First, please add a new boolean column named needs_case_review to the patients table, with a default of FALSE. Then, for all patients that are currently meeting the criteria based on their latest assessment, execute an update to set the flag to TRUE. This will be our new automated safety alert.
In response to a recent critical incident, our safety board has approved a new 'Mandatory Case Review Protocol'. Some patients are exceeding the hospital risk density recently, like John, and because of this, we must execute this protocol to flag and identify more patients that has the same situation as John. To implement this, I need a two-part script. First, please add a new boolean column named needs_case_review to the patients table, with a default of FALSE. Second, execute an update to set this new flag to TRUE for all patients who currently meet the protocol's criteria based on their latest assessment.
[]
[]
[]
[]
[]
Management
true
{ "decimal": -1, "distinct": true, "order": false }
mental_health_M_10
mental_health
Hi, I'm Dr. Rossi. I need an urgent change to a patient's file. My patient David, that's P883117, just lost his entire support system because his wife was in a bad accident. His current support plan is useless now. We've agreed he needs to be twice as self-reliant. Can you find his last assessment, look up his 'support utilization rate' which I think is 1.5, and cut it in half? Please change it in the system to 0.75 so his official plan is up to date.
I have an urgent update for my patient, David (P883117), following a major life event—his primary caregiver is incapacitated. His existing support_util_rate of '1.5 support-level/contact' is no longer viable. We have set a new therapeutic goal to halve his reliance on external support. Please execute a script to find his single most recent assessment record and update the support_util_rate value to '0.75 support-level/contact' to reflect this new plan.
[]
[]
[]
[]
[]
Management
true
{ "decimal": 2, "distinct": false, "order": false }
reverse_logistics_1
reverse_logistics
Show me how much the whole process, from transport to final disposition, cost us for every return. Round the result to 2 decimal places, biggest cost first.
List the Total Return Cost (TRC) for each return case, round the value to 2 decimal places, and sort the results by TRC in descending order.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": true }
reverse_logistics_2
reverse_logistics
Tell me the overall gain or loss from all returns: take what we got back after processing and subtract the combined out-of-pocket amount (transport, getting it sellable again, label fixes, end-of-life handling, fix-up quote). Include the net figure and both parts, rounded to two decimals.
Estimate the overall net impact across all processed returns by subtracting the total handling cost (transport, reintegration, label correction, end-of-life handling, fix-up estimate) from the amount recaptured after processing; also show both components; round each to two decimals.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": false }
reverse_logistics_3
reverse_logistics
Show me the average value recovered per day since sale for the entire portfolio, along with the recovery value and number of days used in the calculation, rounded to 2 decimal places from highest to lowest.
Compute the portfolio-wide average Recovery Rate per Day, rounded to two decimals; also return the aggregated Recovery Value and the aggregated Days Lapsed used in that calculation.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": false }
reverse_logistics_M_1
reverse_logistics
Find store credit refunds that are for zero dollars, mark them as “Pending,” and show me their reference numbers with the new status.
Only for zero-amount reimbursements issued as store credit, set the status to “Pending” and return each affected reference with its new status.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
reverse_logistics_4
reverse_logistics
I want to know the average lost of a return, consider the environmental impact factors. Round to two decimal places.
For all returns, calculate its average Sustainability Adjusted Loss (SAL), rounded to 2 decimal places.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": false }
reverse_logistics_5
reverse_logistics
Show me each processing site with their average and individual processing times , rounded to one decimal place, and list the slowest sites first.
List the Average Processing Time (APT) for each processing site, including individual Processing Time values in the result. Round numeric outputs to 1 decimal places. Sort the results by APT in descending order.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 1, "distinct": false, "order": true }
reverse_logistics_6
reverse_logistics
I want to know the proportion of returns having warranty claims, and round the answer to one decimal point.
Calculate the Warranty Claim Ratio (WCR) for the whole business, and round the result to 1 decimal place.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 1, "distinct": false, "order": false }
reverse_logistics_7
reverse_logistics
For each return, show a severity score equal to the number of signals times the level weight (use 1 for low, 2 for medium, 3 for high). Include both the signal count and the weight, and list the highest scores first.
For each return, compute the Fraud Flag Severity Score (FFS) as the flag count multiplied by a level weight, using Low=1, Medium=2, High=3; also show the flag count and the applied weight; sort by FFS in descending order.
[]
[]
[]
[]
[]
Query
false
{ "decimal": -1, "distinct": false, "order": true }
reverse_logistics_8
reverse_logistics
Provide the grand total of all regulatory penalties we've accumulated to date (show only the final number).
Measure the total Regulatory Compliance Penalty (RCP) incurred to date, only show the final number.
[]
[]
[]
[]
[]
Query
false
{ "decimal": -1, "distinct": false, "order": false }
reverse_logistics_9
reverse_logistics
Show the latest 100 items with a relative transport cost versus what’s typical for the same way of coming back. Include the way it came back, round to two decimals, and list newest first.
For the 100 most recent returns, list each item's Return Channel Cost Index (value = its transport charge divided by the historical average for returns that came back the same way). Include the way it came back, round to two decimals, and sort by the logging time from newest to oldest.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": true }
reverse_logistics_M_2
reverse_logistics
Suspend anyone whose combined severity score (using 1 for low, 2 for medium, 3 for high) is 9 or more, and show their IDs with the new category.
Suspend all customers whose Fraud Flag Severity Score is at least 9 and the weights are Low=1, Medium=2, High=3. Return each customer ID with the updated segment category.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
reverse_logistics_M_3
reverse_logistics
Make the expected expense that bring a defective return back to sellable condition increase by 15% for returns waiting more than 60 days. Show me the case numbers and new estimates (rounded to 2 decimal places).
Increase the repair estimate by 15 percent for any return that has been waiting more than 60 days, and return the case number with the adjusted amount rounded to 2 decimals.
[]
[]
[]
[]
[]
Management
false
{ "decimal": 2, "distinct": false, "order": false }
reverse_logistics_10
reverse_logistics
Show me the average cost of printing and attaching new labels for each product category, rounded to two decimals and sorted from highest to lowest.
List the Average relabeling cost by product category. Round numeric outputs to 2 decimal places and sort descendingly.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": true }
reverse_logistics_11
reverse_logistics
Show overall disposal spend per method, most expensive first.
Show the Total disposal cost by disposal method. Sort the results by the cost in descending order.
[]
[]
[]
[]
[]
Query
false
{ "decimal": -1, "distinct": false, "order": true }
reverse_logistics_12
reverse_logistics
Which 5 returns cost most to fix? Show me from priciest to least pricey.
Display the top 5 returns ranked by repair estimate, ordered from highest to lowest.
[]
[]
[]
[]
[]
Query
false
{ "decimal": -1, "distinct": false, "order": true }
reverse_logistics_13
reverse_logistics
How much do we typically recover through each return method? Give me the average amounts rounded to pennies.
List the average recovery value per return channel, rounded numeric outputs to 2 decimal places.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": false }
reverse_logistics_M_4
reverse_logistics
Find every case marked as finished but never officially closed, mark it closed with today's date, and tell me which case numbers were touched.
Close every case whose action state is 'Completed' and whose close state is still NULL; set its close state to 'Closed', update the close date to today, and return its case number.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
reverse_logistics_14
reverse_logistics
Of all returns, tell me the % flagged with 'high' fraud risk (rounded to hundredths) - show only the percentage.
Figure out the percentage of returns flagged 'high' in fraud risk levels. Round numeric outputs to 2 decimal places and only show the first one.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": false }
reverse_logistics_15
reverse_logistics
Give me the kilograms of carbon dioxide released in different disposal processing activities. Round numeric outputs to 2 decimal places and show from highest to lowest.
List the Average carbon footprint by disposal method. Round numeric outputs to 2 decimal places. Show the results from highest to lowest.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": true }
reverse_logistics_16
reverse_logistics
Show me how many returns we have for each warranty status and return channel combination, sorted by the count from highest to lowest.
List the Count Returns per Warranty status (CNT) and return channel. Sort the results by CNT in descending order.
[]
[]
[]
[]
[]
Query
false
{ "decimal": -1, "distinct": false, "order": true }
reverse_logistics_M_5
reverse_logistics
Find all electronics worth over $700, mark their subcategories as 'High Value', and tell me how many got tagged.
Append the tag 'High Value' to the subcategory of electronics products with unit value greater than 700. Return the number of updated rows.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
reverse_logistics_17
reverse_logistics
Show me how much money we actually get back (after costs) for each type of refund, along with both the recovered amounts and what we spent processing them.
Calculate the Net return profit impact per refund method. Display Recovery Value and Total Return Cost in the result.
[]
[]
[]
[]
[]
Query
false
{ "decimal": -1, "distinct": false, "order": false }
reverse_logistics_18
reverse_logistics
How dirty and pricey is it to scrap items in different states? how me the average values, rounded to two decimals.
Output the Average carbon footprint and disposal cost for each item condition state. Round numeric outputs to 2 decimal places.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": false }
reverse_logistics_M_7
reverse_logistics
Find all unsatisfied customers (ratings 2 or below), flag their cases for follow-up, and give me the case numbers with their new status.
Mark needsfollowup as 'Yes' for cases whose satisfaction score is less than or equal to 2. Return casetie and the new needsfollowup value.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
reverse_logistics_19
reverse_logistics
Show me how many non-compliant items we have divided by disposal method, along with their average carbon footprint (rounded to 2 decimal places). Sort by the highest count of non-compliant items first.
Display the count of items whose Regulatory Compliance Status is non-compliant, grouped by disposal method, with the average carbon footprint rounded to 2 decimals. Sort the list by the non-compliant count in descending order.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": true }
reverse_logistics_M_8
reverse_logistics
Find all supposedly recycled items with heavy carbon footprints (over 50kg), mark them as hazardous waste instead, and tell me how many needed reclassification.
Change disposal method from 'Recycle' to 'Hazardous Waste' for records with carbon footprint greater than 50 kilograms. Return the number of affected rows.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
reverse_logistics_20
reverse_logistics
When fraud risk is high and it comes back by courier, how off-normal is the shipping cost? Please round the answer to two decimals.
When the fraud-risk rating is high and the item comes back by courier, how far above or below average is the shipping cost? Please round the answer to two decimals.
[]
[]
[]
[]
[]
Query
false
{ "decimal": 2, "distinct": false, "order": false }
reverse_logistics_M_10
reverse_logistics
Find all automatic approvals for express processing, bump them up to manager approval, and tell me which locations had changes with both the old and new levels.
Upgrade approval level from 'Automatic' to 'Manager' for processing priority 'Express'. Return loccode, old approval level, and new approval level.
[]
[]
[]
[]
[]
Management
false
{ "decimal": -1, "distinct": false, "order": false }
robot_fault_prediction_1
robot_fault_prediction
Let's get a list of all robots that need urgent maintenance and are running too hot, showing their ID, model, urgency score, and hottest joint temp with worst cases first.
Which robots currently meet the dual criteria of a high Predictive Maintenance Urgency score and a concurrent Thermal Anomaly? Show robot ID, model, maintenance urgency score, and maximum joint temperature. Sort by most critical cases first.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": true }
robot_fault_prediction_3
robot_fault_prediction
Find robots doing precision work that aren't accurate enough, showing their ID, job, error amount, and if they need calibration.
Identify robots used in Precision-Critical Applications that are showing signs of Precision Performance Degradation. Return robot ID, its application type, relative positional error, and current calibration state.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": true }
robot_fault_prediction_4
robot_fault_prediction
Show me robots working too hard right now, listing their model, how much payload capacity they're using, and their cycle speed. Make sure the most overloaded ones are at the top of the list.
List all robots currently operating under an Intensive Workload. Include the robot's model, its payload utilization ratio, and its throughput rate, sorted with the most utilized and fastest robots appearing first.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": true }
robot_fault_prediction_5
robot_fault_prediction
I need to plan next week's emergency maintenance schedule. Find all robots that are likely to fail sometime next week and which the system also considers a high risk to break. Show their ID, how likely they'll break, and how many days they have left.
For next week's maintenance planning, identify robots that are projected to fail within the next 7 days and also have a 'High' Fault Prediction Score Tier. For each, show the robot ID, its fault prediction score, and its remaining useful life in days.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": true }
robot_fault_prediction_6
robot_fault_prediction
Let's see which manufacturers are struggling the most with their robots' health. For manufacturers with at least two robots getting worse, show me how many are affected and what their average decline rate is. Please show the manufacturer names in lowercase.
I require an analysis of health degradation trends, grouped by manufacturer with more than one degrading robot, show the total count of such robots and their average health degradation rate (with manufacturer names in lowercase).
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": false }
robot_fault_prediction_7
robot_fault_prediction
Let's find robots whose controllers are overworked compared to their peers by flagging any with 'Anomalous Controller Stress'. I need to see the robot's ID, its model (in lowercase), its stress score, and what the average for its model was.
Identify all robots experiencing 'Anomalous Controller Stress'. For each, display its robot ID, its model (in lowercase), its specific stress score, and the calculated average stress for its model.
[]
[]
[]
[]
[]
Query
true
{ "decimal": -1, "distinct": false, "order": true }