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
- Overview
- Prerequisites
- Code Set Loading
- Annual Code Set Update Process
- Modifier Configuration
- Payer Rule Configuration
- Dev Seed Data
- 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.adminpermission (typically granted toorg_adminandplatform_adminroles). - 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 inpf_code_sets:
Loading Individual Codes
After inserting the code set row, insert individual codes referencing itsid:
Important: Never hard-delete existing codes. Use effective_to to retire them.
Loading CPT and HCPCS Codes
Same pattern usingpf_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
code_set_id.
Step 4 — Retire the previous version
Rollback Procedure
If a bad load occurs:- Clear the affected
pf_icd10_codes/pf_cpt_codes/pf_hcpcs_codesrows by the newcode_set_id: - Restore the previous version’s
effective_totoNULLif 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 withpf.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 asdenied, prior_auth, or requires_modifier.
Note:payer_idis a bare UUID referencing the PM-layer payer. There is no FK topm_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
- Check code set exists and is active:
- 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. - Check RLS: Run the query as an authenticated user. Platform code sets (
organization_id IS NULL) should be visible to all users. RunSELECT 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.adminpermission: - 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
sanitizeErrorMessageis wrapping all DB errors invalidateCode.ts. - Check the Supabase Edge Function logs if the validation is called via an edge function context.
- For payer rule issues, verify
payer_idis the correct UUID (no FK enforcement — it is the caller’s responsibility to pass the correct UUID).