-
-
Why a language model and not just OCR
-
How it is built, and what I measured on a phone with Gemini Nano
-
Each feature gets the inference mode its data calls for
-
A photo of your dental receipt becomes a filled claim form
-
The model reads, fixed Kotlin rules check
-
Three pieces of paper in, one filled form out
Inspiration
We live in a digital world, but we are still surrounded by paper. A lot of dentists in the US don't bill dental insurance. You pay at the front desk, the office hands you a receipt, and you file the claim yourself. Some insurers still want that claim on paper, by mail: a form with 58 numbered boxes that you fill in from your insurance card, your ID and the receipt.
All of it is sensitive: who you are, your date of birth, your member ID and what was done to your teeth. I didn't want to upload that to a server just to copy it from one sheet of paper onto another. A model that runs on the phone is the right tool for this job, so I built the app around Gemini Nano.
What it does
Dental Claim Filler is an Android app that turns a photo of a dental receipt into a filled claim form PDF, ready to sign, print and mail.
- Set up once. I photograph my insurance card and my driver's license, and the app fills in my details. The license number is never read: the schema has no field for it.
- Import the blank form. The app does not include the claim form. I import my insurer's blank, fillable PDF and the app fills the fields that PDF already has.
- Photograph the receipt. Gemini Nano reads the patient, date, dentist, procedure codes and fees, on the phone.
- Review. Every value can be edited. Each procedure gets a one-sentence explanation in plain language. Fixed Kotlin rules then check the claim: the format of each code, the fees against the total, a 10-digit provider number, and that the patient matches the relationship box.
- Generate the PDF. One tap fills the form. The receipt photo is deleted, and the app says whether anything left the phone.
How I used Firebase AI Logic
Every model call goes through the Firebase AI Logic SDK, behind one interface (ClaimAi). I didn't treat hybrid as "try the phone, fall back to the cloud". Each feature gets the inference mode its data calls for:
| Feature | Inference mode | What can leave the phone |
|---|---|---|
| Reading a receipt, insurance card or license | ONLY_ON_DEVICE |
Nothing |
| The same, on a phone with no on-device model | ONLY_IN_CLOUD, only after I agree, for every photo |
That one photo, once |
| Explaining a procedure | PREFER_ON_DEVICE |
The code and description, only if the phone can't answer |
| Matching a claim form whose fields are named differently | ONLY_IN_CLOUD, when I tap the button |
The blank form's field names |
| Checking the claim and filling the PDF | No AI | Nothing |
The app shows which path answered, from response.inferenceSource: blue for "Read on this phone", orange for "Read in the cloud". On a phone without Gemini Nano it stops and asks before each photo is sent, and I can always type the values instead. A screen called "Where your data goes" lists this feature by feature.
Why a language model and not just OCR
Text recognition returns characters. A model returns what they mean: which name is the patient, which number is a fee, which line is the total. So the app needs no template for each dentist's receipt layout. The same holds on the way out: when an insurer's copy of the claim form names its fields differently, the model matches them to the right boxes, and only the blank form's field names are sent for that.
How I built it
- Kotlin and Jetpack Compose (Material 3), one activity.
firebase-aiandfirebase-ai-ondevice. Answers come back as typed Kotlin objects through@Generabledata classes and the KSP processor, on the phone and in the cloud.- On-device answers should stay short, so a receipt is read in two requests on the same image: the header, then the procedure lines.
- The model lifecycle is handled in the app: it checks the on-device model's status at startup, starts the download if needed, and retries with backoff when AICore is busy.
- PdfBox-Android writes into the form's own fields. There is no AI in that step.
- The profile, claims, photos and PDFs are sealed with AES-256-GCM under an Android Keystore key. There is no account, no backend and no analytics.
- 210 unit tests cover the parsing, the claim rules, the image maths and the PDF mapping.
Challenges I ran into
- Dense tick-box receipts. Many dental receipts print every procedure the office offers and the dentist writes a fee next to the few that were done. Gemini Nano could not pick those few out of sixty printed rows and made up codes in a counting sequence. I added "Read in parts": plain image maths (no model) finds the rows with a fee written on them, cuts them out and sends only those. On the one real receipt I tried, that returned exactly the two rows that were done, with the right codes, in 7 to 10 seconds.
- Handwriting. Nano still misread a handwritten fee digit on every run. I could not fix that, so the review screen asks me to check handwritten fees against the photo.
- AICore refuses some inputs. Its input check rejected a few cut-out strips before the model ran. Strips are now cut to hold similar amounts of text, and a refused strip is tried once more as photographed.
- An experimental API. The hybrid API changed under me. I confirmed signatures against the docs and, where they were silent, against the SDK binaries.
- Copyright. The ADA owns the claim form and the procedure code set, so the app ships neither. The form is imported by the user, and codes are checked by format only.
Accomplishments that I'm proud of
- On a Galaxy S25 Ultra with Gemini Nano, the sample receipt is read on the phone in about 9 seconds, and an insurance card or a license in about 6 seconds.
- It is a complete product, from three pieces of paper to a PDF I can mail, and it works with no on-device model too, without ever sending a photo silently.
- The app is honest about its own limits: it flags readings that look made up, and it tells me what happened to each photo.
What I learned
- A small on-device model is good at meaning and weak at exact characters, above all handwriting. The design has to assume that: small requests, typed output, fixed rules after the model, and a person reviewing the result.
- Preparing the picture mattered more than rewording the prompt.
- Choosing an inference mode is a privacy decision, and it is easier to make per feature than for the whole app.
What's next for Dental Claim Filler
- Reading the exact characters first and letting Gemini Nano work on the text for meaning, which should help with handwriting.
- More versions of the claim form, and other paper-to-form chores such as medical and FSA claims.
- A release build with Play Integrity, tested on more phones with Gemini Nano.
Try it
- The APK and three fictional sample documents are on the release page. Step-by-step instructions are in docs/TESTING.md.
- Reading on the phone needs Gemini Nano through AICore. On other phones and on emulators the app asks before each photo is sent to the cloud. The demo video was recorded on an emulator, so it shows that path.
- The source is under Apache-2.0.
Everything in the video and the screenshots is fictional: the Avery family and Maple Street Dental. The form shown is a plain test template with the same fields. This project is not affiliated with the American Dental Association, any insurer, or Google.