confirm_trip
Status: Verified | Module: booking
Submit the booking and create the trip (or standing order) in MediDrive. Handles BOTH one-time trips AND recurring standing orders — routes automatically based on trip_type set in set_booking_details (standing_order → standing-order creation; otherwise → trip creation). Must call review_trip first.
Annotations
Section titled “Annotations”| Hint | Value |
|---|---|
| readOnlyHint | false |
| destructiveHint | false |
| idempotentHint | false |
v2.0 audit change: destructiveHint was flipped to false. confirm_trip is additive — it creates a new trip/standing-order record; it does not destroy domain data. Cancellations are still routed through cancel_trip (which carries destructiveHint=true).
Prerequisites: review_trip must be called first (draft.LastStep == "review"). MR trips require EnrollmentID (via assign_driver). Pickup and dropoff addresses must already carry coordinates (set by resolve_address or passed directly to set_booking_details).
Standing-Order Branch (NEW in v2.0)
Section titled “Standing-Order Branch (NEW in v2.0)”When the draft’s trip_type == "standing_order", confirm_trip dispatches to the standing-order creator instead of the single-trip creator. The draft must also carry a recurrence rule (RRULE) set during set_booking_details. This folds in the responsibilities of the removed create_standing_order tool — agents now have a single confirmation surface for both flows.
TP Rate Estimation
Section titled “TP Rate Estimation”Before creating the trip, confirm_trip automatically calls trip_estimates_general.Facade.Perform to get TP rate estimates. The returned estimate_ids are passed to each leg for TP selection and cost calculation. For roundtrips the outbound and return estimations run concurrently. Estimation failure is fatal for roundtrips (the will-call return leg requires a customer estimate); for one-way trips it is non-fatal — the trip is still created without estimates.
For MR trips, confirm_trip resolves the DriverID (enrollment ID) to a TpID via the tp_drivers table; the resolved TP is set on each leg with Marketplace = false for direct TP assignment.
Session Lifecycle
Section titled “Session Lifecycle”On success, the draft is deleted but the session stays alive so send_confirmation can authorize the follow-up email. The session snapshot is updated with:
LastConfirmedDraft— by-value copy of the booking draftLastTripIDs/LastFriendlyIDs— allowlist forsend_confirmationIsStandingOrder/StandingOrderID/StandingOrderMeta— when the recurring branch ran
send_confirmation reads these fields to prove the caller is sending an email for THIS session’s trip, not somebody else’s. (See Architecture › Session for the full session model.)
| Field | Type | Required |
|---|---|---|
session_id |
string | yes |
Output
Section titled “Output”| Field | Type | Description |
|---|---|---|
status |
string | success or error |
trip_id |
string | Created trip UUID (single trip / outbound leg) |
trip_friendly_id |
string | Human-readable trip ID (display to member) |
return_trip_id |
string | Return-leg trip UUID (roundtrip only) |
confirmation_number |
string | Group confirmation number |
spellable_confirmation |
string | TTS-friendly: each char dash-separated (e.g. C-O-N-F-4-5-6) |
trip_type |
string | one_way, roundtrip, or standing_order |
appointment_day |
string | Day-of-week for the appointment |
appointment_date |
string | Full appointment timestamp |
appointment_time |
string | Same as appointment_date — convenience echo |
pickup_time |
string | Display pickup time |
pickup_address |
string | One-line “street, city state zip” echo for AI readback |
dropoff_address |
string | One-line “street, city state zip” echo for AI readback |
transport_mode |
string | Echoed transport mode |
return_type |
string | will_call / scheduled (when set) |
treatment_type |
string | Echoed treatment type |
companion_name |
string | Echoed companion (when set) |
special_needs |
string | Echoed special needs (when set) |
notes |
string | Echoed trip notes (when set) |
recurring |
bool | True when the standing-order branch ran |
standing_order_id |
string | Standing-order UUID (recurring only) |
days_of_week |
string[] | Standing-order schedule days (recurring only) |
start_date |
string | Standing-order start date (recurring only) |
end_date |
string | Standing-order end date (recurring only) |
so_appointment_time |
string | Standing-order appointment time HH:MM (recurring only) |
message |
string | Confirmation message |
The echoed pickup/dropoff/appointment/transport/return/treatment/companion/special-needs/notes fields match the source confirmTripResult shape so the AI can read back exact booking details to the member after submission.
Example Response
Section titled “Example Response”{ "status": "success", "trip_id": "trip-uuid-001", "trip_friendly_id": "04-08-2026-0001-A", "return_trip_id": "trip-uuid-002", "confirmation_number": "NEMT-2026-04-08-001", "spellable_confirmation": "N-E-M-T-2-0-2-6-0-4-0-8-0-0-1", "trip_type": "roundtrip", "appointment_date": "Tuesday, April 8, 2026 at 2:00 PM", "pickup_address": "123 Main St, Springfield IL 62701", "dropoff_address": "456 Health Ave, Springfield IL 62701", "transport_mode": "wc", "return_type": "will_call", "treatment_type": "Dialysis", "message": "Trip booked! Confirmation number: NEMT-2026-04-08-001"}Error Codes
Section titled “Error Codes”MISSING_PREREQUISITE—review_tripnot called, MR trip without driver, missing coordinates, ortreatment_typemissingTRIP_ALREADY_EXISTS— Trip already booked at this timeTRIP_LIMIT_EXCEEDED/BOOKING_WINDOW/INELIGIBLE— domain rejections from trip-service
Related
Section titled “Related”- Booking Flow | Standing Orders Flow
- Previous: review_trip
- Next: send_confirmation (uses
LastConfirmedDraftpopulated here)