Skip to content

Workflow Diagrams

Decision trees and flow diagrams for navigating SaveHealth's 4-step tool workflow.


Primary Workflow: Drug Name to Coupon

The most common flow starts with a natural-language drug name and ends with a coupon code. Each tool is called once per turn, in sequence.

User: "Find me a coupon for [drug]"


  search_drug(drug_name)                    ← Step 1

        ├── needs_disambiguation: true
        │       → Present options to user
        │       → User selects one
        │       → Continue with selected slug

        ├── needs_disambiguation: false
        │       → Use returned slug


  get_drug_options(slug, dosage?)            ← Step 2

        │   Returns options sorted:
        │   Generic first, Brand second
        │   Default option marked

        ├── User picks dosage/form/quantity


  get_drug_prices(ndc, quantity)             ← Step 3

        │   Returns pharmacy prices
        │   sorted cheapest first

        ├── User picks pharmacy (or cheapest)


  get_coupon(key)                            ← Step 4


  Return coupon with:
    - pharmacy name
    - discounted price
    - coupon code
    - BIN, PCN, Group ID, Member ID
    - redemption instructions

Shortcut: NDC-Direct to Coupon

For users who already have an NDC code (from their prescription bottle or a previous lookup), steps 1-2 are skipped entirely.

User: "I have NDC 29300039710, qty 30"


  get_drug_prices(ndc, quantity)             ← Step 3


  get_coupon(key)                            ← Step 4


  Return coupon details

TIP

This is the shortest possible workflow — only 2 tool calls.


Partial Workflow: Price Comparison Only

When the user only wants to compare prices without getting a specific coupon.

  search_drug(drug_name)                    ← Step 1


  get_drug_options(slug, dosage?)            ← Step 2


  get_drug_prices(ndc, quantity)             ← Step 3


  Present price table to user
  (user may then request a coupon for a specific pharmacy)

Partial Workflow: Explore Dosage Options

When the user wants to see what's available before committing to a price lookup.

  search_drug(drug_name)                    ← Step 1


  get_drug_options(slug)                     ← Step 2


  Present all options:
    - Dosage strengths (e.g., 10MG, 20MG, 40MG)
    - Forms (Tablet, Capsule, Vial, Pen, etc.)
    - Available quantities
    - Generic vs Brand labels
    - Default option highlighted


  User picks an option → continue to pricing

Decision Tree: Which Path?

Does the user have an NDC code?

  ├── YES → get_drug_prices(ndc, qty)
  │            → get_coupon(key)

  └── NO → search_drug(drug_name)

              ├── Single match
              │     → get_drug_options(slug)

              └── Multiple matches
                    → Present options
                    → User picks
                    → get_drug_options(slug)


                    get_drug_prices(ndc, qty)


                    get_coupon(key)

Tool Dependency Map

ToolRequiresProvidesStep
search_drugdrug_name (string)slug1
get_drug_optionsslug (from search_drug)NDC, dosage, form, quantity, type2
get_drug_pricesNDC + quantity (from get_drug_options or user)price list with keys3
get_couponkey (from get_drug_prices)coupon details4

Common Scenarios

ScenarioWorkflow
"Cheapest coupon for X"search_drugget_drug_optionsget_drug_pricesget_coupon
"Compare prices for X"search_drugget_drug_optionsget_drug_prices
"What dosages for X?"search_drugget_drug_options
"Coupon for NDC 12345"get_drug_pricesget_coupon
"Prices for NDC, qty 90"get_drug_prices
"Coupon at CVS for X"search_drugget_drug_optionsget_drug_pricesget_coupon (CVS key)

Key Design Principles

  1. One tool per turn — Each tool is called separately, never combined in a single turn
  2. Sequential dependency — Each tool's output feeds the next tool's input
  3. Generic first — Options are always sorted with generic alternatives before brand names
  4. Cheapest first — Prices are always sorted ascending
  5. Disambiguation upfront — Multiple matches are resolved before proceeding
  6. NDC shortcut — Users with an NDC skip the discovery steps entirely

Powered by SaveHealth