A care organization misses important opportunities because clinical, claims, pharmacy, scheduling, lab, and care-management data live in six systems. Design a platform that builds a longitudinal member view, recommends explainable care opportunities before home visits, works offline, and captures clinician feedback.
Care, With Context
Design a longitudinal clinical recommendation engine across six legacy systems, with identity and freshness you can explain, offline home visits, and a measured clinician feedback loop.
The answer map
Do not memorize every box. Remember this path and rebuild the answer from it.
Understand the problem
Restate the goal in plain English. Name the one thing the system must never get wrong.
This system helps clinicians. It does not diagnose a patient. Every recommendation must show the facts for it, the facts against it, where those facts came from, and how old they are. If identity or data is uncertain, the screen must say so.
I will keep five things separate: raw facts from each source, the patient identity links, the recommendation, the clinician’s decision, and any follow-up task. That separation lets us fix a wrong patient match without rewriting history.
Step 1 · Set the scope
Name the users, must-have features, speed and safety goals, and what is out of scope.
Define actors, requirements, NFRs, and exclusions for phase one.
Field clinicians view recommendations and record what they did. Care coordinators follow up. Identity and data stewards fix uncertain patient matches and stale sources. Clinical-policy owners approve the rules. Version one joins six sources carefully, builds a dated patient timeline, finds care opportunities, explains the supporting and opposing facts, prepares an encrypted offline visit package, syncs the clinician’s action, and creates an approved follow-up task.
For this mock, we support 60,000 visits a day. Packages should be ready 30 minutes before 99 out of 100 visits, and online recommendations should load within two seconds for 95 out of 100 requests. The app works offline for 72 hours. We are not diagnosing, prescribing medication, denying claims, replacing electronic health record systems, or automatically joining uncertain identities.
Field clinicians, coordinators, identity/data stewards, clinical-policy owners, supervisors, compliance, and SRE.
Six-source ingest, identity resolution, time-aware timeline, recommendations with evidence, offline packages, sync, feedback/tasks.
Conservative identity, explicit freshness markers, observations ≠ resolved facts, versioned opportunities, human authority.
60K visits/day, 99% packages 30 min early, online p95 <2 s, 72 h offline, control plane 99.95%.
PHI-minimal packages, customer/region partition, device keys and attestation, purpose-bound access, break-glass.
Diagnosis, prescribing, automatic denial, EHR replacement, unsafe auto-merge, causal claims from acceptance alone.
Step 2 · Do the useful math
Estimate only what changes the design. After each number, say why it matters.
Assume 60,000 visits/day, 8,000 clinicians, a 3 MB encrypted visit package, 20× traffic peak, eight visits/clinician/day, and three offline days. Calculate.
Sixty thousand visits a day is 0.694 package builds a second on average and about 14 a second at a 20-times peak. Packages create 180 GB a day, roughly 5.4 TB a month before cache copies. At eight visits a day for three offline days, each clinician stores about 72 MB of encrypted protected health information (PHI). That is small enough for a device, but remote key removal and deletion still matter.
If one package needs 400 milliseconds of processor time, the peak needs about 5.6 processor cores. I would start with eight to ten plus spare capacity for each customer and region. The harder problem is combining many data sources and keeping tomorrow’s visits fresh, not raw queries per second. Reusing unchanged evidence files also avoids downloading the same material for a rescheduled visit.
Visit preparation and offline footprint
Steps 4–5 · APIs and data
Start with the few records the system cannot work without. Then add simple endpoints around them.
Give the records, primary keys, and API contract. How do you represent uncertainty and late facts?
A SourceObservation is write-once and carries source record ID, event/effective time, ingest time, status, and payload digest. A MemberLink maps source person to enterprise member with method, score, evidence, version, and steward state. Uncertain matches remain candidate links and do not join clinical truth. A resolved ClinicalFact preserves contributing observations and both valid-time and system-time.
An OpportunityVersion stores evidence fact IDs, contradictions, source freshness markers, rule/model/calibration version list, severity, expiry, and explanation. A clinician action points to the exact opportunity version and includes offline device sequence plus retry key. A new lab supersedes the opportunity rather than rewriting what the clinician saw.
Records and how we find them
| Record | Main key / retry key | Fields we never overwrite | How we find it |
|---|---|---|---|
SourceObservation | (tenant_id, source_system, source_record_id, source_version) | event/valid time, ingest time, status, payload digest | by source ID; lineage by member candidate |
MemberLink | (tenant_id, link_id, version) | source person IDs, enterprise member ID, method/evidence, steward state | resolve source ID; reverse impact by link |
ClinicalFact | (member_id, fact_type, fact_id, version) | valid/system time, contributing observations, confidence/authority | timeline by member/time/type |
OpportunityVersion | (member_id, opportunity_id, version) | evidence/contra facts, watermark vector, policy/model manifest, expiry | active visit list; reverse fact impact |
VisitPackage | (visit_id, package_version) | content digest, authorization scope, expiry, member-link and watermark manifest | device prefetch; revoke by package ID |
OfflineCommand | (tenant_id, device_id, sequence_no) | user, opportunity version, command, captured time, idempotency key | sync high-water; conflict/replay |
ExternalTaskIntent | (opportunity_id, action_version) | business key, payload digest, status, receiver receipt | outbox/reconciliation |
Simple API
POST /v1/source-events source namespace + event id
GET /v1/members/{id}/timeline?as_of= watermark vector included
GET /v1/visits/{id}/opportunities package or online manifest
POST /v1/visits/{id}:prepare Idempotency-Key: visit+schedule-version
GET /v1/visit-packages/{id} signed encrypted delta
POST /v1/devices/{id}/sync last_server_seq + commands[]
POST /v1/opportunities/{id}/actions If-Match: opportunity_version
POST /v1/member-links/{id}:split steward decision + impact job
GET /v1/opportunities/{id}/explanation facts + watermarks + versionsSteps 3 and 6 · Draw, then follow one request
Explain the system in a few parts. Then follow one real request from the user to the final result.
Walk one scheduled visit through the architecture.
Connectors capture change-data feed or batch extracts into write-once source zones with contract checks and per-source freshness markers. An identity service creates fixed-rule links from trusted identifiers and a steward queue for ambiguous cases. A timeline builder builds time-aware member facts. On source change or visit schedule, a durable workflow coordinator evaluates with start and end dates rules and calibrated models, then an explanation service assembles supportive, contradictory, and missing evidence.
Thirty minutes before a visit, a package service pins a member-link version, fact freshness marker vector, opportunity versions, policy version list, expiry, and authorization scope. It encrypts and signs the package. The mobile app verifies it, keeps PHI in hardware-backed storage, records actions in an always-increasing local database-backed event queue, and syncs through a retry-safe gateway. Server-side cross-checking revalidates identity, freshness, opportunity state, and user authority before creating downstream tasks.
Identity and freshness are clinical facts
Conservative links and source-specific freshness markers make uncertainty visible and repairable.
Deep dive into longitudinal identity and freshness. Names and addresses collide. Claims arrive 45 days late. An EHR sends corrections.
I use source-specific IDs from each source as write-once anchors, then fixed-rule high-confidence matches such as verified member ID plus date of birth. AI-based and uncertain matches only propose a link with interpretable evidence. High-risk merges require a steward, and one-to-many contradictions block. The member graph is versioned, so a split or merge has reverse data history to every derived fact, opportunity, package, and action.
Freshness is a vector, not one timestamp: each source has event-time freshness marker, ingest time, expected cadence, completeness status, and known lag distribution. An opportunity can require “lab through T, pharmacy through T−1d, claims through T−45d.” Explanations show these limits. Corrections append a reversed/superseding observation and recompute only impacted members using data history. Policy decides whether stale/absent data causes stopping when unsure, lower confidence, or a caution—not a guessed negative.
Two records share the name “Sam Lee,” but one has a different birth date. We do not merge them just because the names match. We keep the uncertain record separate and ask for stronger evidence.
| Freshness state | Behavior |
|---|---|
FRESH | Source watermark satisfies opportunity policy. |
EXPECTED_LAG | Known claims delay is shown; rule explicitly tolerates it. |
STALE_SOURCE | Connector missed cadence; affected high-risk logic abstains. |
CONFLICT | Authoritative observations disagree; resolve or route to clinician. |
UNKNOWN_IDENTITY | Do not merge; keep observations out of resolved chart. |
Offline writes are commands, not row copies
Signed snapshots, always-increasing device sequences, explicit state transitions, and cross-checking replace last-write-wins.
Deep dive into offline sync. The clinician edits notes and accepts an opportunity while another coordinator resolves it online.
The package is a write-once read snapshot. Offline writes are commands in a local database-backed event queue with device ID, always-increasing sequence, opportunity version, user, captured time, and retry key. The gateway acknowledges only after durable storage, deduplicates on device sequence, and returns per-command status. Sync may be repeated safely.
We do not last-write-win clinical decisions. The server checks a state machine and authority: notes can merge as separate attributed entries. Duplicate equivalent accepts collapse. Accept versus resolved/cancelled becomes a conflict requiring human cross-checking. The UI shows the newer evidence and asks the clinician to confirm or withdraw. A downstream task uses a business retry key and database-backed event queue. An unknown timeout is cross-checked by key. Package expiry prevents indefinite use, but emergency offline access has explicit scope and audit.
A nurse closes a care gap while offline. The server then receives a lab result that changes the recommendation. When the tablet reconnects, we recheck the action against the new lab result instead of copying the old screen over the new truth.
command = {
tenant_id, device_id, device_sequence, user_id,
visit_id, opportunity_id, expected_opportunity_version,
action, reason_code, captured_at, idempotency_key,
package_digest, device_signature
}What if it breaks?
Protect the correct data first. Then contain the problem, recover, and explain what users see.
You discover that two people were wrongly merged for three weeks. Recommendations were viewed and two downstream tasks were created.
I freeze the disputed link and stop new package generation. A steward creates a split version. Reverse data history enumerates mixed facts, opportunity versions, packages, accesses, clinician actions, and external tasks. We do not erase the original audit. Correct member timelines and opportunities are regenerated under new identities.
Unacted recommendations are revoked. Viewed or acted cases create privacy/safety incidents with minimum-necessary notification and supervisor workflow. External tasks receive correction/cancellation through retry-safe cross-checking. Unknown outcomes stay open. We analyze whether matching evidence or threshold caused the merge and add a canary/adversarial pair to the identity golden set. Identity false-merge rate is a hard safety gate, not an average matching score.
What if timing gets messy?
Retries, delayed messages, and two updates at once are normal. State the rule that keeps one clear result.
The pharmacy connector silently stalls. Mobile packages still build green, and 4,000 clinicians are offline when a medication contraindication arrives.
Green package construction is not fresh data. A source-silence detector compares event freshness marker and expected cadence. When pharmacy exceeds policy lag, affected opportunities become STALE_SOURCE and high-risk recommendations stop and ask for human review. The package version list exposes the stale freshness marker and the UI cannot hide it.
The contraindication produces a priority revocation message. Connected devices invalidate package/opportunity IDs immediately. Offline devices cannot be reached, so server-side downstream actions are blocked on sync and the app shows a prominent “reconnect required” gate for expired high-risk content. For truly offline care, policy defines a safe fallback such as clinician verification from the source system—not false confidence. On reconnect, new facts arrive before pending commands are cross-checked.
Keep it safe and running
Cover overload, security, monitoring, and disaster recovery in that order.
Cover consistency, overload control, customer isolation, PHI security, monitoring, and disaster recovery.
Always reading the newest confirmed value protects identity link publication, opportunity state, authorization, command acceptance, and downstream action intent. Timeline/search read-ready copies are allowed to be briefly stale and labeled with freshness markers. Change-data feed and job delivery are at least once. Unique source-event and stage keys make them retry-safe. Per-source queues isolate stalled connectors. Package generation reserves capacity for next-hour visits and sheds background recomputation first.
Customer and region are mandatory partition keys in databases, queues, caches, indexes, object paths, and telemetry. Service identities are purpose-scoped. PHI uses envelope encryption, short-lived tokens, device attestation, remote key revocation, minimal offline retention, and redacted logs. Monitor connector freshness/completeness, identity candidate/false-merge rates, timeline lag, opportunity yield/override/outcome by slice, package readiness/age, sync backlog/conflicts, downstream unknowns, access anomalies, and service target burn. Restore write-once events plus version lists into a warm region and cross-check device command high-water marks.
Event-time and ingest-time freshness markers, silence, contract errors, duplicate events, completeness controls.
Identity false-merge/split, evidence correctness, stale/contradictory opportunity, acceptance reasons, outcomes by slice.
Package ready/age, download failures, offline duration, sync lag, conflicts, command duplicates, revocation reach.
Compare-and-set safety check identity/opportunity state. At-least-once retry-safe change-data feed. Always-increasing device commands. Database-backed event queue external tasks.
Customer+region keys everywhere, access policy purpose/case, hardware-backed device key, minimal PHI, remote key revocation.
Event log + write-once version lists rebuild read-ready copies. Warm coordinator. Cross-check device sequences and downstream tasks.
Rollout and trade-offs
A credible production answer defines how it earns trust and how it retreats safely.
How do you deploy this safely and measure whether recommendations help?
First run identity and freshness dashboards only. Then construct timelines and compare with source experts. Shadow opportunities against historical visits with time-safe replay. Show explanations to a small clinician group without ranking. Canary low-risk opportunity types. Then enable downstream task creation after dual-run cross-checking. Keep a kill switch per rule/model/source slice.
Measure evidence correctness, opportunity precision/recall on adjudicated review, clinician acceptance/dismissal reasons, action completion, time saved, duplicate alerts, subgroup disparity, and—where causal design permits—care outcomes versus matched or randomized controls. Acceptance alone is not health benefit and can reflect alert fatigue. The trade-off is freshness/coverage versus safe stopping when unsure. I expose staleness and miss some suggestions rather than fabricate a complete chart.
- Run source-contract and freshness dashboards first.
- Validate candidate identity links with stewards. Auto-publish only fixed-rule matches.
- Build time-safe historical timelines and test leakage.
- Shadow recommendations against past visits.
- Show evidence-only view to a small clinician cohort.
- Canary low-risk opportunity types with explicit suppress/rollback controls.
- Enable downstream tasks only after retry-safe dual-run cross-checking.
- Measure outcomes with controls. Never equate acceptance with benefit.
One-minute spoken recap
Practice this synthesis until it sounds conversational rather than memorized.
One minute—summarize.
I’ll summarize identity, time-aware facts, explainable opportunities, offline command safety, and outcome evaluation.
Reference shelf
Definitions, traps, and the final checklist stay outside the timed mock.
- Bitemporal fact
- A fact with both business-valid time and system-recorded time.
- Candidate link
- A possible identity match awaiting stronger evidence or steward approval.
- CDC
- Change data capture: incremental source changes delivered to downstream systems.
- Contraindication
- Evidence that a proposed action may be inappropriate or harmful.
- Freshness vector
- One watermark per required source rather than a misleading global timestamp.
- Hardware-backed key
- A device key protected by secure hardware and difficult to export.
- Identity split
- Correction that separates source records incorrectly merged into one member.
- Offline outbox
- Durable ordered local commands waiting to synchronize.
- Opportunity
- Explainable, reviewable care suggestion; not an autonomous diagnosis.
- Purpose binding
- Authorization tied to why data is accessed, not only who accesses it.
- Reverse lineage
- Lookup from a source/link change to every derived item it affected.
- Watermark
- A declared boundary through which source data is believed complete.
- Using fuzzy name matching to auto-merge clinical identities.
- Treating missing claims as proof that care did not occur.
- Showing “updated today” when one critical source is 45 days stale.
- Using last-write-wins for conflicting clinical actions.
- Letting an expired offline package trigger a new downstream task.
- Syncing actions before newly arrived contraindications.
- Embedding all PHI in a shared cross-tenant meaning-based search index.
- Calling clinician acceptance a health outcome.
- Mutating past recommendations after an identity repair.
- Relying on exactly-once mobile networks instead of device sequences.
- Generating every package on demand during the morning burst.
- Logging raw member facts in telemetry.
- Clarified actors, authority, business harm, and out-of-scope.
- Did correct BOTEC and named the variable that changes the architecture.
- Defined stable IDs, versions, access paths, and retry keys.
- Separated source of truth state from derived indexes and model output.
- Explained consistency, retries, overload control, and unknown outcomes.
- Revised the design after both failure injections.
- Covered customer isolation, secrets, least privilege, deletion, and audit.
- Named golden signals, domain quality metrics, rollout gates, and rollback.