The screens your team works in, on data you own.
A front-desk board, a stock count, a performance page. Build the simple ones from widgets and the particular ones in React. Both read the same tables, under the same rules.
Three screens, one set of tables.
Fernhill runs three clinics. The front desk, the practice managers and the pet owners each have a screen of their own, and none of them keeps a copy of the data.
- The tables' rules decide who sees what. Front-desk staff see their own clinic's rows, owners see their own, and managers see everything.
- None of the three screens has a line of code about who may see what, so none can get it wrong.
- Adding a fourth clinic is a row, not a new app.
The right tool for each screen.
From the two examples that run a real day's work. Each screen was built the simplest way that would do the job.
| Screen | Built with | Why that way |
|---|---|---|
| Front desk | A React app, kept in the repository | Booking offers only free times, and a visit moves through check-in, the exam room and done. That's logic on screen. |
| Clinic performance | App Builder, no code | Money, visits and stock, filtered by clinic and date. Lists, totals and charts are what widgets do. |
| Device desk | App Builder, no code | A queue, check-out and check-in buttons that ask first, and a shelf the desk edits in place. |
| Lending | A dashboard | It only reads. Figures, a weekly chart and a pivot, for the desk's manager. |
The rules live in scripts, not screens.
Booking a visit is one script. The front desk calls it, the pet portal calls it, and so does the phone assistant. Each gets the same answer, and the same refusal when a time doesn't work.
- Outside opening hours, every room taken, the named vet busy: refused with a reason a person can read.
- Run by a pet owner, it reads the pets table as them, so they can only book for their own.
- The same pet booked twice in one slot is caught, since that's usually a retry.
- Change the rule once and every screen and agent follows it on the next deploy.
export const bookAppointment = defineScript({
path: "appointments/book",
input: z.object({ pet, clinic, starts_at, reason, vet, notes }),
tables: [pets, clinics, appointments],
async run(input, ctx) {
const who = ctx.run.startedBy;
// An owner sees only their own pets: ask the table as them.
const petTable = who.type === "end_user"
? ctx.table(pets).as(who.id) : ctx.table(pets);
const pet = await petTable.get(input.pet);
if (!pet) throw new Error("There is no such pet, or it is not yours to book for.");
const why = refusal(clinic, booked, start, minutes, input.vet);
if (why) throw new Error(why);
// …insert the visit and return its number
},
}); Shortened from examples/fernhill.
A manager's page, with no code.
Clinic performance is three pages of widgets: money, visits and stock. A practice manager can change it in the builder, and a developer can review the change in the repository.
- Money is kept in cents and shown in dollars, set once as a format.
- Filters by clinic and by date apply to every widget on the page.
- Choose a visit in the list and the card beside it shows that visit.
const DOLLARS = { style: "currency", currency: "USD", minorUnits: true };
export const performance = defineInterface({
path: "screens/performance",
pages: [{
id: "money", title: "Money",
filters: [
{ id: "clinic", label: "Clinic", column: "clinic", type: "value" },
{ id: "issued", label: "Issued", column: "issued_on", type: "date" },
],
widgets: [{
id: "invoiced", type: "figure", title: "Invoiced",
table: "invoices",
summary: { groupBy: [], aggregates: [{ fn: "sum", column: "total", as: "invoiced" }] },
options: { format: DOLLARS },
}, /* …unpaid, average, by week, by clinic… */],
}, /* visits, stock */],
}); What comes with every screen.
- Staff or end users
- Share a screen with members, with a group of end users such as one clinic's front desk, or with every end user.
- Phone to desktop
- The front desk checks patients in from a phone. Widgets reflow, and the builder previews tablet and phone widths.
- Help beside the work
- A page of the clinic handbook opens next to the screen it explains.
- Your name on it
- The tenant's logo and colours, at an address of its own such as the clinic group's domain.
- Tested before it's live
- Built in a dev workspace with copied or sample data, then promoted with everything else.
- Every action recorded
- A button runs a script, and the run says who pressed it, with what, and how it went.
Related
Give each team the screen it needs.
Widgets for the simple ones, React for the rest, one set of rules for all of them.