Skip to content
Logo

Domain relationships

A patient represents the person. A case holds one oncology episode and its workspace. Sources, confirmed chart state, AI drafts, and clinician decisions remain separate records so a new document or generated answer cannot silently change what the chart says.

The clinical record

One organization has many patients, each patient can have many cases, and each case can have many original sources, confirmed patient-state versions, clinician-recorded encounters, and independent case Copilot threads.

Read each arrow as a relationship: one parent can have zero or many children. Explore the record.

RecordWhat it means
PatientThe person, owned by one organization, which may have several case workspaces.
CaseThe oncology episode. It groups the chart, source material, drafts, and review decisions.
EncounterAn actual visit or contact recorded by a clinician. A case can have at most one encounter in progress.
Patient sourceAn uploaded, pasted, or explicitly imported document. Its original source version stays available to historical runs and citations.
Patient-state versionAn immutable snapshot of clinician-confirmed fact revisions. A new confirmation creates a new version.
Case Copilot threadOne conversation within the case. A case can have many independent threads.

The chart is not the document inventory. Extraction proposes findings; a clinician's review or direct edit determines which facts enter a confirmed snapshot. Removing a source from active use does not erase the version behind an earlier result.

Runs and saved versions

A workflow run can pin one confirmed state and register many evidence records, each linked to an exact source version. Drafting runs back artifact versions, treatment artifacts can back clinician-selected plan versions, and Copilot replies retain their own producing run.

A saved version keeps its history even after the case changes. Explore the version links.

A workflow run records one AI request. Its progress changes as work proceeds, while its captured inputs stay fixed. It may pin a confirmed patient-state version or explicitly run without one, according to the workflow. Exact source selections also belong to that captured basis.

An artifact groups one output type in a case, such as a workup assessment or treatment draft. Its artifact versions preserve generated drafts and clinician revisions. Every version retains its producing run; a clinician edit can retain the original run while recording a new author and content version.

A plan version records a clinician's treatment selection or revision. It belongs to a care-plan history and points to the exact treatment artifact used. Only one version in that history is active at a time. Selecting a plan does not order or administer treatment.

An evidence record connects a run's citation alias to an exact source version and passage. An export receipt connects a reviewed artifact version to the exact bytes exported, their hash, format, and exporting clinician. These records answer different questions: what supports the result, and what left the application.

Shared documents and general conversations

Some work belongs to the organization or clinician without belonging to a case:

RecordScope and relationship
Pathway, protocol, or internal trialOrganization-managed Library content with preserved versions that a run can pin.
Personal reference or preferenceBelongs to the clinician within the organization. A reference is not a patient source or chart fact.
General Copilot threadBelongs to the organization and creating clinician; it has no case. Its replies retain their producing runs.
External identifierAssociates an external system and value with a patient, encounter, source document, or export receipt in the same organization.

Library is a view across these permitted sources. It does not move patient documents out of their case or make personal references available to everyone.

Where the records live

The relational record lives in OrganizationCell("primary") through Drizzle. Files SDK stores large immutable bytes in a separate S3-compatible object store. Local prepared files are disposable copies.

The schema is under apps/oncobrain/src/lib/db/schema/: cases.ts, patient-state.ts, workflows.ts, artifacts.ts, copilot.ts, and exports.ts define the relationships above. clinical-guidance.ts, internal-trials.ts, and personal-references.ts hold the corresponding Library records.

User journeys shows when these records are created. From evidence to output follows their source and citation links through an AI request.