Dev Reference

Coding & CDS

Diagnosis and procedure coding (ICD-10-CM, SNOMED CT, CPT, HCPCS), CDS Hooks decision support, order sets, code set versioning, and HCC risk-adjustment re-capture.

Data Classification: Mixed scoping. Diagnosis and Procedure are global (patient-centric, SourceOrganizationID). OrderSet and CdsRule are org-scoped (OrganizationID partition key). CodeSet, CodeSetVersion, and CodeMapping are global reference data (no OrganizationID). CdsHookEvent is org-scoped. Trust tiers range T0 (reference) through T3 (clinical). See Data Model for ownership conventions and Decisions for dual-coding rationale.

Diagnosis P0 — Trust Tier T3

A coded diagnosis on a patient, optionally linked to an encounter. Dual-coded (ICD-10-CM + SNOMED CT). Supports HCC category tagging for risk-adjustment re-capture workflows.

Schema

FieldTypeRequiredPKFKNotes
DiagnosisIDUUIDYesYes
PatientIDUUIDYesPatient
EncounterIDUUIDNoEncounterOptional; standalone diagnoses allowed
CodeSetVersionIDUUIDYesCodeSetVersionLinks to active ICD-10-CM version
Icd10CodeString(50)YesICD-10-CM
SnomedCodeString(50)NoSNOMED CT (dual coding)
OnsetDateTimeUTCNo
AbatementDateTimeUTCNo
ClinicalStatusString(50)Yesactive | recurrence | relapse | inactive | remission | resolved
VerificationStatusString(50)Yesunconfirmed | provisional | differential | confirmed | refuted | entered-in-error
HccCategoryString(50)NoCMS HCC category; nullable for non-HCC diagnoses
IsChronicBoolYesFlags chronic conditions for annual HCC re-capture
EvidenceUriStringNoLink to supporting clinical evidence
SourceOrganizationIDUUIDYesOrganizationOrg that documented this diagnosis
CreatedByUserIDUUIDYesUserAudit
CreatedDateTimeUTCDateTimeUTCYesAudit
UpdatedByUserIDUUIDYesUserAudit
UpdatedDateTimeUTCDateTimeUTCYesAudit
IsDeletedBoolYesSoft-delete

RBAC

Role (Tier)Access
Patient (10)Read own diagnoses (display name only)
FrontDesk (30)None
MA / RN (40)Read
Biller (51)Read; flag HCC re-capture
Clinician (60)Full CRUD
PracticeMgr (70)Read
EditAMI (90+)Schema management

Procedure P0 — Trust Tier T3

A coded procedure performed during an encounter. Supports CPT, HCPCS, modifiers (1-4), E&M level with MDM rationale, and CY2026 AMA AI-augmented flag.

Schema

FieldTypeRequiredPKFKNotes
ProcedureIDUUIDYesYes
PatientIDUUIDYesPatient
EncounterIDUUIDYesEncounter
CodeSetVersionIDUUIDYesCodeSetVersionLinks to active CPT/HCPCS version
CptCodeString(50)NoNullable when only HCPCS applies
HcpcsCodeString(50)No
Modifier1String(50)No
Modifier2String(50)No
Modifier3String(50)No
Modifier4String(50)No
EmLevelString(50)NoE&M level (99211-99215, etc.)
MdmRationaleTextNoMedical Decision Making rationale for E&M
IsAiAugmentedBoolYesCY2026 AMA flag for AI-assisted coding
PerformedDateTimeUTCYes
StatusString(50)Yespreparation | in-progress | not-done | completed | entered-in-error
SourceOrganizationIDUUIDYesOrganizationOrg that performed this procedure
CreatedByUserIDUUIDYesUserAudit
CreatedDateTimeUTCDateTimeUTCYesAudit
UpdatedByUserIDUUIDYesUserAudit
UpdatedDateTimeUTCDateTimeUTCYesAudit
IsDeletedBoolYesSoft-delete

RBAC

Role (Tier)Access
Patient (10)Read own procedures (display name only)
FrontDesk (30)None
MA / RN (40)Read
Biller (51)Read & edit codes/modifiers/E&M
Clinician (60)Full CRUD
PracticeMgr (70)Read
EditAMI (90+)Schema management

OrderSet P1 — Trust Tier T2

A reusable template of orders (labs, meds, referrals) triggered by a diagnosis code. Contains FHIR R4 order stubs.

Schema

FieldTypeRequiredPKFKNotes
OrderSetIDUUIDYesYes
NameString(100)Yes
DescriptionTextNo
VersionString(100)Yes
TriggerIcd10CodeString(50)NoICD-10-CM trigger
TriggerSnomedCodeString(50)NoSNOMED CT trigger
OrderItemsJsonTextYesFHIR R4 order stubs (JSON array)
IsActiveBoolYes
OrganizationIDUUIDYesOrganizationPartition key
CreatedByUserIDUUIDYesUserAudit
CreatedDateTimeUTCDateTimeUTCYesAudit
UpdatedByUserIDUUIDYesUserAudit
UpdatedDateTimeUTCDateTimeUTCYesAudit
IsDeletedBoolYesSoft-delete

RBAC

Role (Tier)Access
Patient (10)None
FrontDesk (30)None
MA / RN (40)Read
Clinician (60)Read & use (trigger order set)
PracticeMgr (70)Full CRUD
EditAMI (90+)Schema management

CdsRule P0 — Trust Tier T2

A CDS Hooks rule definition. Supports multiple hook types, rule kinds (DDI, drug-allergy, HCC recapture, E&M suggest, etc.), with expressions in CQL or JSON-Logic. HTI-1 DSI-flagged rules carry a ModelCardUri.

Schema

FieldTypeRequiredPKFKNotes
CdsRuleIDUUIDYesYes
RuleFamilyIDUUIDNoGroups related rule versions
NameString(100)Yes
HookTypeString(50)Yespatient-view | order-sign | order-select | encounter-discharge | medication-prescribe | problem-list-item-create
RuleKindString(50)Yesddi | drug-allergy | drug-disease | dose-range | hcc-recapture | em-level | order-set | em-suggest | other
SeverityString(50)Yesinfo | warning | critical
ExpressionTextYesCQL or JSON-Logic rule body
VersionString(100)Yes
EffectiveDateDateTimeUTCYes
RetiredDateDateTimeUTCNoNull = active
OverrideThresholdDecimalNo0.0 - 1.0; confidence below this allows override
IsAiDsiBoolYesHTI-1 Decision Support Intervention flag
ModelCardUriStringNoLink to model card (when IsAiDsi = true)
OrganizationIDUUIDYesOrganizationPartition key
CreatedByUserIDUUIDYesUserAudit
CreatedDateTimeUTCDateTimeUTCYesAudit
UpdatedByUserIDUUIDYesUserAudit
UpdatedDateTimeUTCDateTimeUTCYesAudit
IsDeletedBoolYesSoft-delete

RBAC

Role (Tier)Access
Patient (10)None
FrontDesk (30)None
MA / RN (40)Read
Clinician (60)Read; override with reason
PracticeMgr (70)Full CRUD (configure rules)
EditAMI (90+)Schema management

CodeSet P1 — Trust Tier T0

A reference code system (ICD-10-CM, CPT, HCPCS, SNOMED CT, etc.). Global data, no org partition.

Schema

FieldTypeRequiredPKFKNotes
CodeSetIDUUIDYesYes
NameString(100)Yese.g. "ICD-10-CM", "CPT"
OidString(50)YesHL7 OID
SystemUriStringYesFHIR CodeSystem URI
StewardString(50)Yese.g. "CMS", "AMA", "NLM"
IsLicensedBoolYesCPT is licensed; ICD-10-CM is not
CreatedByUserIDUUIDYesUserAudit
CreatedDateTimeUTCDateTimeUTCYesAudit
UpdatedByUserIDUUIDYesUserAudit
UpdatedDateTimeUTCDateTimeUTCYesAudit
IsDeletedBoolYesSoft-delete

RBAC

Role (Tier)Access
All clinical rolesRead
EditAMI (90+)Full CRUD (manage reference data)

CodeSetVersion P1 — Trust Tier T0

A specific release of a code set (e.g. ICD-10-CM FY2026). Tracks effective dates and supersession. Global reference data.

Schema

FieldTypeRequiredPKFKNotes
CodeSetVersionIDUUIDYesYes
CodeSetIDUUIDYesCodeSet
VersionString(100)Yese.g. "FY2026", "2026.1"
EffectiveDateDateTimeUTCYes
SupersededDateDateTimeUTCNoNull = current version
SourceUriStringNoDownload URL for code set content
CreatedByUserIDUUIDYesUserAudit
CreatedDateTimeUTCDateTimeUTCYesAudit
UpdatedByUserIDUUIDYesUserAudit
UpdatedDateTimeUTCDateTimeUTCYesAudit
IsDeletedBoolYesSoft-delete

RBAC

Role (Tier)Access
All clinical rolesRead
EditAMI (90+)Full CRUD (manage reference data)

CodeMapping P1 — Trust Tier T0

Cross-walks between code set versions (e.g. ICD-10-CM FY2025 to FY2026, SNOMED to ICD-10-CM). Global reference data.

Schema

FieldTypeRequiredPKFKNotes
CodeMappingIDUUIDYesYes
FromCodeSetVersionIDUUIDYesCodeSetVersion
ToCodeSetVersionIDUUIDYesCodeSetVersion
FromCodeString(50)Yes
ToCodeString(50)Yes
MappingKindString(50)Yesequivalent | broader | narrower | inexact | retired-no-replacement
NotesTextNo
CreatedByUserIDUUIDYesUserAudit
CreatedDateTimeUTCDateTimeUTCYesAudit
UpdatedByUserIDUUIDYesUserAudit
UpdatedDateTimeUTCDateTimeUTCYesAudit
IsDeletedBoolYesSoft-delete

RBAC

Role (Tier)Access
All clinical rolesRead
EditAMI (90+)Full CRUD (manage reference data)

CdsHookEvent P0 — Trust Tier T2

An audit record of a CDS rule firing. Captures the hook context, request/response payloads, clinician action, and evaluation latency.

Schema

FieldTypeRequiredPKFKNotes
CdsHookEventIDUUIDYesYes
EncounterIDUUIDNoEncounterOptional; some hooks fire outside encounters
PatientIDUUIDYesPatient
UserIDUUIDYesUserClinician who received the card
CdsRuleIDUUIDYesCdsRule
HookTypeString(50)YesDenormalized from CdsRule for query efficiency
FiredAtDateTimeUTCYes
RequestPayloadJsonTextYesCDS Hooks request context
ResponseCardsJsonTextYesCDS Hooks response cards
ActionString(50)Yesaccepted | overridden | dismissed | timed-out
OverrideReasonString(50)NoRequired when Action = overridden
EvaluationLatencyMillisIntYes
OrganizationIDUUIDYesOrganizationPartition key
CreatedByUserIDUUIDYesUserAudit
CreatedDateTimeUTCDateTimeUTCYesAudit
UpdatedByUserIDUUIDYesUserAudit
UpdatedDateTimeUTCDateTimeUTCYesAudit
IsDeletedBoolYesSoft-delete

RBAC

Role (Tier)Access
Patient (10)None
FrontDesk (30)None
MA / RN (40)Read
Clinician (60)Read own events; action on cards
PracticeMgr (70)Read all org events; override analytics
EditAMI (90+)Schema management

Trust tiers

TierEntitiesAuth requirement
T0 — openCodeSet, CodeSetVersion, CodeMappingAuthenticated user (any role); reference data is broadly readable.
T1 — clinicalDiagnosis, ProcedureAAL2 plus authorization-chain trace for the patient. Reads logged to read-access audit.
T2 — practice-configOrderSet, CdsRuleAAL2 + role compliance.lead or practice.admin for write; clinician role for read.
T3 — auditCdsHookEventAAL2 + role compliance.lead or practice.admin; immutable in practice (soft-delete only with override audit row).

RBAC permission thresholds

RoleDiagnosis / ProcedureOrderSetCdsRuleCdsHookEvent
clinicianread / write (own patients)read / applyreadread (own events)
coder.certifiedread / edit-codes (org patients)readreadread (org)
billing.specialistreadreadreadread (org)
compliance.leadreadread / writeread / write / retireread / export (org)
practice.adminreadread / writeread / write / retireread / export (org)
front-desk
patient (self)read (own diagnoses / procedures)

FK Relationship Diagram

erDiagram
    Patient ||--o{ Diagnosis : "diagnosed with"
    Encounter ||--o{ Diagnosis : "documented during"
    CodeSetVersion ||--o{ Diagnosis : "coded using"
    Patient ||--o{ Procedure : "receives"
    Encounter ||--o{ Procedure : "performed during"
    CodeSetVersion ||--o{ Procedure : "coded using"
    CodeSet ||--o{ CodeSetVersion : "versioned as"
    CodeSetVersion ||--o{ CodeMapping : "maps from"
    CodeSetVersion ||--o{ CodeMapping : "maps to"
    CdsRule ||--o{ CdsHookEvent : "fires"
    Patient ||--o{ CdsHookEvent : "context for"
    Encounter ||--o| CdsHookEvent : "during"
    User ||--o{ CdsHookEvent : "received by"
  

CDS Hooks Evaluation Flow

graph TD
    A[EHR Trigger Event] --> B{Hook Type}
    B -->|patient-view| C[Load patient context]
    B -->|order-sign| D[Load order context]
    B -->|order-select| D
    B -->|encounter-discharge| E[Load encounter context]
    B -->|medication-prescribe| F[Load Rx context]
    B -->|problem-list-item-create| G[Load problem context]
    C --> H[CDS Rule Engine]
    D --> H
    E --> H
    F --> H
    G --> H
    H --> I[Evaluate CQL / JSON-Logic expressions]
    I --> J{Rules matched?}
    J -->|No| K[No cards returned]
    J -->|Yes| L[Generate CDS Hooks response cards]
    L --> M[Return cards to EHR]
    M --> N{Clinician action}
    N -->|accepted| O[Apply suggestion]
    N -->|overridden| P[Log override + reason]
    N -->|dismissed| Q[Log dismissal]
    N -->|timed-out| R[Log timeout]
    O --> S[CdsHookEvent record]
    P --> S
    Q --> S
    R --> S
  

Functional Requirements

  1. P0 The system shall store Diagnoses with dual coding (ICD-10-CM + SNOMED CT) linked to active CodeSetVersions.
  2. P0 The system shall store Procedures with CPT, HCPCS, up to 4 modifiers, E&M level, and MDM rationale.
  3. P0 The system shall flag AI-augmented procedures with IsAiAugmented per CY2026 AMA guidelines.
  4. P0 The system shall evaluate CDS rules at each CDS Hooks trigger point (patient-view, order-sign, order-select, encounter-discharge, medication-prescribe, problem-list-item-create).
  5. P0 The system shall return CDS Hooks response cards with severity (info, warning, critical) and actionable suggestions.
  6. P0 The system shall log every CDS rule firing as a CdsHookEvent with clinician action (accepted, overridden, dismissed, timed-out).
  7. P0 The system shall require an override reason when a clinician overrides a critical-severity CDS card.
  8. P0 The system shall flag chronic diagnoses (IsChronic) with HCC categories for annual risk-adjustment re-capture.
  9. P0 The system shall flag AI-powered CDS rules with IsAiDsi and link to a ModelCardUri per HTI-1 DSI requirements.
  10. P1 The system shall manage CodeSet, CodeSetVersion, and CodeMapping records for annual code set updates (ICD-10-CM FY rollover, CPT annual release).
  11. P1 The system shall provide cross-walk mappings (equivalent, broader, narrower, inexact, retired-no-replacement) between code set versions.
  12. P1 The system shall support OrderSets triggered by diagnosis codes containing FHIR R4 order stubs.
  13. P2 The system shall provide a CDS analytics dashboard showing override rates, alert fatigue metrics, and rule effectiveness by kind.

Non-Functional Requirements

icApplication Overrides

How the Coding & CDS noun-apps generate from AMI: module-specific stack additions, project layout, override component bindings, worked Cosmos container definitions, a versioning worked example, environment cascade, and RBAC enforcement.

Shared generation map. The IC platform code-gen flow, default bindings, environment cascade, RBAC model, and CLI commands are identical across all modules. See the IC Reference for the canonical shared reference. This section covers only Coding & CDS-specific content.

Technology stack P0

The shared platform stack (Cosmos DB, Redis, IC-generated API, Angular 21, SQS+SNS, OpenTelemetry, etc.) is documented in the IC Reference. Module-specific additions:

LayerChoiceNotes
LanguageTypeScript (Node 22 LTS)Shared across IC-generated services in REV.health.
API frameworkFastify + tRPC; FHIR R4 facade via HAPI-style adapterJSON-First per IC hard rule #10.
Terminology serverIMO Health (primary) with CTS2/FHIR Terminology API; NLM UMLS Metathesaurus, RxNorm, SNOMED-CT US Edition, LOINC consumed via the same façade; AMA CPT licensed and served through the terminology server.Code sets are never embedded in container images. Tokens scoped per-deployment.
CDS Hooks runtimeBUILD — REV.health's own CDS service, implementing CDS Hooks 2.0.Per the PRD §4.4 BUILD/BUY: CDS Hooks runtime is BUILD.
Rule expression languageCQL (HL7 Clinical Quality Language) for clinical rules; JSON-Logic for simple guard rules.Stored in ExpressionText on CdsRule.
AI coding QA partnerHYBRID — CodaMetrix or Fathom for retrospective QA; native real-time per PRD §4.4.QA partner is consulted via API; results round-trip into CdsHookEvent as analytic markers.
Drug knowledgeBUY — Lexidrug, FDB, or Medi-Span via licensed feedBacks DDI / drug-allergy / drug-disease / dose-range checks.
Object storageS3 with Object LockPersisted CDS hook payloads > 256 KB are offloaded to S3; reference held in row.

Project directory layout P0

This module uses a non-standard directory layout; the standard skeleton is documented in the IC Reference.

modules/coding-cds/
├── ami/
│   ├── Diagnosis.ami.json
│   ├── Procedure.ami.json
│   ├── OrderSet.ami.json
│   ├── CdsRule.ami.json
│   ├── CodeSet.ami.json
│   ├── CodeSetVersion.ami.json
│   ├── CodeMapping.ami.json
│   └── CdsHookEvent.ami.json
├── api/                  (generated; do not edit)
│   ├── Diagnosis.controller.ts
│   ├── Procedure.controller.ts
│   ├── OrderSet.controller.ts
│   ├── CdsRule.controller.ts
│   ├── CdsHookEvent.controller.ts
│   └── codeset/...       (read-only generated controllers)
├── cds/
│   ├── service.ts                  (CDS Hooks 2.0 service entrypoint)
│   ├── hooks/
│   │   ├── patient-view.ts
│   │   ├── order-sign.ts
│   │   ├── medication-prescribe.ts
│   │   ├── problem-list-item-create.ts
│   │   └── encounter-discharge.ts
│   ├── eval/
│   │   ├── cql-runtime.ts
│   │   ├── json-logic-runtime.ts
│   │   └── override-tracker.ts
│   ├── checks/
│   │   ├── ddi.ts
│   │   ├── drug-allergy.ts
│   │   ├── drug-disease.ts
│   │   └── dose-range.ts
│   └── em-leveler/                 (E/M MDM-based level prediction)
│       ├── mdm-rationale.ts
│       └── leveler.ts
├── coding/
│   ├── icd10-suggester.ts
│   ├── cpt-suggester.ts
│   ├── hcpcs-suggester.ts
│   ├── modifier-suggester.ts
│   └── hcc-recapture.ts
├── components/                     (UI bindings)
│   ├── ic-ng21-cds-suggestion-card/
│   ├── ic-ng21-cds-code-picker/
│   ├── ic-ng21-cds-em-leveler/
│   ├── ic-ng21-cds-orderset-applier/
│   └── ic-ng21-cds-override-reason-picker/
├── db/
│   ├── container-definitions/     (Cosmos container definitions emitted from AMI)
│   ├── container-policies/        (Cosmos partition-key isolation for org-scoped tables)
│   └── seed/                      (platform-default CdsRule seeds)
├── tests/
│   ├── unit/
│   ├── integration/
│   └── replay/                    (deterministic replay corpus)
└── package.json

Coding & CDS code-gen details

The CDS Hooks 2.0 service is built alongside the generated services and deployed in the same cascade.

Component bindings P0

Default AMI-type bindings are listed in the IC Reference. Module-specific overrides are below.

AMI type / fieldOverride (module-specific)
Diagnosis.Icd10CodeString50ic-ng21-cds-1-code-picker bound to system=icd-10-cm
Procedure.CptCodeString50ic-ng21-cds-1-code-picker bound to system=cpt
Procedure.HcpcsCodeString50ic-ng21-cds-1-code-picker bound to system=hcpcs
Procedure.EmLevelString50ic-ng21-cds-1-em-leveler
OrderSet.OrderItemsJsonTextic-ng21-cds-1-orderset-applier
CdsHookEvent.OverrideReasonString50ic-ng21-cds-1-override-reason-picker
(suggestion card surface)ic-ng21-cds-1-suggestion-card

Worked Cosmos container definitions (org-scoped CdsRule) P1

Emitted by the IC generator from CdsRule.ami.json. Types follow the Cosmos AMI mapping. Partition key isolates by OrganizationID.

CREATE TABLE cds_rule (
  cds_rule_id              UUID         PRIMARY KEY,
  rule_family_id           UUID         NOT NULL,
  name_string100           VARCHAR(200) NOT NULL,
  hook_type_string50       VARCHAR(64)  NOT NULL,
  rule_kind_string50       VARCHAR(32)  NOT NULL,
  severity_string50        VARCHAR(16)  NOT NULL,
  expression_text          TEXT         NOT NULL,
  version_string50         VARCHAR(64)  NOT NULL,
  effective_datetime_utc   TIMESTAMPTZ  NOT NULL,
  retired_datetime_utc     TIMESTAMPTZ  NULL,
  override_threshold_decimal Decimal (JSON number) NULL,
  is_ai_dsi_bool           BOOLEAN      NOT NULL DEFAULT false,
  model_card_uri_string200 TEXT         NULL,
  organization_id           UUID         NOT NULL,
  updated_datetime_utc      TIMESTAMPTZ NOT NULL DEFAULT now(),
  updated_by_user_id        UUID         NOT NULL,
  deleted_datetime_utc      TIMESTAMPTZ  NULL
);

CREATE INDEX cds_rule_org_active_idx
  ON cds_rule (organization_id, rule_family_id, effective_datetime_utc DESC)
  WHERE deleted_datetime_utc IS NULL AND retired_datetime_utc IS NULL;

-- Partition key: /organization_id (Cosmos container partition key for org isolation)
-- All queries automatically scoped to the request context's OrganizationID partition

Global tables (Diagnosis, Procedure, CodeSet, CodeSetVersion, CodeMapping) omit OrganizationID and do not use OrganizationID partition key. Authorization on Diagnosis / Procedure is enforced at the application layer via the patient-scoped authorization-chain trace and the read-access audit; DB-layer partition key would falsely partition global data. This is documented as DEC-RH-002.

Versioning · worked example for a CdsRule break P0

Versions follow the IC break.feature.bug.buildtimestamp scheme. Every change to a CdsRule creates a new immutable row; the prior row is retired with RetiredDateTimeUTC. The active version per (OrganizationID, RuleFamilyID, t) is the one with the highest EffectiveDateTimeUTC ≤ t and a null RetiredDateTimeUTC.

StepChangeOld versionNew versionReason
1Tweak warning text wording1.0.0.20260115T1730Z1.0.1.20260203T1010ZBug-fix bump (text-only). Backward compatible.
2Add a new OverrideReasonString50 code benefit-outweighs-risk1.0.1.20260203T1010Z1.1.0.20260307T0915ZFeature bump. Adds an option; old payloads remain valid.
3Change HookTypeString50 from order-sign to medication-prescribe only1.1.0.20260307T0915Z2.0.0.20260411T1404ZBreak. Trigger surface changed; consumers and hook-binding configs must be updated. Prior version retired.

Permission gating (IC hard rule #5). The break in step 3 cannot ship without the compliance.lead or practice.admin role; the build pipeline rejects break-bumps lacking the role's signed approval marker.

Illustrative timestamps. The buildtimestamp values above are illustrative formatting examples (YYYYMMDDTHHMMZ); they are not asserted to correspond to any real build artifact.

Coding & CDS environment details

Coding & CDS RBAC notes

Cross-Module Links

See also: Coding & CDS walkthrough · IC Reference