✏️ Important Math

Refill Calculation Explained Simply

The refill computation process determines how many medication refills a patient has left and when they can get their next refill. Here's how it works in straightforward terms:

Step 1: Gather the Information

The system collects two key pieces of information: - The original prescription details (from the MedicationRequest) - A history of all times the medication was dispensed (from MedicationDispense records)

Step 2: Calculate Basic Numbers

  • Total allowed fills: This is the initial fill plus all refills
    • For example: If the doctor allows 5 refills, the total is 6 fills (1 initial + 5 refills)
  • Fills used so far: Count how many times the pharmacy has given the medication to the patient
  • Remaining refills: Subtract the fills used from the total allowed

Step 3: Determine Next Refill Date

  • Look at when the patient last picked up their medication
  • Check how many days that supply was meant to last (usually 30 days)
  • Add those days to the last pickup date to find when they can get their next refill

Step 4: Check If Prescription Is Still Valid

  • Prescriptions typically expire after a certain period (often 6 months)
  • The system compares today's date with the prescription's end date
  • If today's date is past the end date, the prescription is no longer valid, regardless of remaining refills

Example:

For patient Stephen Gitau: - His doctor wrote a prescription for Amlodipine with 5 refills (6 total fills) - He's picked up the medication twice already - He has 4 refills remaining - His next refill is due on May 27, 2025 - His prescription remains valid until September 28, 2025

The Python code does all this automatically by processing the FHIR resources from the patient's health record, saving pharmacists from having to calculate these details manually.

Discard
Save
Review Changes ← Back to Content
Message Status Space Raised By Last update on