- Use SQLite for SQL query generation.
- Use DENSE_RANK() only when ranking is explicitly requested (e.g., most common/frequent items or top N events). If ranking is not mentioned, do not use DENSE_RANK(). Retrieve only the relevant names/items without counts or ranks.
- For the top N results, return only the relevant items, excluding their counts.
- Use DISTINCT in queries related to the cost of events, drug routes, or when counting or listing patients or hospital/ICU visits.
- When calculating the total cost, sum the patient’s diagnoses, treatments, lab events, and medication costs within a single hospital admission only.
- Use DISTINCT to retrieve the cost of a single event (diagnosis, treatment, lab event, or medication).
- For cost-related questions, use cost.event_type to specify the event type ('diagnosis', 'treatment', 'lab', 'medication') when retrieving costs for diagnoses, treatments, lab events, or medications, respectively.
- Treat questions that start with "is it possible," "can you confirm," or "verify" as true/false questions.
- Calculate a patient's age once per hospital admission. The age remains constant even if the hospital stay exceeds one year.
- Use intakeoutput for both input and output events. Either type of event can be specified using intakeoutput.cellpath LIKE '%intake%' or intakeoutput.cellpath LIKE '%output%'.
- When a question involves the time of diagnosis in relation to other types of events, use the first diagnosis time for each patient.
- All values in the database are stored in lowercase, and they exactly match the format used in the question.
- When the results are numerical values, round them to three decimal places.
- When calculating time differences relative to today, use the fixed current time: 2100-12-31 23:59:00.
- When calculating the N-year survival/mortality rate:
  - A patient is considered deceased if a death record exists between their first diagnosis and N years later.
  - If no death record exists within N years, or if the death occurs afterward, the patient is considered to have survived.
  - Express the result as a percentage or proportion (values between 0 and 1).
  - "3 months" refers to 365/4 days, and "6 months" refers to 365/2 days when calculating a duration.
- Time-related SQL operations:
  - Use the following information for the current time instead of SQLite's native function.
  - Use '2100-12-31 23:59:00' instead of 'now', '2100-12-31' instead of 'today', '2100-12' instead of 'this month', and '2100' instead of 'this year'.
    - Examples:
      - medications today: datetime(medication.drugstarttime,'start of day') = datetime('2100-12-31 23:59:00','start of day','-0 day')
      - medications yesterday: datetime(medication.drugstarttime,'start of day') = datetime('2100-12-31 23:59:00','start of day','-1 day')
  - "this month/02" and "last month/02" refer to the 2nd day of the current and previous month, respectively.
    - Examples:
      - output events on this month/02: datetime(intakeoutput.intakeoutputtime,'start of month') = datetime('2100-12-31 23:59:00','start of month','-0 month') AND strftime('%d',intakeoutput.intakeoutputtime) = '02' AND intakeoutput.cellpath LIKE '%output%'
      - output events on last month/02: datetime(intakeoutput.intakeoutputtime,'start of month') = datetime('2100-12-31 23:59:00','start of month','-1 month') AND strftime('%d',intakeoutput.intakeoutputtime) = '02' AND intakeoutput.cellpath LIKE '%output%'
  - "11/this year" refers to November of this year; "11/2100" refers to November 2100; "12/31/this year" refers to December 31st of this year.
    - Examples:
      - microbiology lab in 11/this year: datetime(microlab.culturetakentime,'start of year') = datetime('2100-12-31 23:59:00','start of year','-0 year') AND strftime('%m',microlab.culturetakentime) = '11'
      - microbiology lab in 11/2100: strftime('%Y-%m',microlab.culturetakentime) = '2100-11'
      - microbiology lab on 06/15/this year: datetime(microlab.culturetakentime,'start of year') = datetime('2100-12-31 23:59:00','start of year','-0 year') AND strftime('%m-%d',microlab.culturetakentime) = '06-15'
  - When a question involves a time window (e.g., "since"):
    - Example:
      - output events since 1 year ago: datetime(intakeoutput.intakeoutputtime) >= datetime('2100-12-31 23:59:00','-1 year') AND intakeoutput.cellpath LIKE '%output%'
  - Time Comparison for Two Different Events:
    - Examples:
      - Same Day: datetime(T1.diagnosistime,'start of day') = datetime(T2.drugstarttime,'start of day')
      - Same Month: datetime(T1.diagnosistime,'start of month') = datetime(T2.drugstarttime,'start of month')
      - Same Hospital Admission: T1.patienthealthsystemstayid = T2.patienthealthsystemstayid
  - A "current hospital admission/visit/encounter" refers to records where the hospital discharge time does not exist (indicating a current patient). A "last hospital visit" is only if the hospital discharge time is present; the first hospital visit is simply the earliest recorded visit. This rule also applies to ICU admissions and careunit transfers.
    - Examples:
      - current hospital admission: patient.hospitaldischargetime IS NULL
      - last hospital admission: patient.hospitaldischargetime IS NOT NULL ORDER BY patient.hospitaladmittime DESC LIMIT 1
      - first hospital admission: patient.hospitaldischargetime IS NOT NULL ORDER BY patient.hospitaladmittime ASC LIMIT 1
- Value Mapping Assumptions:
  - Use "patient.admissionweight" for weight.
  - Use "patient.admissionheight" for height.
  - Except for the above, use the value as it is.
- Vital-related events are stored in vitalperiodic. Normal ranges for vital signals are as follows:
  - temperature: BETWEEN 35.5 AND 38.1
  - sao2: BETWEEN 95.0 AND 100.0
  - heartrate: BETWEEN 60.0 AND 100.0
  - respiration: BETWEEN 12.0 AND 18.0
  - systolicbp: BETWEEN 90.0 AND 120.0
  - diastolicbp: BETWEEN 60.0 AND 90.0
  - systemicmean: BETWEEN 60.0 AND 110.0