A surgical operation record automatic coding method, device, equipment and medium
Patent Information
- Application Number
- CN202611157912.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-31
- Publication Date
- 2026-10-20
AI Technical Summary
[0005]有鉴于此,本申请的目的在于提供一种手术操作记录自动编码方法、装置、设备及介质,有效地解决了现有的手术编码技术难以满足合规性与临床数据可靠性要求的问题
[0015]第四方面,本申请实施例提供了一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行任一项所述的一种手术操作记录自动编码方法的步骤。
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This application relates to the field of medical event recognition technology, and more specifically, to a method, apparatus, device, and medium for automatic encoding of surgical operation records. Background Technology
[0002] In the context of medical informatization, surgical operation records need to be uniformly converted into ICD-9-CM-3 standard codes to support DRG grouping and hospital performance management. Currently, manual coding is mainly relied upon, but it faces problems such as complex dimensions, ambiguous terminology, low efficiency, and high error rates: a single surgery requires simultaneous judgment of multiple dimensions such as anatomical location, surgical type, approach, and implants. Clinical records contain a large number of subspecialty idioms (such as "endoscopic screw placement" and "ligament insertion reconstruction"), which are difficult to accurately map to standard code names; large tertiary hospitals perform hundreds of surgeries per day, and manual coding takes an average of 3-5 minutes, resulting in serious backlog and easy occurrences of site misalignment, approach misjudgment, or omission of key operations, leading to data distortion.
[0003] To address these issues, academia and industry have proposed various automated coding schemes. However, existing automated coding schemes have inherent flaws: rule-based systems based on keyword matching have weak generalization capabilities and cannot handle semantic variations and new surgical procedures; traditional machine learning models rely on shallow text features, making it difficult to distinguish highly similar surgical procedures in orthopedics (such as unicompartmental knee replacement vs. total knee replacement); end-to-end deep learning methods require massive amounts of labeled data and GPU computing power for training, while medical coding labeling is extremely costly and has sparse samples; commercial software is mostly adapted to the English ICD system, with insufficient support for Chinese clinical descriptions and domestic medical device naming. In particular, the automatic coding method and system for surgical operation records based on a large language model, as described in patent publication number CN119092046A, provides a "generation-mapping" path that relies on the large language model to generate standard surgical names before mapping and coding. This is prone to mapping failure due to the large language model's illusion of outputting names or descriptions outside the coding library that do not match.
[0004] The aforementioned limitations indicate an urgent need for a lightweight autocoding paradigm that requires no model fine-tuning, has a controllable output space, strong domain adaptability, and can be rapidly iterated. Summary of the Invention
[0005] In view of this, the purpose of this application is to provide a method, device, equipment and medium for automatic coding of surgical operation records, which effectively solves the problem that existing surgical coding technologies cannot meet the requirements of compliance and clinical data reliability.
[0006] In a first aspect, embodiments of this application provide an automatic encoding method for surgical operation records, applied to an automatic encoding system. The automatic encoding system includes a data quality inspection layer, a hard rule engine layer, a vector retrieval layer, and an LLM fine sorting layer. The method includes: The surgical operation record to be encoded is obtained through the data quality inspection layer. The surgical information of the surgical operation record to be encoded is extracted for pre-quality verification. After the pre-quality verification is passed, the surgical operation record is input into the hard rule engine layer. Based on predefined keyword combination matching rules, the system matches surgical operation records that have passed the pre-qualification with the rule knowledge base pre-built in the hard rule engine layer, and generates corresponding matching results. Based on the matching results, the vector retrieval layer is controlled to encode and retrieve key information in the surgical operation record based on a pre-built encoding library, so as to obtain a target number of candidate codes and their standard names; The LLM fine sorting layer is used to construct the complete input from the candidate codes of the target number and their standard names, and discriminative selection is performed through the selection rules enforced in the large language model to obtain the target code, so as to realize the automatic encoding of surgical operation records.
[0007] In conjunction with the first aspect, this application provides a first possible implementation of the first aspect, wherein controlling the vector retrieval layer to encode and retrieve key information in the surgical operation record based on a pre-built encoding library, obtaining a target number of candidate codes and their standard names, including: Extract the surgical name, surgical procedure, and preoperative diagnosis from the surgical operation record, and use them as key information to construct a query text, and perform synonym expansion processing; The target model is fine-tuned to process the expanded query text to obtain a standardized query vector, which is then used to retrieve the target number of candidate codes and their standard names from the coding library.
[0008] In conjunction with the first aspect, this application provides a second possible implementation of the first aspect, wherein retrieving the target number of candidate codes and their standard names based on the standardized query vector includes: Calculate the cosine similarity between the standardized query vector and all vector indices of the pre-built encoding library, and sort them to obtain the ranking result; Traverse the sorted results and continuously select the top N non-repeating surgical operation codes and their corresponding standard names to form the final TopN candidate list.
[0009] In conjunction with the first aspect, this application provides a third possible implementation of the first aspect, wherein the LLM fine sorting layer is used to construct a complete input from the candidate codes and their standard names of the target number, and discriminative selection is performed through the selection rules enforced in the large language model, including: Based on the target number of candidate codes and their standard names, system prompt words and user prompt words are constructed respectively, and the system prompt words and user prompt words are concatenated to form a complete input; Based on the selection rules enforced in the complete input, the target letter identifier is obtained by reasoning about the candidate codes and their standard names through the Large Language Model API; The target letter identifier is mapped to a target number of candidate codes, and the target code is selected based on the mapping result.
[0010] In conjunction with the first aspect, this application provides a fourth possible implementation of the first aspect, wherein after the Large Language Model API infers the target letter identifier from the candidate codes and their standard names, it further includes: If the output of the large language model is invalid or the API call is abnormal, directly read the TopN candidate list output by the vector retrieval layer; Let the surgical operation code with the first sorting number in the TopN candidate list and its standard name be the target code, and use it as the final output.
[0011] In conjunction with the first aspect, this application provides a fifth possible implementation of the first aspect, wherein extracting surgical information from the surgical operation record to be encoded for pre-qualification includes: Extract the core anatomical nouns and surgical verbs from the surgical name, as well as the anatomical nouns and execution verbs that appear most frequently in the surgical procedure text; Determine whether the surgical procedure name does not contain any high-frequency anatomical site nouns appearing in the surgical procedure, or whether the surgical procedure verb in the surgical procedure name and the execution verb in the surgical procedure are mutually exclusive in medical semantics. Based on the matching results obtained from the judgment, it was determined that there was a semantic contradiction in the surgical operation record, and the pre-qualification was deemed to have failed.
[0012] In conjunction with the first aspect, this application provides a sixth possible implementation of the first aspect, wherein matching surgical operation records that have passed pre-qualification with a pre-built rule knowledge base in the hard rule engine layer includes: Extract the surgical name field and surgical procedure field from the surgical operation record, and determine whether the surgical name field contains all the necessary keywords corresponding to the candidate rules in the candidate rule set, and does not contain any prohibited keywords corresponding to the candidate rules; If so, determine whether the surgical procedure field contains all the necessary keywords corresponding to the candidate rules in the candidate rule set to complete the matching.
[0013] Secondly, embodiments of this application provide an automatic encoding device for surgical operation records, applied to an automatic encoding system. The automatic encoding system includes a data quality inspection layer, a hard rule engine layer, a vector retrieval layer, and an LLM fine sorting layer. The device includes: The acquisition module is used to acquire the surgical operation record to be encoded through the data quality inspection layer, extract the surgical information of the surgical operation record to be encoded for pre-quality verification, and input the surgical operation record to the hard rule engine layer after the pre-quality verification is passed. The matching module is used to match surgical operation records that have passed the pre-qualification with the rule knowledge base pre-built in the hard rule engine layer based on predefined keyword combination matching rules, and generate corresponding matching results. The retrieval module is used to control the vector retrieval layer to encode and retrieve key information in the surgical operation record based on the matching results and a pre-built encoding library, so as to obtain a target number of candidate codes and their standard names; The encoding module is used to construct a complete input from the candidate codes and their standard names of the target number using the LLM fine sorting layer, and to perform discriminative selection through the selection rules enforced in the large language model to obtain the target code so as to realize the automatic encoding of surgical operation records.
[0014] Thirdly, embodiments of this application provide an electronic device, including: a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, the steps of any of the surgical operation record automatic encoding methods described above are performed.
[0015] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of any of the methods for automatically encoding surgical operation records.
[0016] This application provides an automatic encoding method for surgical operation records. The method constructs a four-level progressive architecture: a data quality inspection layer, a hard rule engine layer, a vector retrieval layer, and an LLM fine sorting layer. This achieves the following significant technical advancements: By setting up a data quality inspection layer, consistency checks are performed on the input surgical operation records to verify the surgical name and procedure, thereby preventing the propagation of incorrect encodings due to inconsistencies in clinical writing and improving the overall reliability of the system. The hard rule engine makes judgments based on predefined keyword combination matching rules, allowing high-confidence samples to be directly encoded without calling subsequent modules, thus reducing the risk of errors. The system reduces computational overhead and shortens response latency. The vector retrieval layer performs semantic retrieval on samples that do not match hard rules, recalling a target number of candidate codes from a predefined coding library. This limits the output space of the large language model to the standard coding set, fundamentally eliminating the illusionary risk caused by open generation. The LLM fine-ranking layer constructs a complete input from the candidate codes and their standard names, and performs discriminative selection based on the mandatory selection rules embedded in the large language model. This allows the model to complete only a limited number of option recognition tasks, avoiding the uncertainty of text generation and eliminating the need for domain fine-tuning of the large language model. The design of sequential execution of four modules and termination upon success of the previous level ensures decoupling of functions at each level and on-demand allocation of resources, forming a stable, controllable, and sustainably evolving automatic coding mechanism. Attached Figure Description
[0017] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A flowchart illustrating an automatic encoding method for surgical operation records provided in an embodiment of this application is shown. Figure 2 This paper illustrates a flowchart of the hard rule engine layer provided in an embodiment of this application. Figure 3 A flowchart of the vector retrieval layer provided in an embodiment of this application is shown; Figure 4 This paper shows a structural block diagram of an automatic coding device for surgical operation records provided in an embodiment of this application; Figure 5 A structural block diagram of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0020] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0021] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0022] Based on this, embodiments of this application provide a method, apparatus, device, and medium for automatic encoding of surgical operation records, which are described below through embodiments.
[0023] Example 1 To facilitate understanding of this embodiment, a method for automatically encoding surgical operation records disclosed in this application will first be described in detail. For example... Figure 1 The diagram illustrates an automatic encoding method for surgical procedure records. This application provides an automatic encoding method for surgical procedure records, applied to an automatic encoding system. The automatic encoding system includes a data quality inspection layer, a hard rule engine layer, a vector retrieval layer, and an LLM fine sorting layer. The method includes: S101. Obtain the surgical operation record to be encoded through the data quality inspection layer, extract the surgical information of the surgical operation record to be encoded for pre-quality verification, and input the surgical operation record into the hard rule engine layer after the pre-quality verification is passed. S102. Based on predefined keyword combination matching rules, match the surgical operation records that have passed the pre-qualification with the rule knowledge base pre-built in the hard rule engine layer, and generate the corresponding matching results. S103. Based on the matching results, control the vector retrieval layer to encode and retrieve key information in the surgical operation record based on a pre-built encoding library, and obtain a target number of candidate codes and their standard names; S104. The LLM fine sorting layer is used to construct the candidate codes and their standard names of the target number into a complete input, and the discriminative selection is performed through the selection rules enforced in the large language model to obtain the target code so as to realize the automatic encoding of the surgical operation record.
[0024] In step S101, this application first obtains the surgical operation record to be encoded through a data quality inspection layer. As the first quality checkpoint in the entire automatic encoding process, the core function of the data quality inspection layer is to perform a preliminary semantic consistency check on the input raw surgical operation record to identify and intercept obviously distorted or logically contradictory abnormal records, preventing erroneous information from entering subsequent processing stages. The data quality inspection layer first extracts three types of key surgical information from the surgical operation record to be encoded in a structured manner: surgical name, surgical procedure summary, and preoperative diagnosis. Then, based on preset logical constraint rules, it determines whether there is a fundamental contradiction between the surgical name and the surgical procedure. For example, if the surgical name is "left knee replacement" while the preoperative diagnosis is "right femoral neck fracture," it is determined to be a left-right contradiction. Such contradictions indicate significant omissions in clinical writing or system input errors. If these are not verified and directly entered into the encoding process, it will lead to unreliable results in all subsequent stages. Therefore, the data quality inspection layer will only transmit the surgical operation record to the hard rule engine layer completely and without modification if the verification passes. If the verification fails, the entire record will be marked as "quality inspection failed", will no longer participate in any coding calculations, and will trigger a manual review alarm.
[0025] In a specific implementation of step S101, one embodiment involves extracting surgical information from the surgical operation record to be encoded for preliminary quality verification, including: S1011 Extract the core anatomical nouns and surgical verbs from the surgical name, as well as the anatomical nouns and execution verbs that appear most frequently in the surgical procedure text. S1012. Determine whether the surgical procedure name does not contain any high-frequency anatomical site nouns appearing in the surgical procedure, or whether the surgical procedure verb in the surgical procedure name and the execution verb in the surgical procedure are mutually exclusive in medical semantics. S1013. Based on the matching results obtained from the judgment, it is determined that there is a semantic contradiction in the surgical operation record, and the pre-qualification quality check is deemed to have failed.
[0026] In steps S1011-S1013, when the data quality inspection layer of this application performs pre-qualification, it first performs fine-grained semantic parsing on the input surgical operation record: extracting core anatomical nouns such as "knee joint", "tibial intercondylar spine", and "femoral neck" from the surgical name, and core surgical verbs such as "replacement", "reduction", "fixation", "reconstruction", and "suture"; simultaneously, it performs verb-noun co-occurrence frequency statistics on the surgical procedure summary text, and identifies the most frequently occurring anatomical nouns such as "tibial insertion", "anterior cruciate ligament", and "synovium", and execution verbs such as "resection", "reduction", "fixation", "anchor", and "suture". Subsequently, a dual semantic consistency check is performed: First, if the surgical name does not contain the terminology for the most frequently mentioned anatomical location in the surgical procedure, it is considered that the anatomical subject is missing. For example, if the surgical name is "knee arthroscopy," and the surgical procedure frequently mentions "tibial intercondylar spine fracture," but this key anatomical structure is not reflected in the name, it indicates that the name is inappropriately summarized. Second, if the surgical procedure verbs in the surgical name and the execution verbs in the surgical procedure are mutually exclusive in medical semantics, it is considered that the operational logic is contradictory. For example, if the name contains "replacement," but the procedure only describes "reduction and cannulated screw fixation," without mentioning any prosthesis implantation-related actions; or if the name is "suture," but the procedure clearly states "resection + shaping." If either of the above situations is true, the surgical operation record is determined to have an inherent semantic contradiction, the preliminary quality check fails, the entire record process is terminated, and it enters the manual review queue.
[0027] In step S102, this application receives surgical operation records that have successfully passed the pre-qualification of the data quality inspection layer through the hard rule engine layer. These pre-qualified surgical operation records are considered high-confidence samples by the hard rule engine layer. These high-confidence samples, i.e., the pre-qualified surgical operation records, are then matched against a rule knowledge base pre-built and continuously maintained by the hard rule engine layer. The matching rules are based on predefined keyword combination matching rules. Each rule consists of three parts: Condition 1 = The surgical name contains all keywords from name_contains; Condition 2 = The surgical name does not contain any keywords from name_excludes; Condition 3 = The surgical procedure contains all keywords from text_contains (if this field is not empty), as shown in Table 1. During matching, the surgical name, surgical procedure, and preoperative diagnosis in the pre-qualified surgical operation records are all matched against the rule knowledge base. The results include successful matching and failed matching. If conditions 1-3 are all met: return the code corresponding to expected_code, with a confidence level of 0.99 and a method label of HardRule, terminate the entire process, and do not proceed to the subsequent retrieval and ranking stages, thereby achieving fast processing with zero computational overhead. If the match fails, further processing is required to obtain the final code. In addition, a match failure flag and structured diagnostic information can be generated when a match fails. The structured diagnostic information includes at least the field type that failed validation, the keyword that was not hit, and the corresponding context type identifier.
[0028] Table 1. Description of Rule Fields in Hard Rule Engine
[0029] In the specific implementation of step S102, one embodiment is as follows: Figure 2 As shown, the surgical operation records that have passed the pre-qualification are matched with the pre-built rule knowledge base in the hard rule engine layer, including: S1021. Extract the surgical name field and surgical procedure field from the surgical operation record, and determine whether the surgical name field contains all the necessary keywords corresponding to the candidate rules in the candidate rule set, and does not contain any prohibited keywords corresponding to the candidate rules. S1022. If yes, determine whether the surgical procedure field contains all the necessary keywords corresponding to the candidate rules in the candidate rule set to complete the matching.
[0030] In steps S1021-S1022, this application first performs lightweight semantic parsing on the surgical operation records that have passed the pre-qualification, extracting high-frequency verbs such as "resection," "anastomosis," and "reconstruction," core anatomical locations such as "knee joint," "tibial intercondylar spine," and "femoral neck," and surgical modifiers such as "replacement," "reduction," "fixation," "reconstruction," and "suture," to construct a keyword fingerprint vector for the record. Subsequently, using the inverted index pre-set in the rule knowledge base (with necessary keywords as keys), all possible subsets of rules that may cover the keyword fingerprint vector, i.e., the "candidate rule set," are quickly located. Then, two core text fields, the surgical name field and the surgical procedure field, are precisely extracted from the surgical operation records that have passed the pre-qualification. The surgical name field is a structured entry item that carries the core semantics of the surgical procedure type and anatomical location; the surgical procedure field is a free text description used to supplement key intraoperative details and contextual constraints. Subsequently, the system traverses each candidate rule in the candidate rule set and performs cascaded logical verification on the two fields: First, it strictly determines whether the surgical name field simultaneously contains all the necessary keywords associated with the rule, such as "total knee" and "replacement," and completely excludes any prohibited keywords listed in the rule, such as "unicompartmental." During the judgment process, keyword instances located in negation, conditional, or ambiguous contexts are automatically filtered. Only when the first step is successful is the second step triggered: further verifying whether the surgical procedure field also contains all the necessary keywords corresponding to the candidate rule to confirm the consistency and completeness of the surgical intent. For example, the rule "(total knee + replacement) AND NOT (biopsy)" requires the surgical name to contain all three items and exclude "biopsy." If this is satisfied, the system continues to verify whether supporting statements such as "total knee surface replacement" appear in the surgical procedure. The two levels of verification together constitute the deterministic coding basis. If any step fails, the matching of the rule is terminated, and the process moves to the next rule or enters the matching failure process, as shown in Table 2, which is a matching example table of the hard rule engine.
[0031] Table 2. Matching Examples of the Hard Rule Engine
[0032] In step S103, when the matching result is a failure, this application activates the vector retrieval layer and controls the vector retrieval layer to encode and retrieve key information in the surgical operation record based on a pre-built encoding library. The key information includes the standardized surgical name field, the anatomical location extracted by entity recognition in the surgical procedure field, surgical verbs and modifiers, and removes negation, conditional, and ambiguous contextual fragments. The key information is then organized into retrieval text, and the retrieval text is used to generate a standardized query vector using a domain-fine-tuned BERT-Surgery model. The standardized query vector is input into the encoding library, and an approximate nearest neighbor search is performed, returning the target number (default 5) of candidate codes and their corresponding standard names. Each candidate is accompanied by a similarity score, matching keyword coverage, and terminology consistency confidence. All candidate results are sorted and output according to the comprehensive score for subsequent manual review or automatic fusion module use. The encoding library contains 1,384 surgical operation codes and their corresponding standard names, covering all major orthopedic surgical procedures to obtain the target number of candidate codes and their standard names. See Table 3 for the encoding library field descriptions.
[0033] Table 3. Description of Encoding Library Fields
[0034] In the specific implementation of step S103, one embodiment is as follows: Figure 3 As shown, the vector retrieval layer controls the encoding and retrieval of key information in the surgical operation record based on a pre-built encoding library, obtaining a target number of candidate codes and their standard names, including: S1031. Extract the surgical name, surgical procedure and preoperative diagnosis from the surgical operation record, and use them as key information to construct a query text, and perform synonym expansion processing. S1032. The input expanded query text is processed by the fine-tuned target model to obtain a standardized query vector, so as to retrieve the target number of candidate codes and their standard names in the coding library based on the standardized query vector.
[0035] In steps S1031-S1032, this application, based on a vector retrieval layer, extracts the surgical name, surgical procedure, and preoperative diagnosis from the surgical operation record as key information. These three elements are semantically complementary: the surgical name carries the main information about the surgical procedure type and anatomical location; the surgical procedure describes the specific operational steps, approach methods, and technical details; and the preoperative diagnosis provides the nature, stage, and surgical indications of the disease. Together, they constitute a complete clinical context. These are then concatenated into query text using structured tagging and undergo synonym expansion processing. The expanded query text is input into a finely tuned target model running on the CPU for processing. This includes encoding the finely tuned target model into a 768-dimensional vector, performing L2 normalization to obtain a standardized query vector, and then searching the encoding library based on the standardized query vector. The search format is: surgical operation code + "" + surgical operation name; retrieving the target number of candidate codes and their standard names.
[0036] To ensure accuracy in encoding retrieval, which is prone to being missed by the vector retrieval layer, this application semantically expands the query text to make it more similar to other query expressions in the semantic space, as shown in Table 4. The fine-tuned target model adopts the Sentence-BERT architecture and was fine-tuned using 488 high-quality orthopedic coding data (text2vec_finetuned_v2). This fine-tuning process enables the model to better distinguish key differences in orthopedic surgical descriptions (such as anatomical location, surgical procedure type, and approach), thereby achieving higher semantic matching accuracy in the encoding retrieval task.
[0037] Table 4. Examples of semantic extensions for the encoding library
[0038] In a specific implementation of step S1032, one embodiment is as follows: Based on the standardized query vector, candidate codes and their standard names for the target quantity are retrieved, including: S10321. Calculate the cosine similarity between the standardized query vector and all vector indices of the pre-built encoding library, and sort them to obtain the ranking result; S10322. Traverse and sort the results, and continuously select the top N non-repeating surgical operation codes and their corresponding standard names to form the final TopN candidate list.
[0039] In steps S10321-S10322, after obtaining the standardized query vector, the vector retrieval layer of this application performs similarity calculation and structured candidate generation in the encoding library: First, it performs batch cosine similarity calculation between the standardized query vector and all 1,384 standard encoding vectors in the pre-built encoding library vector index. The vector index of the encoding library is built once at system startup and resides in memory. It is directly loaded and used in subsequent retrieval processes without repeated encoding, and is uniformly injected into the FAISS-GPU index structure to ensure that the query and index vectors are in the same semantic space and are comparable. If new encodings or vector indexes appear later, they can be added to the encoding library after relevant processing. Since the standardized query vector and all standard encoding vectors in the encoding library vector index have been L2 normalized, the cosine similarity calculation result is [ The similarity scores are set to real values within the range [1, 1], with values closer to 1 indicating greater semantic similarity. The system then sorts all similarity scores in descending order, generating a complete ranking result including index position, code ID, standard name, and original score. Based on this, a deduplication traversal selection process is performed: starting from the first position in the ranking, the system sequentially traverses, skipping duplicate codes (where different index positions point to the same code), retaining only the first occurrence of the code; the first N non-repeating surgical operation codes are selected consecutively (N is the preset target number, typically 5), and their corresponding standard names are extracted simultaneously. Each selected entry is appended with three metadata items: cosine similarity score, keyword coverage completeness (number of necessary terms hit / total number of rule-defined terms), and the recommendation level indicator in the clinical coding guidelines (e.g., "preferred," "alternative," "requires manual review"). Finally, the N entries are organized into a structured Top-N candidate list in descending order of similarity score, output in JSON format, with fields including code, standard name, score, coverage, and recommendation level.
[0040] In step S104, this application utilizes the LLM fine-ranking layer to construct a complete input from the candidate codes and their standard names of the target number, and performs discriminative selection through the selection rules enforced in the large language model to obtain the target code for automatic encoding of surgical operation records. The specific process is as follows: the complete input is converted into a complete large language model input, the large language model API is called to call the large language model for processing, thereby obtaining the model output of the large language model. The plain text content of the model output is de-whitelisted and converted to uppercase. If the output is one of A, B, C, D, and E, it is mapped to the corresponding candidate code as the final target code, realizing the automatic encoding of surgical operation records. It also achieves deep coupling between "retrieval breadth" and "discrimination accuracy": vector retrieval ensures coverage, and LLM fine-ranking ensures clinical rationality and rule compliance, avoiding encoding deviations caused by semantic drift or granularity mismatch in traditional methods, and significantly improving the accuracy of surgical coding. The large language model API is used for fine-ranking, and the specific calling parameters are shown in Table 5.
[0041] Table 5. Example of API call parameters for fine-tuning of large language models
[0042] In the specific implementation of step S104, one embodiment is as follows: The LLM fine sorting layer is used to construct a complete input from the candidate codes and their standard names for the target number of characters, and discriminative selection is performed using the selection rules enforced in the large language model, including: S1041. Based on the target number of candidate codes and their standard names, construct system prompt words and user prompt words respectively, and concatenate the system prompt words and user prompt words to form a complete input; S1042. Based on the selection rules enforced in the complete input, the target letter identifier is obtained by reasoning about the candidate codes and their standard names through the Large Language Model API; S1043. Map the target letter identifier to the target number of candidate codes, and select the target code based on the mapping result.
[0043] In steps S1041-S1043, this application constructs system prompts and user prompts based on the target number of candidate codes and their standard names. The system prompts mainly include: role definition, example learning, and important selection rules. The role definition designates a large language model to act as a "senior coder," responsible for selecting the best-matching code from the candidate codes. Example learning provides 15-18 correctly selected examples, each with the following structure: Examples cover easily confused coding scenarios, including: unicompartmental knee replacement vs. total knee replacement, femoral head replacement vs. total hip replacement, meniscus repair vs. meniscus suture, Achilles tendon suture vs. Achilles tendon repair, endoscopic discectomy vs. conventional discectomy, etc. Example N: Surgery: {Surgical scenario description}; Candidates: A. {Code 1} {Name 1}, B. {Code 2} {Name 2}; Correct selection: {Letter} ({Reason for selection}); Important selection rules are shown in Table 6. The user prompts use the following template: Surgery Name: {Surgery Name extracted from input}; Surgery Process: {Surgery Process extracted from input}; Preoperative Diagnosis: {Preoperative Diagnosis extracted from input}. Candidate Codes: A. {Candidate Code 1} {Candidate Name 1}; B. {Candidate Code 2} {Candidate Name 2}; C. {Candidate Code 3} {Candidate Name 3}; D. {Candidate Code 4} {Candidate Name 4}; E. {Candidate Code 5} {Candidate Name 5}.
[0044] Table 6 Examples of Important Selection Principles
[0045] The system prompt and user prompt are concatenated to form a complete input, which is then submitted to the API of a large language model deployed in a trusted environment. This large language model is fine-tuned using 180,000 expert-annotated coding decision samples, and its vocabulary is controlled. The large language model operates under mandatory decoding constraints: its output layer vocabulary only opens a preset letter set (A–Z), and the decoder uses a token-level masking mechanism to intercept non-target letter outputs in real time. The inference process focuses on term triad matching—comparing each candidate verb (e.g., "resection" vs. "reconstruction"), location (e.g., "arm" vs. "palm"), and modifier with the semantic consistency of the original record. After the model outputs a unique target letter identifier, such as "A", the system immediately performs a lookup mapping: mapping the letter "A" to the candidate code numbered A in the user prompt, such as 78.57012, generating a mapping result; finally, based on this mapping result, the corresponding code is directly selected as the target code.
[0046] In a specific implementation of step S1042, one embodiment is as follows: after the Large Language Model API infers the target letter identifier from the candidate code and its standard name, it further includes: S10421. If the output of the large language model is invalid or the API call is abnormal, directly read the TopN candidate list output by the vector retrieval layer. S10422. Let the surgical operation code with the first sorting number in the TopN candidate list and its standard name be the target code, and use it as the final output.
[0047] In steps S10421-S10422, this application establishes a comprehensive fault tolerance and degradation mechanism to ensure that the system can still output compliant and usable encoding results when anomalies occur at the Large Language Model (LLM) layer. When two typical anomalies occur at the LLM fine sorter layer: one is model API call failure (such as network timeout, service unavailability, HTTP status code other than 200), and the other is invalid model output response (including but not limited to: no letter identifiers output, multiple characters output, characters not from the preset letter set (such as "0", "#", "X1"), empty strings or only whitespace characters), the system immediately triggers the Fail-Safe protocol. The protocol automatically terminates the LLM inference process and seamlessly switches to the original output of the vector retrieval layer as a fallback solution. At this time, the system directly reads the Top-N candidate list generated by the vector retrieval layer; extracts the surgical operation code with the first sort number (i.e., index position 0) and its corresponding standard name, and determines it as the target code; this code, together with its standard name, original similarity score and terminology coverage integrity index, is encapsulated into a structured output object as the final result of this encoding task.
[0048] The following are examples of the methods provided in this application: Input: Surgical name: Arthroscopic reduction and fixation of tibial intercondylar spine fracture; Surgical procedure: Extensive synovial hyperplasia was observed anterior to the knee joint and removed using a synovial shear; the anterior cruciate ligament was continuous and in good tension, and avulsed bone fragments were visible at the tibial insertion point; the fracture fragments were reduced using curved forceps, temporarily fixed with cannulated screws and guide pins, and then fixed with two cannulated screws; Preoperative diagnosis: tibial intercondylar spine fracture. The procedure described in this application is as follows: Data quality inspection level: The surgical procedure is named "arthroscopic reduction and fixation of tibial intercondylar spine fracture". The description of the surgical procedure is consistent with the name, both pointing to the fixation operation of tibial intercondylar spine fracture. There is no obvious contradiction. The quality inspection is passed and it enters the first level.
[0049] Hard rule engine layer: The surgery name is not matched in any hard rule name_contains list, proceed to the second level.
[0050] Vector Retrieval Layer: The query text "arthroscopic reduction and fixation of tibial intercondylar spine fracture + surgical procedure summary + tibial intercondylar spine fracture" is vectorized and its similarity is calculated with the coding library. The following Top 5 candidates are retrieved, as shown in Table 7.
[0051] Table 7. Examples of Top 5 Candidates
[0052] LLM fine-tuning layer: System prompts guide the model to focus on the difference between "bone fragment fixation" and "ligament repair"; user prompts provide 5 candidates. The model judges that "cannulated screw fixation of fracture fragments" in the surgical procedure belongs to bone fragment fixation operation and does not involve ligament suturing or anchor repair. Therefore, it selects the first-ranked option 78.57012 (arthroscopic fixation of tibial intercondylar spine fracture) and outputs "A".
[0053] Example 2 This application also provides an automatic encoding device for surgical procedure records, such as... Figure 4 The diagram shows a structural block diagram of an automatic surgical procedure record encoding device. This device performs functions corresponding to the steps of an automatic surgical procedure record encoding method executed on the aforementioned terminal device. The device can be understood as a server component including a processor. This automatic surgical procedure record encoding device is applied to an automatic encoding system, which includes a data quality inspection layer, a hard rule engine layer, a vector retrieval layer, and an LLM fine ranking layer. The device includes: The acquisition module 401 is used to acquire the surgical operation record to be encoded through the data quality inspection layer, extract the surgical information of the surgical operation record to be encoded for pre-quality verification, and input the surgical operation record to the hard rule engine layer after the pre-quality verification is passed. The matching module 402 is used to match surgical operation records that have passed the pre-qualification with the rule knowledge base pre-built in the hard rule engine layer based on predefined keyword combination matching rules, and generate corresponding matching results. The retrieval module 403 is used to control the vector retrieval layer to encode and retrieve key information in the surgical operation record based on the matching result and a pre-built encoding library, so as to obtain a target number of candidate codes and their standard names; The encoding module 404 is used to construct a complete input from the candidate codes and their standard names of the target number using the LLM fine sorting layer, and to perform discriminative selection through the selection rules enforced in the large language model to obtain the target code so as to realize the automatic encoding of the surgical operation record.
[0054] In one feasible implementation, the retrieval module includes: Extract the surgical name, surgical procedure, and preoperative diagnosis from the surgical operation record, and use them as key information to construct a query text, and perform synonym expansion processing; The target model is fine-tuned to process the expanded query text to obtain a standardized query vector, which is then used to retrieve the target number of candidate codes and their standard names from the coding library.
[0055] In one feasible implementation, the retrieval module further includes: Calculate the cosine similarity between the standardized query vector and all vector indices of the pre-built encoding library, and sort them to obtain the ranking result; Traverse the sorted results and continuously select the top N non-repeating surgical operation codes and their corresponding standard names to form the final TopN candidate list.
[0056] In one feasible implementation, the encoding module includes: Based on the target number of candidate codes and their standard names, system prompt words and user prompt words are constructed respectively, and the system prompt words and user prompt words are concatenated to form a complete input; Based on the selection rules enforced in the complete input, the target letter identifier is obtained by reasoning about the candidate codes and their standard names through the Large Language Model API; The target letter identifier is mapped to a target number of candidate codes, and the target code is selected based on the mapping result.
[0057] In one feasible implementation, the encoding module further includes: If the output of the large language model is invalid or the API call is abnormal, directly read the TopN candidate list output by the vector retrieval layer; Let the surgical operation code with the first sorting number in the TopN candidate list and its standard name be the target code, and use it as the final output.
[0058] In one feasible implementation, the acquisition module includes: Extract the core anatomical nouns and surgical verbs from the surgical name, as well as the anatomical nouns and execution verbs that appear most frequently in the surgical procedure text; Determine whether the surgical procedure name does not contain any high-frequency anatomical site nouns appearing in the surgical procedure, or whether the surgical procedure verb in the surgical procedure name and the execution verb in the surgical procedure are mutually exclusive in medical semantics. Based on the matching results obtained from the judgment, it was determined that there was a semantic contradiction in the surgical operation record, and the pre-qualification was deemed to have failed.
[0059] In one feasible implementation, the matching module includes: Extract the surgical name field and surgical procedure field from the surgical operation record, and determine whether the surgical name field contains all the necessary keywords corresponding to the candidate rules in the candidate rule set, and does not contain any prohibited keywords corresponding to the candidate rules; If so, determine whether the surgical procedure field contains all the necessary keywords corresponding to the candidate rules in the candidate rule set to complete the matching.
[0060] Example 3 This application also provides an electronic device, such as Figure 5 As shown, it includes: a processor 501, a memory 502, and a bus 503. The memory 502 stores machine-readable instructions that can be executed by the processor 501. When the electronic device is running, the processor 501 and the memory 502 communicate through the bus 503. When the machine-readable instructions are executed by the processor 501, the steps of the automatic encoding method for surgical operation records are performed.
[0061] Example 4 This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the described automatic encoding method for surgical operation records.
[0062] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.
[0063] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0064] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0065] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a platform server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0066] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An automatic coding method for surgical procedure records, characterized in that, The method is applied to an automatic coding system, which includes a data quality inspection layer, a hard rule engine layer, a vector retrieval layer, and an LLM fine sorting layer. The surgical operation record to be encoded is obtained through the data quality inspection layer, the surgical information of the surgical operation record to be encoded is extracted for pre-quality verification, and the surgical operation record is input into the hard rule engine layer after the pre-quality verification is passed. Based on predefined keyword combination matching rules, the system matches surgical operation records that have passed the pre-qualification with the rule knowledge base pre-built in the hard rule engine layer, and generates corresponding matching results. Based on the matching results, the vector retrieval layer is controlled to encode and retrieve key information in the surgical operation record based on a pre-built encoding library, so as to obtain a target number of candidate codes and their standard names; The LLM fine sorting layer is used to construct the complete input from the candidate codes of the target number and their standard names, and discriminative selection is performed through the selection rules enforced in the large language model to obtain the target code, so as to realize the automatic encoding of surgical operation records.
2. The method according to claim 1, characterized in that, The vector retrieval layer controls the encoding retrieval of key information in the surgical operation record based on a pre-built encoding library, obtaining a target number of candidate codes and their standard names, including: Extract the surgical name, surgical procedure, and preoperative diagnosis from the surgical operation record, and use them as key information to construct a query text, and perform synonym expansion processing; The target model is fine-tuned to process the expanded query text to obtain a standardized query vector, which is then used to retrieve the target number of candidate codes and their standard names from the coding library.
3. The method according to claim 2, characterized in that, Based on the standardized query vector, candidate codes and their standard names for the target quantity are retrieved, including: Calculate the cosine similarity between the standardized query vector and all vector indices of the pre-built encoding library, and sort them to obtain the ranking result; Traverse the sorted results and continuously select the top N non-repeating surgical operation codes and their corresponding standard names to form the final TopN candidate list.
4. The method according to claim 1, characterized in that, The LLM fine sorting layer is used to construct the complete input from the candidate codes and their standard names for the target number of words, and discriminative selection is performed using the selection rules enforced in the large language model, including: Based on the target number of candidate codes and their standard names, system prompt words and user prompt words are constructed respectively, and the system prompt words and user prompt words are concatenated to form a complete input; Based on the selection rules enforced in the complete input, the target letter identifier is obtained by reasoning about the candidate codes and their standard names through the Large Language Model API; The target letter identifier is mapped to a target number of candidate codes, and the target code is selected based on the mapping result.
5. The method according to claim 4, characterized in that, After the Large Language Model API infers the target letter identifier from the candidate codes and their standard names, it also includes: If the output of the large language model is invalid or the API call is abnormal, directly read the TopN candidate list output by the vector retrieval layer; Let the surgical operation code with the first sorting number in the TopN candidate list and its standard name be the target code, and use it as the final output.
6. The method according to claim 1, characterized in that, Extracting surgical information from the surgical procedure record to be encoded for preliminary quality verification includes: Extract the core anatomical nouns and surgical verbs from the surgical name, as well as the anatomical nouns and execution verbs that appear most frequently in the surgical procedure text; Determine whether the surgical procedure name does not contain any high-frequency anatomical site nouns appearing in the surgical procedure, or whether the surgical procedure verb in the surgical procedure name and the execution verb in the surgical procedure are mutually exclusive in medical semantics. Based on the matching results obtained from the judgment, it was determined that there was a semantic contradiction in the surgical operation record, and the pre-qualification was deemed to have failed.
7. The method according to claim 1, characterized in that, Matching surgical operation records that have passed pre-qualification with the pre-built rule knowledge base in the hard rule engine layer, including: Extract the surgical name field and surgical procedure field from the surgical operation record, and determine whether the surgical name field contains all the necessary keywords corresponding to the candidate rules in the candidate rule set, and does not contain any prohibited keywords corresponding to the candidate rules; If so, determine whether the surgical procedure field contains all the necessary keywords corresponding to the candidate rules in the candidate rule set to complete the matching.
8. An automatic encoding device for surgical operation records, characterized in that, Applied to an automatic coding system, the automatic coding system includes a data quality inspection layer, a hard rule engine layer, a vector retrieval layer, and an LLM fine ranking layer, the device includes: The acquisition module is used to acquire the surgical operation record to be encoded through the data quality inspection layer, extract the surgical information of the surgical operation record to be encoded for pre-quality verification, and input the surgical operation record into the hard rule engine layer after the pre-quality verification is passed. The matching module is used to match surgical operation records that have passed the pre-qualification with the rule knowledge base pre-built in the hard rule engine layer based on predefined keyword combination matching rules, and generate corresponding matching results. The retrieval module is used to control the vector retrieval layer to encode and retrieve key information in the surgical operation record based on the matching results and a pre-built encoding library, so as to obtain a target number of candidate codes and their standard names; The encoding module is used to construct a complete input from the candidate codes and their standard names of the target number using the LLM fine sorting layer, and to perform discriminative selection through the selection rules enforced in the large language model to obtain the target code for automatic encoding of surgical operation records.
9. An electronic device, characterized in that, include: The device includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus. When the machine-readable instructions are executed by the processor, they perform the steps of an automatic encoding method for surgical operation records as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the automatic encoding method for surgical operation records as described in any one of claims 1-7.
Citation Information
Patent Citations
Automatic coding method and system for surgical operation records based on large language model
CN119092046A