Blog

    Healthcare Terminology Services for AI and FHIR: Checking AI-Suggested Codes Before Write-Back

    By GauravNovember 27, 20269 mins read
    On this page

    Language models are good at reading a note and proposing a diagnosis or lab code. They are also good at proposing codes that look right and are not: retired concepts, codes from the wrong system, or codes outside the set the receiving field allows. Writing those straight into an EHR turns a model error into a chart error.

    This post is for teams adding AI coding suggestions to clinical software. It explains how FHIR terminology operations act as a check before write-back, where the check sits, what it misses, and which licences to sort out first.

    What is a healthcare terminology service?

    Adding AI coding to a FHIR application?

    Our FHIR and SMART on FHIR development team builds terminology checks and safe write-back into clinical apps.

    A healthcare terminology service is a server that answers questions about codes: whether a code exists, what it means, which codes a value set allows and how a code translates to another system. Agnotic Technologies places one between an AI model and the EHR, so no generated code is written back without being checked.

    The service does not decide whether the diagnosis is clinically right. It decides whether the code is real, current and allowed in that field, which removes a whole class of errors before a clinician ever looks.

    Why do AI-extracted codes need checking?

    AI-extracted codes need checking because a model predicts text, and a code is just text to it. A code can be well formed, plausible and still wrong for the system, the version or the field.

    • Invented codes: a string in the right shape that exists in no release.
    • Inactive codes: concepts that were valid once and have since been retired.
    • Wrong system: an ICD-10-CM code sent where the field expects SNOMED CT.
    • Out of set: a valid code that the target value set does not allow.
    • Display mismatch: the code and its label describe different things.

    Which FHIR terminology operations matter?

    Four operations cover most AI checks: $validate-code, $lookup, $expand and $translate. Each answers a different question, and a write-back path usually needs at least the first two.

    • $validate-code: is this code allowed in this value set, or valid in this code system?
    • $lookup: what does this code mean, and is it still active?
    • $expand: which codes does this value set contain right now?
    • $translate: what is the equivalent code in another system, based on a ConceptMap?

    You can run these operations on a terminology server you host or call a hosted service. Either way, the AI pipeline should call them through one small client with timeouts and logging, not scattered through prompt code.

    How does $validate-code catch bad codes?

    $validate-code catches bad codes by testing each suggestion against the value set bound to the target field. A code that fails is stopped before review, with the server's message attached.

    HL7 FHIR R4 defines the ValueSet $validate-code operation to check that a coded value is in the set of codes a value set allows; it returns a true or false result, an error message and the recommended display for the code.

    Use the returned display as a second check. If the model's label and the server's recommended display disagree, flag the suggestion even when the result is true, because the model may have paired a real code with the wrong meaning.

    Using $lookup to check meaning

    $lookup tells you what a code means and whether it is active, which is the information a reviewer needs beside the model's evidence. It also gives the canonical display to show in the review screen.

    HL7 FHIR R4 defines the CodeSystem $lookup operation, which takes a code and system, or a Coding, and returns details about the concept, including its definition, status, designations and properties.

    Show the reviewer three things side by side: the text span the model used, the concept's display, and its status. A reviewer comparing those three can accept or reject in seconds, instead of searching a browser for the code.

    Where do $expand and $translate fit?

    $expand fits before the model runs, and $translate fits when sources use local codes. Expanding a small value set lets you constrain the model to choose from allowed codes rather than generate one freely.

    Constraining only works for small sets, such as a list of screening results or specimen types. For large sets like all diagnoses, let the model propose and let $validate-code decide. Use $translate when a lab or device sends local codes that must become standard ones before the AI step.

    Where does the check sit in the write-back path?

    The check sits after extraction and before any human or system accepts a code. Suggestions flow from the model to the terminology service, then to a clinician review queue, and only accepted codes are written to the EHR.

    AI-extracted codes checked before EHR write-back: a model proposes candidate codes with evidence from a clinical note, a FHIR terminology service runs validate-code, lookup and translate, a clinician accepts, edits or rejects each suggestion, and accepted codes are written to the EHR as FHIR resources, with a version record bar for code system and value set versions
    • AI extraction: candidate system, code and display, the evidence span and a confidence score.
    • Terminology service: $validate-code against the field's value set, $lookup for status and display, $translate for local codes.
    • Clinician review: accept, edit or reject, with a reason for each rejection.
    • EHR write-back: a FHIR resource such as a Condition, with the reviewer recorded as the author.

    Store the code system version, value set version and model version with every decision. When a release changes, you can see which past suggestions were checked against the old content.

    Which code system licences apply?

    Each code system you load into a terminology server comes with its own terms, and some need a licence before you can use or distribute the content. Check the terms for every system before it ships in your product.

    As the United States National Release Center for SNOMED CT, the National Library of Medicine provides SNOMED CT data and resources to licensees of the NLM UMLS Metathesaurus.

    Licensing also shapes architecture. If your product serves customers in other countries, or bundles code content inside a mobile app, confirm what each licence allows before choosing between a hosted terminology service and content loaded on your own server.

    Terminology check failure points

    A terminology check fails in ways that look like success, so test for these on purpose.

    • Stale content: the server holds an old release, so new codes fail and retired ones pass.
    • Wrong binding: the check uses a broad value set while the target field allows a narrow one.
    • Silent fallback: the service times out and the pipeline writes the code anyway.
    • Display trust: the review screen shows the model's label instead of the server's display.
    • Lost versions: decisions saved without the code system and value set versions used.

    Treat an unreachable terminology service as a failed check, never as a pass. Queue the suggestions and retry, and alert someone if the queue grows.

    A worked example: problem list suggestions from a discharge summary

    A hospitalist app reads discharge summaries and proposes problem list entries in SNOMED CT. The model returns five candidates, each with a code, a display, the sentence it relied on and a confidence score.

    $validate-code rejects one candidate because it sits outside the problem list value set. $lookup shows a second is inactive, and a third returns a display that describes a different condition from the model's label, so it is flagged.

    The reviewer sees two clean suggestions and one flagged item with evidence beside it, accepts two, fixes the flagged one and writes three Condition resources. The rejected and inactive codes are logged with reasons and feed the next model evaluation.

    Who owns what?

    Terminology checks cross three teams, and each owns a different part of the risk.

    • Clinical informatics: value set choices, bindings per field and review rules.
    • Terminology owner: code system releases, licences and the update schedule.
    • AI team: prompts, model versions, constrained choices and evaluation sets.
    • Engineering: the service, the review queue, write-back and the audit log.

    Write the bindings down in one place that all four teams can read: target field, value set, version and review rule. When a clinician asks why a code was blocked, the answer should come from that table, not from someone reading the pipeline code.

    How do you measure the check?

    Measure the check by what it stops and what reviewers still change. A check that rejects nothing may be misconfigured, and one that rejects most suggestions points to a prompt or model problem.

    • Rejection rate by reason: invalid, inactive, out of set, display mismatch.
    • Reviewer edit rate: accepted codes that a clinician changed before write-back.
    • Release lag: days between a code system release and its load on your server.
    • Check latency: time added to the review step, measured per suggestion.

    Review these numbers with the AI team each month. A rise in out-of-set rejections after a model change usually means the prompt lost its value set guidance, and the fix belongs upstream, not in the check.

    What are AI terminology check best practices?

    Validate every AI code against the value set bound to its target field, look up status and display, and show the server's display, not the model's, to reviewers. Treat a failed or unreachable check as a stop.

    Keep code content current and licensed, store versions with every decision, constrain small value sets with $expand, and track rejection reasons to improve the model.

    How Agnotic can help

    Agnotic builds the terminology layer behind AI coding features: a FHIR terminology service or integration with an existing one, value set bindings, review queues and safe write-back. We also set up the version records and metrics that show whether the check works.

    Put a terminology check in front of your AI

    We connect model suggestions to FHIR terminology operations and a review step your clinicians trust.

    Sources

    Frequently Asked Questions

    No. It tells you whether a code is real, active and allowed in the target field. Whether the diagnosis fits the patient is still a clinical review decision.

    Talk to an engineer about your project

    Tell us which fields your AI fills and which code systems they use. We will outline the terminology checks and review flow.

    Go deeper

    Services and solutions on this topic