---
id: 18305
lang: en
title: "A Developer Built an AI Medical Assistant on OpenCode: 144 Documents, About 80 Rubles in Tokens, and a 1,700 RUB/Month Server"
published_at: "2026-11-26 10:30:39"
source_name: "Habr AI"
source_url: "https://habr.com/ru/articles/1112308/?utm_campaign=1112308&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/18305"
categories: ["llm", "autonomous"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# A Developer Built an AI Medical Assistant on OpenCode: 144 Documents, About 80 Rubles in Tokens, and a 1,700 RUB/Month Server

> **Краткая суть (BLUF):** Medical records are scattered across clinics and email, and a doctor during a short appointment has no time to dig through them. The author exported 144 PDFs from Medsi and INVITRO and connected them to an OpenCode agent running a DeepSeek model, accessed through Telegram. Over 6.5 weeks the agent consumed 172.9 million tokens (units of text that models are billed for), costing about 80 rubles, while the server costs 1,700 RUB per month. So the expensive part is not the model but data preparation.  • Claude in Chrome downloaded 140+ documents from Medsi in 10 minutes • INVITRO tables have no grid lines, so columns are extracted by word coordinates • LDL ("bad") cholesterol dropped 44%, total cholesterol dropped 33%

Most people's medical history is scattered across different places: appointments and certificates at one clinic, test results in emails from a lab, scans in a desk drawer. During a state-insurance (OMS) appointment, a doctor has no time to sort through them, and the patient often cannot remember what was tested and when. The author of a post on Habr tackled this problem with a personal AI agent: he exported 144 PDF documents from the Medsi clinic and the INVITRO laboratory and built a medical case manager on top of them. The agent runs on a rented server (VPS), answers in Telegram around the clock, and remembers test results from several years.

The cost is modest. Over 6.5 weeks the agent used 172.9 million tokens (the units of text for which models are billed), which came to roughly 80 rubles. The server in Germany costs about 1,700 RUB per month. The agent is built on OpenCode (a tool for running AI agents) and the inexpensive DeepSeek model.

The author himself makes an important caveat: he has no medical education, and the agent does not make diagnoses or cancel prescriptions. It stores the history, reminds the user of deadlines, and prepares a summary for appointments. For real symptoms, a live doctor is needed.

## The most tedious part is getting your own documents

The data was spread across three places. Medsi offers no bulk export, either in its app or its web account: documents have to be downloaded one at a time, which would take several hours. The author handed this routine work to the Claude in Chrome browser extension, which scrolled the page, opened records, and saved the files. Over 140 documents from the past year were collected in 10 minutes. Because of Claude access restrictions, he suggests an alternative: OpenCode with the Browse plugin. But both options send your data to the model provider's servers, and that risk should be weighed.

INVITRO results arrive by email as PDFs, and they are the easiest to collect. The main technical problem here is tables without grid lines, which the standard table extraction in the pymupdf library does not detect. The author extracts columns using word coordinates via get_text("words"). Scans are processed with OCR through tesseract. He has not yet exported anything from state clinics, but he names two routes: the electronic medical record on Gosuslugi and regional portals, or an official request to the polyclinic under Ministry of Health order No. 789n.

It took 40 minutes from the first extracted file to a finished vector index (a meaning-based search database). But that is an MVP on "clean" documents. The remaining weeks went to scans, tables without grid lines, and identical indicators listed under different names by different laboratories.

## How the agent works and what it costs

The architecture is deliberately simple: OpenCode on a remote server plus a ready-made Telegram bot for it. The pipeline runs as follows: PDF, extraction, SQLite, hybrid search, reply in Telegram. The author simply forwards new documents to the bot, and it parses and indexes them automatically.

- Storage: SQLite with no external databases, with tables for documents, tests, consultations, studies, profile, goals, and a diary.
- Search: full-text FTS5 for exact terms such as "creatinine" and "MRI", plus semantic search over embeddings.
- Embeddings: paraphrase-multilingual-MiniLM-L12-v2 via fastembed (ONNX), 384-dimensional vectors, computed locally. Chunks of 600 characters with a 100-character overlap.
- Similarity is computed with numpy, without FAISS or Chroma.

To keep the agent from relying on forums and "folk recipes," the author set a source priority: Russian Ministry of Health clinical guidelines, Cochrane reviews, studies in PubMed, and for drug safety, the FDA, EMA, the Russian State Register of Medicines (GRLS), and WHO.

On economics: the 4VPS server (4 CPUs, 4 GB RAM, 40 GB NVMe) is also used for a genealogical tree and calendar sync, so the whole rental cost does not fall on the agent. To check the database, simple questions such as "when was I at the doctor?" were enough: if the answer matches the calendar, the data was assembled correctly.

## Results and limitations

The author reports personal results without a control group. Over a month and a half his weight dropped by 3.55 kg out of a planned 12, by cutting flour and sugar and adding fiber. The agent suggests breakfast recipes, estimates calories from photos, and reminds him to weigh himself. It was also the agent that first told him to get a blood test, noticed problems with his lipid profile, and referred him to a cardiologist. Afterward, LDL ("bad") cholesterol fell 44% and total cholesterol fell 33%. The text does not establish how much of this effect came from treatment and how much from diet.

The most practical feature is a one-page PDF summary before an appointment: key dates, study results on the topic, and a list of questions for the doctor. With limited time at an OMS appointment, this saves minutes spent searching for paperwork. A psychological effect also turned up unexpectedly: confessing to the agent that he had eaten a burger felt nearly as awkward as admitting it to a person.

The practical takeaway for developers: a personal agent built on a cheap model, SQLite, and local embeddings costs hundreds of rubles. Most of the effort goes into data extraction, not into choosing an LLM. The author himself wrote not a single line of code by hand: OpenCode configured itself, and the starting prompt is published on GitHub. The main constraint is privacy: medical data goes to the LLM provider, and this must be resolved before launch.

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/articles/1112308/?utm_campaign=1112308&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/18305
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
