Use cases · Multi-stage · Staged flow
Specialty clinic
A specialty clinic where care isn't one appointment but a journey: an intake consult, then — only if it's indicated — a procedure that needs a deposit and a signed consent, then a follow-up. Each stage is its own booking, but they have to behave as one flow, with the gaps, the branch, and the money all in one place.
The shape
The journey is a Seldon staged_flow Offer orchestrated by a Daneel DAG — book consult → wait → branch on the outcome → book procedure → follow-up. The procedure's deposit is a Need in the Daneel needs ledger; the consent form is a Sign envelope; the patient and their consent live in Terminus.
- Seldon keeps each stage a single Booking on a provider's variable-duration grid. The journey itself is a
staged_flowOffer carrying anorchestrationActionId— it's booked through its DAG, and a directPOST /bookingsis refused. - Daneel owns the gaps and the branch. A
seldon.book_offerstep books each stage;waitandbranchnodes hold between stages and decide whether the procedure happens;seldon.cancel_bookingis the saga rollback if the journey is abandoned. - Needs ledger: the procedure won't confirm until two obligations clear — a deposit-to-confirm payment and an approval-to-proceed sign-off from the clinician. Each is a
Needthat gates the next stage and expires on a timer. - Sign handles informed consent: a
SignatureEnvelopewhose document is a Media asset and whose signer is the Terminus patient. The procedure stage waits on the envelope reachingCOMPLETED. - Terminus is the patient record — identity, typed attributes (allergies, insurance member id), and consent that gates every outbound message.
- Payments takes the deposit and the balance; Mallow invoices each stage; Speaker sends stage reminders, consent-gated.
Walk-through
Start the journey
A new patient requests treatment. Rather than book a single appointment, the clinic starts the staged_flow Offer; its Daneel DAG opens with a seldon.book_offer step that books the intake consult on the right provider's grid. Terminus creates the patient Person with their intake attributes.
Consult, then branch
After the consult, the clinician records the outcome. The DAG's branch node reads it: if no procedure is indicated, the flow completes; if it is, the DAG advances to the procedure stage instead of dead-ending in a separate system.
Consent and deposit
Before the procedure can confirm, two Needs must clear. A Sign SignatureEnvelope goes out for informed consent — the patient signs the Media-hosted PDF, and an HMAC-verified webhook advances it to COMPLETED. In parallel, Payments collects a deposit, satisfying the deposit-to-confirm Need. With consent signed and deposit cleared, the needs ledger releases the procedure booking.
Procedure and follow-up
The procedure stage books and runs. On its completion emission, the DAG schedules the follow-up automatically — another seldon.book_offer step — and Mallow invoices the balance against the deposit already on file.
If the patient cancels
If the patient backs out after the deposit but before the procedure, Daneel runs the saga: seldon.cancel_booking releases the held slot, the needs ledger unwinds, and the clinic's deposit policy decides what's refunded — all as recorded compensation, not a manual cleanup.
Why this is hard without LatticeKit
Multi-stage care normally means a scheduler that only understands single appointments, a separate e-sign tool, a separate deposit-taking step, and a coordinator manually chasing each handoff. The "don't schedule the procedure until consent is signed and the deposit clears" rule lives in someone's head. Here the journey is a DAG, each gate is a durable Need, the consent is a first-class Sign envelope tied to the patient record, and an abandoned journey unwinds through compensation — so the conditional, money-gated, consent-gated path runs itself instead of relying on a coordinator's checklist.