Inspiration
I'm a speech-language therapist. In every clinic I've worked in, the therapy was the easy part and the money was the mess: deposits, part payments, insurers, outside labs and department budgets. Staff lose hours chasing payments and having awkward conversations at the desk. I wanted billing to feel calm and clear, with a person always in control.
What it does
TJS Pay runs a hospital's billing on PayPal, for three kinds of staff: the billing office, the finance department and department staff.
- Check-in & pay: families check in by link or QR code. Self-pay families choose a sliding-scale price (no proof asked), and a deposit is held on their PayPal, not taken, until they arrive.
- Insurance: one click splits a bill into the family's excess and a claim to the insurer; any shortfall goes back to the family.
- Surgery plans: a deposit now and instalments later, each a PayPal invoice, with Pay in 3.
- Departments: every invoice line carries a department code. Finance approves budget requests, paid with PayPal Payouts; partner labs are paid only from money collected.
- AI billing and finance assistants: ask in plain words. They check PayPal, find what needs doing and propose actions. Nothing happens until a person approves.
How I built it
- Cloudflare Workers + D1, plain JavaScript, no framework.
- PayPal: Invoicing, Checkout (Orders v2), deposit holds (authorise → capture or void), Payouts and webhooks.
- Anthropic Claude as a tool-using assistant: the billing code defines the tools; the AI can only look things up and propose.
- Every amount is plain, tested code (34 tests), never AI. For example, the sliding scale and the insurance split:
$$\text{price} = \text{base} \times (1 - d), \qquad d \in {0, 0.2, 0.4, 0.6}$$
$$\text{family pays} = \min(\text{excess},\ \text{bill}), \qquad \text{claim} = \text{bill} - \text{family pays}$$
- I built it with Claude Code as my coding partner, bringing the clinical and workflow knowledge myself.
Challenges I ran into
- Who does what: my first version had the billing office allocating budgets, until I realised that's Finance's job. Separating the roles, including which AI tools each team may use, made everything clearer.
- Real money is messy: cash, bank transfers, part payments and partial insurer payments all have to add up to the penny.
- Keeping AI safe around money: the AI writes, reads and plans, but never calculates or acts on its own.
- One PayPal account per clinic: payments go to whichever account a copy is connected to, so each clinic runs its own copy, locked with a passcode.
- Ethics: I chose not to build referral commissions for doctors, which are prohibited in India and the UK.
What I learned
How PayPal's APIs fit together (authorise now and capture later, Payouts, webhooks), and that good AI is mostly about boundaries: what it may see, what it may propose, and what always needs a human.
What's next
Connect with PayPal for hosted clinics, family wallets, text-to-pay, electronic insurance claims, and hospital-scale accounting.