BAIEnterprise Digitalization · AI Application Development中文EN

Building a Family Health Service: From a Household Scenario to System Design

Date: 2026-11-05Category: Systems & ArchitectureTags: Family Steward · Health Management · System Design · Agent Architecture

Starting from an everyday scene — three generations asking a chatbot one-off health questions — a ten-step chain of questions derives the health records, the forward-looking database design, the three-layer rule system, and the model choices, plus three deliberate refusals to expand.

Building a Family Health Service: From a Household Scenario to System Design

This is the design retrospective (the “thinking” edition) of the health service inside my family steward, “Xiaoguanjia”: it does not chronicle the development process, but records, for each design decision, which problem forced it, how the reasoning went at the time, and what it left open for the future. The system went live in November 2026. This article contains no real health data of any family member.

1. The Starting Point: Read the Scenario First, Talk Systems Later

The starting point was not technology but a slice of family life: three generations under one roof — an elder, a teenager, adults. A health question comes up, someone opens Doubao, asks, and the answer evaporates. Checkup reports sit in phone photo albums and drawers; the elder sees three different specialists and takes several medications, and nobody has ever looked at them all together.

Four facts can be read out of this scene, and every design that follows is a corollary of them:

  1. Care is fragmented, but illness is continuous. Hospitals bill per visit and triage by department; no single institution holds a person’s complete picture across years — the only node that possibly can is the family itself. This fixes the system’s positioning: not “treating illness,” but managing continuity — no gaps, no missed items, no conflicts, and being able to explain things clearly when you get to the hospital.
  2. The three generations’ health problems are structurally different. For the elder: chronic conditions, medication safety, follow-ups that must not lapse. For adults: checkup trends and screening cadence. For the teenager: growth, eyesight, sleep — plus an extra layer of autonomy and privacy. Any design that tries to cover all three generations with one template is wrong at step one.
  3. The flaw of stateless Q&A is not answer quality; it is the absence of “your ledger.” Doubao does not know what medication your father takes, or what that indicator was last year. So what needs building is not a smarter Q&A, but a stateful system, with Q&A as merely its outermost face.
  4. Family members are not medical staff, and they will not change their habits for a system. They will not categorize before uploading, will not keep up check-ins, will not tolerate daily reminders. Any design that requires the family to first learn a workflow dies on adherence — this point came back repeatedly to adjudicate concrete proposals.

From these four facts, I first fixed an ordering, which later proved to be the most important methodological decision of the whole project: think the system through first → build the records and architecture → hand over to the agent last. Have the answers to “what is managed, and how” before tools and models enter the picture.

2. How the Thinking Unfolded: A Chain of Questions

The whole design was not a blueprint drawn in one pass; each step was forced by a gap the previous step left behind. What follows retraces the reasoning in the order it happened.

Step 1: What to Manage — From “Collecting Data” to “Managing Risk”

The first temptation is “completeness”: ingest every report, every indicator. One question overturned it: for everything we take in, what action does it trigger? Blood pressure connects to follow-ups and medication — clear. Certain tumor markers trigger nothing but anxiety. So the organizing unit was set as risk, not data: one risk list per person, each risk carrying an action and a cadence; data with no action attached is not collected. This single filter governs three things at once — the scope of collection, the legitimacy of reminders (a reminder must point back to some risk), and the system’s credibility (the family keeps trusting it only while “everything it says is relevant”).

At the same level, three tensions were set down. They are not slogans; each later materialized into a concrete design: completeness vs. sustainability (→ the indicator dictionary collects trend items only), care vs. autonomy (→ member permissions and the teenager boundary), peace of mind vs. anxiety (→ a separate nagging budget for the health domain, restraint in reminding taking priority over completeness of reminders). Time runs on three clocks — yearly, event-driven, daily — with an advance warning to ourselves: the daily clock is the easiest to overdo, and is switched on only for people on chronic medication.

Step 2: What the Data Looks Like — From “Storing Reports” to “Storing Facts”

The first draft of an archive easily becomes “a report folder plus summaries.” The word that overturned it is trend: the value of a checkup is not whether one year was normal, but the line drawn across several years; if the line cannot be drawn, the archive is just a warehouse. So the data was broken down into “facts”:

  • One row = one person, one examination, one indicator (observations became the core of the whole database), with value, unit, time, and source all present;
  • Reference ranges are stored alongside each value, not taken from a unified dictionary range — forced by reality: different institutions use different reference intervals, and judging last year’s value against this year’s range gets it wrong. Wherever something “looks like it should be normalized,” first ask whether reality is actually uniform — the most valuable pause in this step;
  • Findings and values live apart: nodules and fatty liver are findings (conclusions), a different kind of thing from indicator values, with different lifecycles and uses — never mixed in one table;
  • The dictionary admits only indicators with trend value; anything outside it is not extracted, just kept as an original — the extraction scope is decided by “will we need to draw a line through this later,” not by “can we extract it”;
  • The baseline card is filled in through a single interview: allergies, medical history, family history, current medications — the most critical information is precisely what no report contains. The archive design must include “data beyond the reports,” with a standing rule: what is missing is only listed, waiting for a person to fill it in — the system must never infer and fill it in. This later became a hard acceptance criterion for the pilot.

Step 3: Foresight in the Database — Not Spare Tables, but Four Extension Rules

“Foresight” is most easily misunderstood as building a few extra tables just in case. This time the approach was the opposite: build only the tables needed now, and write the extensibility into the rules.

  • Dictionary-driven: adding any indicator or examination type in the future means adding a row to the dictionary table, not changing the schema. The cost of extension is compressed to “filling in data” instead of “engineering work.”
  • The ext-field discipline: every table keeps one JSON extension column for odds and ends only; any field that needs to be queried, reminded on, or referenced by rules must be a real column. This is the anti-rot rule: abuse the JSON column and in three years the whole database becomes a swamp nobody can query.
  • Facts are append-only: medical facts are always soft-deleted; a correction is a new row with a supersedes_id pointing at the old one. The reason: every “change” to medical data may become evidence at the next medical visit, so history must remain traceable — this is not audit fastidiousness, it is what the medical scenario itself demands.
  • Versioned migrations from day one: schema_migrations is in force from the first day the database exists, and hand-editing the production schema is forbidden. The most common way family projects die is “just patch it for now”; versioning is a lock we put on ourselves.

Under the same philosophy, two deliberate “non-tables”: home self-measurements get no table of their own — blood pressure, blood glucose, and checkup indicators share observations, distinguished by source type, because at assessment time they are meant to be read on one line anyway; access auditing gets no new table — it reuses the steward’s existing /audit with a health flag, since auditing is a whole-steward concern and the health domain should not build its own. Restraint is also foresight: every table not built is one less thing to maintain in the future.

There is also one back door left deliberately for the future: extraction_jobs retains, in full, the raw JSON of every extraction, along with the model version and dictionary version. The reasoning at the time: it does not matter that today’s 8B model extracts imperfectly — as long as the originals and the raw extractions are kept, when models get stronger we can re-extract from the stored stock and upgrade wholesale, without asking the family to dig out reports and OCR them again. Leave an interface for future capability, rather than betting that present capability is enough.

The technology choice follows the same logic: a single SQLite file, read and written exclusively through the gateway, borrowing FHIR’s naming concepts without running a FHIR server, and keeping an escape hatch to migrate to PostgreSQL. Choose the lightest form that fits the family’s real scale, but write “how we migrate when it grows” into the design in advance — foresight is not starting with heavy weaponry; it is not painting yourself into a corner.

Step 4: Who Uses the Data — Five Loops, and “Judgment Belongs to Code”

Once the archive existed, the question changed immediately: data sitting still creates no value — who uses it, and when? The answer was not a feature list but five loops, each corresponding to a gap that really happens: reports are read once and thrown away (the report loop: on ingest, diff against history, turn each recommendation into a follow-up task, close the task when the follow-up is done); medications accumulate with nobody reconciling them (the medication loop: a new prescription is diffed against the current list, changes keep versions and discontinuation reasons); at the hospital, nobody can explain the history (the visit loop: a one-pager goes out the door, the doctor’s orders come back in); due dates are remembered by no one (the patrol loop: the ledgers are scanned for due items); a question comes up on the spot (the Q&A and emergency loop: answer with context, red flags produce the emergency card first).

With the loops fixed, one division-of-labor question remained: which of these go to the model? The principle was nailed down here — judgment belongs to code, language belongs to the model. Whether something is due, whether a value crossed a line, whether a trend rose — these are deterministic computations, done in SQL and rules, and they must never be wrong. The model handles only what it is good at and where being wrong is affordable: extracting from reports, phrasing results in plain human language, understanding the family’s questions. Tools are graded by risk; every write is previewed first and lands only after human confirmation; diagnosis, prescribing, and stopping or changing medication have no tools at all — not a prompt telling the model not to do it, but making it impossible at the tool level. Once this layer was thought through, no later model choice could shake the safety boundary, because the boundary does not live in the model.

Step 5: Entry and Exit — From “Features” Back to Human Behavior

The loops were listed from the system’s viewpoint; looking from the family’s viewpoint, both ends had problems: how data gets in, and how results get out. This round of thinking was entirely about human behavior, not features:

  • There must be exactly one entry point, and it must not demand categorization. Family members will snap a photo of a lab slip at any moment, narrate how they feel, call out a blood pressure reading. So the design is “one entry, internal routing”: throw anything in, and the system classifies first, then routes (reports into the archive, prescriptions to comparison, invoices attached to a visit, anything unrecognizable into the pending-review zone with one clarifying question). Making the family pick a category first just offloads the system’s complexity onto the people least able to carry it.
  • Some records are valuable precisely because they are not interpreted. “Just noting how the body feels — probably nothing wrong” — this scenario forced a new data type (the body-feel log): the verbatim words plus a timestamp, stored as-is; at capture time no probing, no comforting, no interpreting — at most a “noted.” Only when similar entries recur does the system, in the background, thread them into a symptom line, to be merged into the chief-complaint timeline at the next visit. Restraint here is the feature itself: a logging tool that has to “show care” every time would be abandoned by the family in three days.
  • The exit is constrained by the physical properties of the channel. Why do full results travel as “summary + one-time signed link” instead of a direct WeChat message? Three practical reasons: messages have length limits, what is sent cannot be retracted, and a broadcast cannot be permission-trimmed per member. The shape of the design is pushed out by the channel’s properties, not an aesthetic choice.

Step 6: Organizational Design — Once Features Multiply, Settle “Who Is Responsible, What Is Forbidden” First

As features multiply, the new problem is not technical but governance: health matters and turning lights on and off inside one agent will eventually collide somewhere in the rules. The proposal was to “set up an independent department in the home” — with its own tasks, rules, plans, and SOPs. Once adopted, one key correction was made: the department is a domain pack, not a second agent. The reasoning: the foundation (scheduling, channels, auditing, model routing) only needs to exist once for the whole household; building it twice just confronts the family with two stewards. But rules, task calendars, documents, and permissions must be independent, because health’s risk level and privacy granularity are structurally unlike home control.

The role design hides the finest piece of reasoning in the whole project. Intuitively, “four roles” easily becomes four sub-agents; the final decision was four work modes of one and the same agent, for three reasons: health work is serial (ingest → remind → visit → Q&A naturally relay into each other), not parallel; the four jobs share one archive context, and splitting them means repeatedly passing and merging state; and what truly needs isolation is permissions, not data — the reminder is read-only, the archivist can propose writes but cannot send reminders — which a configuration pack (prompt fragment + tool whitelist + SOP) plus policy-layer enforcement handles fine. Sub-agents are reserved for exactly one situation: temporary workers for long batch jobs (such as importing years of past reports), and even they must work wearing a role’s configuration pack and have their output accepted and merged by the main agent. Role assignment does not rely on model guessing either: the trigger source decides the role (a scheduled task is always the reminder; a new document is always the archivist), triage is only a fallback, and low confidence defaults to the read-only on-duty answerer — when unsure, land on the role with the least privilege, a general technique for pushing uncertainty toward the safe side.

Step 7: Rule Design — Why Three Layers, and Why SOPs and Rules Must Live Apart

The rule design started from one specific worry: “the model has read the rules” is not the same as “the rules are enforced.” Write “do not diagnose” into a prompt, and the day the model misses it, skims past it, or has it diluted by context, the defense is gone. So the rules were layered by whether they can be enforced in code:

  • L0, the global baseline: identity and channel security, risk grading, human confirmation for money and real-name actions, no shell, auditing, general data-egress principles — all enforced by the policy engine, regardless of whether the model has read them, and no domain may loosen them;
  • L1, the domain rule pack: health’s R-H01 to R-H15 (the first action on a red-flag symptom is to urge medical care; unconfirmed data must not be cited by Q&A; rule changes require the owner’s approval, and so on), loaded per domain, and only ever stricter;
  • L2, task SOPs: concrete steps, phrasing, and exception handling, loaded on demand, with versions recorded in the audit log.

Keeping SOPs and rules apart is the crux of this step: procedures change often; the defense line must not change with them. A badly written SOP at worst makes a procedure awkward; but if rules are copied into SOPs, editing a procedure can casually edit away a defense — so an SOP may only cite rule numbers, never reproduce the rule text. Conflicts resolve top-down: if an SOP conflicts with a rule, stop, follow the rule, and flag the SOP for revision. Cross-domain tasks (buying medicine = health + transaction) load multiple packs at once and take the stricter rule item by item; one domain’s confirmation never substitutes for another’s.

Step 8: The Carrier for SOPs — An “Isomorphism Discovery”

With “three rule layers, SOPs loaded on demand” settled, an engineering question remained: what mechanism implements on-demand loading — do we build our own SOP reading and versioning system? That is when something ready-made came into view — a Skill’s progressive disclosure is on-demand loading itself: normally only the description participates in triage matching, and the body is loaded only on a hit; the description is naturally the trigger condition. This is not bending to a format; it is two problems turning out to have the same shape. Following this discovery, several side questions got answers at the same time: metadata goes in the file header (domain, role, tool whitelist, risk, version, cited rule numbers) for the policy engine to read; deterministic steps go into scripts/ so the model cannot improvise them; the canonical copy lives in the gateway’s domain-pack directory and deploys with the gateway (its audience is the steward runtime), not in the development skill directory, while keeping the generic format — so authoring and maintenance can continue on the same toolchain, Codex. Look for an isomorphism first, then decide whether to build your own — that is the method this step leaves behind.

Step 9: Model Capability — Divide the Work First, Choose Models Second; “Authority” Must Be Taken Apart

When it came to models, the first move was not selection but division of labor. The health domain contains two entirely different kinds of work: extraction is copying work — moving numbers out of reports accurately; it needs to be cheap, stable, and local-capable (originals never leaving the intranet is a hard constraint), and a local general-purpose 8B model is quite enough — a medical model has no advantage here; Q&A is judgment work — it needs depth of medical knowledge and a sense of proportion, which is what “DeepSeek isn’t authoritative enough” actually pointed at. Discuss selection with the two kinds of work mixed together and you will inevitably choose wrong.

Next, the word “authority” was taken apart: half of it is the model’s own medical capability, and the other half is whether the answer can produce verifiable evidence. Once split, the decisive metric for selection changed — not who answers more fluently, but whose answers carry sources. This judgment was planted before looking at any test results, and it did end up being the basis of the final decision.

The selection direction was reversed once midway by the user: the original plan was local small medical models first; the decision was changed to go straight to Baichuan’s cloud for Q&A. In hindsight the reversal holds up: the Q&A context pack was always designed to leave the network only after de-identification (the design already allowed it), and a flagship cloud medical model’s capability ceiling is far above what a small local model can run; while extraction, because of the originals red line, must stay local — the local-vs-cloud argument was never a matter of stance, but of asking, task by task, “may this data leave, and is the capability sufficient.”

The verification process itself is part of the methodology; three points, compressed: First, in the first test round everything returned 401 — read the error code before concluding anything: five models plus the control group all reporting the same “key is empty” can only mean the parameter never got sent, nothing to do with permissions or balance, which avoided a blind top-up and a wrong attribution. Second, the Plus models refuse non-medical questions — at first glance a defect, from another angle exactly the domain isolation the role requires: whether something is a flaw or a feature depends on where it is placed. Third, after the user brought in the DeepSeek flagship’s answer to the same question as a control, the selection rationale was rewritten on the spot: the general flagship is not weak, and the medical model’s irreplaceability narrowed to evidence anchoring, clinical-detail precision, and domain isolation. A conclusion may be changed by new evidence, and the change itself is put on record — that matters more than the conclusion, because the next selection still depends on this method. Finally, availability was designed in too: a three-level fallback chain (M3-Plus → M3 → DeepSeek), with the footer honestly naming the model that actually answered — acknowledging that a single point will fail, and deciding in advance what happens then, and how the family is told.

Step 10: The Cadence of Expansion — Growing Along the Lifecycle, and Three Refusals

Looking back at the feature map, expansion did not follow “add whatever comes to mind,” but grew section by section along the data lifecycle: in (unified entry, the feel log) → stored (records and database) → used (the five loops, the ledgers, patrol) → asked (the on-duty answerer + the medical model) → continuous (the hardware-collection proposition). Each section is a gap exposed by the previous one: without records, Q&A has no context; without loops, the records are dead data; without continuous collection, the records hold only yearly snapshots, no daily baseline. The hardware proposition comes last precisely because it depends on everything before it standing — observations had already reserved source-type and device markers, so continuous data needs no schema change when it arrives; that is Step 3’s foresight being redeemed at Step 10.

Equally important are the three refusals to expand — half of foresight is recognizing fake channels: Ant Afu (only a consumer app; its “open platform” is institutional onboarding — fine for a family’s own use, but there is no door for system integration), JD Health and iFlytek Spark Medical (institution-only), and local small models for Q&A (capability ceiling too low — reversed by the user before verification, and proven right after). Every refusal has its reason recorded in the documents — so that nobody in the future (including ourselves) proposes it again and repeats the research.

3. Thinking Habits That Run Through It All (Reusable for the Next Domain Pack)

  1. Reason backward from the scenario, not forward from the technology. Every design must point back to some family fact; one that cannot is self-indulgence.
  2. Decide what not to do first. The red lines (no diagnosis, no fabrication, nothing original leaves the intranet) and the refusal list (fake channels, fake needs) are filed at the same time as the feature list, and taken just as seriously.
  3. Constraints precede features. Privacy permissions, reminder restraint, and confirmation discipline were all fixed before the features; features grow inside the constraints, rather than having constraints bolted on afterward.
  4. Leave structure for “what will change,” and lists for “what we don’t have.” Dictionary-driven design, versioning, and retained raw extractions are the former; the missing-information list is the latter — the system must explicitly know what it does not know.
  5. Pilot to verify a hypothesis, then roll out. One report validates the template, one question validates the model, one indicator validates the hardware chain — bet small each time, and scale only after winning.
  6. When new evidence arrives, change the conclusion — and keep the trace. The rewritten selection rationale and the corrected pilot approach were both written back into the documents; documents are the ledger of thinking, not promotional copy.

4. Status and Open Items (Compressed; Details in Each Document’s Header)

The system is live: the records and database, the four roles and rule system, and the Baichuan Q&A (M3-Plus by default) were all implemented by Codex directly from the documents as delivered, and the pilot report ingest has been tested. Honestly unfinished: the charter rules have not been specially tested (the decision is to verify them gradually in practice; values left undecided in the documents, such as the health push cap, have become de facto defaults); the Baichuan integration acceptance checklist and the same-question spot checks (including trap questions) have not been run, and whether a source-list field exists behind the citation anchors is still to be confirmed against the development delivery notes; SOP-01 through SOP-10 are not yet written as files (the SOP-01 pilot already ran through its outline, so its conditions for finalization are met); the household-wide rollout (baseline interviews, bulk import of past years’ reports, per-person permission confirmation) has not started; continuous hardware collection has only the framework and selection research, with the sample build waiting on two family facts (the elder’s chronic conditions, and the existing device inventory) still to be collected.

Appendix: A Minimal Timeline

Nov 3 — kickoff and positioning, working order, records architecture v0.1, pilot finalized → Nov 4 — database and application layer, department charter and the four roles, three rule layers and the SOP carrier, scenario expansion, model research and reversal, three rounds of Baichuan live testing and finalization, integration requirements delivered, hardware-proposition research → Nov 5 — documents handed to Codex as-is for development, go-live confirmed, status backfilled, this retrospective.