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.
Opening prompt
The interviewer gives a deliberately broad application problem. The candidate creates structure before drawing boxes.
I’ll optimize for trustworthy decision support, not diagnosis. First I’ll clarify who is allowed to see and act, whether a source is authoritative for each fact, how late claims/labs arrive, identity-error tolerance, offline duration, and whether a recommendation can trigger an order or only suggest review. My safety invariant is that every opportunity shows the supporting and contradicting facts, their source and freshness, the policy/model version, and an explicit uncertainty state.
I’ll separate source observations, resolved longitudinal facts, recommendation candidates, clinician decisions, and downstream actions. Collapsing those into one mutable patient row makes identity repair, audit, and feedback impossible.
Scope the contract
Actors, boundaries, correctness, latency, and what deliberately waits for a later phase.
Define actors, requirements, NFRs, and exclusions for phase one.
Actors: clinicians in the field, care coordinators, supervisors, member-identity stewards, clinical-policy owners, data stewards, security/compliance, and SREs. Required: source ingestion and watermarks; conservative identity resolution; bitemporal timeline; effective-dated rule and model evaluation; deduplicated opportunities with evidence and contraindications; visit package prefetch; encrypted offline view and action outbox; synchronization; clinician accept/dismiss/defer with reason; downstream task creation; and quality/impact monitoring.
Mock NFRs: 60,000 visits/day; 99.95% online control-plane availability; scheduled packages ready 30 minutes before 99% of visits; online recommendation p95 under two seconds; offline for 72 hours; RPO under five minutes and RTO under one hour for actions. Out of scope: autonomous diagnosis, medication prescribing, automatic claim denial, replacing EHRs, and unsafe probabilistic identity merges.
Field clinicians, coordinators, identity/data stewards, clinical-policy owners, supervisors, compliance, and SRE.
Six-source ingest, identity resolution, bitemporal timeline, recommendations with evidence, offline packages, sync, feedback/tasks.
Conservative identity, explicit watermarks, 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, tenant/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.
Back-of-the-envelope math
These numbers are supplied mock constraints. Change them to see where the design bends.
Assume 60,000 visits/day, 8,000 clinicians, a 3 MB encrypted visit package, 20× traffic peak, roughly eight visits/clinician/day, and three offline days. Calculate from the fleet totals rather than the rounded per-clinician figure.
Average visit preparation is 0.694/s; a 20× peak is 13.9/s. Packages create 180 GB/day of payload and roughly 5.4 TB/month before CDN/cache effects. The exact mean is 7.5 visits/clinician/day, so three offline days require 67.5 MB of encrypted package payload per device on average—about 72 MB if capacity planning rounds to eight visits—plus app overhead. That is manageable, but deletion and key revocation matter.
If opportunity generation takes 400 ms of CPU/visit, peak work is about 5.6 cores; with 40% headroom the calculator rounds to eight, and I would provision eight to ten plus tenant/region reserve. Scale pressure comes from fan-in, member timeline cardinality, package freshness, and synchronized field bursts more than request QPS. Content-addressing can deduplicate unchanged evidence across rescheduled packages only inside the same tenant, region, authorization, and key domain; cross-tenant deduplication would create isolation and side-channel risk.
Visit preparation and offline footprint
Data, keys, and APIs
Names turn ambiguous boxes into durable contracts. The primary keys below are part of the answer.
Give the records, primary keys, and API contract. How do you represent uncertainty and late facts?
A SourceObservation is immutable 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 watermarks, rule/model/calibration manifest, severity, expiry, and explanation. A clinician action points to the exact opportunity version and includes offline device sequence plus idempotency key. A new lab supersedes the opportunity rather than rewriting what the clinician saw. All keys and secondary indexes are physically prefixed by tenant and residency region even when the table abbreviates them; member or visit IDs are never treated as globally safe partition keys.
Records and access paths
| Record | Primary / idempotency key | Important immutable fields | Main access path |
|---|---|---|---|
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 | (tenant_id, member_id, fact_type, fact_id, version) | valid/system time, contributing observations, confidence/authority | timeline by member/time/type |
OpportunityVersion | (tenant_id, member_id, opportunity_id, version) | evidence/contra facts, watermark vector, policy/model manifest, expiry | active visit list; reverse fact impact |
VisitPackage | (tenant_id, 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 | (tenant_id, opportunity_id, action_version) | business key, payload digest, status, receiver receipt | outbox/reconciliation |
External contract
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 + versionsEnd-to-end architecture
Control truth stays authoritative; expensive or probabilistic work is asynchronous, bounded, and replayable.
Walk one scheduled visit through the architecture.
Connectors capture CDC or batch extracts into immutable source zones with contract checks and per-source watermarks. An identity service creates deterministic links from trusted identifiers and a steward queue for ambiguous cases. A timeline builder materializes bitemporal member facts. On source change or visit schedule, a durable orchestrator evaluates effective-dated 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 watermark vector, opportunity versions, policy manifest, expiry, and authorization scope; it encrypts and signs the package. The mobile app verifies it, keeps PHI in hardware-backed storage, records actions in a monotonic local outbox, and syncs through an idempotent gateway. Server-side reconciliation revalidates identity, freshness, opportunity state, and user authority before creating downstream tasks.
Identity and freshness are clinical facts
Conservative links and source-specific watermarks 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 namespace IDs as immutable anchors, then deterministic high-confidence matches such as verified member ID plus date of birth. Probabilistic 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 lineage to every derived fact, opportunity, package, and action.
Freshness is a vector, not one timestamp: each source has event-time watermark, 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 lineage. Policy decides whether stale/absent data causes abstention, lower confidence, or a caution—not a guessed negative.
| 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, monotonic device sequences, explicit state transitions, and reconciliation 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 an immutable read snapshot; offline writes are commands in a local outbox with device ID, monotonically increasing sequence, opportunity version, user, captured time, and idempotency 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 reconciliation. The UI shows the newer evidence and asks the clinician to confirm or withdraw. A downstream task uses a business idempotency key and outbox; an unknown timeout is reconciled by key. Package expiry prevents indefinite use, but emergency offline access has explicit scope and audit.
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
}Failure injection I
The design changes under pressure. The candidate preserves correctness before convenience.
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 lineage 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 idempotent reconciliation; 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.
Failure injection II
Partial failure, stale inputs, duplication, and unknown external outcomes are normal distributed states.
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 watermark and expected cadence; when pharmacy exceeds policy lag, affected opportunities become STALE_SOURCE and high-risk recommendations abstain. The package manifest exposes the stale watermark 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 reconciled.
Security and operations
Tenant isolation, backpressure, observability, evaluation, SLOs, recovery, and cost belong in the core design.
Cover consistency, backpressure, tenant isolation, PHI security, observability, and disaster recovery.
Strong consistency protects identity link publication, opportunity state, authorization, command acceptance, and downstream action intent. Timeline/search projections are eventual and labeled with watermarks. CDC and job delivery are at least once; unique source-event and stage keys make them idempotent. Per-source queues isolate stalled connectors; package generation reserves capacity for next-hour visits and sheds background recomputation first.
Tenant 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 SLO burn. Restore immutable events plus manifests into a warm region and reconcile device command high-water marks.
Event-time and ingest-time watermarks, 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.
CAS identity/opportunity state; at-least-once idempotent CDC; monotonic device commands; outbox external tasks.
Tenant+region keys everywhere, ABAC purpose/case, hardware-backed device key, minimal PHI, remote key revocation.
Event log + immutable manifests rebuild projections; warm control plane; reconcile 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 point-in-time replay; show explanations to a small clinician group without ranking; canary low-risk opportunity types; then enable downstream task creation after dual-run reconciliation. 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 abstention; 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 deterministic matches.
- Build point-in-time 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 idempotent dual-run reconciliation.
- 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, bitemporal 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 vector 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 idempotency keys.
- Separated authoritative state from derived indexes and model output.
- Explained consistency, retries, backpressure, and unknown outcomes.
- Revised the design after both failure injections.
- Covered tenant isolation, secrets, least privilege, deletion, and audit.
- Named golden signals, domain quality metrics, rollout gates, and rollback.