healthcare.dev docs
Agents

Example: claim code validator

Validate the diagnosis, procedure and HCPCS codes on a claim against the release in effect on the date of service.

Runs before a claim is submitted: every code must exist, be billable and be active on the date of service. Uses as_of so last year's claims are checked against last year's codes.

import { HealthcareDev, NotFoundError } from "@healthcare.dev/sdk";

const hdev = new HealthcareDev();
type System = "icd10cm" | "icd10pcs" | "hcpcs";

export async function validateClaimCodes(
  serviceDate: string,
  codes: { system: System; code: string }[],
) {
  return Promise.all(
    codes.map(async ({ system, code }) => {
      try {
        const { data, meta } = await hdev.codes.get(system, code, { as_of: serviceDate });
        const valid = data.billable && data.status === "active";
        return { system, code, valid, display: data.display, version: meta.data_version };
      } catch (err) {
        if (err instanceof NotFoundError)
          return { system, code, valid: false, display: null, version: null };
        throw err;
      }
    }),
  );
}

This checks code validity only. It doesn't check medical necessity, coverage or payer edits, and it isn't coding advice.