A method and system for generating an outpatient medical record based on a large model reexamination scene

By performing structured coding and analysis of changes in diagnosis and treatment in patients' historical medical records, and combining this with medical knowledge graph generation methods, redundancy and logical problems in the generation of follow-up medical records were solved, achieving efficient and accurate medical record generation and meeting the actual needs of follow-up scenarios.

CN121483471BActive Publication Date: 2026-03-24GUANGZHOU SIYUN DATA TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-01-08
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

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.

Method used

By structuring and coding patients' historical outpatient medical records, calculating treatment fingerprint vectors and change vectors, generating treatment change labels using medical knowledge graphs, constructing structured prompt vectors, and guiding a language generation model to generate follow-up medical records with change awareness and causal logic.

Benefits of technology

It significantly improves the accuracy and clinical applicability of medical record generation in follow-up visit scenarios, ensuring that the medical record content is logically clear and highlights key points, meeting the needs of high-risk early warning and treatment compliance assessment in scenarios such as government medical care, military physical examinations, and chronic disease follow-up.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121483471B_ABST
    Figure CN121483471B_ABST
Patent Text Reader

Abstract

The application provides a method and system for generating an outpatient medical record based on a large model reexamination scene, the method comprising: structurally coding a patient historical outpatient medical record sequence, and generating a historical diagnosis and treatment fingerprint vector according to a time attenuation weighting strategy; coding current medical information into a current medical vector, comparing the current medical vector with the historical diagnosis and treatment fingerprint vector to generate a diagnosis and treatment change vector, and combining a medical knowledge graph to obtain a diagnosis and treatment change label set with a medical cause and effect explanation; constructing a structured prompt vector based on the diagnosis and treatment change vector and the label set; and inputting the prompt vector spliced with the position codes of six paragraphs of chief complaint, present illness history, past medical history, physical examination, auxiliary examination, diagnosis and treatment opinion into a language generation model of a Transformer architecture to guide the language generation model to generate a reexamination outpatient medical record text in a standard paragraph order. The application can accurately capture disease evolution characteristics, and improve the pertinence, logic and clinical practicability of a reexamination medical record.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of medical informatization, and particularly relates to a method and system for generating an outpatient medical record in a re-consultation scenario based on a large model. BACKGROUND

[0002] With the rapid progress of artificial intelligence technology, large-scale language models have gradually matured in the application of medical document generation, especially in the generation of outpatient medical records, the extraction of consultation summaries, and the structuring of medical dialogues, which have shown strong language organization capabilities and medical knowledge generalization capabilities. However, in clinical practice, medical records are not a one-time writing task, and re-consultation scenarios are more common. Patients often form a continuous diagnosis and treatment trajectory at different time nodes and multiple medical visits, and their disease state, medication regimen, test results, and complaint content will change over time. The writing of re-consultation medical records requires not only covering the current symptoms and treatment plan, but also accurately reflecting the differences between the patient and the previous visit, clearly pointing out the changes, symptom recurrence, new abnormalities, etc., so that doctors can judge the disease control state, treatment adherence, and potential risk factors accordingly. However, existing medical record generation methods based on large models generally target the initial consultation scenario, and usually simply concatenate or summarize historical medical record texts and input them into the model. In the re-consultation context, they lack the ability to extract structured information that evolves with diagnosis and treatment, and cannot identify which parts belong to stable background information and which parts need to be focused on and expanded. This results in a large amount of redundant content in the generated results, missing of description focus, or logical jumps. More importantly, the re-consultation scenario has a distinct "disease evolution" property, but existing methods lack an explanation mechanism for changes, patterns, and backgrounds. They cannot express the possible medical reasons behind symptom changes, medication changes, or test abnormalities in a clinically logical manner, making it difficult for the generated content to support doctors' diagnosis reasoning or decision analysis. In government medical care, military physical examination, and chronic disease follow-up scenarios, re-consultation information is often closely related to high-risk early warning mechanisms, long-term health record management, and diagnosis and treatment adherence assessment. The existing technology cannot automatically construct change information and evolution logic based on historical diagnosis and treatment trajectories and this visit results, so it is difficult to truly meet the actual application needs of the re-consultation scenario. In summary, how to extract structured trend features from multiple historical medical records of a patient, how to accurately identify the differences between the current consultation information and the history, how to provide medical causal explanations for the changes, and how to effectively map these structured information to the generation control logic of the large model are key problems that need to be solved by the current technology. SUMMARY

[0003] The purpose of the present application is to design a method and system for generating an outpatient medical record in a re-consultation scenario based on a large model, which can generate a re-consultation medical record with change awareness, causal logic, and consistent paragraph structure, significantly improving the accuracy, relevance, and clinical practicality of medical record generation in a re-consultation scenario.

[0004] To achieve the above object, in the first aspect of the present application, a method for generating an outpatient medical record based on a large model re-consultation scenario is provided, the method comprising:

[0005] extracting a diagnosis code, a prescription drug name and a dose, a test value, and a chief complaint text from each medical record in a historical outpatient medical record sequence of a patient, and concatenating the respective structure fields after converting them into vectors to obtain a structured coding vector for a single medical record;

[0006] calculating an exponential decay weight according to the current visit time and the time stamp of each historical medical record, and performing weighted summation on the structured coding vector to generate a historical diagnosis and treatment fingerprint vector;

[0007] encoding the four structure fields of the current visit into a current visit vector in the same way, calculating 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;

[0008] According to the activated fields in the diagnosis and treatment change vector, matching the triple path in the preset medical knowledge graph to generate a diagnosis and treatment change label set containing change type, field position and medical causal explanation;

[0009] constructing a structured prompt vector based on the diagnosis and treatment change vector and the diagnosis and treatment change label set;

[0010] concatenating the structured prompt vector with the paragraph position encoding corresponding to the chief complaint section, the history section, the past history section, the physical examination section, the auxiliary examination section, and the diagnosis and treatment opinion section, and inputting it into a language generation model using the Transformer architecture to guide the language generation model to generate a re-consultation outpatient medical record text in the order of the six paragraphs.

[0011] Further, the step of concatenating the respective structure fields after converting them into vectors comprises:

[0012] mapping the diagnosis code to a first embedding vector through a lookup table;

[0013] After sparse multi-hot encoding, the prescription drug name and dose are compressed into a second embedding vector through linear transformation;

[0014] normalizing the test values and concatenating them into a third embedding vector;

[0015] extracting semantic features from the chief complaint text through a convolutional neural network to obtain a fourth embedding vector;

[0016] concatenating the first embedding vector, the second embedding vector, the third embedding vector, and the fourth embedding vector into the structured coding vector.

[0017] Further, in the calculation formula of the exponential decay 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] Further, before the step of matching a triple path in the preset medical knowledge graph according to the activated field in the diagnosis and treatment change vector, the method further comprises:

[0019] Obtaining a high-risk warning mark of the patient in the electronic health record;

[0020] If there is a high-risk warning mark, multiplying the change amount of the corresponding field in the diagnosis and treatment change vector by a reinforcement factor to obtain a reinforced diagnosis and treatment change vector;

[0021] The matching is performed based on the reinforced diagnosis and treatment change vector.

[0022] Further, the preset medical knowledge graph includes three types of triple paths of diagnosis and treatment causal pairs, symptom diagnosis relationships, and drug examination interactions.

[0023] Further, the step of constructing a structured prompt vector based on the diagnosis and treatment change vector and the diagnosis and treatment change label set comprises:

[0024] Generating a prompt mask vector according to the first three classification codes of the current primary diagnosis disease code;

[0025] Performing dimension screening on the diagnosis and treatment change vector using the prompt mask vector to obtain a preliminary prompt vector;

[0026] Converting each label in the diagnosis and treatment change label set into a dense embedding vector, and fusing the dense embedding vector after confidence weighting according to a graph path matching degree score with the preliminary prompt vector to obtain the structured prompt vector.

[0027] Further, the step of converting each label in the diagnosis and treatment change label set into a dense embedding vector comprises:

[0028] Mapping the change type into a one-hot vector, mapping the field position into a unit vector, and converting the medical causal explanation into a path vector through a triple template lookup table;

[0029] Concatenating the one-hot vector, the unit vector, and the path vector and mapping them through a linear layer into a label embedding vector of the same dimension as the preliminary prompt vector.

[0030] Further, the step of constructing a structured prompt vector further comprises applying a sparse regularization term to dimensions with an activation value below a preset threshold to suppress the response strength of non-key change dimensions.

[0031] Further, the step of guiding the language generation model to generate the follow-up outpatient medical record text in the order of six paragraphs comprises:

[0032] The paragraph attention weight is calculated according to the activation intensity of the structured prompt vector on the corresponding dimension of each paragraph;

[0033] When each paragraph is generated, the paragraph attention weight and the paragraph position encoding of the corresponding paragraph are combined to control the output content and style of the language generation model.

[0034] In a second aspect of the application, a system for generating a follow-up scene outpatient medical record based on a large model is provided, the system comprising:

[0035] A historical medical record fingerprint extraction module is configured to extract four structure fields of diagnosis code, prescription drug name and dosage, examination and test value, and chief complaint text from each medical record in a historical outpatient medical record sequence of a patient, concatenate the vectors converted from the structure fields respectively to obtain a structured coding vector of a single medical record, calculate an exponential decay weight according to a current visit time and a time stamp of each historical medical record, and perform weighted summation on the structured coding vector to generate a historical diagnosis and treatment fingerprint vector;

[0036] A diagnosis and treatment change identification and causal relationship extraction module is configured to encode the four structure 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, and match a triple path in a preset medical knowledge graph according to the activated fields in the diagnosis and treatment change vector to generate a diagnosis and treatment change label set containing change type, field position, and medical causal explanation;

[0037] A prompt construction module is configured to construct a structured prompt vector based on the diagnosis and treatment change vector and the diagnosis and treatment change label set;

[0038] A medical record generation module is configured to concatenate the structured prompt vector with the paragraph position encoding corresponding to the chief complaint paragraph, the present illness paragraph, the past history paragraph, the physical examination paragraph, the auxiliary examination paragraph, and the diagnosis and treatment suggestion paragraph respectively, and input the concatenated result into a language generation model adopting a Transformer architecture to guide the language generation model to generate a follow-up outpatient medical record text in the order of six paragraphs.

[0039] The application has at least the following beneficial technical effects:

[0040] To solve the above problems, the application provides a method and system for outpatient medical record generation in a large model reconsultation scenario. The method compresses the multi-round historical medical record information of the reconsultation patient in a structured manner, constructs a historical diagnosis and treatment fingerprint with time decay characteristics, so that the model can understand the diagnosis and treatment trajectory of the patient in a low-dimensional but high-expression manner. Then, the current medical information is compared with the historical structure fingerprint, an abnormal reinforcement mechanism specific to the reconsultation scenario is introduced, a diagnosis and treatment change vector that can truly reflect the new elements and change trends of this medical visit is formed, and a change label and causal explanation with clinical significance are obtained through medical atlas logic matching. The application further maps the change vector and the change label into structured prompt information, constructs a prompt vector that can be used to guide the generation process through change screening, semantic embedding enhancement, confidence weighted combination and sparse control strategy, so that the generation model can express around the diagnosis and treatment points of this reconsultation. Finally, the application introduces a paragraph-level structure guiding mechanism in the medical record generation stage, so that the prompt vector can play a differential control role in different paragraphs, and the key points of the content, clear logic and standard format are realized through paragraph attention distribution, paragraph position coding and activated sparse regularization. The application realizes a complete technical link from "historical diagnosis and treatment compression" to "diagnosis and treatment change identification" to "structured generation control", can generate a reconsultation medical record with change awareness, causal logic and paragraph structure consistency, and significantly improves the accuracy, pertinence and clinical practicability of medical record generation in the reconsultation scenario. BRIEF DESCRIPTION OF DRAWINGS

[0041] The application is further described by the accompanying drawings, but the embodiments in the drawings do not constitute any limitation on the application. Those skilled in the art can obtain other drawings without creative labor according to the following drawings.

[0042] Figure 1 A flowchart of a method for generating an outpatient medical record in a large model reconsultation scenario.

[0043] Figure 2 A system framework diagram for generating an outpatient medical record in a large model reconsultation scenario. DETAILED DESCRIPTION

[0044] The embodiments of the application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference signs represent the same or similar elements or elements with the same or similar functions throughout. The embodiments described below by reference to the drawings are exemplary and are only used to explain the application, and cannot be understood as a limitation on the application.

[0045] In one or more embodiments, as shown in Figure 1 a method for generating an outpatient medical record in a large model reconsultation scenario is disclosed, the method comprising 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 visit 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 cue vector is constructed based on the diagnosis and treatment change vector and the set of diagnosis and treatment change labels; the step of constructing the structured cue vector based on the diagnosis and treatment change vector and the set of diagnosis and treatment change labels 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; 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 unique 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; 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 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.

7. 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.

8. 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; A 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 step of constructing the structured prompt 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; 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 unique 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; 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