A medical examination report structuring method based on LLM

By employing an LLM-based structuring method for medical examination reports, the problems of low efficiency, high error rates, and data security risks in the diagnosis and treatment of cardiovascular diseases are addressed. This method achieves highly accurate structured data extraction and multidimensional data support, enabling in-depth analysis in clinical research and ensuring data security.

CN122245591APending Publication Date: 2026-06-19SHANDONG UNIV QILU HOSPITAL

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHANDONG UNIV QILU HOSPITAL
Filing Date
2026-03-23
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

In the diagnosis and treatment of cardiovascular diseases, existing technologies suffer from problems such as low efficiency, high error rate, data security risks, insufficient output reliability, poor terminology adaptability, and fragmented technical architecture in the processing of unstructured or semi-structured text reports from examinations such as echocardiography, coronary CT, and coronary angiography DSA.

Method used

A structured approach for medical examination reports based on LLM is adopted, including data preprocessing, local LLM structure extraction, multi-level optimization, medical knowledge graph construction, vector database indexing, and data merging and storage. Combined with semantic bidirectional matching illusion suppression, few-sample adaptive extraction, and error retry mechanism, localized data processing and in-depth data mining are achieved.

Benefits of technology

It significantly reduces the hallucination rate and improves the extraction accuracy to ≥97%, solving the problems of poor terminology adaptability and fragmented technical architecture in data-scarce scenarios. It provides multi-dimensional and traceable data support for clinical research and ensures data security and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122245591A_ABST
    Figure CN122245591A_ABST
Patent Text Reader

Abstract

This invention discloses a structured method for medical examination reports based on LLM, comprising the following steps: Step 1: Data preprocessing: performing field association and merging, anomaly marking, and format standardization; Step 2: Local LLM structure extraction: constructing a structured prompt word template of "role definition - task boundary - output constraint - basis annotation"; sending a request to the local server LLM interface to generate initial results; Step 3: Multi-level optimization: optimizing through a semantic bidirectional matching illusion suppression mechanism, a few-sample adaptive extraction mechanism, a multi-dimensional data cleaning mechanism, and an error retry mechanism; Step 4: Medical knowledge graph construction: performing entity relationship extraction, community discovery and visualization operations, and constructing an incremental update mechanism; Step 5: Construction of vector database index and semantic retrieval: completing the construction of semantic index, voice retrieval and source tracing, and scientific research data screening.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical data processing and artificial intelligence, and in particular to a method for structuring medical examination reports based on LLM. Background Technology

[0002] In the cardiovascular disease diagnosis and treatment system, reports from examinations such as echocardiography, coronary CT, and coronary angiography (DSA) are core clinical evidence for disease assessment, treatment planning, and prognostic follow-up. These reports are mostly in unstructured or semi-structured free text format, covering key data such as patient basic information, examination indicators, lesion characteristics, imaging findings, diagnostic conclusions, and follow-up recommendations. Traditional processing methods rely on medical staff manually entering data into the electronic data capture (EDC) system, which suffers from low efficiency, high error rates, and waste of data value.

[0003] Existing medical text parsing solutions based on Natural Language Processing (NLP) can effectively address the aforementioned issues, but they still suffer from the following key drawbacks: 1. Data security and privacy risks: The "Guidelines for Medical Data Security" stipulate that sensitive medical data is prohibited from cross-platform transmission. If external APIs are used to call third-party large models to process medical data, sensitive medical data must be transmitted across platforms, violating the "Guidelines for Medical Data Security" and posing a high risk of data leakage; 2. Insufficient output reliability: Large models are prone to "illusions" (generating structured data that does not match the reported facts) and feature omissions, and lack error verification mechanisms based on medical semantics. The extraction accuracy is generally below 90%, making it difficult to meet the accuracy requirements of medical data; 3. Limited data adaptability: Medical terminology is diverse (e.g., "increased left ventricular filling pressure" versus "abnormal left ventricular filling"), and there are individual differences in the description of the same disease. Existing solutions lack the ability to adapt to terminology variations and rely on massive amounts of labeled data for training, resulting in a significant performance drop in scenarios with few samples; 4. Fragmented technical architecture: Focusing only on a single data extraction stage, lacking in-depth mining of medical entity relationships, and unable to provide multi-dimensional data support for clinical research.

[0004] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention

[0005] The purpose of this invention is to address the shortcomings of existing technologies by proposing an LLM-based method for structuring medical examination reports.

[0006] To achieve the above objectives, the present invention also employs the following technical solution: A method for structuring medical examination reports based on LLM includes the following steps: Step 1: Data preprocessing: Perform field association and merging, anomaly marking, and format standardization. Step 2: Local LLM Structured Extraction: Construct a structured prompt template of "role definition - task boundary - output constraint - basis annotation"; send a request to the local server LLM interface to generate the initial results; Step 3: Multi-level optimization: Optimization is carried out through semantic bidirectional matching illusion suppression mechanism, few-sample adaptive extraction mechanism, multi-dimensional data cleaning mechanism and error retry mechanism; Step 4: Construction of the medical knowledge graph: Extracting entity relationships, discovering communities, and performing visualization operations, and building an incremental update mechanism; Step 5: Construction of Vector Database Index and Semantic Retrieval: Complete the construction of semantic index, speech retrieval and source tracing, and scientific research data screening; Step 6: Data Merging and Storage: Complete intelligent association merging, multi-format storage output, version management, and traceability; Step 7: Manual review: Generate a structured review checklist for manual review, and optimize prompts and validation rules.

[0007] Furthermore, step 1 includes the following steps: Step 1.1 Data Loading and Field Association Merging: Construct semantic association rules for medical data, identify the association information scattered across different fields in the examination report, and merge them into a unified field using Pandas tools; Step 1.2 Anomaly Labeling: Construct a medical dictionary containing abnormal terms; identify and label abnormal descriptions in the examination report using regular expressions and semantic matching algorithms; Step 1.3 Format standardization: Standardize and convert dates, medical units, and abbreviations.

[0008] Furthermore, in step 2, a structured prompt template of "role definition - task boundary - output constraint - basis annotation" is constructed, and the results are generated based on the preprocessed examination report; the role is defined as "senior cardiovascular disease diagnosis and treatment expert", the task boundary is the information source, the output constraint is that the format is limited to JSON, and each field output by the basis annotation must be accompanied by the extraction basis.

[0009] Furthermore, the semantic bidirectional matching illusion suppression mechanism in step 3 includes calculating the character-level n-gram F1 score to quantify the matching degree. The formula is F1 = 2 × precision × recall / (precision + recall). When the matching degree is ≤ 0.3, it is judged as an illusion. The few-sample adaptive extraction mechanism in step 3 includes fusing 3-5 sets of "unstructured text-structured results" few-sample examples with chain-like thinking prompts to guide the model to reason and extract logic step by step, reducing the dependence on massive labeled data; Step 3's multi-dimensional data cleaning mechanism includes: validating the format of fields such as dates and numbers using regular expressions; unifying non-standard expressions based on a medical terminology dictionary; and extracting long text reports in segments according to "examination items - lesion description - diagnosis conclusion" to improve the extraction accuracy of complex texts. Step 3's error retry mechanism includes constructing field integrity verification rules for verification. These rules include field quantity matching verification rules, required field non-empty verification rules, field data type compliance verification rules, field hierarchy and nesting compliance verification rules, and extraction basis and field association verification rules.

[0010] Furthermore, the few-sample adaptive extraction mechanism in step 3 includes the following steps: Step 3.1 Few-shot example embedding: Display the provided 3-5 input-output pairs in the prompt words. The input includes real unstructured medical report text, and the output is the corresponding structured JSON file. Each field in the output is followed by a verbatim reference "Basis: [...]". Step 3.2 Chain-like reasoning: Clearly define the step-by-step reasoning instructions. First, identify abnormal terms by scanning all medical terms in the report that are outside the normal range or contain keywords such as "increased," "decreased," or "abnormal." Then, locate the description by finding the corresponding numerical value, unit, and contextual description for the abnormal term. Next, map the fields by matching the abnormal terms to predefined target field names. Then, verify the basis by copying the complete original sentence containing the abnormal term as the basis for extraction. Finally, output a JSON file.

[0011] Furthermore, the entity relation extraction operation in step 4 adopts the process of "text segmentation - triple extraction - relation filtering". The input file is read by DirectoryLoader, the text is segmented by the characters period and newline and a unique chunk_id is assigned. The df2Graph function is called to extract the "entity 1-relationship-entity 2" medical triples, and invalid relations are filtered in combination with the medical relation dictionary. Step 4, community discovery and visualization, involves constructing an undirected medical knowledge graph with entities as nodes and relationships as edges. The Girvan-Newman algorithm is used to divide the community into "disease-symptom" and "examination-lesion" categories, with each community assigned a unique color. An interactive HTML graph is then generated using the PyVis library. The incremental update mechanism in step 4 involves extracting the triples from the new inspection report data and adding them to the existing map when new inspection report data is added, thus avoiding full reconstruction.

[0012] Furthermore, in step 5, the construction of the semantic index involves dividing the standardized report text into semantic units by periods, then converting the semantic units into 768-dimensional vectors using the LangChain+HuggingFaceEmbeddings model, and storing them in the FAISS vector database to establish a semantic index for medical text. In step 5, voice retrieval and source tracing respond to user questions. The M3E pre-trained language model is used to vectorize the user query and the standardized medical report text blocks. The input text is mapped into a 768-dimensional semantic vector by calling the encoder of the M3E model. The vector is stored in the FAISS vector index library. The top-5 most similar text blocks and structured data are retrieved and concatenated into prompt words input LLM to generate semantic answers. Step 5, the scientific research data screening, completes batch data screening based on entity relationships, providing efficient data support for clinical research.

[0013] Furthermore, in step 6, the intelligent association and merging automatically associates the structured data with the original Excel spreadsheet based on the unique identifier of "inspection record number", supplementing the structured fields into the original dataset to maintain data integrity and relevance. The multi-format storage output in step 6 is saved as Excel, CSV, JSON and other formats and stored in the local database, which can be connected to the hospital's existing EDC system to achieve seamless data flow; The version management and traceability in step 6 records the version information for each process and supports data rollback and quality traceability.

[0014] Compared with the prior art, the beneficial effects of this invention are as follows: Through a full-link mechanism of "prevention (prompt words) → detection (F1 check) → correction (retry)," the hallucination rate is reduced by more than 85%, and the extraction accuracy is improved to ≥97%. The small sample guidance and built-in medical knowledge base enable flexible adaptation to different terminology expressions and individualized descriptions, solving the performance bottleneck in data-scarce scenarios. By integrating the links of "extraction → optimization → analysis (knowledge graph) → retrieval (vector library) → storage," a complete solution is formed to provide multi-dimensional, in-depth, and traceable data support for clinical research, completely solving the problem of fragmented technical architecture. Attached Figure Description

[0015] Figure 1 A flowchart illustrating a structured approach to medical examination reports based on LLM (Liquid Management Model). Figure 2 This is a framework diagram of an execution system for a structured medical examination report method based on LLM. Detailed Implementation

[0016] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0017] Example 1: This example provides a method for structuring medical examination reports based on LLM. The implementation environment is as follows: 1. Hardware environment: High-performance local server in the hospital, configured with CPU: Intel Xeon Gold 6330, GPU: NVIDIA A100 40G, memory: 256G, storage: 4T SSD, deployed on the hospital's intranet, with no external network access.

[0018] 2. Software environment: Operating system is Ubuntu 22.04 LTS, Python version 3.9, LangChain version 0.1.0, HuggingFace Transformers version 4.35.0, Pandas version 2.1.0, PyVis version 0.3.2, FAISS version 1.7.4, MySQL version 8.0.

[0019] 3. Model Deployment: Deploy the open-source LLM model Qwen2.5-72B-Instruct on the local server, complete the fine-tuning for the medical field, open the hospital intranet API interface, and set the model inference parameters to temperature=0.1 and max_tokens=2048 by default.

[0020] This embodiment presents a method for structuring medical examination reports based on LLM, such as... Figures 1-2 As shown, it includes the following steps: Step 1: Data preprocessing: Perform field association and merging, anomaly marking, and format standardization.

[0021] In this embodiment, step 1 includes the following steps: Step 1.1 Data Loading and Field Association Merging: Construct semantic association rules for medical data, identify the association information scattered in different fields in the examination report (such as "coronary artery stenosis location" and "stenosis degree" and "lesion range"), and merge them into a unified field using Pandas tools.

[0022] Specifically, in step 1.1, Pandas is used to read the Excel file of the examination report. Based on the user-configured medical data semantic association rules, the merge_field function is called to merge and generate a new unified field, ensuring the integrity of the association information and avoiding extraction bias caused by information fragmentation.

[0023] Step 1.2 Abnormal Labeling: Construct a medical dictionary containing abnormal terms (such as "abnormal", "stenosis", "enlargement", "reflux", "thickening"); identify and label abnormal descriptions in the examination report using regular expressions and semantic matching algorithms.

[0024] Specifically, in step 1.2, a medical anomaly terminology dictionary is loaded. By combining regular expressions and semantic matching algorithms, abnormal keywords in the new field are detected and marked. Records marked as "abnormal" are processed in deep structured processing, while unmarked records are archived directly.

[0025] Step 1.3 Format standardization: Standardize and convert dates (e.g., “2024.5.20” and “2024-05-20” are unified as “YYYY-MM-DD”), medical units (e.g., “mm Hg” and “millimeters of mercury” are unified as “mmHg”), and abbreviations (e.g., “LVEF” is expanded to “left ventricular ejection fraction”).

[0026] Specifically, in step 1.3, the format_standardize function is called to standardize the format of dates, units, and abbreviations, and output a standardized Excel file to reduce the interference of format differences on LLM extraction and improve the consistency of input data.

[0027] Step 2: Local LLM Structure Extraction: Construct a structured prompt template of "role definition - task boundary - output constraint - basis annotation"; send a request to the local server LLM interface to generate the initial result.

[0028] In this embodiment, step 2 constructs a structured prompt template of "role definition - task boundary - output constraint - basis annotation" and generates results based on the preprocessed examination report; the role is defined as "senior cardiovascular disease diagnosis and treatment expert", the task boundary is the information source, the output constraint is that the format is limited to JSON, and each field output by basis annotation must be accompanied by the extraction basis (quoting the original report fragment).

[0029] In this embodiment, in the four-dimensional prompt words of step 2.1, the role definition is used to enhance domain professionalism, the task boundary is used to prevent information overload or deviation, the output constraint is used to ensure structural uniformity and parsability, and the annotation is used to force the model to be faithful to the original text, thereby significantly suppressing illusions from the source, improving the accuracy and traceability of the extraction results, and reducing the randomness of the output from the source.

[0030] An example of a prompt word constructed based on the template in step 2.1 is as follows: { "system_message": "You are a senior cardiovascular disease expert and need to extract structured information from the [Medical Examination Report] and output it in JSON format, including required fields: presence of heart problem (yes / no), abnormality description, diagnosis conclusion, and judgment basis (quoted from the original text). Fields not mentioned are marked as 'none'". "few_shot_examples": [ {"input": "Echocardiography results: Left atrial enlargement, increased left ventricular filling pressure, no obvious abnormalities in segmental motion", "output": {"Heart problem present": "Yes", "Abnormality description": "Left atrial enlargement, increased left ventricular filling pressure", "Diagnosis conclusion": "Left atrial enlargement with abnormal left ventricular filling", "Basis for judgment": "Left atrial enlargement (original text), increased left ventricular filling pressure (original text)"}} ], "user_message": "[Medical Examination Report] Echocardiography Results: The patient is a 56-year-old male. The ultrasound showed interventricular septal thickening, normal thickness of the left ventricular posterior wall, abnormal left ventricular filling, and abnormal segmental motion of the anterior wall. The diagnosis was interventricular septal thickening with abnormal left ventricular filling." }

[0031] In this embodiment, an open-source LLM is deployed on a high-performance local server in the hospital, providing an intranet API interface. Medical data only flows within the local server in the form of a Prompt. Input, processing, and output do not leave the hospital's intranet, completely eliminating the risk of privacy leakage caused by cross-platform data transmission. In step 2.1, the result is generated based on the preprocessed examination report and is completed using the open-source LLM deployed on the local server. The initial parameter is set to temperature=0.1, and JSON-formatted structured data is received.

[0032] In addition, in this embodiment, custom field configurations can be set, allowing users to customize extracted fields through a visual interface (such as configuring fields like "abnormal left ventricular filling," "abnormal segmental motion," and "left ventricular ejection fraction" for cardiac ultrasound, and fields like "coronary branch stenosis location," "degree of stenosis," and "plaque type" for coronary CT). Required field attributes can also be set to adapt to the personalized needs of different examination reports.

[0033] Step 3: Multi-level optimization: Optimization is carried out through semantic bidirectional matching illusion suppression mechanism, few-sample adaptive extraction mechanism, multi-dimensional data cleaning mechanism and error retry mechanism.

[0034] In this embodiment, the semantic bidirectional matching illusion suppression mechanism in step 3 includes calculating the character-level n-gram F1 score to quantify the matching degree. The formula is F1 = 2 × precision × recall / (precision + recall). When the matching degree is ≤ 0.3, it is determined to be an illusion.

[0035] In this embodiment, the semantic bidirectional matching hallucination suppression mechanism in step 3 introduces a medical terminology semantic matching mechanism to construct a bidirectional matching verification process of "extraction result - original report". When the matching degree is ≤0.3, it is determined to be a hallucination, which can trigger the correction process and return to step 2.

[0036] In this embodiment, the few-sample adaptive extraction mechanism in step 3 includes fusing 3-5 sets of "unstructured text-structured results" few-sample examples with chain-like thinking prompts to guide the model to reason and extract logic step by step, reducing the dependence on massive labeled data.

[0037] In this embodiment, the few-sample adaptive extraction mechanism in step 3 ensures an extraction accuracy of ≥95% in the few-sample scenario.

[0038] Specifically, the few-sample adaptive extraction mechanism in step 3 includes the following steps: Step 3.1 Few-sample embedding: Display the provided 3-5 input-output pairs in the prompt, where the inputs include real unstructured medical report text (such as echocardiogram descriptions), and the output is the corresponding structured JSON file, with each field in the output followed by a verbatim reference "Based on: [...]".

[0039] An example of an input-output pair in step 3.1 is as follows: Input: "Left ventricular end-diastolic diameter (LVEDD) 58mm (normal <55mm), left atrial diameter 42mm". Output: { Left ventricular end-diastolic diameter (mm): 58 "Based on Left Ventricular End-Diaphragmatic Diameter (LVEDD):" 58 mm (normal <55 mm) }

[0040] Step 3.2 Chain-like reasoning: Clearly define the step-by-step reasoning instructions. First, identify abnormal terms by scanning all medical terms in the report that are outside the normal range or contain keywords such as "increased," "decreased," or "abnormal." Then, locate the description by finding the corresponding numerical value, unit, and contextual description for the abnormal term. Next, map the fields by matching the abnormal term to a predefined target field name (e.g., "left ventricular ejection fraction _%"). Then, verify the basis by copying the complete original sentence containing the abnormal term as the basis for extraction. Finally, output a JSON file, only outputting the final JSON without any explanation.

[0041] In this embodiment, step 3.2 includes explicit step-by-step reasoning instructions, requiring the model to simulate the expert's thought process.

[0042] In addition, based on the current report type to be processed (such as echocardiography, pathology, CT), the few sample examples and field list in the prompt words can be dynamically replaced to ensure that the guidance content is highly relevant to the task.

[0043] In this embodiment, the multi-dimensional data cleaning mechanism in step 3 includes: validating the format of fields such as date and numerical values ​​using regular expressions; unifying non-standard expressions based on a medical terminology dictionary; and extracting long text reports in segments according to "examination items - lesion description - diagnosis conclusion" to improve the extraction accuracy of complex texts.

[0044] In this embodiment, the error retry mechanism in step 3 includes constructing field integrity verification rules for verification. The verification rules include field quantity matching verification rules, required field non-empty verification rules, field data type compliance verification rules, field hierarchy and nesting compliance verification rules, and extraction basis and field association verification rules.

[0045] In this embodiment, the error retry mechanism in step 3 constructs field integrity verification rules for validation. If the model returns a result missing required fields or the number of fields does not match the configuration, the prompt details are adjusted, and recursively retrying up to 3 times to ensure field integrity ≥ 99%. The field integrity verification rules adopt a "three-layer architecture + five core verification rules" design. All rules are deeply linked with the LLM four-dimensional prompt template, and the verification results drive the retry process. The three-layer architecture consists of a basic configuration layer, a rule engine layer, and an execution feedback layer. All rules are designed according to the standardized principles of "rule definition, construction details, triggering conditions, and processing logic." The five core verification rules are: field quantity matching verification rule, required field non-empty verification rule, field data type compliance verification rule, field hierarchy and nesting compliance verification rule, and extraction basis and field correlation verification rule.

[0046] Step 4: Construction of the medical knowledge graph: Extract entity relationships, discover communities and perform visualization operations, and build an incremental update mechanism.

[0047] In this embodiment, the entity relation extraction operation in step 4 adopts the process of "text segmentation - triple extraction - relation filtering". The input file is read by DirectoryLoader, the text is segmented by the characters "." and newline characters and assigned a unique chunk_id. The df2Graph function is called to extract the medical triple "entity 1-relationship-entity 2" and invalid relations are filtered in combination with the medical relation dictionary.

[0048] In this embodiment, step 4 involves text segmentation and triple extraction: the text is segmented into blocks to generate a DataFrame, and the df2Graph function is called to extract triples. An example is shown below: Table 1 Examples of Triple Extraction

[0049] In this embodiment, the community discovery and visualization operation in step 4 includes constructing an undirected medical knowledge graph, with entities as nodes (node ​​size determined by the number of connecting edges) and relationships as edges (recording relationship type and weight). The Girvan-Newman algorithm is used to divide the community into "disease-symptom" and "examination-lesion" categories, with each community assigned a unique color. An interactive HTML graph is generated using the PyVis library, supporting node dragging, zooming, and detailed viewing. A force-directed layout is used to automatically cluster closely related nodes.

[0050] In this embodiment, an undirected graph is constructed, communities are divided, an interactive HTML graph is generated, and the graph is saved to a local server.

[0051] In this embodiment, the incremental update mechanism in step 4 is to extract the triples from the new inspection report data and add them to the existing map when new inspection report data is added, thus avoiding full reconstruction.

[0052] Step 5: Construction of Vector Database Index and Semantic Retrieval: Complete the construction of semantic index, voice retrieval and source tracing, and scientific research data screening.

[0053] In this embodiment, the construction of the semantic index in step 5 involves dividing the standardized report text into semantic units by periods, then converting the semantic units into 768-dimensional vectors using the LangChain+HuggingFaceEmbeddings model, and storing them in the FAISS vector database to establish a medical text semantic index.

[0054] In this embodiment, the retrieval response time is ≤0.5 seconds by constructing the semantic index in step 5.

[0055] In this embodiment, the voice retrieval and source tracing in step 5 responds to the user's question. The M3E (Multilingual Multi-task Medical Embedding) pre-trained language model is used to vectorize the user query and the standardized medical report text blocks respectively. The input text is mapped into a 768-dimensional semantic vector by calling the encoder of the M3E model, and the vector is stored in the FAISS vector index library. The top-5 most similar text blocks and structured data are retrieved and concatenated into prompt words input LLM to generate a semantic answer.

[0056] In this embodiment, all results from step 5 are accompanied by traceability information such as report number and original text excerpt, which meets the requirements for the rigor of medical data.

[0057] In this embodiment, step 5, the scientific research data screening, completes batch data screening based on entity relationships, providing efficient data support for clinical research.

[0058] Step 6: Data merging and storage: Complete intelligent association merging, multi-format storage output, version management, and traceability.

[0059] In this embodiment, the intelligent association and merging in step 6 automatically associates the structured data with the original Excel spreadsheet based on the unique identifier of "inspection record number", supplements the structured fields to the original dataset, and maintains data integrity and relevance.

[0060] In this embodiment, the multi-format storage output in step 6 is saved as Excel, CSV, JSON and other formats and stored in a local database (MySQL / PostgreSQL), which can be connected to the hospital's existing EDC system to achieve seamless data transfer.

[0061] In this embodiment, the version management and traceability in step 6 records the version information for each process and supports data rollback and quality traceability.

[0062] Step 7: Manual review: Generate a structured review checklist for manual review, and optimize prompts and validation rules.

[0063] In this embodiment, a structured verification checklist is automatically generated, aligning core information by row: original report text fragments (i.e., the original sentences on which the model extracts data); structured field values ​​output by the model (e.g., "left ventricular ejection fraction _%": 45); and extraction criteria marked by the system (i.e., the specific citation location or content in the original text).

[0064] This comparison table is organized by field, allowing doctors to quickly compare, correct, or confirm with a single click. All results modified or confirmed by doctors are automatically recorded as high-quality optimized samples and used for subsequent iterations of prompt word templates and updates to the small-sample example library, achieving a continuous optimization loop through human-machine collaboration.

[0065] This embodiment integrates core technologies such as Python programming, prompt word engineering, bidirectional semantic matching, few-shot adaptive learning, knowledge graph construction, and vector database retrieval. Using Excel spreadsheets corresponding to cardiac ultrasound, coronary CT, and coronary angiography DSA reports as input, it achieves fully automated conversion from unstructured text to structured data through a complete workflow design of "intelligent preprocessing - localized LLM extraction - multi-level accuracy optimization - knowledge graph construction - semantic retrieval enhancement - data merging and storage." While ensuring the localized flow of medical data throughout the process and preventing privacy leaks, it solves problems such as large model illusion, feature omission, and poor terminology adaptability, significantly improving data processing efficiency and accuracy, and providing the medical industry with a "safe, accurate, efficient, and scalable" structured data solution.

[0066] The method in this embodiment reduces the hallucination rate by more than 85% and improves the extraction accuracy to ≥97% through a full-link mechanism of "prevention (prompt words) → detection (F1 check) → correction (retry)". The small sample guidance and built-in medical knowledge base enable flexible adaptation to different terminology expressions and individualized descriptions, solving the performance bottleneck in data-scarce scenarios. By integrating the links of "extraction → optimization → analysis (knowledge graph) → retrieval (vector library) → storage", a complete solution is formed to provide multi-dimensional, in-depth and traceable data support for clinical research, completely solving the problem of fragmented technical architecture.

[0067] Specifically, the method in this embodiment has the following effects: 1. Localized end-to-end security architecture: Through a triple security mechanism of "local deployment + intranet transfer + privacy verification", medical data does not leave the hospital's local environment throughout the entire process, complies with the "Medical Data Security Guidelines", reduces the risk of data leakage to 0, and solves the privacy risks of existing solutions that rely on external APIs.

[0068] 2. Semantic Bidirectional Matching Illusion Suppression System: This system integrates medical terminology semantic matching, confidence verification, and few-sample guidance to construct a full-link "prevention-detection-correction" illusion suppression mechanism. Prevention Phase: In the localized LLM structured extraction module, the model is forced to work as a "senior cardiovascular expert" through four-dimensional prompt word engineering, with output limited to JSON format and each field required to include original text fragments, thus constraining illusions from the generation source. Simultaneously, 3–5 sets of few-sample examples and chained thinking instructions (e.g., "first identify abnormal terms → locate description → map fields → verify evidence") are introduced to guide the model in establishing a reliable reasoning path, reducing the risk of conjecture about unseen statements. Detection Phase: In the multi-level accuracy optimization module, semantic bidirectional matching verification is performed—the character-level n-gram F1 score of the extracted results and the original report text is calculated. When the F1 value of any field is ≤0.3, it is judged as a high-risk illusion. Correction Phase: Triggering an intelligent error retry mechanism, dynamically enhancing the details of prompts (such as explicitly emphasizing missing fields and refining task boundaries), and recursively calling the local LLM up to 3 times until field completeness is ≥99% and F1 > 0.3. This mechanism achieved a reduction of the hallucination rate by more than 85% and a structured extraction accuracy of ≥97% in real medical report testing, effectively addressing the core pain point of insufficient reliability of large model output in medical scenarios.

[0069] 3. Few-sample adaptive extraction mechanism: Through the "few-sample examples + chain thinking" prompt strategy, only 3-5 sets of labeled samples are needed to adapt to different types of medical examination reports. The performance retention rate is ≥95% in the few-sample scenario, which solves the problems of scarce medical labeled data and poor scenario adaptability.

[0070] 4. Full-chain integration of "extraction-analysis-visualization": Extraction: Through localized LLM and multi-level optimization modules, outputs highly accurate (≥97%) structured JSON with original text evidence; Analysis: Parallel construction of a medical knowledge graph (mining entity relationships) and an M3E vector library (supporting semantic retrieval) to achieve deep data understanding; Visualization: Provides interactive graph display and an "answer + traceability" search panel in a unified database, supporting research screening and evidence backtracking. Overall data utilization is improved by over 60%, providing multi-dimensional, computable, and traceable data support for clinical research. Integrating structured extraction, knowledge graph analysis, and vector database retrieval, it deeply mines entity relationships in medical data, supports semantic retrieval and research data screening, and improves data utilization by over 60%, breaking through the limitations of existing solutions that only focus on a single extraction stage.

[0071] 5. Human-Machine Collaborative Optimization Mechanism: Through knowledge graph visualization, retrieval result tracing, and data version management, the system supports manual review and correction by doctors. Corrected results are fed back into the prompt word optimization process, enabling continuous system iteration and upgrades. A comparison table of "Original Report Text - Extracted Results - Judgment Basis - Matching Degree" is automatically generated and pushed to the clinician review interface. Doctors can directly modify erroneous results, and the corrected results are automatically saved as high-quality, low-sample data to optimize the prompt word template and model extraction capabilities. The original report text serves as the verification benchmark and is the sole reference source for all subsequent extracted results and judgment basis. Extracted results, as the verification object, are the standardized structured field values ​​extracted by the LLM from the original report text and must be compared with the actual content of the original report text. Judgment basis, as the verification bridge, consists of the original text citations annotated by the LLM for each extracted result and must be compared bidirectionally with both the original report text and the extracted results. Matching degree, as a quantitative verification indicator, is the semantic matching score between the extracted results + judgment basis and the original report text, directly reflecting the credibility of the extracted results. Based on a local server-based structured data caching library, raw report database, and matching degree calculation result library, the system automatically generates comparison tables using a preset table generation engine (Python-Pandas+Jinja2 template).

[0072] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A method for structuring medical examination reports based on LLM, characterized in that, Includes the following steps: Step 1: Data preprocessing: Perform field association and merging, anomaly marking, and format standardization. Step 2: Local LLM Structure Extraction: Construct a structured prompt template for "role definition - task boundary - output constraint - basis annotation"; Send a request to the local server's LLM interface to generate initial results; Step 3: Multi-level optimization: Optimization is carried out through semantic bidirectional matching illusion suppression mechanism, few-sample adaptive extraction mechanism, multi-dimensional data cleaning mechanism and error retry mechanism; Step 4: Construction of the medical knowledge graph: Extracting entity relationships, discovering communities, and performing visualization operations, and building an incremental update mechanism; Step 5: Construction of Vector Database Index and Semantic Retrieval: Complete the construction of semantic index, speech retrieval and source tracing, and scientific research data screening; Step 6: Data Merging and Storage: Complete intelligent association merging, multi-format storage output, version management, and traceability; Step 7: Manual review: Generate a structured review checklist for manual review, and optimize prompts and validation rules.

2. The method for structuring medical examination reports based on LLM according to claim 1, characterized in that, Step 1 includes the following steps: Step 1.1 Data Loading and Field Association Merging: Construct semantic association rules for medical data, identify the association information scattered across different fields in the examination report, and merge them into a unified field using Pandas tools; Step 1.2 Anomaly Labeling: Construct a medical dictionary containing abnormal terms; identify and label abnormal descriptions in the examination report using regular expressions and semantic matching algorithms; Step 1.3 Format standardization: Standardize and convert dates, medical units, and abbreviations.

3. The method for structuring medical examination reports based on LLM according to claim 1, characterized in that, In step 2, a structured prompt template of "role definition - task boundary - output constraint - basis annotation" is constructed, and the results are generated based on the preprocessed examination report. The role is defined as "senior cardiovascular disease diagnosis and treatment expert", the task boundary is the information source, the output constraint is that the format is limited to JSON, and each field output by basis annotation must be accompanied by the extraction basis.

4. The method for structuring medical examination reports based on LLM according to claim 1, characterized in that, Step 3, the semantic bidirectional matching hallucination suppression mechanism, includes calculating the character-level n-gram F1 score to quantify the matching degree. The formula is F1 = 2 × precision × recall / (precision + recall). When the matching degree is ≤ 0.3, it is judged as a hallucination. The few-sample adaptive extraction mechanism in step 3 includes fusing 3-5 sets of "unstructured text-structured results" few-sample examples with chain-like thinking prompts to guide the model to reason and extract logic step by step, reducing the dependence on massive labeled data; Step 3's multi-dimensional data cleaning mechanism includes: validating the format of fields such as dates and numbers using regular expressions; unifying non-standard expressions based on a medical terminology dictionary; and extracting long text reports in segments according to "examination items - lesion description - diagnosis conclusion" to improve the extraction accuracy of complex texts. Step 3's error retry mechanism includes constructing field integrity verification rules for verification. These rules include field quantity matching verification rules, required field non-empty verification rules, field data type compliance verification rules, field hierarchy and nesting compliance verification rules, and extraction basis and field association verification rules.

5. The method for structuring medical examination reports based on LLM according to claim 4, characterized in that, The few-sample adaptive extraction mechanism in step 3 includes the following steps: Step 3.1 Few-shot example embedding: Display the provided 3-5 input-output pairs in the prompt, where the input is real unstructured medical report text and the output is the corresponding structured JSON file, with each field in the output appended with a verbatim reference "Basis: [...]"; Step 3.2 Chain-like reasoning: Clearly define the step-by-step reasoning instructions. First, identify abnormal terms by scanning all medical terms in the report that are outside the normal range or contain keywords such as "increased," "decreased," or "abnormal." Then, locate the description by finding the corresponding numerical value, unit, and contextual description for the abnormal term. Finally, map the fields by matching the abnormal terms to predefined target field names. Then, verify the basis by copying the complete original sentence containing the abnormal terms as the basis for extraction; finally, output a JSON file.

6. The method for structuring medical examination reports based on LLM according to claim 1, characterized in that, Step 4, entity relation extraction, adopts the process of "text chunking - triple extraction - relation filtering". The input file is read by DirectoryLoader, the text is divided into chunks according to the characters period and newline and assigned a unique chunk_id. The df2Graph function is called to extract the "entity 1-relationship-entity 2" medical triples, and invalid relations are filtered in combination with the medical relation dictionary. Step 4, community discovery and visualization, involves constructing an undirected medical knowledge graph with entities as nodes and relationships as edges. The Girvan-Newman algorithm is used to divide the community into "disease-symptom" and "examination-lesion" categories, with each community assigned a unique color. An interactive HTML graph is then generated using the PyVis library. The incremental update mechanism in step 4 involves extracting the triples from the new inspection report data and adding them to the existing map when new inspection report data is added, thus avoiding full reconstruction.

7. The method for structuring medical examination reports based on LLM according to claim 1, characterized in that, In step 5, the construction of the semantic index involves dividing the standardized report text into semantic units by periods. Then, the semantic units are converted into 768-dimensional vectors using the LangChain+HuggingFaceEmbeddings model and stored in the FAISS vector database to establish a semantic index for medical text. In step 5, voice retrieval and source tracing respond to user questions. The M3E pre-trained language model is used to vectorize the user query and the standardized medical report text blocks. The input text is mapped into a 768-dimensional semantic vector by calling the encoder of the M3E model. The vector is stored in the FAISS vector index library. The top-5 most similar text blocks and structured data are retrieved and concatenated into prompt words input LLM to generate semantic answers. Step 5, the scientific research data screening, completes batch data screening based on entity relationships, providing efficient data support for clinical research.

8. The method for structuring medical examination reports based on LLM according to claim 1, characterized in that, The intelligent association and merging in step 6 automatically associates the structured data with the original Excel spreadsheet based on the unique identifier of "inspection record number", supplements the structured fields to the original dataset, and maintains data integrity and relevance; The multi-format storage output in step 6 is saved as Excel, CSV, JSON and other formats and stored in the local database, which can be connected to the hospital's existing EDC system to achieve seamless data flow; The version management and traceability in step 6 records the version information for each process and supports data rollback and quality traceability.