Code Like Humans: A Multi-Agent Solution for Medical Coding (2025)

Abstract: In medical coding, experts map unstructured clinical notes to alphanumeric codes for diagnoses and procedures. We introduce ‘Code Like Humans’: a new agentic framework for medical coding with large language models. It implements official coding guidelines for human experts, and it is the first solution that can support the full ICD-10 coding system (+70K labels). It achieves the best performance to date on rare diagnosis codes. Fine-tuned discriminative classifiers retain an advantage for high-frequency codes, to which they are limited. Towards future work, we also contribute an analysis of system performance and identify its ‘blind spots’ (codes that are systematically undercoded).

## introduction for statistical and billing purposes, unstructured clinical notes need to be mapped to medical codes: alphanumeric codes of diagnoses or procedures @xcite . the international classification of diseases (icd) is the most widely used system for diagnosis codes. unfortunately, it is a time-intensive task, 1 in which errors can cause patient mistreatment and lost revenue @xcite . progress in nlp methods for medical coding has been stagnant in recent years. there have been several attempts to apply large language models (llms) @xcite , but they have yet to yield improvements over the 2022 state-of-the-art @xcite that used the bert architecture @xcite . we hypothesize that one reason for the lack of progress may be the disconnect between current modeling approaches and how human medical 1 it takes a professional inpatient human coder approximately 30 minutes per case on average @xcite . coders work @xcite . human coders begin not from memory but from the alphabetical index of icd, a list that exhaustively maps clinical terms to codes capturing synonyms, eponyms, and contextual cues. although this resource is an authoritative source of information used by medical coders to narrow down the search space, the current approaches do not consider it in any way. to address this, we propose clh (code like humans): an llm-based agentic framework foot_0 that leverages icd resources such as the alphabetic index. clh is inspired by the medical coding workflow developed for healthcare professionals in the uk ( @xcite . our approach is summarized in figure 1 . ## related work and novelty current approaches rely on encoder-decoder architectures that embed clinical notes and codes into separate embedding spaces. label-wise attention with fine-tuning is typically used to align them @xcite . prior work has sought to improve alignment by initializing embeddings with textual descriptions @xcite , synonyms @xcite , or code co-occurrence @xcite . however, state-of-the-art results have been achieved using discriminative models, pre-trained on biomedical texts and then fine-tuned for classification (plm-icd) @xcite . this is the main baseline considered in this work. these methods face three main challenges, listed below, together with our proposed solutions. our solution. clh retrieves codes from the icd alphabetic index, enabling true open-set coding at inference. this makes clh the first approach to cover foot_1 the full icd-10 solution space. our solution. rather than learning a labelfrequency prior from training data, clh uses a retrieval-induced distributional prior from the alphabetical index, which enables probability mass on codes with few or zero training examples. our solution. clh adopts an agentic approach, which decomposes the processing of long context as a sequential task, where the system searches, verifies, and predicts one code at a time based on guidelines. this avoids having to process extremely long context in one go. ## background: a gentle introduction to medical coding human medical coders are healthcare professionals with extensive training in one or more medical coding systems. 5 . given some clinical documentation (progress notes, discharge summaries, etc.), they must choose among the thousands of codes the most specific one that applies to this case. we will use the example of the us modification of icd-10 (icd-10-cm) (cms and nchs, 2025), which comprises over 70,000 codes. example snippets from the icd hierarchy and alphabetical index can be seen in the appendix a. these codes are defined in a tree-structured hierarchy where the proximity of the codes indicates some similarity. 6 the alphanumeric characters in a medical code refer to its position in the hierarchy: e.g., in the code a22.7, "a" points to a chapter, "22" points to a category, and the numbers after the punctuation indicate the conditions with increasing level of specificity. only the most specific possible code can be assigned. however, proximity in the hierarchy does not guarantee clinical similarity. for example, 'sepsis' is mentioned 39 times in multiple chapters, and it corresponds to codes a22.7 and t81.44, among many others. therefore, finding the correct code by traversing from the top of the hierarchy to the bottom is difficult. to resolve such cases, the coders must also use the alphabetical index, which provides information about the context in which a given code is appropriate. for example, it could help the coder to decide between a22.7 and t81.44 codes for 'sepsis', because the former is listed under "anthrax" context, and the latter under "postprocedural". the alphabetical index alone is also insufficient because it does not necessarily point to the most specific code (i.e., the leaf node in the icd tree). hence, the coder must verify that the candidate code is the most specific code possible for this case in the icd hierarchy. the output of medical coding is not a single code, but a list of applicable codes. the order of those codes may itself be meaningful in some cases. there are also rules for precedence between specific codes, e.g., the code for "alzheimer's" should come before the code for "dementia". all human coders must be familiar with official icd guidelines to ensure accurate and comprehensive coding. the current icd-10-cm guidelines are 115 pages long. these guidelines serve as the manual for medical coding and provide instructions on using the alphabetical index and navigating the hierarchy. additionally, they provide chapterspecific rules on selecting and combining codes, which are fundamental to clarifying otherwise ambiguous choices among several candidate codes. ## model analysis while the end-to-end results provide a summary, they do not capture the nuances of the individual stages of the framework. to better understand the limitations of clh, we present five observations to guide future improvements. ## discussion discriminative classifiers, such as plm-icd, retain knowledge about every code in their weights, whereas our clh framework dynamically retrieves icd codes from the alphabetic index, enabling true open-set coding at inference. clh does not yet outperform the plm-icd baseline on frequent codes, but it achieves comparable performance, and has several practical advantages. clh is much easier to update when coding conventions change: one would only need to substitute external resources in the prompt. it also suffers less from distributional priors and theoretically can handle even extremely rare codes such as w59.22 "struck by a turtle" @xcite . nevertheless, both discriminative classifiers and llms have apparent limitations that would make both approaches unusable for the real-world icd-10 end-to-end classification. the former inherit strong distributional priors and only support a toy version of the real 70k label task. the latter still struggles with precision. given the current state of the technology, we argue that a more realistic goal for nlp for medical coding is to develop assistive tools that keep human coders in the loop, rather than aim for full end-to-end classification. in that approach, clh has a key advantage, as it already mimics the workflow of human coders. ## conclusion we introduced code like humans, a multi-agent framework for medical coding that aligns with human coding practices by integrating previously overlooked resources: the alphabetical index and official guidelines of icd-10 classification. by relying on these in-context materials rather than only training examples, clh became the first solution that could support the complete icd-10 system (over 70k codes). the current implementation outperforms state-of-the-art fine-tuned classifiers on rare codes. a performance gap remains for frequent codes, where fine-tuned classifiers have a natural advantage, but this comes at the expense of addressing only a toy version of the real icd-10 coding task. our framework offers advantages in easy adaptability to yearly coding updates and opportunities for human-in-the-loop collaboration. our results suggest that while the current nlp systems can support medical coding, they should aim to complement rather than replace human expertise.