Skip to main content
Feature ID: PF-70
Version: 1.0.0
Status: ✅ Implemented
Last Updated: 2026-02-19
Audience: Platform Administrators, Org Admins
Permission Required: pf.codes.admin
This guide covers code set loading, effective dating, modifier configuration, payer rule management, and troubleshooting for the PF-70 Medical Terminology & Code Library.

Table of Contents

  1. Overview
  2. Prerequisites
  3. Code Set Loading
  4. Annual Code Set Update Process
  5. Modifier Configuration
  6. Payer Rule Configuration
  7. Dev Seed Data
  8. Troubleshooting

Overview

The PF-70 code library provides a centralized, platform-managed repository of medical codes used across the Encore OS: Architecture pattern:
  • Platform-managed codes (organization_id IS NULL) — readable by all authenticated users in all orgs.
  • Org-scoped modifiers/payer rules (organization_id IS NOT NULL) — visible only within the owning organization.
  • User-scoped data (pf_code_favorites, pf_code_recent) — visible only to the owning user.

Prerequisites

Before loading any code data:
  • You must have pf.codes.admin permission (typically granted to org_admin and platform_admin roles).
  • For platform-managed code sets, mutations require a Supabase service role or migration script (RLS blocks app-layer writes on platform-managed tables).
  • Effective dates must be verified against CMS or the relevant governing body’s published release.

Code Set Loading

How Platform Code Sets Work

Each code version is a separate row in pf_code_sets:

Loading Individual Codes

After inserting the code set row, insert individual codes referencing its id:
Important: Never hard-delete existing codes. Use effective_to to retire them.

Loading CPT and HCPCS Codes

Same pattern using pf_cpt_codes and pf_hcpcs_codes respectively:

Where to Run Load Scripts

  • Development/Staging: Supabase Dashboard → SQL Editor (https://supabase.com/dashboard/project/{project_id}/sql/new)
  • Production: Via a reviewed and approved migration script in supabase/migrations/ or Supabase SQL Editor with Live environment selected.

Annual Code Set Update Process

CMS releases ICD-10-CM updates annually on October 1. CPT codes update on January 1.

Step-by-Step Update Procedure

Step 1 — Obtain the new code file
  • ICD-10-CM: Download the CMS flat file from cms.gov/Medicare/Coding/ICD10
  • CPT: AMA annual CPT data file (licensed)
  • HCPCS: CMS HCPCS quarterly update files
Step 2 — Insert a new code set version
Step 3 — Insert new codes for the new version Use a bulk INSERT or import script against the new code_set_id. Step 4 — Retire the previous version
Step 5 — Verify via search API

Rollback Procedure

If a bad load occurs:
  1. Clear the affected pf_icd10_codes / pf_cpt_codes / pf_hcpcs_codes rows by the new code_set_id:
  2. Restore the previous version’s effective_to to NULL if it was incorrectly retired.

Modifier Configuration

Modifiers are org-scoped (not platform-managed). Each organization configures its own modifier set.

Who Can Configure Modifiers

Users with pf.codes.admin permission (org_admin or platform_admin roles).

Adding a Modifier

Via the Supabase SQL Editor or, once a UI is built, via Settings → Code Library → Modifiers:

Retiring a Modifier


Payer Rule Configuration

Payer rules allow orgs to flag specific code-payer combinations as denied, prior_auth, or requires_modifier.
Note: payer_id is a bare UUID referencing the PM-layer payer. There is no FK to pm_payers (architecture decision C-3: no PF→PM boundary crossing).

Supported Rule Types

Adding a Payer Rule


Dev Seed Data

The following seed data is loaded automatically via migration for development/testing environments. It includes a minimal set of ICD-10-CM, CPT, and HCPCS codes to unblock E2E testing of the search and validation APIs. ICD-10-CM seed codes (BH + SDOH): CPT seed codes: HCPCS seed codes:

Troubleshooting

Search returns no results

  1. Check code set exists and is active:
  2. Check effective date: The search filters to codes where effective_from <= today AND (effective_to IS NULL OR effective_to >= today). Ensure your seed/load date covers the queried date.
  3. Check RLS: Run the query as an authenticated user. Platform code sets (organization_id IS NULL) should be visible to all users. Run SELECT pf_can_read_code_set('<code_set_id>') in the SQL editor to test the SECURITY DEFINER helper.

Permission denied on INSERT/UPDATE

  • Verify the user has pf.codes.admin permission:
  • Platform-managed code tables (pf_icd10_codes, pf_cpt_codes, pf_hcpcs_codes) block all app-layer mutations (by design). Loads must be done via service role or migration.

loinc_unavailable: true in search metadata

LOINC is deferred to a future PF-70 phase. When CL-08 implementation begins, a pf_loinc_codes table will be added. Until then, codeSet: 'LOINC' always returns { results: [], meta: { loinc_unavailable: true } }.

validateCode returns unexpected errors

  • Ensure sanitizeErrorMessage is wrapping all DB errors in validateCode.ts.
  • Check the Supabase Edge Function logs if the validation is called via an edge function context.
  • For payer rule issues, verify payer_id is the correct UUID (no FK enforcement — it is the caller’s responsibility to pass the correct UUID).