Retail pharmacies
Prescriptions filled by the patient's own pharmacy, for pickup or by mail. Drugs, pharmacies, price estimates, choosing and moving a pharmacy, and the pickup statuses.
A requested line can ask for the patient's own retail pharmacy instead of a row of the formulary. The clinician always decides: they may prescribe the line for a retail pharmacy or not. A prescription the clinician sends to a retail pharmacy raises a retail order, and you can choose the pharmacy, see price estimates, and move the order to another pharmacy once it is there, until it is picked up or has shipped.
Retail is available to every organization unless Cuvo has switched it off for one. Where it is off,
every retail operation is 403 retail_not_enabled: both searches, setting or clearing a patient's
pharmacy, setting an order's pharmacy, its price estimates, and a case with a retail line. A case
with a retail line is also 403 retail_not_enabled until retail prescriptions are available for the
organization in the patient's state, and so is releasing a held case that has one
(POST/v1/cases/{id}/release_hold); the searches, price estimates and choosing a pharmacy stay open
meanwhile. Test
mode always has retail available. When the pharmacy network does not answer, a call is
503 unavailable and is safe to retry. An error's detail that comes from the pharmacy network
calls it "the pharmacy network".
Every organization's orders, patients and requested medications carry the new retail fields, empty
until it uses retail. Where Cuvo has switched retail off, an organization's orders and
prescriptions read as they did before retail: GET/v1/cases/{id}/prescriptions lists no retail line (the comparison still counts each one as
sent_to_retail_pharmacy), an order's status is one of preparing, at_pharmacy, shipped,
delivered, blocked and failed (a retail pickup reads at_pharmacy, then delivered), its
fulfillment is null, and blocked_reason is never pharmacy.
Asking for a retail line
#A line on POST/v1/cases is a catalog line or a retail line, never both.
{ "retail": true, "retail_medication_id": "sbx_rx_atorvastatin_20", "name": "Atorvastatin", "quantity": 30, "refills": 1, "days_supply": 30, "directions": "One tablet daily."}retail: truemakes it a retail line. It names nomedication_idand nopharmacy_id; either one besideretail: trueis400 invalid_requestwith an issue on that field. A catalog line still needsmedication_id.retail_medication_idis optional, a drug fromGET/v1/retail_medications. Without it the clinician picks the drug.nameis the drug's name, shown to the clinician. It is required withretail_medication_id: send thenamethatGET/v1/retail_medicationsreturned for that id. The drug is checked against a search for that name, and an id the search does not return is400 invalid_requestonretail_medication_id. Without an id,nameis optional free text.retail_medication_idornameon a line withoutretail: trueis400 invalid_request.prescriber_decidesand the dose fields work as on a catalog line, except thatrefillsis 0 to 10, the most the pharmacy network takes. More is400 invalid_requestonrefills, live and in test mode.
A case returns a retail line with retail: true, its retail_medication_id and name as sent
(each null when not sent), and medication_id: null. A catalog line returns retail: false and
retail_medication_id and name as null.
A case's lines are all retail or all catalog, live and in test mode. A mix is
400 invalid_request with an issue on requested_medications: file the two kinds as separate
cases.
A retail line is checked against the patient's state under the category of the question set the case names. On a case that names no set, or a set with no category, it has no category, so a state that blocks some categories or needs a visit for some refuses it (Cases).
Controlled substances are never available at retail. The drug list leaves them out, and the pharmacy network does not transmit them.
Finding a drug
#GET/v1/retail_medications?q= needs catalog:read. q is part of the drug's name, two
characters or more. Each row carries id, name, form and strength, the last two null when
the network states none. The list is paged with starting_after and has_more.
Finding a pharmacy
#GET/v1/retail_pharmacies?near=&type= needs catalog:read. near is required: an address, a
city or a ZIP code. type is pickup or mail_order, pickup when not sent: each request
searches one kind, so search twice for both. Each
row carries id, name, address, phone, type and distance_miles from the place searched,
any of the last four null when the network states none. A mail-order pharmacy ships to the
patient, so its distance_miles is always null. The list is paged. In live mode a place the
network cannot find is 400 invalid_request with an issue on near.
The patient's pharmacy
#PUT/v1/patients/{id}/pharmacy with { "pharmacy_id": "...", "type": "mail_order" } sets it and
DELETE/v1/patients/{id}/pharmacy clears it. Both need patients:write, return the patient, and
announce patient.updated.v1 when the pharmacy changes. Setting the pharmacy already in place, or
clearing one nobody set, returns the patient unchanged and announces nothing. A pharmacy that fills only one way is
that type whatever type says. For one that fills both ways, send the type the search found it
as; without one it is taken as a pickup pharmacy. A pharmacy id the network does not list is
404 not_found.
A patient carries pharmacy, null until one is chosen: the pharmacy's id, name, address,
phone and type, plus chosen_by (partner, patient, staff or clinician) and
chosen_at. Anyone may choose, and the last choice wins.
Until a retail order of the patient's goes out, its fulfillment shows the patient's pharmacy.
One that is waiting only on a pharmacy goes to the new one on the next pass (see
the order). An order already sent stays where it is; move it with
PUT/v1/orders/{id}/pharmacy.
The order
#An approved retail line is listed by GET/v1/cases/{id}/prescriptions with medication_id: null
and retail_medication set to the drug's id and name. Its order carries fulfillment, which
is null on a catalog order:
| Field | Meaning |
|---|---|
type | pickup or mail_order, null until a pharmacy is chosen |
pharmacy | id, name, address, phone, type, null until a pharmacy is chosen |
ready_for_pickup_at | When the pharmacy reported the order ready, or null |
picked_up_at | When the pharmacy reported it collected, or null |
When the patient has a pharmacy, the order goes to it: at_pharmacy. Without one, the order waits
blocked with blocked_reason: "pharmacy", announced by order.blocked.v1, until a pharmacy is
set on the patient or on the order. It then goes out on the next pass and reads at_pharmacy: in
live mode within about two minutes, in test mode at once. order.at_pharmacy.v1, sent to the
pharmacy, follows the pharmacy network's own confirmation: in live mode usually within minutes, in
test mode at once.
Until the clinician signs it, a retail prescription's dose can change: the clinician may amend it
after approval, announced by prescription.updated.v1, and GET/v1/cases/{id}/prescriptions and
the comparison then read the new dose.
When an order is sent, the pharmacy network texts the patient at the phone number on their record.
Price estimates
#GET/v1/orders/{id}/pharmacy_options?near=&type= needs orders:read and takes the same type as
the pharmacy search, pickup when not sent. For pickup, near is required, as in the search. For
mail order it is optional and not used: a mail-order pharmacy is near no place, so the list holds
the mail-order pharmacies that can fill the order, wherever near points or without it. Each
entry is a pharmacy (as the search returns one, with distance_miles null in live mode, where
the priced search measures none) and its offers, one per prescription on the order that the
pharmacy quoted:
prescription, therx_...the price is forprice_type:cash,insurance,membership, ornullwhen the source names noneamount_cents, andretail_amount_cents, the pharmacy's list price ornullsource, who quoted the price, ornulldelivery_estimate, the pharmacy's own words on when a mail order arrives, ornull
Prices are estimates, not charges: the pharmacy sets the price at the counter. offers may be
empty: a pharmacy may quote nothing. The call answers 409 conflict until the clinician has signed
every retail prescription on the order, for a catalog order, and for an order that can no longer
take a pharmacy: one picked up, shipped, delivered or failed.
Choosing or moving an order's pharmacy
#PUT/v1/orders/{id}/pharmacy with { "pharmacy_id": "...", "type": "pickup" } needs
patients:write and returns the order. type works as on the patient's pharmacy. A pharmacy id
the network does not list is 404 not_found.
- Before the order goes out (
preparing, orblockedfor any reason), it sets the PATIENT's pharmacy, exactly asPUT/v1/patients/{id}/pharmacydoes:chosen_by: "partner", announced bypatient.updated.v1. The response is the order as it stands, stillblockedif it was, with the chosen pharmacy infulfillment. An order that was waiting only on a pharmacy then goes out on the next pass, in live mode within about two minutes, in test mode at once, andorder.at_pharmacy.v1follows the pharmacy network's confirmation (see the order). An order blocked for another reason goes to the patient's pharmacy once that is put right. - At a pharmacy, until it is picked up or has shipped, it moves the order, announced by
order.pharmacy_changed.v1withstatus: "at_pharmacy", and then the patient's pharmacy follows, announced bypatient.updated.v1. The order isat_pharmacyat its new pharmacy, andready_for_pickup_atis cleared. - The pharmacy already in place changes nothing: the order is returned unchanged and nothing is announced. A pharmacy event fires only when the pharmacy actually changes.
- Anything else is
409 conflict: a catalog order, and an order that was picked up, shipped, delivered or failed. When the pharmacy network refuses a move, the call is409 conflictwith the network's reason indetail.
Pickup and mail order
#A pickup order moves at_pharmacy, then ready_for_pickup, then picked_up, announced by
order.ready_for_pickup.v1 and order.picked_up.v1. Both arrive only when the pharmacy reports
them, and not every pharmacy reports either; a pickup may also arrive without a ready before it.
Only at_pharmacy, the order sent to the pharmacy, is certain. Accept both statuses, and never
wait on them. A pickup order has no ship_to.
A mail-order order ships and is delivered as a catalog order is: shipped, then delivered, with
ship_to, carrier and tracking. delivered means a mail-order pharmacy delivered it. There is no
same-day courier.
ship_to is the address the pharmacy network was given when the order went out: the patient's
address then, also for an order sent for pickup and moved to a mail-order pharmacy later. Once
the order has gone to a pharmacy, pickup or mail order, PATCH/v1/cases/{id}/shipping_address is
409 shipping_address_locked, live and in test mode: the pharmacy network already holds the
address.
Test mode
#Test mode never reaches a pharmacy network. It answers from fixtures:
- Five drugs, none controlled, for
GET/v1/retail_medications. - Four pharmacies wherever
nearpoints: Main Street Pharmacy and Corner Drug for pickup, and Sandbox Mail Pharmacy and Parcel Pharmacy for mail order. Corner Drug and Parcel Pharmacy quote no price. POST/v1/test/cases/{id}/ready_for_pickupandPOST/v1/test/cases/{id}/pick_upreport a pickup order's two steps;shipanddelivermove a mail-order one.- The simulated clinician prescribes a retail plan line as
retail: truewith aretail_medication_id, and 0 to 10refills, as a live clinician does. More is400 invalid_requestonrefills. Autopilot prescribes a retail request as asked, and a request that names no drug as the first sandbox drug. - Each fixture pharmacy fills one way, so it is always its own type, whatever
typesays. - A pharmacy set through the API reads
chosen_by: "partner". No pharmacy network refuses a move. - An order that was waiting only on a pharmacy goes out as soon as one is set, right after the call that set it has answered, with the same events in the same order as live.
- The simulated clinician signs every prescription at approval, so price estimates are available as soon as the order exists.
- Every test state needs a visit for some categories, so a retail case files only under a question
set whose category the state allows without one. Otherwise it is
409 visit_required. - A test plan's dispensable lines are all retail or all catalog, as a clinician's are. A mix is
400 invalid_request.