Method and system for generating outpatient medical records based on large model re-visit scene
By performing structured coding and analysis of changes in diagnosis and treatment in patients' historical medical records, and combining this with a medical knowledge graph, follow-up medical records with consistent paragraph structure are generated. This solves the redundancy and logical problems in the generation of follow-up medical records in existing technologies, and improves the accuracy and clinical applicability of medical record generation.
Patent Information
- Application Number
- CN202610021370.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-08
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2046-01-08
AI Technical Summary
Existing medical record generation methods based on large models lack the ability to extract structured information about the evolution of diagnosis and treatment in follow-up visit scenarios. They cannot identify changes in diagnosis and treatment, resulting in redundant generated results, missing key descriptions, or logical jumps, which cannot meet the actual application needs of follow-up visit scenarios.
By structurally encoding patients' historical outpatient medical records, a historical treatment fingerprint vector is generated, a treatment change vector is calculated, and a medical knowledge graph is used to match causal explanations to construct a structured prompt vector, which guides the language generation model to generate follow-up medical records with consistent paragraph structure.
It significantly improves the accuracy and clinical applicability of medical record generation in follow-up visit scenarios, accurately identifies changes in diagnosis and treatment and provides medical causal explanations, and generates medical records with clear logic and prominent key points.
Smart Images

Figure CN121483471A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of medical information technology, and in particular relates to a method and system for generating outpatient medical records based on a large-scale model follow-up visit scenario. Background Technology
[0002] With the rapid advancement of artificial intelligence technology, the application of large-scale language models in medical document generation has gradually matured, particularly demonstrating strong language organization and medical knowledge generalization capabilities in areas such as outpatient medical record generation, consultation summary extraction, and structured medical dialogue. However, in clinical practice, medical records are not a one-time writing task; follow-up visits are more common. Patients often form a continuous medical history at different time points and through multiple medical visits, and their condition, medication regimen, examination results, and chief complaints evolve over time. The requirements for writing follow-up medical records should not only cover current symptoms and treatment plans but also accurately reflect the differences between the patient's previous visit and those of the previous visit, clearly indicating additions, subtractions, symptom recurrences, and new abnormalities, so that doctors can assess disease control status, treatment adherence, and potential risk factors. However, existing medical record generation methods based on large models generally target initial consultation scenarios, typically inputting simply concatenated or summarized historical medical record texts into the model. In the context of follow-up consultations, they lack the ability to extract structured information about the evolution of treatment, failing to identify which parts are stable and unchanging background information and which parts require focused attention and expansion. This results in a large amount of redundant content, missing key descriptions, or logical jumps in the generated results. More importantly, follow-up consultation scenarios have a distinct "disease evolution" attribute, but existing methods lack mechanisms to explain the causes, patterns, and backgrounds of these changes. They cannot express the possible medical reasons behind changes in symptoms, medication, or abnormal examinations in a clinically logical manner, making it difficult for the generated content to support doctors' diagnostic reasoning or decision analysis. In scenarios such as government healthcare, military physical examinations, and chronic disease follow-up, follow-up consultation information is often closely related to high-risk early warning mechanisms, long-term health record management, and treatment adherence assessment. Existing technologies cannot automatically construct change information and evolutionary logic based on historical treatment trajectories and the results of the current visit, thus failing to truly meet the practical application needs of follow-up consultation scenarios. In summary, the key issues that current technology urgently needs to address are: how to extract structured trend features from patients' multi-round historical medical records, how to accurately identify differences between current and historical treatment information, how to provide medical causal explanations for changes, and how to effectively map this structured information to the generation and control logic of large models. Summary of the Invention
[0003] The purpose of this invention is to design a method and system for generating outpatient medical records based on a large-scale model follow-up visit scenario. This method can generate follow-up visit medical records that have awareness of changes, causal logic, and consistent paragraph structure, significantly improving the accuracy, relevance, and clinical applicability of medical record generation in follow-up visit scenarios.
[0004] To achieve the above objectives, the first aspect of the present invention provides a method for generating outpatient medical records based on a large-scale model follow-up visit scenario, the method comprising:
[0005] For each medical record in the patient's historical outpatient medical record sequence, four structural fields are extracted: diagnosis code, prescription drug name and dosage, examination and test values, and chief complaint text. Each structural field is converted into a vector and then concatenated to obtain the structured coding vector of a single medical record.
[0006] Based on the current consultation time and the timestamps of each historical medical record, the exponential decay weight is calculated, and the structured coding vector is weighted and summed to generate a historical medical fingerprint vector.
[0007] The four structural fields of the current medical visit are encoded into a current medical visit vector in the same way. The difference between the current medical visit vector and the historical medical fingerprint vector in each field dimension is calculated to obtain the medical visit change vector.
[0008] Based on the fields activated in the diagnosis and treatment change vector, match the triple paths in the preset medical knowledge graph to generate a set of diagnosis and treatment change tags containing change type, field position and medical causal explanation;
[0009] A structured prompt vector is constructed based on the diagnosis and treatment change vector and the diagnosis and treatment change label set;
[0010] The structured prompt vector is concatenated with the paragraph position codes corresponding to the chief complaint paragraph, present illness paragraph, past medical history paragraph, physical examination paragraph, auxiliary examination paragraph, and diagnosis and treatment opinion paragraph, respectively, and then input into a language generation model using the Transformer architecture. This guides the language generation model to generate the follow-up outpatient medical record text in the order of the six paragraphs.
[0011] Furthermore, the step of converting each structural field into a vector and then concatenating them includes:
[0012] The diagnostic code is mapped to a first embedding vector through a lookup table;
[0013] The prescription drug name and dosage are compressed into a second embedding vector through sparse multi-thermal encoding and then linear transformation.
[0014] The normalized test values are concatenated into a third embedding vector.
[0015] The semantic features of the main complaint text are extracted using a convolutional neural network to obtain a fourth embedding vector;
[0016] The first embedding vector, the second embedding vector, the third embedding vector, and the fourth embedding vector are concatenated to form the structured coding vector.
[0017] Furthermore, in the formula for calculating the exponentially decaying weight, the decay coefficient is greater than 0.9, and the sum of the weights corresponding to all historical medical records is normalized to 1.
[0018] Furthermore, prior to the step of matching the activated fields in the diagnostic change vector with the triple paths in the preset medical knowledge graph, the method further includes:
[0019] Obtain high-risk warning markers from patients' electronic health records;
[0020] If a high-risk warning marker exists, the change in the corresponding field of the diagnosis and treatment change vector is multiplied by an enhancement factor to obtain the enhanced diagnosis and treatment change vector.
[0021] The matching is performed based on the enhanced diagnostic change vector.
[0022] Furthermore, the preset medical knowledge graph includes three types of triplet paths: diagnosis-treatment causal pairs, symptom-diagnosis relationships, and drug-examination interactions.
[0023] Furthermore, the step of constructing a structured cue vector based on the diagnosis and treatment change vector and the diagnosis and treatment change label set includes:
[0024] Generate a hint mask vector based on the first three levels of classification codes of the disease code of the current primary diagnosis;
[0025] The diagnostic change vector is filtered by dimension using the aforementioned prompt mask vector to obtain a preliminary prompt vector;
[0026] Each label in the set of diagnostic and treatment change labels is converted into a dense embedding vector, and after being weighted by confidence based on the graph path matching score, it is fused with the preliminary prompt vector to obtain the structured prompt vector.
[0027] Furthermore, the step of converting each label in the set of diagnostic and treatment change labels into a dense embedding vector includes:
[0028] The change type is mapped to a unique heat vector, the field position is mapped to a unit vector, and the medical causal explanation is converted into a path vector through a triplet template lookup table.
[0029] The one-hot vector, unit vector, and path vector are concatenated and mapped through a linear layer to form a tag embedding vector with the same dimension as the initial prompt vector.
[0030] Furthermore, the step of constructing the structured cue vector also includes: applying a sparse regularization term to dimensions with activation values below a preset threshold to suppress the response intensity of non-critical change dimensions.
[0031] Furthermore, the step of guiding the language generation model to generate the follow-up outpatient medical record text in the order of six paragraphs includes:
[0032] The paragraph attention weight is calculated based on the activation intensity of the structured cue vector in the corresponding dimension of each paragraph;
[0033] When generating each paragraph, the paragraph attention weight and the corresponding paragraph position encoding are combined to control the output content and style of the language generation model.
[0034] In a second aspect of the present invention, a system for generating outpatient medical records based on a large-scale model follow-up visit scenario is provided, the system comprising:
[0035] The historical medical record fingerprint extraction module is used to extract four structural fields from each medical record in the patient's historical outpatient medical record sequence: diagnosis code, prescription drug name and dosage, examination and test values, and chief complaint text. Each structural field is converted into a vector and then concatenated to obtain a structured coding vector for a single medical record. Based on the current consultation time and the timestamps of each historical medical record, an exponential decay weight is calculated, and the structured coding vector is weighted and summed to generate a historical medical fingerprint vector.
[0036] The diagnosis and treatment change identification and causal relationship extraction module is used to encode the four structural fields of the current visit into a current visit vector in the same way, calculate the difference between the current visit vector and the historical diagnosis and treatment fingerprint vector in each field dimension to obtain a diagnosis and treatment change vector; based on the fields activated in the diagnosis and treatment change vector, match the triple path in the preset medical knowledge graph to generate a set of diagnosis and treatment change labels containing change type, field position and medical causal explanation;
[0037] The prompt construction module is used to construct a structured prompt vector based on the diagnosis and treatment change vector and the diagnosis and treatment change label set;
[0038] The medical record generation module is used to concatenate the structured prompt vector with the paragraph position codes corresponding to the chief complaint paragraph, present illness paragraph, past medical history paragraph, physical examination paragraph, auxiliary examination paragraph, and diagnosis and treatment opinion paragraph, and input them into the language generation model using the Transformer architecture, guiding the language generation model to generate the follow-up outpatient medical record text in the order of the six paragraphs.
[0039] The beneficial technical effects of the present invention are at least as follows:
[0040] To address the aforementioned issues, this invention provides a method and system for generating outpatient medical records based on a large-scale model for follow-up visits. It compresses multi-round historical medical record information of follow-up patients in a structured manner, constructing a historical treatment fingerprint with time decay characteristics. This allows the model to understand the patient's treatment trajectory in a low-dimensional but highly expressive way. Subsequently, the current visit information is structurally compared with the historical structural fingerprint. An anomaly enhancement mechanism specific to the follow-up visit scenario is introduced to form a treatment change vector that accurately reflects the new elements and trends of change in this visit. Clinically meaningful change labels and causal explanations are obtained through medical atlas logical matching. This invention further maps the change vector and change labels to structured prompt information. Through change filtering, semantic embedding enhancement, confidence weighted combination, and sparse control strategies, prompt vectors that can guide the generation process are constructed, enabling the generation model to express the key points of the current follow-up visit. Finally, this invention introduces a paragraph-level structural guidance mechanism in the medical record generation stage, allowing the prompt vector to play a differentiated control role in different paragraphs. Through paragraph attention distribution, paragraph position encoding, and activation of sparse regularization, the key points of the content are highlighted, the logic is clear, and the format is standardized. This invention realizes a complete technical link from "historical diagnosis and treatment compression" to "diagnosis and treatment change recognition" and then to "structured generation control". It can generate follow-up medical records with change awareness, causal logic and paragraph structure consistency, which significantly improves the accuracy, relevance and clinical applicability of medical record generation in follow-up scenarios. Attached Figure Description
[0041] The present invention will be further described with reference to the accompanying drawings, but the embodiments in the drawings do not constitute any limitation on the present invention. For those skilled in the art, other drawings can be obtained based on the following drawings without creative effort.
[0042] Figure 1 This is a flowchart of a method for generating outpatient medical records based on a large-scale model follow-up visit scenario according to the present invention.
[0043] Figure 2 This is a system framework diagram for generating outpatient medical records based on a large-scale model follow-up visit scenario, according to the present invention. Detailed Implementation
[0044] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0045] In one or more embodiments, such as Figure 1 As shown, a method for generating outpatient medical records based on a large-scale model follow-up visit scenario is disclosed. The method includes the following:
[0046] S1: Extract four structural fields from each medical record in the patient's historical outpatient medical record sequence: diagnosis code, prescription drug name and dosage, examination and test values, and chief complaint text. Convert each structural field into a vector and then concatenate them to obtain a structured coding vector for a single medical record. Calculate the exponential decay weight based on the current consultation time and the timestamps of each historical medical record, and perform a weighted summation on the structured coding vector to generate a historical medical fingerprint vector.
[0047] Specifically, this step aims to construct a representation of the historical medical history of patients returning for follow-up visits, serving as a benchmark for identifying subsequent changes in medical treatment. Since patients typically have multiple outpatient visits before a follow-up visit, each medical record contains diagnostic information, medication regimens, examination indicators, and doctor's complaints, exhibiting significant temporal sequence and semantic redundancy. Directly concatenating all medical records would result in an excessively large input dimension and fail to effectively highlight the importance of recent medical records.
[0048] The raw input is provided by the electronic medical record system and the hospital information system, and is represented as a historical medical record sequence. ,in Indicates the first Second outpatient medical record Indicates the number of historical consultation sessions. Each medical record. It includes five structural fields: diagnostic code (e.g., ICD-10 format), sourced from the outpatient diagnosis module; prescription drug name and dosage, sourced from the hospital prescription management system; examination and test values (e.g., blood glucose, blood lipids, blood pressure), sourced from the test report interface; the doctor's written chief complaint text, sourced from the medical record entry module; and the medical record timestamp. Record the time when the visit occurred.
[0049] For the aforementioned structural fields, each medical record is first represented using a unified vector. The diagnostic code is mapped to a 16-dimensional embedding vector using a lookup table. The drug field is sparsely multi-hot encoded and then compressed into a 32-dimensional vector by a linear layer. The diagnostic indicators are normalized according to their fields and then concatenated into a 10-dimensional real-number vector. The chief complaint text is extracted using a single convolutional layer to obtain key semantic features, outputting a 32-dimensional text vector. Finally, each medical record is encoded into a 90-dimensional vector. ,Right now
[0050] ;
[0051] in Represents the diagnostic vector. Represents the drug usage vector. This represents the vector of inspection results. This represents the vector of the main complaint text.
[0052] All medical records were concatenated in chronological order to form a diagnostic and treatment feature matrix. Considering the differences in treatment weights over time, an exponential decay function is introduced to construct weight coefficients, and all medical record features are weighted and summed to obtain the final historical structure fingerprint representation:
[0053] ;
[0054] Among them, weight Defined as:
[0055] ;
[0056] The patient's historical structural fingerprint vector will be used in subsequent steps to identify changes in diagnosis and treatment. This indicates the current appointment time, which can be obtained through the outpatient queuing system interface; Indicates the first The timestamp of the medical record; The time decay factor controls the validity period of historical information; it is recommended to set it to [value missing]. to The scope depends on the frequency of medical record updates; The weighting ratio for each medical record satisfies the normalization constraint. .
[0057] For example, if a patient visits the doctor three times within the last 90 days, on the 90th day, the 30th day, and the 7th day, then the corresponding... The values are 0, 60, and 83 respectively (based on the current time). The corresponding weights are approximately , , This demonstrates that recent medical records contribute more significantly to the final historical status.
[0058] When a medical record is missing a certain type of field (e.g., the chief complaint is missing), the corresponding feature vector is set to an all-zero vector, while the remaining parts are encoded normally and used in the calculation, without affecting the overall vector structure of the model. This mechanism ensures the stability of the system when dealing with real-world data loss scenarios. The final generated historical structure fingerprint vector... This will serve as one of the inputs for identifying changes in diagnosis and treatment and constructing medical interpretations in subsequent steps, forming the first key intermediate result in the entire follow-up medical record generation chain.
[0059] S2: Encode the four structural fields of the current medical visit into a current medical visit vector in the same way, calculate the difference between the current medical visit vector and the historical medical fingerprint vector in each field dimension to obtain a medical change vector; based on the fields activated in the medical change vector, match the triple path in the preset medical knowledge graph to generate a set of medical change tags containing change type, field position and medical causal explanation;
[0060] Specifically, this step aims to identify the points of change in a patient's treatment status between this follow-up visit and their previous treatment, and to construct a medical causal explanation for these changes to guide subsequent medical record generation tasks. In the context of a follow-up visit, patients often already have a relatively clear diagnostic foundation and treatment history. Therefore, whether the content of this visit has been "adjusted," "added," or "reversed" from the original context is the most informational part of the generated medical record. If the medical record is generated directly based on the current information without comparing it with historical status, it can easily lead to problems such as repetitive chief complaints, redundant diagnostic descriptions, and conflicting medication logic.
[0061] The input is the historical structure fingerprint generated in step one. With the current medical treatment structure vector .in, It has integrated four types of historical characteristics of patients: diagnosis, medication, examination, and chief complaint, and highlighted recent consultation information through a time-weighted mechanism. Current consultation vector. It is directly encoded from structured medical record data, and its field structure corresponds one-to-one with the historical vector, including disease code embedding, medication code mapping, examination numerical vector and text feature pooling vector.
[0062] To identify significant changes between the current visit and historical status, the treatment difference vector is first calculated:
[0063] ;
[0064] in This represents the change in each item along the structural field dimension. This difference vector reflects the absolute direction and magnitude of change in all diagnostic features between their historical and current states. For example, in a dimension related to a chief complaint, if the frequency of the word "dizziness" in the chief complaint description increases significantly, the change value in the corresponding vector dimension will be positive, indicating a recurrence or worsening of the chief complaint symptoms; conversely, if the change in the corresponding dimension for a certain type of drug feature is negative, it may indicate that the drug has been adjusted or discontinued.
[0065] After calculating the change vector, a "re-examination abnormality reinforcement term" is introduced, which takes the form:
[0066] ;
[0067] in, This is a sparse binary vector representing "abnormal attention indicators" manually or automatically marked by doctors during the current medical visit. These markings originate from early warning strategy modules in actual government, military, and emergency medical systems. For example, a patient might be marked as a "key follow-up subject for chronic diseases" or a "high-risk indicator warning (such as three recent abnormal blood pressure readings)" in their electronic health record. This information serves as... Non-zero trigger item. As a strengthening factor, experience points are set... arrive Intervals are used to amplify the presence of outliers in the change vector, thereby enhancing the system's ability to perceive key changes.
[0068] Enhanced diagnostic and treatment change vector It was used to match structured paths in a medical knowledge graph to construct a causal explanation structure. (Graph structure) This is a set of triplets, including diagnosis-treatment causal pairs (e.g., "discontinuing antihypertensive medication"). "Recurring symptoms" and the relationship between symptoms and diagnosis ("dizziness") "Hypertension," and medication testing interaction ("Taking thiazide antibiotics") "Lower blood potassium levels," etc. The matching logic is based on the following graph constraint expressions:
[0069] ;
[0070] in Indicates the first One extracted label representing a change in diagnosis and treatment. Represents the current change vector and the graph path The structural compatibility is primarily calculated based on semantic entity coverage and relational direction consistency. If an entity has a large activation value in the vector and the path logic is reasonable, it is considered valid. This process does not use complex model reasoning but relies entirely on structural matching rules, and can be deployed in local area systems in government and military scenarios.
[0071] For example, if a patient has a history of long-term use of valsartan, but the drug has been discontinued in the current medical record and blood pressure has increased significantly, the drug dimension in the change vector decreases while the examination dimension increases. If this patient is labeled as a "hypertensive follow-up population," then the enhanced difference matching map path is: "discontinuation of antihypertensive medication." "Symptom recurrence" - generate tags "Suspected blood pressure loss of control due to discontinuation of medication." This step ultimately outputs two variables: one is the treatment change vector. Firstly, it serves as a structural control reference for subsequent medical record generation; secondly, it is a structured set of diagnostic and treatment change labels. each It consists of three components: change type, field location, and causal explanation.
[0072] S3: Construct a structured prompt vector based on the diagnosis and treatment change vector and the diagnosis and treatment change label set;
[0073] Specifically, this step, building upon the differences identified in the previous module between the current follow-up visit and historical treatment status, constructs structured input prompts for a large-scale model. This structured prompts precisely guide the medical record generation model to focus on the most clinically significant changes during the follow-up visit. Traditional large-scale models suffer from significant input redundancy in medical text generation. Even when receiving historical and current information, they struggle to distinguish between "changes to focus on" and "repetitions to ignore," resulting in a large amount of information backtracking and repetitive descriptions lacking clinical value in the generated medical records. The core task of this step is to construct a structured vector of clinical change. and a set of labels for changes in diagnosis and treatment Based on this, input control vectors with "structural alignment, semantic control, and disease-specific adjustability" are generated to form a preset framework for the content generated by the large model.
[0074] The input for this step consists of two variables: one is the structural change vector generated in the previous step. This vector is derived from the current medical information. fingerprints of historical status The first is constructed from the difference and enhanced expression formed by incorporating scene-related high-risk patient identifiers; the second is a set of diagnosis and treatment change labels. Each label in this set It is a triple structure, containing the change type, field position, and corresponding causal explanation path. All tags are generated by the medical atlas reasoning module in the previous step and have clear semantic positioning capabilities.
[0075] To improve the efficiency of structural change vectors in cue construction, this step first constructs the cue mask vector. This mask is used to remove feature dimensions irrelevant to the current diagnostic main class. The mask is generated based on the first three levels of classification codes in the diagnostic coding information (e.g., the first three levels of ICD-10 coding). A rule table is used to match relevant sub-modules involved in the current main diagnosis (e.g., cardiovascular system, nervous system), retaining only the corresponding structural dimensions and setting the remaining positions to zero. Subsequently, the mask vector is used to filter the structural change vectors, resulting in a preliminary structural cue vector. :
[0076] ;
[0077] in This represents an element-wise multiplication operation. The vector retains structural changes relevant to the current condition and removes redundant dimensions to prevent the model from focusing on irrelevant regions. Building upon this, a label enhancement mechanism is further introduced, assigning labels to each change. Vectorized embedding is performed and weighted fusion is carried out with the structural vector to obtain the final structural control cue vector. :
[0078] ;
[0079] in, Indicates that the label The encoding is done as a dense vector, with the following methods: mapping "change type" to a 4-dimensional one-hot vector (e.g., addition, deletion, adjustment, no change); mapping "field position" to a unit vector at the corresponding position of the structural feature; and converting "causal path" into a set of diagnosis-related path vectors (e.g., discontinuation-relapse path) after looking up a table using a triplet template. These three types of information are concatenated and then mapped through a linear layer to... Vectors of the same dimension; The label confidence coefficient is calculated as follows:
[0080] ;
[0081] in The score is given for the matching degree of the labeled path in the graph, ranging from... The depth is usually determined by the extent of entity coverage and path depth in the map.
[0082] This solution is applicable to fields such as government healthcare, military physical examinations, and chronic disease follow-up, emphasizing the safety requirements of two types of follow-up visits: "key monitoring" and "abnormal early warning." This step specifically introduces a structural cue-based sparse regularization term to compress the activation region of ineffective change vectors. This regularization term is defined as:
[0083] ;
[0084] in, The sparse control coefficient (usually taken as...) ), Low activation threshold (recommended value) ), This indicates an indicator function, which is 1 when the activation value of a certain dimension is less than a threshold, and 0 otherwise. This term is used to forcibly suppress non-critical dimensions during the generation process, allowing the model to maintain stronger focus during the generation stage. It is particularly suitable for the cue structure after high-dimensional vector compression, in order to reduce the interference of cue on irrelevant paragraph content.
[0085] Final output hint vector With regularization terms This information is input into the generation module in the next step to guide the medical record generation system to prioritize key changes during the overall paragraph generation process, while maintaining causal consistency and focus on diagnosis and treatment within the content logic.
[0086] S4: The structured prompt vector is concatenated with the paragraph position codes corresponding to the chief complaint paragraph, present illness paragraph, past medical history paragraph, physical examination paragraph, auxiliary examination paragraph, and diagnosis and treatment opinion paragraph, respectively, and then input into the language generation model using the Transformer architecture to guide the language generation model to generate the follow-up outpatient medical record text in the order of the six paragraphs.
[0087] Specifically, the core task of this step is to utilize the structured cue vectors constructed in the previous module. This process guides the large model to generate complete outpatient medical record texts with paragraph structure, reflecting the characteristics of a follow-up visit scenario. Unlike initial visits, follow-up medical records need to fully demonstrate the changes in the patient's condition during this visit compared to previous treatments, especially regarding recurring symptoms, medication adjustments, and diagnostic upgrades, requiring clear and medically reasonable expressions. To meet this requirement, this step introduces a structure-guided mechanism during the generation phase, enabling the language generation model to "write content around the structure" rather than "guess content from the context."
[0088] The input for this step is the structured hint vector output from the previous module. This vector integrates information on the differences between the current medical visit and historical medical records. It also incorporated a set of diagnostic and treatment change labels obtained through graph reasoning. The embedded representation reflects the aggregation strength of various medical changes in the follow-up visit scenario. This vector is not directly used as natural language input, but rather to control the attention distribution and paragraph writing strategies during the generation of each segment within the large model. Furthermore, the system predefines the outpatient medical record template structure, dividing it into... Each standard paragraph consists of: chief complaint, present illness, past medical history, physical examination, auxiliary examinations, diagnosis and treatment recommendations. Each paragraph requires an independent control mechanism to expand the sentences within it during generation.
[0089] To achieve paragraph-level generation control, the system will The vector dimension is fed into a segmentation mask constructor, which divides the data into segments based on the medical subdomains (such as medication, symptoms, and examination items) corresponding to the vector dimensions, thus creating a set of focus dimensions. For example, if paragraph 1 is the chief complaint section, it includes dimension numbers related to symptoms and signs; if paragraph 4 is the physical examination section, it includes dimensions related to the examination scales. (Systematic statistics) The average activation intensity across this segment dimension forms the segment attention weight. :
[0090] ;
[0091] in As a normalization constant, the sum of the weights of all paragraphs is 1, ensuring a relatively balanced distribution of attention. This mechanism ensures that paragraph content focuses on the sub-domains most relevant to the change. For example, if a patient develops chest tightness during this visit, the weight of the chief complaint paragraph will increase significantly, causing the generated result to automatically expand the description in that paragraph, such as "The patient's chief complaint during this follow-up visit was significantly worse, especially at night."
[0092] The generation process is based on a structure-guided language model, which uses a standard multi-layer Transformer structure. During the first layer of input, cue vectors are provided. Paragraph position encoding Concatenation as model input:
[0093] ;
[0094] in This is a paragraph structure position vector, generated by one-hot encoding and mapping from predefined paragraph indices (e.g., paragraph 1 main complaint, paragraph 6 treatment opinion). In the vector space. This concatenation structure allows the model to adaptively switch "writing styles" at different paragraph positions. For example, the main complaint paragraph uses a concise and intuitive descriptive style, while the treatment opinion paragraph adopts a formal and standardized medical terminology structure.
[0095] During the generation process, to prevent content repetition between paragraphs and internal sentence redundancy, the system introduces a sparsity control term based on activation strength. Specifically, when the activation weight of a paragraph is high, the model tends to output lengthy content; therefore, a sparsity penalty term is introduced.
[0096] ;
[0097] in This is the sparse control coefficient, typically set between 0.05 and 0.2; For paragraph Activation results in the first layer of the model; This refers to the attention weight of paragraphs. This regularization term encourages the model to use more efficient and compressed language expressions in high-attention paragraphs, strengthens the focus of diagnosis and treatment through content refinement, and avoids the proliferation of combinations of "high-frequency words + template sentences" in the generation process. It is especially suitable for scenarios with strong structural rigidity and high content density requirements, such as government medical care and military physical examinations.
[0098] The generated medical record results are output as a sequence. Each of them Each sentence is a language sentence, and the paragraph to which the sentence belongs is controlled by the paragraph index code. Finally, they are concatenated in order to form a complete outpatient medical record text. Taking a chronic disease follow-up patient as an example, if his / her medical history shows that he / she has been using "amlodipine + valsartan" for a long time, and the physical examination this time found that his / her blood pressure was not well controlled, and "palpitations" was added to the chief complaint, then the final generated medical record text will add "recently, obvious palpitations have occurred frequently" to the chief complaint paragraph, and give "considering that the current treatment plan is not enough to lower blood pressure, it is proposed to adjust it to valsartan combined with telmisartan" to the treatment opinion paragraph.
[0099] In one or more embodiments, such as Figure 2 As shown, a system for generating outpatient medical records based on a large-scale model follow-up visit scenario is disclosed. The system includes:
[0100] The historical medical record fingerprint extraction module is used to extract four structural fields from each medical record in the patient's historical outpatient medical record sequence: diagnosis code, prescription drug name and dosage, examination and test values, and chief complaint text. Each structural field is converted into a vector and then concatenated to obtain a structured coding vector for a single medical record. Based on the current consultation time and the timestamps of each historical medical record, an exponential decay weight is calculated, and the structured coding vector is weighted and summed to generate a historical medical fingerprint vector.
[0101] The diagnosis and treatment change identification and causal relationship extraction module is used to encode the four structural fields of the current visit into a current visit vector in the same way, calculate the difference between the current visit vector and the historical diagnosis and treatment fingerprint vector in each field dimension to obtain a diagnosis and treatment change vector; based on the fields activated in the diagnosis and treatment change vector, match the triple path in the preset medical knowledge graph to generate a set of diagnosis and treatment change labels containing change type, field position and medical causal explanation;
[0102] The prompt construction module is used to construct a structured prompt vector based on the diagnosis and treatment change vector and the diagnosis and treatment change label set;
[0103] The medical record generation module is used to concatenate the structured prompt vector with the paragraph position codes corresponding to the chief complaint paragraph, present illness paragraph, past medical history paragraph, physical examination paragraph, auxiliary examination paragraph, and diagnosis and treatment opinion paragraph, and input them into the language generation model using the Transformer architecture, guiding the language generation model to generate the follow-up outpatient medical record text in the order of the six paragraphs.
[0104] It is worth noting that the specific workflow of the system for generating outpatient medical records based on a large-scale follow-up visit scenario provided in this embodiment of the invention is the same as that of the method for generating outpatient medical records based on a large-scale follow-up visit scenario described in the above embodiment, and will not be repeated here.
[0105] This invention also provides a device for generating outpatient medical records based on a large-scale model follow-up visit scenario, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, it implements the steps described in the above-described method embodiment for generating outpatient medical records based on a large-scale model follow-up visit scenario. Figure 1 The steps S1 to S4 described above; or, when the processor executes the computer program, it implements the functions of each module in the above system embodiments.
[0106] For example, the computer program may be divided into one or more modules, which are stored in the memory and executed by the processor to complete the present invention. The one or more modules may be a series of computer program instruction segments capable of performing specific functions, which describe the execution process of the computer program in the device for generating outpatient medical records based on a large-scale follow-up visit scenario.
[0107] The device for generating outpatient medical records based on a large-scale model follow-up visit scenario can be a desktop computer, laptop, handheld computer, or cloud server, etc. This device may include, but is not limited to, processors and memory. Those skilled in the art will understand that the device may also include input / output devices, network access devices, buses, etc.
[0108] The processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASACs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. The processor is the control center of the device for generating outpatient medical records based on a large-scale follow-up visit scenario, connecting various parts of the device via various interfaces and lines.
[0109] The memory can be used to store the computer program and / or modules. The processor implements various functions of the device for generating outpatient medical records based on a large-scale follow-up visit scenario by running or executing the computer program and / or modules stored in the memory and calling the data stored in the memory. The memory may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function, etc.; the data storage area may store data created based on the operation of the air conditioner controller, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital card (SD card), flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage devices.
[0110] The module integrated into the device for generating outpatient medical records based on a large-scale follow-up visit scenario, if implemented as a software functional unit and sold or used as an independent product, can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the above embodiments of the present invention can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a portable hard drive, a magnetic disk, an optical disk, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium, etc.
[0111] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0112] The above description represents the preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A method for generating outpatient medical records based on a large-scale model follow-up visit scenario, characterized in that, The method includes: For each medical record in the patient's historical outpatient medical record sequence, four structural fields are extracted: diagnosis code, prescription drug name and dosage, examination and test values, and chief complaint text. Each structural field is converted into a vector and then concatenated to obtain the structured coding vector of a single medical record. Based on the current consultation time and the timestamps of each historical medical record, the exponential decay weight is calculated, and the structured coding vector is weighted and summed to generate a historical medical fingerprint vector. The four structural fields of the current medical visit are encoded into a current medical visit vector in the same way. The difference between the current medical visit vector and the historical medical fingerprint vector in each field dimension is calculated to obtain the medical visit change vector. Based on the fields activated in the diagnosis and treatment change vector, match the triple paths in the preset medical knowledge graph to generate a set of diagnosis and treatment change tags containing change type, field position and medical causal explanation; A structured prompt vector is constructed based on the diagnosis and treatment change vector and the diagnosis and treatment change label set; The structured prompt vector is concatenated with the paragraph position codes corresponding to the chief complaint paragraph, present illness paragraph, past medical history paragraph, physical examination paragraph, auxiliary examination paragraph, and diagnosis and treatment opinion paragraph, respectively, and then input into a language generation model using the Transformer architecture. This guides the language generation model to generate the follow-up outpatient medical record text in the order of the six paragraphs.
2. The method for generating outpatient medical records based on a large-scale model follow-up visit scenario according to claim 1, characterized in that, The step of converting each structural field into a vector and then concatenating them includes: The diagnostic code is mapped to a first embedding vector through a lookup table; The prescription drug name and dosage are compressed into a second embedding vector through sparse multi-thermal encoding and then linear transformation. The normalized test values are concatenated into a third embedding vector. The semantic features of the main complaint text are extracted using a convolutional neural network to obtain a fourth embedding vector; The first embedding vector, the second embedding vector, the third embedding vector, and the fourth embedding vector are concatenated to form the structured coding vector.
3. The method for generating outpatient medical records based on a large-scale model follow-up visit scenario according to claim 1, characterized in that, In the formula for calculating the exponentially decaying weight, the decay coefficient is greater than 0.9, and the sum of the weights corresponding to all historical medical records is normalized to 1.
4. The method for generating outpatient medical records based on a large-scale model follow-up visit scenario according to claim 1, characterized in that, Before the step of matching the activated fields in the diagnosis and treatment change vector with the triple path in the preset medical knowledge graph, the method further includes: Obtain high-risk warning markers from patients' electronic health records; If a high-risk warning marker exists, the change in the corresponding field of the diagnosis and treatment change vector is multiplied by an enhancement factor to obtain the enhanced diagnosis and treatment change vector. The matching is performed based on the enhanced diagnostic change vector.
5. The method for generating outpatient medical records based on a large-scale model follow-up visit scenario according to claim 1, characterized in that, The preset medical knowledge graph includes three types of triplet paths: diagnosis-treatment causal pairs, symptom-diagnosis relationships, and drug-examination interactions.
6. The method for generating outpatient medical records based on a large-scale model follow-up visit scenario according to claim 1, characterized in that, The step of constructing a structured cue vector based on the diagnosis and treatment change vector and the diagnosis and treatment change label set includes: Generate a hint mask vector based on the first three levels of classification codes of the disease code of the current primary diagnosis; The diagnostic change vector is filtered by dimension using the aforementioned prompt mask vector to obtain a preliminary prompt vector; Each label in the set of diagnostic and treatment change labels is converted into a dense embedding vector, and after being weighted by confidence based on the graph path matching score, it is fused with the preliminary prompt vector to obtain the structured prompt vector.
7. The method for generating outpatient medical records based on a large-scale model follow-up visit scenario according to claim 6, characterized in that, The step of converting each label in the set of diagnostic and treatment change labels into a dense embedding vector includes: The change type is mapped to a unique heat vector, the field position is mapped to a unit vector, and the medical causal explanation is converted into a path vector through a triplet template lookup table. The one-hot vector, unit vector, and path vector are concatenated and mapped through a linear layer to form a tag embedding vector with the same dimension as the initial prompt vector.
8. The method for generating outpatient medical records based on a large-scale model follow-up visit scenario according to claim 1, characterized in that, The step of constructing the structured cue vector further includes: applying a sparse regularization term to dimensions with activation values below a preset threshold to suppress the response intensity of non-critical change dimensions.
9. The method for generating outpatient medical records based on a large-scale model follow-up visit scenario according to claim 1, characterized in that, The steps for guiding the language generation model to generate follow-up outpatient medical record text in the order of six paragraphs include: The paragraph attention weight is calculated based on the activation intensity of the structured cue vector in the corresponding dimension of each paragraph; When generating each paragraph, the paragraph attention weight and the corresponding paragraph position encoding are combined to control the output content and style of the language generation model.
10. A system for generating outpatient medical records based on a large-scale model follow-up visit scenario, characterized in that, The system includes: The historical medical record fingerprint extraction module is used to extract four structural fields from each medical record in the patient's historical outpatient medical record sequence: diagnosis code, prescription drug name and dosage, examination and test values, and chief complaint text. Each structural field is converted into a vector and then concatenated to obtain a structured coding vector for a single medical record. Based on the current consultation time and the timestamps of each historical medical record, an exponential decay weight is calculated, and the structured coding vector is weighted and summed to generate a historical medical fingerprint vector. The diagnosis and treatment change identification and causal relationship extraction module is used to encode the four structural fields of the current visit into a current visit vector in the same way, calculate the difference between the current visit vector and the historical diagnosis and treatment fingerprint vector in each field dimension to obtain a diagnosis and treatment change vector; based on the fields activated in the diagnosis and treatment change vector, match the triple path in the preset medical knowledge graph to generate a set of diagnosis and treatment change labels containing change type, field position and medical causal explanation; The prompt construction module is used to construct a structured prompt vector based on the diagnosis and treatment change vector and the diagnosis and treatment change label set; The medical record generation module is used to concatenate the structured prompt vector with the paragraph position codes corresponding to the chief complaint paragraph, present illness paragraph, past medical history paragraph, physical examination paragraph, auxiliary examination paragraph, and diagnosis and treatment opinion paragraph, and input them into the language generation model using the Transformer architecture, guiding the language generation model to generate the follow-up outpatient medical record text in the order of the six paragraphs.
Citation Information
Patent Citations
Dosage regulation and control data storage method and system based on multi-modal diagnosis and treatment data
CN120895156A