Medical record extraction method based on large language model

By using a medical record extraction method based on a large language model, and leveraging the BERT-Md model and predefined structural templates to generate high-quality and standardized clinical summaries, this approach addresses the issues of low efficiency, insufficient accuracy, and inadequate privacy protection in existing technologies, achieving efficient and accurate extraction of key information while ensuring privacy protection.

CN121964026APending Publication Date: 2026-05-01CHONGQING UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHONGQING UNIV OF TECH
Filing Date
2025-12-01
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing technologies for generating medical record summaries suffer from inefficiency, insufficient accuracy, low degree of structuring, inadequate privacy protection, and insufficient clinical relevance of keyword extraction techniques, making it difficult to meet the needs of modern medical informatization.

Method used

A medical record extraction method based on a large language model is adopted. The BERT-Md model is used for fine-grained classification and contextual verification of key clinical elements. Combined with topic prior injection and aspect terminology modeling techniques, contextual examples that conform to clinical logic are generated. The predefined structural template is used for constraint decoding to form a standardized clinical summary.

Benefits of technology

It improves the quality and clinical usability of generated abstracts, ensures that the generated abstracts conform to the standard format, contain key information and protect privacy, supports the generation of abstracts of different lengths, improves semantic similarity and Rouge-L scores, and reduces the hallucination rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121964026A_ABST
    Figure CN121964026A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of medical treatment, in particular to a medical record extraction method based on a large language model. The method comprises the following steps: performing fine-grained classification and context verification on candidate terms through a BERT-Md model, and outputting a fact support; guiding the first call of the large language model through the first composite prompt, and synthesizing a context example specific to a case; and guiding the second calling of the large language model through the second composite prompt to generate a target clinical abstract. The invention provides a large language model-based medical record extraction method, which comprises the following steps of: extracting and classifying key clinical elements from an original medical record through a BERT-Md model, and inputting the extracted key words into a large language model to generate a context example conforming to clinical logic; and ensuring that the generated abstract contains eight necessary modules through a constraint decoding technology, automatically marking an abnormal test value reference range, and outputting a clinical abstract with a standard format and standard information density.
Need to check novelty before this filing date? Find Prior Art

Description

A Medical Record Extraction Method Based on a Large Language Model Technical Field

[0001] This invention relates to the field of medical technology, and in particular to a method for extracting medical records based on a large language model. Background Technology

[0002] Medical records are the core carriers of patient disease progression, treatment decisions, and health information, containing immense clinical, research, and management value. Efficiently and accurately extracting key information from medical records, such as disease diagnoses, surgical procedures, medication records, laboratory test results, symptoms, and signs, is a crucial prerequisite for applications such as clinical decision support, disease risk prediction, medical quality monitoring, and medical research.

[0003] However, medical records are usually in the form of unstructured free text (such as admission records, progress notes, discharge summaries, etc.), and their language is highly professional, complex and diverse.

[0004] The following technical problems exist in the current field of medical record summary generation:

[0005] 1. Limitations of traditional manual writing methods: low efficiency, poor standardization, inaccurate expression, and difficulty in meeting the needs of modern medical informatization.

[0006] 2. Shortcomings of existing large language model generation methods:

[0007] It lacks professionalism and accuracy, and contains errors in medical knowledge and hallucinations;

[0008] The structure is poor and there is a lack of standardized medical terminology frameworks.

[0009] Quality control is difficult, making it hard to guarantee the clinical applicability of the generated abstracts;

[0010] Insufficient privacy protection and direct processing of original medical records pose a risk of data leakage.

[0011] 3. Shortcomings of the existing prompt word project:

[0012] Traditional few-shot and simple ICL templates are not effective enough in the medical field;

[0013] Designing domain-knowledge-based prompt templates is time-consuming and labor-intensive;

[0014] Without a systematic medical logic to guide it, it is difficult to guarantee the clinical decision-making value of the abstract.

[0015] 4. Limitations of keyword extraction technology: Traditional BERT models lack medical domain knowledge, and the extracted and classified keywords are not clinically relevant enough to support the generation of high-quality summaries.

[0016] To address this issue, a medical record extraction method based on a large language model is designed to provide an alternative technical solution. Summary of the Invention

[0017] Therefore, it is necessary to provide a medical record extraction method based on a large language model to address the aforementioned technical problems.

[0018] To solve the above-mentioned technical problems, the present invention adopts the following technical solution:

[0019] A method for extracting medical records based on a large language model, comprising the following steps:

[0020] S1: Based on existing medical dictionaries as the answer set, identify key clinical elements in the original medical record text to form a candidate terminology set;

[0021] S2: Use the BERT-Md model to perform fine-grained classification and contextual validation of candidate terms, and output fact scaffolds;

[0022] S3: Guide the first call of the large language model through the first compound prompt, and synthesize a case-specific context example;

[0023] S4: The second call to the large language model is guided by the second compound prompt to generate the target clinical summary.

[0024] In a preferred embodiment of the medical record extraction method based on a large language model provided by the present invention, step S2 includes the following steps:

[0025] The candidate terms extracted in step S1 are input into the BERT-Md model;

[0026] The BERT-Md model uses topic prior injection and aspect term modeling techniques to perform contextual validation and fine-grained classification of all candidate terms, classifying them into one of the five key clinical elements: disease, drug, treatment, numerical value, and time.

[0027] The classification results are aggregated to form a fact scaffold output.

[0028] As a preferred embodiment of the medical record extraction method based on a large language model provided by the present invention, topic prior injection involves compressing a high-dimensional sparse topic distribution vector into a low-dimensional dense global topic embedding through a trainable linear projection. The steps are as follows:

[0029] The global topic embedding is added element-wise to the standard lexical embedding to obtain the topic-enhanced lexical embedding matrix;

[0030] The final input representation is composed of topic-enhanced lexical embeddings, fragment embeddings, and positional embeddings.

[0031] As a preferred embodiment of the medical record extraction method based on a large language model provided by the present invention, aspect terminology modeling distinguishes candidate terms and their related aspect terms during input, and the steps are as follows:

[0032] When inputting data, assign different fragment IDs to "candidate terms" and "aspect terms" to inform the model of their respective roles at the input level;

[0033] When the BERT-Md model processes input data, the self-attention mechanism can utilize clearly distinguished contextual cues to achieve accurate disambiguation.

[0034] As a preferred embodiment of the medical record extraction method based on a large language model provided by the present invention, in step S4, the first composite prompt consists of task instruction 1, complete original clinical notes, and a serialized fact scaffold.

[0035] Task instruction 1 is used to guide the LLM to perform specific tasks;

[0036] Complete original clinical notes, providing the full context for generating the required examples for large language models;

[0037] The serialized fact scaffold is the fact scaffold obtained in step S2, which is converted into a text string readable by the large language model.

[0038] As a preferred embodiment of the medical record extraction method based on a large language model provided by the present invention, in step S4, the second composite prompt consists of task instruction 2, the complete original clinical notes, the context example obtained in step S3, and the predefined structural template.

[0039] Task instruction 2 is used to guide the large language model in generating the final summary;

[0040] Complete original clinical notes are used to provide all the context needed for the generation of large language models;

[0041] The context examples obtained in step S3 are used to provide case-specific content anchoring for the large language model;

[0042] Predefined structural templates are used to provide strict structural constraints for clinical reports.

[0043] As a preferred embodiment of the medical record extraction method based on a large language model provided by the present invention, a predefined structural template restricts the large language model to output in a specific format when encountering abnormal values ​​through macro-module constraints and micro-format constraints.

[0044] The format and logical order of the eight essential modules—chief complaint, present illness, past medical history, physical examination, auxiliary examinations, diagnosis, treatment plan, and follow-up recommendations—are defined through macro-module constraints.

[0045] Micro-format constraints define the output format of specific information.

[0046] It is clear without a doubt that the technical solution described above in this application can solve the technical problem that this application aims to address.

[0047] Meanwhile, through the above technical solutions, the present invention has at least the following beneficial effects:

[0048] This invention provides a medical record extraction method based on a large language model. It extracts and categorizes five key clinical elements from original medical records using the BERT-Md model: disease, medication, treatment, numerical values, and time. This model innovatively introduces a medical topic enhancement mechanism, integrating domain knowledge through attention weighting. The extracted keywords are then input into the large language model to generate contextual examples that conform to clinical logic. These examples are intelligently fused with a pre-set structured medical template to form standardized prompts. Finally, constraint decoding technology ensures that the generated summary contains eight essential modules (from chief complaint to follow-up recommendations) and automatically marks the reference range for abnormal test values. The output is a clinical summary with a standardized format and sufficient information density (≥3 key entities per 100 characters). The entire process operates under strict privacy protection, supports summary generation of different lengths from 200 to 800 characters, and is validated by a dual-index evaluation system (semantic similarity + Rouge-L), significantly improving the generation quality and clinical applicability. Attached Figure Description

[0049] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0050] Figure 1 is a flowchart of the fact extraction process of the present invention;

[0051] Figure 2 is a flowchart of the narrative generation process of the present invention. Detailed Implementation

[0052] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0053] To enable those skilled in the art to better understand the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings.

[0054] It should be noted that, unless otherwise specified, the embodiments and features and technical solutions in the present invention can be combined with each other.

[0055] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0056] Example 1

[0057] Referring to Figures 1-2, a method for extracting medical records based on a large language model is presented.

[0058] Through a two-stage decoupled grounding framework, fact-checking and classification (stage one) are explicitly separated from narrative generation (stage two).

[0059] Phase 1: Fact Extraction and Classification (Constructing a Fact Scaffold)

[0060] The goal of this phase is to build a high-confidence, structured fact scaffold:

[0061] 1. Utilize existing medical dictionaries (such as UMLS) as the answer set to search and match within the original medical record text, thereby identifying all potentially important words (i.e., "candidate terms").

[0062] 2. Model Construction (BERT-Md): A medical topic-enhanced BERT (BERT-Md) model is used to perform fine-grained classification and contextual validation of candidate terms;

[0063] First, the candidate terms extracted in the previous step are input into the BERT-Md model with medical topic enhancement. The core mechanism of this model is topic prior injection: it compresses a "global topic prior" representing the global semantics of the document into a low-dimensional dense global topic embedding and adds it element-wise with the standard lexical embedding. At the same time, the model also combines "aspect term modeling" technology to distinguish candidate terms and their related aspect terms at input, so as to use contextual cues for accurate disambiguation.

[0064] Finally, the BERT-Md model, by fusing this global topic information and local contextual information, performs a classification task on each candidate term, categorizing it into one of the five key clinical elements: "disease, drug, treatment, numerical value, and time," ultimately outputting a structured fact scaffold containing (term, category) key-value pairs.

[0065] 3. Topic Prior Injection: The BERT-Md model is characterized by injecting a pre-computed global topic prior (e.g., topic distribution vectors obtained by training an LDA model on a large clinical corpus directly into its embedding layer).

[0066] Specifically, the high-dimensional sparse topic distribution vector is compressed into a low-dimensional dense global topic embedding through a trainable linear projection. This global topic embedding is then added element-wise to the standard lexical embedding to obtain a topic-enhanced lexical embedding matrix. The final input representation is composed of the sum of the topic-enhanced lexical embeddings, fragment embeddings, and positional embeddings.

[0067] 4. Aspect Term Modeling: This model also incorporates aspect term modeling to distinguish candidate terms and their related aspect terms upon input, enabling the model to accurately disambiguate using contextual cues (e.g., distinguishing the role of "metformin" in different contexts).

[0068] Specifically, aspect terminology modeling primarily achieves differentiation by labeling different terms at model input. This is typically accomplished using segment embeddings in BERT (as shown in Figure 1 and the description of segments); the system assigns different segment IDs to "candidate terms" and "aspect terms," ​​explicitly informing the model of their respective roles at the input level. After the model (such as the BERT encoding layer) processes these inputs, its self-attention mechanism can utilize these explicitly differentiated contextual cues (i.e., the specific context provided by the aspect terms) to achieve accurate disambiguation.

[0069] 5. Scaffold Output: The BERT-Md model classifies each candidate term and outputs a structured, high-confidence fact scaffold.

[0070] The scaffold is a collection of (term, category) key-value pairs; specifically, after the BERT-Md model performs contextual validation and fine-grained classification (i.e., categorized into five classes: "disease, drug, treatment, numerical, and time") on all candidate terms using its topic prior injection and aspect term modeling techniques, it aggregates these classification results. This final output set is the fact scaffold.

[0071] Phase Two: Scaffold-Guided Dynamic Narrative Generation

[0072] This phase utilizes the fact scaffolding generated in the first phase to drive a two-step dynamic cueing mechanism:

[0073] 1. Fact scaffold serialization

[0074] The structured fact scaffold output from the first stage is serialized into a text string readable by a large language model (LLM). This means translating machine-readable structured data (e.g., a set of key-value pairs such as {('gemcitabine','drug'),('pancreas','disease')}) into a continuous, plain text format that the LLM can understand, so that it can be input into the LLM as part of a prompt in the second stage.

[0075] 2. Dynamic Contextual Example Generation (First LLM Call) The goal of this step is to synthesize case-specific contextual examples. A prompt is constructed that includes Task Instruction 1, the complete original clinical notes, and a serialized fact scaffold. Specifically, this process integrates three distinct parts into a single composite prompt that will be input into the large language model: the first part is Task Instruction 1, an explicit instruction guiding the LLM to perform a specific task; the second part is the complete original clinical notes, providing the LLM with the full context for generating the required examples; and the third part is the serialized fact scaffold, a text string derived from the structured key-value pairs output of the first stage, providing the raw, structured facts that need to be translated into natural language. These three parts (instruction, complete notes, fact string) are combined to form a complete input to guide the LLM in its first call, generating coherent example sentences that are both consistent with the fact scaffold content and the context of the original notes.

[0076] 3. Composite Hint Construction and Final Abstract Generation (Second LLM Call): The goal of this step is to generate a final high-fidelity clinical abstract by constructing a composite hint. This composite hint mainly consists of the following parts:

[0077] The first part is Task Instruction 2, which is responsible for guiding the LLM to generate the final summary;

[0078] The second part is the complete original clinical notes, which provide all the context needed for the generation of LLM;

[0079] The third part is the dynamically generated example from the previous step (the first LLM call), which provides LLM with content anchoring specific to this case.

[0080] The fourth part is a predefined structural template that provides strict structural constraints for clinical reports (such as SOAP format), serving as a structural constraint.

[0081] By combining these four parts, the composite prompt establishes a dual mechanism of content anchoring and structural constraint to guide LLM in generating fact-accurate and structurally sound final clinical summaries.

[0082] Task Instruction 2: Guide the LLM in generating the final summary; specifically, Task Instruction 2 is an explicit instruction that instructs the LLM to simultaneously adhere to the original clinical notes (D): using them as the most complete source of contextual information needed to generate the summary; dynamically generated examples: using them as content anchors to ensure that the generated content is consistent in fact and expression with the key points of the case (derived from the fact scaffold of the first phase); and a predefined structural template: using it as a structural constraint to enforce that the output of the summary must conform to a strict clinical report format;

[0083] Original Clinical Notes: Providing Complete Context: First, the fact scaffold itself contains only isolated, structured keywords. LLM requires the complete narrative provided by the original clinical notes to understand the specific relationships and descriptive methods between these keywords. Second, the original clinical notes serve as a complete and undone set of facts for the final summary. When LLM needs to populate each section of the template (e.g., "Past Medical History" or "Physical Examination"), it must review and rely on the information provided therein to ensure that the final generated summary is comprehensive, complete, and without omissions.

[0084] Dynamically generated example: Providing case-specific content anchoring: This dynamically generated example is included as a core component when constructing the compound prompts used to generate the final summary. When the second LLM call begins generating the summary, this example acts as a powerful, readily available content anchor. It essentially tells the LLM, "The final summary must contain these validated core facts that have been translated into natural language," thus anchoring the LLM's attention and ensuring that the final generated summary strictly revolves around these validated clinical facts from the first phase, effectively preventing information omissions or factual illusions.

[0085] Predefined structural templates provide strict structural constraints for clinical reports (e.g., SOAP format): First, macro-level module constraints (mandatory chapter structure): This template predefines the specific chapters and logical order that the final clinical summary must contain. The technical solution explicitly states that this ensures the generated summary conforms to a standard structure, namely *eight essential modules: "Chief Complaint - Present Illness - Past Medical History - Physical Examination - Ancillary Examinations - Diagnosis - Treatment Plan - Follow-up Recommendations". Second, micro-level format constraints (specific annotation guidelines): This template not only defines the chapters but also the output format for specific information. The template includes corresponding instructions or format placeholders to guide the LLM (Low-Level Clinical Research) system to output data according to a specific format when encountering abnormal values.

[0086] This composite prompt establishes a dual mechanism of content anchoring and structural constraint; finally, the composite prompt is submitted to the LLM to generate a fact-accurate, structurally sound final clinical summary.

[0087] Summarize:

[0088] The technical solution flow of this invention is shown in the accompanying drawings. This flow explicitly decouples fact extraction (first stage, corresponding to Figure 1) from narrative generation (second stage, corresponding to Figure 2). In the first stage (Figure 1), the system adopts a medical topic-enhanced BERT (BERT-Md) architecture to construct a fact scaffold. Its core mechanism is to add a topic embedding Z, representing the global semantics of the document, element-wise with the original lexical embedding Etoken at the BERT embedding layer to generate an enhanced topic embedding E'token. This enhanced embedding is then combined with the segment embedding Esegment and the position embedding Eposition to form the final input representation X', and sequentially passed through the BERT Encoding Layer and the Classification Layer to finally output a structured, high-confidence fact scaffold S. After entering the second stage, the fact scaffold S is first serialized, and then, in a dynamic context example generation step, it is input into a large language model along with the original medical text D and the instruction to generate a context example E for a specific case. Finally, in the case-specific prompt generation step, the dynamic example E, the original text D, a structured template P, and the instruction 2 are combined into a highly controlled composite prompt P', which is then input into the LLM to generate the final, highly reliable summary S.

[0089] Achieved effect:

[0090] 1. Performance Improvement:

[0091] Semantic similarity improved by 2.2%;

[0092] Rouge-L score improved by 20.6%;

[0093] The rate of hallucinations was significantly reduced, and clinical accuracy and applicability were improved.

[0094] 2. Advantages of structuring:

[0095] To achieve framework structuring and data standardization;

[0096] Maintain strict control over clinical decision-making and information density;

[0097] The generated summary conforms to the standard structure of "chief complaint - present illness - past medical history - physical examination - auxiliary examinations - diagnosis - treatment plan - follow-up recommendations".

[0098] 3. Clinical applicability:

[0099] The generated summaries can be used directly for clinical decision support;

[0100] Key medical information (diagnosis, test values, treatment plan, time trajectory) is extracted accurately and completely;

[0101] Abnormal values ​​are automatically labeled with reference ranges (e.g., "[Hb 82g / L↓(130-175)]").

[0102] 4. Privacy Protection:

[0103] Privacy is protected by extracting keywords rather than directly processing original medical records;

[0104] The preprocessing stage includes de-anonymization operations, which comply with medical data compliance requirements.

[0105] 5. Adaptability:

[0106] The method is adaptable to various large language models (GPT-5, Claude-4, etc.);

[0107] Supports summary generation requirements of different lengths from 200 to 800 characters;

[0108] Each 100 words contains at least 3 key clinical entities, and the information density is controllable.

[0109] Example 2:

[0110] The difference from Embodiment 1 above is:

[0111] The differences in the keyword extraction modules are as follows:

[0112] 1. Model architecture replacement:

[0113] Use medical pre-trained models such as BioBERT / ClinicalBERT;

[0114] Add terminology associations for graph neural network layer modeling;

[0115] Joint training is conducted using a multi-task learning framework;

[0116] 2. Classification system replacement:

[0117] Expanded to a seven-dimensional classification (adding symptoms and examination items);

[0118] A hierarchical classification system is adopted (major category → subcategory).

[0119] Example 3

[0120] The difference from Embodiment 1 above is:

[0121] The differences between the prompt word generation modules are as follows:

[0122] 1. Example of generating alternatives:

[0123] Search Enhancement Generation (RAG) retrieves cases from literature databases;

[0124] Use a predefined template library instead of dynamic generation;

[0125] Hybrid generation (LLM + manual verification).

[0126] 2. Hints at fusion and substitution:

[0127] Dynamic weight fusion (adjusted according to keyword importance);

[0128] Phased guidance (diagnosis → treatment proceeds step by step);

[0129] Integrate medical knowledge graph information.

[0130] Example 4

[0131] The difference from Embodiment 1 above is:

[0132] The differences between the summary generation modules are as follows:

[0133] 1. Model substitution:

[0134] Fine-tuning in the medical field (efficient methods such as LoRA);

[0135] Integration of specialist expert models;

[0136] Miniaturized professional models (knowledge distillation).

[0137] Example 5

[0138] Based on the above embodiment one, an application case is disclosed as follows:

[0139] Enter a medical record excerpt:

[0140] "The patient is a 58-year-old male who presented with upper abdominal pain for one week. CT scan showed a 3cm mass in the head of the pancreas, CA19-9 at 1200 U / mL, and WBC count of 3.5 × 10⁻⁶." 9 / L..."

[0141] Generate summary:

[0142] """

[0143] Chief complaint: 58-year-old male, upper abdominal pain for 1 week.

[0144] Auxiliary examination: Abdominal CT showed a 3cm mass in the head of the pancreas [CA19-9 1200U / mL ↑(0-37)], [WBC 3.5×10 9 / L↓(4-10)].

[0145] Diagnosis: Pancreatic mass, to be investigated (highly likely malignant).

[0146] Treatment plan: Endoscopic ultrasound-guided biopsy is recommended.

[0147] Follow-up plan: It is recommended to have a blood routine test again in 3 days.

[0148] The preferred embodiments of the present invention disclosed above are merely illustrative of the invention. These preferred embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the invention, thereby enabling those skilled in the art to better understand and utilize the invention. The invention is limited only by the claims and their full scope and equivalents.

Claims

1. A method for extracting medical records based on a large language model, characterized in that, The steps are as follows: S1: Based on the existing medical dictionary as the answer set, identify key clinical elements in the original medical record text to form a candidate term set; S2: Use the BERT-Md model to perform fine-grained classification and contextual verification of the candidate terms and output fact scaffolds; S3: Guide the first call of the large language model through the first compound prompt to synthesize case-specific contextual examples. S4: The second call to the large language model is guided by the second compound prompt to generate the target clinical summary.

2. The medical record extraction method based on a large language model according to claim 1, characterized in that, In step S2, the steps are as follows: The candidate terms extracted in step S1 are input into the BERT-Md model; the BERT-Md model uses topic prior injection and aspect term modeling techniques to complete contextual validation and fine-grained classification of all candidate terms, classifying them into one of the five key clinical elements: disease, drug, treatment, numerical value, and time; the classification results are aggregated to form a fact scaffold output.

3. The medical record extraction method based on a large language model according to claim 2, characterized in that, Topic prior injection compresses a high-dimensional sparse topic distribution vector into a low-dimensional dense global topic embedding through a trainable linear projection. The steps are as follows: the global topic embedding is added element-wise to the standard lexical embedding to obtain the topic-enhanced lexical embedding matrix; the final input representation is composed of the topic-enhanced lexical embedding, fragment embedding and position embedding.

4. The medical record extraction method based on a large language model according to claim 2, characterized in that, Aspect term modeling distinguishes candidate terms and their related aspect terms at input time. The steps are as follows: At input time, different fragment IDs are assigned to "candidate terms" and "aspect terms" to inform the model of their respective roles at the input level; When the BERT-Md model processes input data, the self-attention mechanism can utilize clearly distinguished contextual cues to achieve accurate disambiguation.

5. The medical record extraction method based on a large language model according to claim 1, characterized in that, In step S3, the first compound prompt consists of task instruction 1, the complete original clinical notes, and the serialized fact scaffold. Task instruction 1 is used to guide the LLM to perform specific tasks. The complete original clinical notes are used to provide the large language model with the full context for generating the required examples. The serialized fact scaffold is the fact scaffold obtained in step S2, converted into a text string that the large language model can read.

6. The medical record extraction method based on a large language model according to claim 1, characterized in that, In step S4, the second compound prompt consists of task instruction 2, the complete original clinical notes, the context example obtained in step S3, and a predefined structural template; task instruction 2 is used to guide the large language model in generating the final summary; the complete original clinical notes are used to provide the large language model with all the context required for generation; the context example obtained in step S3 is used to provide the large language model with content anchoring specific to this case; and the predefined structural template is used to provide strict constraints on the structure of the clinical report.

7. The medical record extraction method based on a large language model according to claim 6, characterized in that, The predefined structural template, through macro-module constraints and micro-format constraints, requires the large language model to output in a specific format when encountering abnormal values. The macro-module constraints define the format and logical order of the eight essential modules, including chief complaint, present illness, past medical history, physical examination, auxiliary examinations, diagnosis, treatment plan, and follow-up recommendations. The micro-format constraints define the output format of specific information.