Automatic columnar structured method and system for outpatient doctor-patient conversation
Patent Information
- Application Number
- CN202611257723.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-19
- Publication Date
- 2026-11-03
AI Technical Summary
Existing technologies cannot effectively understand polysemous words and referential relationships in medical contexts, and the column logic and processing rules cannot be flexibly adapted to different specialties, resulting in low accuracy and efficiency in generating outpatient medical records.
A cross-departmental, three-level configurable template library is constructed. A dual-model architecture is used for semantic understanding and implicit information reasoning. Structured medical records are generated through semantic vector encoding and medical logic verification, supporting role separation and text normalization processing.
It enables the generation of high-precision medical records that are adaptable to all departments, reduces system maintenance costs, and improves processing speed and accuracy, making it suitable for real-time outpatient diagnosis and treatment scenarios.
Smart Images

Figure CN123033677A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of medical information technology, specifically to a method and system for automatically segmenting outpatient doctor-patient dialogues. Background Technology
[0002] With the widespread adoption of electronic medical record systems, speech-to-text-assisted medical record generation has become a clinical necessity. However, existing technologies have consistently failed to overcome the industry bottleneck of inaccuracy when universally applicable and lacking universality when accurately applied. On one hand, general natural language processing models lack sufficient medical expertise, failing to accurately understand polysemous words and referential relationships in medical contexts. They struggle to accurately convert patients' colloquial expressions into standard medical terminology and have limited ability to recognize negative expressions and implicit clinical information. On the other hand, the column layout logic and processing rules of existing systems are mostly hard-coded into the system code. Different departments have vastly different consultation patterns, medical record structures, and core concerns. Hard-coded systems cannot flexibly adapt to different specialties, have long update cycles, and cannot meet the personalized medical record writing habits of hospitals and doctors. Summary of the Invention
[0003] The purpose of this invention is to overcome the above-mentioned defects of the prior art and provide an automatic column-based structured method and system for outpatient doctor-patient dialogue. Through the collaborative architecture of understanding semantics through medical models and defining configurable template structures, it achieves low-threshold, high-precision, and department-wide adaptability automatic generation of outpatient medical records.
[0004] To achieve the above objectives, the present invention provides a method for automatically structuring outpatient doctor-patient dialogue in columns, comprising:
[0005] Construct a three-level configurable template library across departments. The template library includes one or more templates. Each template contains one or more of the following layers: basic layer, specialty layer, and institutional layer. The basic layer, specialty layer, and institutional layer contain medical record columns, mapping rules, and / or validation rules.
[0006] Obtain outpatient doctor-patient dialogue data, perform role separation and text normalization preprocessing on the dialogue data to obtain one or more dialogue contents;
[0007] The one or more dialogue contents are semantically vector-encoded, the cosine similarity between each dialogue content and each medical record section of the loaded template is calculated, and the medical record section corresponding to each dialogue content is determined.
[0008] Based on the dialogue content corresponding to each medical record section, the structured medical record data of each dialogue content is extracted through the first model and / or the second model, and the results extracted by the first model and / or the second model are merged and output through the fusion module. The first model performs semantic understanding and terminology conversion, and the second model performs implicit information reasoning and logical verification.
[0009] Based on the template rules, the merged structured medical record data is subjected to medical logic verification to generate structured outpatient medical records.
[0010] Furthermore, the basic layer conforms to the national electronic medical record specifications; the specialty layer inherits from the basic layer and also includes standardized extended fields covering clinical specialties; the institution layer supports hospital-defined medical record templates and inherits the standard fields of the specialty layer; the mapping rules include column-level mapping, field-level mapping, and terminology-level mapping, wherein the column-level mapping defines the correspondence between the dialogue content and the medical record column, the field-level mapping defines the correspondence between entities within the medical record column and the fields contained in the medical record column, and the terminology-level mapping defines the correspondence between colloquial expressions and standard terminology.
[0011] Furthermore, before calculating the cosine similarity between each dialogue content and each medical record section of the loaded template, the following steps are included:
[0012] The optimal template is automatically matched based on the department, disease, and hospital identifier to obtain the loaded template. The hospital identifier belongs to the institutional layer, and the department and disease belong to the specialty layer, including:
[0013] Determine whether all three conditions—hospital identifier, department, and disease—are met. If so, load the personalized template corresponding to the hospital identifier, department, and disease from the institution layer.
[0014] If not, determine whether the two conditions of the department and disease type are met; if yes, load the standardized extended template corresponding to the department and disease type in the specialty layer.
[0015] If not, determine whether the condition for the visiting department matches; if yes, load the general template corresponding to the department in the specialty layer.
[0016] If not, load the general template corresponding to the basic layer that conforms to the national electronic medical record standard.
[0017] Furthermore, the first model, as a semantic understanding engine, is used to perform one or more operations among semantic vector encoding, terminology standardization, negative information normalization, and intelligent slot filling; the second model, as a medical reasoning engine, is used to perform one or more operations among implicit information mining, medical history logical consistency verification, physiological indicator rationality judgment, and complex multi-turn dialogue reasoning. The method further includes:
[0018] Controlling the first and second models to perform two-stage training includes:
[0019] Control the first model to perform LoRA-supervised fine-tuning;
[0020] Based on labeled preference data containing preferred and rejected answers, the first and second models are controlled to perform a second stage of direct preference optimization alignment, wherein the loss function f of the direct preference optimization alignment is... DPO for:
[0021] f DPO = -E[log σ(β(log π_θ(y_w|x) - log π_ref(y_w|x)) - β(log π_θ(y_l|x) - log π_ref(y_l|x)))],
[0022] Where y_w is the preferred answer, y_l is the rejected answer, π_θ is the strategy model, π_ref is the reference model, and β is the temperature parameter.
[0023] Furthermore, the extraction of structured medical record data from each dialogue content based on the dialogue content corresponding to each medical record section, using the first model and / or the second model, includes:
[0024] The first model is used for fast semantic processing, and the semantic understanding results and confidence scores are output.
[0025] Determine whether the confidence level of the first model output is lower than a preset confidence level threshold.
[0026] If so, semantic understanding results below the confidence threshold are routed to the second model for deep inference;
[0027] If not, after the semantic understanding result is output by the fusion module, the extracted structured medical record data is subjected to medical logic verification based on the template rules to generate structured outpatient medical records.
[0028] Furthermore, the intelligent slot filling uses sequence labeling to fill the symptoms, signs, time, and numerical information in the dialogue content into the corresponding medical record fields; the terminology standardization uses ICD-11 and a medical thesaurus to convert colloquial expressions into standard medical terms; and the implicit information mining uses a negation trigger word list and syntactic dependency analysis to uniformly identify explicit and implicit negations and convert them into a standardized format.
[0029] Furthermore, the verification rules include integrity verification, consistency verification, and rationality verification. The integrity verification checks whether required fields are missing, the consistency verification detects logical contradictions in medical history, and the rationality verification determines whether physiological indicators are within a preset range.
[0030] Furthermore, the method also includes:
[0031] The structured medical record data output by the first model with a confidence level higher than the preset training threshold are automatically labeled as new training samples;
[0032] The newly added training samples are compared with the verification results of the second model on the structured medical record data. Samples with a consistency rate not lower than a preset quality threshold are added to the training set. The consistency comparison includes structural consistency, value consistency, and semantic consistency.
[0033] The structural consistency includes parsing the structured medical record data output by the first model and the review results of the second model into hierarchical field trees, and comparing the medical record column set, field set and field hierarchy relationship of the two at each level. When the medical record column or field name is inconsistent, it is determined that it does not meet the structural consistency.
[0034] Based on the passing of the structural consistency comparison, the value consistency includes comparing the values of each corresponding field one by one. When the values of each corresponding field are consistent, it is determined that the value consistency is met. Among them, numerical fields are considered to be consistent within a preset tolerance range, text fields are considered to be consistent after normalization and precise matching, and enumerated fields must be completely consistent.
[0035] For fields that do not conform to the aforementioned value consistency, a semantic similarity score is used to determine whether they belong to the same medical meaning. If so, they are deemed to conform to semantic consistency.
[0036] The consistency rate is calculated based on the comparison results of structural consistency, value consistency, and semantic consistency.
[0037] Consistency rate = Number of fields with consistent data at the field level ÷ Total number of fields compared × 100%
[0038] The total number of fields to be compared is the union of the medical record columns and fields in the output of the first model and the review results of the second model. The number of fields with consistent field-level values is the total number of fields with consistent values or semantic equivalence.
[0039] Furthermore, the acquisition of outpatient doctor-patient dialogue data, and the preprocessing of the dialogue data including role separation and text normalization, includes:
[0040] Role separation is performed based on speaker identification tags in the dialogue;
[0041] Regular expression matching is used to filter noise.
[0042] Text normalization is performed using a unified text processing rule base;
[0043] The preprocessed dialogue content for each round is used to construct a sliding window context according to a preset window size.
[0044] The present invention also provides an automated, structured, column-based outpatient doctor-patient dialogue system, comprising at least one processor and a memory communicatively connected to the at least one processor. The memory stores a computer program executable by the at least one processor, and when the processor executes the program, it implements the following modules:
[0045] The template management module is used to build a three-level configurable template library across departments. The template library includes one or more templates, and each template contains one or more of the following layers: basic layer, specialty layer, and institutional layer. The basic layer, specialty layer, and institutional layer contain medical record columns, mapping rules, and / or validation rules.
[0046] The dialogue preprocessing module is used to acquire outpatient doctor-patient dialogue data, perform role separation and text normalization preprocessing on the dialogue data, and obtain one or more dialogue contents.
[0047] The semantic matching module is used to encode the one or more dialogue contents into semantic vectors, calculate the cosine similarity between each dialogue content and each medical record column in the loaded template, and determine the medical record column corresponding to each dialogue content.
[0048] The dual-model collaborative service module extracts structured medical record data from each dialogue content based on the dialogue content corresponding to each medical record column through the first model and / or the second model, and outputs the results extracted by the first model and / or the second model through the fusion module. The first model performs semantic understanding and terminology conversion, and the second model performs implicit information reasoning and logical verification.
[0049] The structured generation module is used to perform medical logic verification on the merged structured medical record data according to template rules, and generate structured outpatient medical records.
[0050] Compared with existing technologies, this invention has the following advantages: First, it achieves dynamic adaptation across all departments through a three-level configurable template system, allowing for one-click switching between departments and diseases by loading different templates, without requiring modification of system code. Second, in the dual-model collaborative architecture, the first model quickly processes routine semantic understanding, while the second model performs deep inference for low-confidence scenarios, balancing processing speed and accuracy. Third, it adopts a lightweight training scheme using LoRA supervised fine-tuning and direct preference optimization, enabling cold-start training with only a few hundred samples, without the need for massive amounts of labeled data and high-end computing power. Fourth, it achieves autonomous model iteration through weakly supervised self-labeling and online incremental training mechanisms, continuously improving accuracy. Fifth, it supports deployment on both central processing units and lightweight graphics processors throughout the entire process, resulting in a small size and high speed after quantization, making it suitable for real-time outpatient diagnosis and treatment scenarios. Attached Figure Description
[0051] Figure 1This is a schematic diagram of the overall architecture of the outpatient doctor-patient dialogue automatic column structured system provided in an embodiment of the present invention.
[0052] Figure 2 A flowchart of an outpatient doctor-patient dialogue automatic column structure method provided in an embodiment of the present invention.
[0053] Figure 3 This is a schematic diagram of the dual-model collaborative engine architecture provided in an embodiment of the present invention.
[0054] Figure 4 This is a schematic diagram illustrating the semantic matching and medical record column mapping principle provided in an embodiment of the present invention. Detailed Implementation
[0055] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the following embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the present invention. Unless otherwise specified, the embodiments and features described in this specification can be combined with each other.
[0056] Please see Figure 1 The diagram shows the overall architecture of the outpatient doctor-patient dialogue automatic column structured system provided in this embodiment of the invention. The system includes a template management module 100, a dialogue preprocessing module 200, a semantic matching module 300, a dual-model collaborative service module 400, and a structured generation module 500. The functions of each module are as follows: The template management module 100 manages a three-level configurable template library across departments (this template library defines the mapping rules between medical record columns and fields), providing functions for template creation, editing, version switching, and distribution of verification rules. Its output matching templates are passed to the semantic matching module 300, and the verification rules are passed to the structured generation module 500. The dialogue preprocessing module 200 performs standardized cleaning and text normalization processing on the collected outpatient doctor-patient dialogue data, and its output preprocessed dialogue text (or dialogue content) is passed to the semantic matching module 300. The semantic matching module 300 calculates the semantic similarity between the preprocessed dialogue text and each medical record field under template guidance. Its output matching results (including candidate field identification, similarity confidence, and dialogue text after contextual referencing resolution) are passed to the dual-model collaborative service module 400. The dual-model collaborative service module 400 includes a first model 401 and a second model 402, which performs semantic entity extraction, terminology standardization, negation recognition, implicit information reasoning, and medical logic verification on the dialogue text in the matching results. Its output structured medical record data is passed to the structured generation module 500. The structured generation module 500 performs integrity, consistency, and rationality checks on the received structured medical record data according to template verification rules. After passing the checks, it concatenates the data according to the template format to generate the final structured outpatient medical record.
[0057] Please refer to the following: Figure 2 The diagram shows a flowchart of an automatic column-based structured method for outpatient doctor-patient dialogue provided by an embodiment of the present invention. The method includes:
[0058] Step S1: Construct a three-level configurable template library across departments. The template library includes one or more templates, and each template contains one or more of the following layers: basic layer, specialty layer, and institutional layer.
[0059] In this embodiment, the template management module 100 is used to execute step S1. This invention defines a set of universal template description specifications independent of departments and diseases. Any department and any disease can define its own consultation template according to these specifications without modifying the system code.
[0060] In this embodiment, the template library includes one or more templates. Each template contains one or more of the following: the basic layer 101, the specialty layer 102, and the institutional layer 103. Each template is defined using the JSON Schema specification and includes metadata (meto), medical record sections, mapping rules (mapping_rules), and validation rules (validation_rules), wherein:
[0061] The basic layer 101 complies with the national electronic medical record specifications. For example, medical record columns can include standard columns or fields such as chief complaint, present illness, physical examination, past medical history, personal history, family history, medication history, and treatment.
[0062] Specialty layer 102 covers standardized extended templates for multiple clinical specialties such as internal medicine, surgery, obstetrics and gynecology, and pediatrics. Each specialty layer 102 template extends specialty fields on top of the basic layer 101. For example, obstetrics and gynecology adds pregnancy and childbirth history, and pediatrics adds growth and development history.
[0063] Institutional layer 103 supports hospitals to customize personalized templates that conform to their own medical record standards, and supports individual templates for doctors. Institutional layer 103 automatically inherits the standard fields of specialty layer 102 through the template inheritance mechanism.
[0064] In this embodiment, the templates for the basic layer 101, the specialized layer 102, and the institutional layer 103 can be stored as separate files. Under this storage method, the inheritance relationship between layers is reflected through a field reference mechanism within each layer's template.
[0065] 1) The base layer template file independently defines common fields;
[0066] 2) The specialist layer template file references field definitions from the basic layer template file and adds specialist extended fields;
[0067] 3) The institutional template file references the field definitions in the specialty template file and adds custom fields for the institution.
[0068] For example, taking the respiratory medicine outpatient template as an example, a general template specification is adopted. Specific forms may include: the template is defined in JSON Schema format, containing metadata, medical record categories, mapping rules, and validation rules. Mapping rules include category-level mapping, field-level mapping, and terminology-level mapping. Category-level mapping defines the correspondence between dialogue content and medical record categories (e.g., symptom description mapping to the chief complaint category). Field-level mapping defines the correspondence between entities within a medical record category and the fields contained in that category (e.g., numerical description mapping to the temperature field). Terminology-level mapping defines the correspondence between colloquial expressions and standard terminology (e.g., "fever" mapping to "heat"). In other implementations, category-level and terminology-level mapping rules can be automatically generated by the first model 401 based on historically annotated dialogues, replacing or supplementing manually configured mapping rules. Validation rules are expressed in JSON Schema in the form of allOf combined validation clauses, covering three types of rules: integrity validation (required fields), consistency validation (dependent required fields), and reasonableness validation (minimum / maximum numerical range). The following is an example of the JSON Schema for the respiratory medicine outpatient clinic template:
[0069] {
[0070] "schema": "template-schema-v1",
[0071] "meta": {
[0072] "template_id": "RESP_OPD_V1",
[0073] "name": "Respiratory Medicine Outpatient Medical Record Template",
[0074] "department": "Respiratory Medicine"
[0075] "version": "1.0",
[0076] "inherit_from": "BASE_EMR_V1"
[0077] },
[0078] "sections": {
[0079] "chief_complaint": {
[0080] "label": "Chief Complaint",
[0081] "required": true,
[0082] "fields": {
[0083] "content": { "type": "string", "desc": "chief complaint", "example": "cough with phlegm for 3 days"},
[0084] "duration": { "type": "string", "desc": "duration duration", "example": "3 days"}
[0085] }
[0086] },
[0087] "present_illness": {
[0088] "label": "Present Illness History",
[0089] "required": true,
[0090] "fields": {
[0091] "symptoms": { "type": "array", "items": { "type": "string"},"desc": "list of symptoms", "example": ["cough", "phlegm"]},
[0092] "temperature": { "type": "number", "unit": "℃", "desc": "body temperature", "example": 38.5},
[0093] "onset_time": { "type": "string", "desc": "onset time", "example": "3 days ago"}
[0094] }
[0095] },
[0096] "physical_exam": {
[0097] "label": "Physical Examination",
[0098] "required": true,
[0099] "fields": {
[0100] "temperature": { "type": "number", "unit": "℃", "desc": "body temperature", "example": 38.5},
[0101] "lung_auscultation": { "type": "string", "desc": "lung auscultation", "example": "coarse breath sounds in both lungs"}
[0102] }
[0103] },
[0104] "past_history": {
[0105] "label": "Past History",
[0106] "required": false,
[0107] "fields": {
[0108] "smoking": { "type": "string", "desc": "smoking history", "example": "smoking for 20 years, one pack a day"}
[0109] }
[0110] }
[0111] },
[0112] "mapping_rules": [
[0113] {"source": "colloquial expression: fever", "target_field": "temperature", "standard_term": "fever"},
[0114] {"source": "verbal expression: shortness of breath", "target_field": "symptom", "standard_term": "difficulty breathing"}
[0115] ],
[0116] "validation_rules": {
[0117] "completeness": [
[0118] { "rule": "required", "sections": ["chief_complaint", "present_illness", "physical_exam"], "message": "Chief complaint, present illness, and physical examination are required fields"}
[0119] ],
[0120] "consistency": [
[0121] { "rule": "dependentRequired", "from": "present_illness.temperature", "to": "physical_exam.temperature", "message": "The body temperature during the present illness should be consistent with the body temperature observed during the physical examination"},
[0122] { "rule": "cross_field", "expr": "chief_complaint.duration ==present_illness.onset_time", "message": "The duration of the chief complaint should be consistent with the onset time of the present illness"}
[0123] ],
[0124] "reasonableness": [
[0125] { "rule": "range", "field": "temperature", "min": 35, "max":42, "unit": "℃", "message": "Body temperature should be between 35 and 42 degrees Celsius"},
[0126] { "rule": "range", "field": "systolic_pressure", "min": 60, "max": 300, "unit": "mmHg", "message": "Systolic blood pressure should be within the range of 60 to 300 mmHg"} ]
[0128] }
[0129] }
[0130] The JSON Schema consists of several parts: The `meta` section contains the template's metadata, identifying the department, disease, and level to which the template belongs; the `sections` section defines the medical record columns and their subordinate fields, each containing a field identifier, name, data type, unit, and whether it is required; the `mapping_rules` section contains mapping rules that map patients' colloquial expressions to standard terminology and target fields; and the `validation_rules` section contains validation rules that can be used to verify the completeness, consistency, and reasonableness of subsequent steps. For example, completeness rules check whether required fields are filled, consistency rules detect logical inconsistencies such as discrepancies between the patient's present medical history temperature and the temperature observed during physical examination, and reasonableness rules determine whether the temperature exceeds the range of 35 to 42 degrees Celsius. The structure defined in this JSON Schema is independent of department and disease; any department can define its own template according to the same specification.
[0131] In one implementation, the institutional layer 103 supports hospitals to customize personalized templates that conform to their own medical record standards, and also supports individual templates for doctors. The institutional layer 103 template extends the specialty layer 102 template through a template inheritance mechanism, requiring only the definition of differentiated custom fields, without needing to redefine basic columns. Taking the respiratory medicine department of a tertiary hospital as an example, the hospital customizes a hospital-level template based on the specialty layer respiratory medicine template RESP_OPD_V1, with the template identifier HOSP_RESP_OPD_V1. Its inherit_from field from the specialty layer template is RESP_OPD_V1, and it adds the following hospital-specific columns and fields:
[0132] {
[0133] "meta": {
[0134] "template_id": "HOSP_RESP_OPD_V1",
[0135] "name": "Template of a Respiratory Medicine Outpatient Clinic at a Top-Tier Hospital",
[0136] "department": "Respiratory Medicine"
[0137] "version": "1.1",
[0138] "inherit_from": "RESP_OPD_V1",
[0139] "hospital_id": "HOSP_001
[0140] },
[0141] "sections": {
[0142] "hospital_exam": {
[0143] "label": "Auxiliary examinations conducted by this hospital",
[0144] "required": true,
[0145] "fields": {
[0146] "pft_no": { "type": "string", "desc": "Lung function test number", "example": "PFT20260731001"},
[0147] "ct_result": { "type": "string", "desc": "Summary of chest CT results", "example": "Patterned high-density shadow in the lower lobe of the right lung"}
[0148] }
[0149] }
[0150] },
[0151] "validation_rules": {
[0152] "completeness": [
[0153] { "rule": "required", "sections": ["hospital_exam"], "message":"Auxiliary examinations at this hospital are required fields"} ]
[0155] }
[0156] }
[0157] The physician personal template is a further expansion of the institution-level template. Taking Dr. Zhao from the Department of Respiratory Medicine as an example, his personal template identifier is DR_ZHAO_RESP_V1, the inherit_from field is HOSP_RESP_OPD_V1, and the newly added physician personal preference fields are as follows:
[0158] {
[0159] "meta": {
[0160] "template_id": "DR_ZHAO_RESP_V1",
[0161] "name": "Dr. Zhao's Respiratory Medicine Outpatient Medical Record Template",
[0162] "department": "Respiratory Medicine"
[0163] "version": "1.0",
[0164] "inherit_from": "HOSP_RESP_OPD_V1",
[0165] "doctor_id": "DR_ZHAO
[0166] },
[0167] "sections": {
[0168] "doctor_fields": {
[0169] "label": "Doctor's Supplement",
[0170] "required": false,
[0171] "fields": {
[0172] "smoking_index": { "type": "string", "desc": "smoking index", "example": "400 (20 cigarettes / day x 20 years)"},
[0173] "followup_note": { "type": "string", "desc": "follow-up notes", "example": "chest CT scan to be performed in 1 week"}
[0174] }
[0175] }
[0176] },
[0177] "validation_rules": {}
[0178] }
[0179] In the above institutional layer example, the hospital custom template only defines the auxiliary examination column of the hospital, that is, it inherits all the basic columns of the respiratory medicine specialty template. The doctor personal template only defines the doctor supplementary column, that is, it inherits all the columns and fields of the hospital template, forming a hierarchical inheritance chain of "basic layer → specialty layer → institutional layer (hospital template → doctor personal template)". Each level of template only needs to define differentiated content.
[0180] In other implementations, the three-tier template can also aggregate multi-level definitions within the same template through field referencing and merging mechanisms. Under the various storage methods described above, the field references within each template level all reflect inheritance relationships. When the template loading engine 104 parses the template, it recursively expands the field references of each level, merging the multi-level field definitions into a complete template.
[0181] In this embodiment, the template loading engine 104 adopts a priority loading strategy. It automatically matches the optimal template based on three levels of conditions: patient's department, disease, and hospital identifier, and loads the template in a progressively backward order from specific to general. The template loading engine 104 executes template matching according to a priority pattern of "institutional layer → specialty layer → basic layer." The matching conditions at each level are specific implementations of the loading priority: the institutional layer prioritizes matching based on a combination of hospital identifier, department, and disease; the specialty layer prioritizes matching based on a combination of department and disease; and the basic layer prioritizes matching based on a fallback without specific conditions.
[0182] In this embodiment, the step-by-step rollback loading process of the template loading engine 104 may include:
[0183] The first matching condition is that all three conditions—hospital identifier, department, and disease—are met. When a match is found, the personalized template corresponding to the hospital identifier, department, and disease in institution layer 103 is directly loaded.
[0184] If no match is found in the institution layer 103, the second matching condition is executed, that is, the two conditions of the department and the disease are matched. When matched, the standardized extended template corresponding to the department and the disease in the specialty layer 102 is loaded.
[0185] If no match is found in specialty layer 102, the third matching condition is executed, that is, only the condition of the department to be visited is matched. When a match is found, the general template corresponding to that department in specialty layer 102 is loaded.
[0186] If none of the above three conditions are met, the system will fall back to the basic layer 101 and load a general template that conforms to the national electronic medical record standard.
[0187] For example, if a patient visits the endocrinology department of a tertiary hospital and is diagnosed with type 2 diabetes, the template loading engine 104 first attempts to match the institutional layer 103 template for type 2 diabetes in the endocrinology department of that hospital; if the hospital has not customized a template for this disease, it matches the specialty layer 102 template for type 2 diabetes in the endocrinology department; if the specialty layer 102 has not defined a template for this disease either, it matches the general template for the endocrinology department; if the endocrinology department has not defined one either, it finally falls back to the general outpatient medical record template in the basic layer 101.
[0188] In other implementations, the template description specification can use YAML or XML format instead of JSON Schema, and the template loading strategy supports matching rules based on more dimensions such as patient age and gender. Templates for the basic, specialty, and institutional layers can be stored in separate files, or multiple layers of definitions can be aggregated within the same template file through field referencing and merging mechanisms. The template loading engine 104 parses the field definitions of each layer level by level according to the matching conditions. The two storage methods have no impact on the step-by-step backtracking matching logic of the loading engine.
[0189] Through the aforementioned three-tiered configurable template library design, the system achieves dynamic adaptation across all departments—switching between applicable departments and diseases simply by loading different templates, without modifying any system code. This solves the problems of difficult specialty adaptation and long update cycles associated with hard-coded rules in existing technologies. Compared to existing solutions where each specialty requires independent development or code modification, this invention achieves vertical reuse between the basic and specialty layers through a template inheritance mechanism. The institutional layer only needs to define differentiated custom fields based on the standard fields inherited from the specialty layer, significantly reducing the maintenance cost of medical record templates.
[0190] Step S2: Perform dual-model cold start training.
[0191] Please refer to the following: Figure 3 The diagram shows a schematic of the dual-model collaborative service module architecture provided in an embodiment of the present invention. The dual-model collaborative service module 400 is used to execute steps S2, S5, and S6. Step S2 is the model initialization training during the system deployment phase, which is not repeated after being completed once. In actual operation, it starts directly from step S3.
[0192] This invention employs a two-layer model collaborative architecture for model training. The first model 401 uses Qwen3-8B as its semantic understanding engine, responsible for semantic vector encoding, conversion from spoken language to standard medical terminology, negative information recognition, and intelligent slot filling. During LoRA fine-tuning, the first model 401 retains the semantic encoding capability of the base model, obtaining a 4096-dimensional semantic vector output from the last hidden state through feature extraction. The second model 402 uses DeepSeek-R1-Distill-Qwen-7B as its medical inference engine, responsible for implicit information reasoning, consistency verification of medical history, rationality judgment of physiological indicators, and complex multi-turn dialogue reasoning. Both models can be compressed to approximately 4-5GB after AWQ (Activation-aware Weight Quantization) 4-bit quantization.
[0193] The training process employs a two-stage strategy. The first stage is LoRA (Low-Rank Adaptation) supervised fine-tuning, which uses LoRA to freeze all parameters of the pre-trained model and trains only the injected low-rank matrix. In this implementation, the LoRA rank r is 16, the scaling factor α is 32, the dropout is 0.05, and the target fine-tuning modules are q_proj, v_proj, k_proj, o_proj, gate_proj, up_proj, and down_proj. The optimizer used is AdamW with a learning rate of 2e-4, a warmup ratio of 0.03, and cosine annealing for learning rate scheduling. During training, per_device_train_batch_size is 4, gradient_accumulation_steps is 8, the effective batch size is 32, and the maximum sequence length max_seq_length is 2048. During the cold start phase, a preset number of training samples (e.g., 500) are used. In each training batch, the dialogue text and template requirements are concatenated into a unified format Prompt, with structured medical record JSON as the target output, and optimization is performed using the cross-entropy loss function. On a single RTX 4090 (24GB VRAM) card, LoRA training uses approximately 12GB of VRAM, and a cold start of 500 samples over 3 epochs takes approximately 15 to 20 minutes. The SFT (Supervised Fine-Tuning) instruction template is used to train the first model 401, covering four tasks: semantic matching, negation recognition, terminology conversion, and implicit information. This enables the first model 401 to independently complete all medical record structuring steps (corresponding to the four processing steps in step S5) in high-confidence scenarios. The second model 402 is fine-tuned using independent training data containing CoT inference chains. The training data format is "patient description + inference chain + conclusion," used to enhance its implicit information reasoning and logical verification capabilities. The unified format of the SFT instruction template is as follows:
[0194] <|im_start|>system
[0195] You are a professional medical record structuring assistant. Please extract key information and generate structured medical records based on doctor-patient dialogues and template requirements.
[0196] Task Description:
[0197] 1. Semantic matching: Mapping dialogue content to template categories.
[0198] 2. Terminology Conversion: Converting colloquial expressions into standard terminology according to ICD-11 and the medical thesaurus (International Classification of Diseases, 11th Revision).
[0199] 3. Negation Recognition: Identifies explicit / implicit negation and outputs "No XX".
[0200] 4. Implicit Information: Clinical Implicit Information in Indirect Descriptions
[0201] <|im_end|>
[0202] <|im_start|>user
[0203] Doctor-patient dialogue:
[0204] Doctor: {doctor_utterance}
[0205] Patient: {patient_utterance}
[0206] Template: {template_json}
[0207] <|im_end|>
[0208] <|im_start|>assistant
[0209] {structured_output_json}
[0210] <|im_end|>
[0211] The second stage is DPO (Direct Preference Optimization), which utilizes doctor-annotated preference data pairs (preferred and rejected answers) to align the model output with medical record writing standards, reducing illusions and standardizing formatting. DPO applies to both Model 401 and Model 402: for Model 401, the preference data pairs are the preferred and rejected results of structured medical records from the same dialogue, used to align medical record writing standards; for Model 402, the preference data pairs are the preferred and rejected inference chains describing the same patient, used to strengthen the rigor of the inference chains and the medical rationality of the conclusions. Both models are optimized using the DPO loss function, with a beta parameter of 0.1, a learning rate of 5e-6, and the same LoRA configuration as SFT. DPO The loss function is:
[0212] f DPO= -E[log σ(β(log π_θ(y_w|x) - log π_ref(y_w|x)) - β(log π_θ(y_l|x) - log π_ref(y_l|x)))], where y_w is the preferred answer, y_l is the rejected answer, π_θ is the strategy model, π_ref is the reference model, and β is the temperature parameter.
[0213] The dual-model collaborative service module employs a confidence-based routing mechanism. The first model 401 first completes rapid semantic processing and outputs a confidence score. Based on a preset confidence threshold (e.g., 0.85), semantic understanding results with confidence scores higher than this threshold are directly output to the fusion module 403. For scenarios with confidence scores lower than this threshold or requiring logical reasoning, the input is automatically routed to the second model 402 for deep reasoning. The output of the second model 402 and the preliminary results of the first model 401 are merged by the fusion module 403 and then filled into the template.
[0214] In other implementations, the dual-model architecture can be replaced by a single model with reasoning capabilities performing all semantic understanding and reasoning tasks, or by using three or more models to handle semantic understanding, reasoning verification, and format calibration tasks respectively. In scenarios with limited computing resources (such as primary healthcare institutions equipped only with ordinary central processing unit workstations), a single, extremely small open-source Chinese medical model (such as Chinese Medical-MiniLM or Medical-TinyBERT) can be used to replace the dual-model architecture. This single model has 16M to 32M parameters, a model size of no more than 50MB, supports central processing unit training and inference throughout the process, a single dialogue processing speed of no more than 300ms, and does not require graphics processing unit computing power.
[0215] The confidence routing mechanism can also be replaced by a parallel processing mechanism, where two models process the same input simultaneously and then fuse the output.
[0216] The lightweight training scheme described above enables cold starts with a small sample size of around 100, eliminating the need for massive amounts of labeled data and high-end graphics processing unit (GPU) power, thus significantly lowering the barrier to model deployment. In particular, the confidence routing mechanism of this invention offers the following technical advantages: high-confidence scenarios are processed quickly by the first model (approximately 200ms / item), meeting the response time requirements of real-time outpatient interaction; low-confidence scenarios are automatically routed to the second model for deep inference (approximately 800ms / item), ensuring the accuracy of semantic understanding in complex medical contexts. The two processing paths automatically switch based on confidence scores, balancing processing efficiency and semantic accuracy. Compared to existing schemes that use fixed processing paths, this achieves a dynamic balance between processing speed and inference accuracy.
[0217] Step S3: Obtain outpatient doctor-patient dialogue data, perform role separation and text normalization preprocessing on the dialogue data to obtain one or more dialogue contents.
[0218] The dialogue preprocessing module 200 is used to perform step S3. The standardized preprocessing of outpatient doctor-patient dialogue data includes four sub-steps:
[0219] The role separation sub-step is implemented based on the speaker identification tags of the dialogue. Specifically, each round of dialogue text carries speaker identification tags (such as "Doctor:" or "Patient:" prefix tags). The role separation sub-step uses a tag segmentation algorithm to divide the dialogue text into doctor statement sequences and patient statement sequences according to the rounds. The segmentation rule is: using the "Doctor:" or "Patient:" tag as the starting point of the statement, and the next speaker tag as the ending point of the current statement, forming a list of statement units with role labels. For example, the dialogue text "Doctor: Where do you feel unwell? Patient: I've been coughing a lot lately. Doctor: How long have you been coughing?" after tag segmentation, yields three statement units: doctor's statement "Where do you feel unwell?", patient's statement "I've been coughing a lot lately", and doctor's statement "How long have you been coughing?". For statements lacking speaker tags, their roles are inferred based on the alternation pattern of dialogue rounds: if the previous statement was a doctor's statement, the current statement is determined to be a patient's statement, and vice versa. By performing role separation on dialogue data, the dialogue data can be segmented into multiple dialogue contents, thereby enabling better semantic matching and medical record column mapping.
[0220] The noise reduction and cleaning sub-step 220 uses regular expressions to filter common noise patterns, including filler words, repeated sentences, and redundant punctuation. Specifically, a noise pattern rule base is pre-built, and the noise patterns include: filler words (such as "um", "ah", "that", "that is to say"), repeated expressions (such as "I I I", "cough cough"), redundant punctuation (such as consecutive commas ",,,", consecutive periods "..."), and ambient sound annotations (such as "[laughter]", "[cough]", "[background sound]"). The noise reduction and cleaning sub-step 220 performs line-by-line matching and deletion of dialogue text according to the regular expressions in the rule base. For example, the regular expression "um|ah|that|that is to say" matches and deletes filler words, and the regular expression "([\u4e00-\u9fa5])\1+" matches and deletes consecutive repeated words. For example, the patient's statement "um, I've been coughing a lot lately, coughing" is reduced to "I've been coughing a lot lately" after noise reduction and cleaning.
[0221] The text normalization sub-step uses a unified text processing rule library to convert full-width English letters and numbers into half-width characters, and unify the writing formats of dates and times. Specifically, the text processing rule library includes: a full-width character conversion rule, which converts full-width English letters (such as ABC) and full-width numbers (such as 123) into corresponding half-width characters (such as ABC, 123); a date format unification rule, which unifies different date writing formats such as "May 1, 2024", "2024-05-01" and "24.5.1" into the "2024-05-01" format; a time format unification rule, which unifies formats such as "9 a.m.", "9:00" and "nine o'clock" into the "09:00" format; a numerical format unification rule, which unifies "thirty-eight point five" and "38.5 degrees" into the "38.5" format while retaining the unit (such as "℃"). For example, after text normalization, the patient's statement "My body temperature is 38.5 degrees and my blood pressure is 130 / 80 this morning" becomes "My body temperature is 38.5℃ and my blood pressure is 130 / 80 this morning".
[0222] In the context window construction sub-step, a sliding window context is constructed for each round of preprocessed dialogue content according to a preset window size. Specifically, a window size N (such as the previous 5 rounds of dialogue) is set, with the current round as the right end of the window, and N rounds of dialogue are taken forward to form a context window; if there are fewer than N rounds before the current round, all existing rounds are taken. The window slides round by round as the dialogue proceeds, and a new context window is constructed each time a new round of dialogue is added. For example, if there are 10 rounds of outpatient dialogue in total, the context window of the 6th round of dialogue contains 5 rounds of dialogue from the 2nd to the 6th round, and the context window of the 7th round of dialogue contains 5 rounds of dialogue from the 3rd to the 7th round. The constructed context window provides complete dialogue history data support for anaphora resolution in the subsequent semantic matching step.
[0223] In other embodiments, role separation can be automatically completed by combining voiceprint features with dialogue logic rules without relying on speaker labels in the dialogue records, where the voiceprint features include formants, timbre, frequency, tone and speech speed, and the dialogue logic rules automatically determine the speaker role according to the question-answer pattern between the doctor and the patient. For noise reduction and cleaning, a language model can be introduced to judge the clinical relevance of statements, so as to automatically filter out content irrelevant to the consultation.
[0224] Through the standardized preprocessing mechanism described above, high-quality conversion of outpatient dialogues from raw speech-to-text to structured input was achieved. Role separation ensures that subsequent semantic matching is performed only on the doctor's valid inquiry text, avoiding the problem of patient responses being incorrectly matched to the medical record section. Noise reduction and cleaning filters out filler words and repetitive sentences, reducing noise interference in semantic vector encoding, thereby improving the accuracy of cosine similarity matching. Context window construction provides complete dialogue history data for the subsequent semantic matching step of pronoun resolution—the sliding window mechanism ensures that pronoun resolution can parse the actual referent of pronouns in the context of continuous multi-turn dialogues, rather than making inferences based on isolated single-turn dialogues. In other implementations, role separation can be automatically completed by combining voiceprint features with dialogue logic rules, without relying on speaker labels in the dialogue record. Voiceprint features include formants, timbre, frequency, tone, and speech rate, while dialogue logic rules automatically determine the speaker role based on the question-and-answer pattern between the doctor and patient. Noise reduction and cleaning can introduce a language model to determine the clinical relevance of statements and automatically filter out content irrelevant to the consultation.
[0225] Step S4: Semantic vector encoding is performed on the one or more dialogue contents, the cosine similarity between each dialogue content and each medical record column in the loaded template is calculated, and the medical record column corresponding to each dialogue content is determined.
[0226] Please refer to the following: Figure 4 The diagram illustrates the semantic matching and medical record column mapping principle provided in this embodiment of the invention. The semantic matching module 300 executes step S4. Before step S4, the template loading engine 104 performs a step-by-step backward loading based on the patient's department, disease type, and hospital identifier, loading the matched current template's medical record columns, mapping rules, and verification rules into the semantic matching module 300. The semantic matching module 300 performs semantic vector encoding on the preprocessed dialogue content and calculates the cosine similarity between each dialogue content and each medical record column of the loaded template. Specifically, the semantic matching module 300 uses the set of medical record columns and fields contained in the loaded template as the reference space for semantic matching, calculating the cosine similarity between the dialogue content and the description vectors of each medical record column and its subordinate fields in the loaded template, determining the medical record column to which each round of dialogue should belong, and then performing matching within the framework of medical record columns and fields defined by the loaded template.
[0227] In this embodiment, the first model 401, trained in step S2, encodes the content of each round of dialogue into a semantic vector of a preset dimension (e.g., 4096 dimensions). This semantic vector is the vector output from the last hidden state layer of the first model 401. The cosine similarity of this semantic vector is calculated one by one with the description encoding vectors of each medical record section and its sub-fields in the template. The formula for calculating the cosine similarity sim is:
[0228] sim = (A·B) / (‖A‖×‖B‖),
[0229] Where A is the semantic vector of the dialogue text, B is the description encoding vector of the medical record section or fields under the medical record section, A·B is the sum of the corresponding dimensions of A and B (i.e., vector dot product), ‖A‖ and ‖B‖ are the magnitudes of A and B respectively (i.e., the square root of the sum of the squares of each dimension), and sim takes the value range from -1 to 1. The closer to 1, the more similar the dialogue content is to the semantics of the medical record section. The closer to -1, the more opposite the semantics. 0 indicates that the semantics are unrelated. sim aims to measure the degree of semantic matching between the dialogue content and the medical record section and is used to determine the medical record section corresponding to the dialogue content.
[0230] In this implementation, the medical record category description encoding vector uses the concatenated text of the category name and its field names as the encoding input (e.g., "duration of chief complaint symptoms"), and is encoded into a 4096-dimensional vector by the first model 401. The field description encoding vector uses the field name and example value as the encoding input (e.g., "body temperature 38.5℃"). Each dimension in the 4096-dimensional semantic vector corresponds to a semantic feature dimension, and the dimension coordinates range from 1 to 4096. The top 3 categories with the highest similarity (K=3) are selected as candidate categories.
[0231] For dialogue content containing personal pronouns, contextual reference resolution is performed, parsing the referents of the pronouns from the preceding dialogue to ensure the accuracy of semantic matching. Semantic matching supports automatic contextual reference resolution, automatically parsing polysemous words and ambiguous referents in medical contexts, using previously mentioned medical entities as candidate referents, and determining the actual referent target through semantic similarity scoring. The confidence score is directly taken from the highest cosine similarity value among the candidate categories. When the highest similarity is lower than a preset matching threshold (e.g., 0.5), the dialogue round is marked as requiring manual confirmation. The category attribution result serves as the category context constraint for subsequent key information extraction: for example, in step S5, intelligent slot filling is performed under the field structure corresponding to the category, filling the corresponding fields of the category with entities such as symptoms, signs, time, and values extracted from the dialogue text in key-value pairs, so that the dialogue content is filled into the corresponding medical record category in a structured form. Finally, the structured generation module 500 splices the data according to the category order to generate a structured outpatient medical record.
[0232] In other implementations, the semantic vector dimension can be adjusted according to the model size (e.g., 384-dimensional or 1024-dimensional), and cosine similarity calculation can be replaced by similarity measures such as Euclidean distance or Manhattan distance. Substitution resolution can be performed using a separate substitution resolution model.
[0233] The semantic matching mechanism guided by the aforementioned template enables automatic mapping from free-flowing conversations to structured medical record sections. The core technical advantages of this mechanism are: First, it eliminates the need to pre-write matching rules for each type of inquiry. The semantic encoding capability of the first model can automatically map semantically similar expressions to the same section, solving the problems of high rule maintenance costs and incomplete coverage in rule engines. Second, the contextual reference resolution mechanism can automatically use previously mentioned medical entities as candidate referents, determining the referent of personal pronouns through semantic similarity scoring, eliminating the need for doctors to ask supplementary questions or manually annotate, thus reducing the number of interaction rounds and the burden of information entry during the consultation process.
[0234] Step S5: Based on the dialogue content corresponding to each medical record column, structured medical record data is extracted from each dialogue content through the first model and / or the second model. The first model performs semantic understanding and terminology conversion, and the second model performs implicit information reasoning and logical verification. The structured medical record data under each medical record column includes one or more of the following: symptoms, signs, time, numerical values, negative states, and implicit reasoning conclusions.
[0235] The dual-model collaborative service module 400 is used to execute step S5. The structured medical record data under each medical record category in this step refers to the medical entities and their standardized results extracted from the dialogue content that can be filled into the medical record category fields, including one or more of symptoms, signs, time, numerical values, negative states, and implicit inference conclusions; the medical record category refers to the category to which the dialogue content belongs, as determined in step S4, and the slot refers to the placeholder for the medical record field defined in the template under that category. This step uses the category attribution results determined in step S4 as the processing basis:
[0236] For dialogue content belonging to the same medical record category, the following four processing steps are performed under the field structure corresponding to that medical record category. The entities extracted from the dialogue are then filled into the corresponding fields of that medical record category, generating structured medical record data organized by medical record category.
[0237] The dual-model collaborative service module completes the extraction and standardization transformation of core dialogue information, specifically including the following four processing steps, forming a serial pipeline operation:
[0238] (1) Intelligent slot filling: The first model 401 uses sequence labeling to mark the symptoms, signs, time and values in the preprocessed dialogue text as BIO (Begin-Inside-Outside) tags. For example, in "body temperature 38.5℃", "body temperature" is labeled as B-symptom, "38.5" is labeled as B-value, and "℃" is labeled as B-unit. The first model 401 is based on the sequence labeling model and is trained as one of the four core tasks in SFT training. After labeling, each entity is mapped to the field structure defined in the template in the form of key-value pairs. Each field contains the value and confidence level. The structured entities extracted in this step (such as symptom name, measurement value, and time description) are used as input for the next step.
[0239] (2) Negation Information Regularization: The first model 401 receives the entity content output from the intelligent slot filling stage and identifies the negation information in the entities based on the negation trigger word list, including explicit negation words ("no", "not", "without", "not yet") and implicit negation patterns (such as the combination of negation words and symptom verbs). For explicit negation, it is directly identified through trigger word matching; for implicit negation, it is identified through syntactic dependency analysis to identify the modification relationship between negation words and symptom verbs. After unified processing, the negation state of each entity is marked. For example, "no fever" is marked as a negation state after explicit negation word matching; "no fever" is marked as a negation state after syntactic dependency analysis confirms the negation relationship. The set of entities with negation marks output by this stage is used as the input of the next stage.
[0240] (3) Terminology Standardization: The first model 401 receives the entity content with negative tags output from the negative information normalization stage and performs table lookup and conversion through a pre-constructed ICD-11 and medical thesaurus spoken-standard terminology mapping table. The mapping table covers the mapping relationship between standard diagnostic terms, symptom and sign terms and spoken synonyms. When looking up the table, the standard term corresponding to the patient's spoken expression is first searched in the mapping table; if the matching confidence is lower than a preset threshold (e.g., 0.8), it falls back to the first model 401 for semantic matching. For new expressions not covered in the mapping table, it falls back to the second model 402 to infer the corresponding standard term based on the context. Entities marked with a negative state are uniformly normalized to the "no XX" format after being converted to standard terms. For example, "fever" is converted to "heat" and then normalized to "no fever" after being combined with the negative tag. The set of standardized terms output in this stage is merged into the structured medical record data.
[0241] (4) Implicit Information Mining: The second model 402 receives the structured medical record data after the three stages mentioned above are combined. The second model 402 extracts key clinical information from the patient's indirect descriptions through chain-of-thought (CoT) reasoning. The Prompt format for CoT reasoning is as follows:
[0242] Based on the following patient description, infer possible clinically implicit information and output the inference chain and conclusion in JSON format.
[0243] Patient description: {patient_description}
[0244] Reasoning chain: Step 1: Observation → Step 2: Comparison with normal values → Step 3: Infer clinical meaning. Conclusion: {"implication": "XX", "reasoning_chain": "..."}
[0245] For example, inferring increased nocturia from a patient's description of "waking up three or four times at night" follows this reasoning chain: Observing the patient urinate 3-4 times at night → Normal nocturia is 0-1 times, 3-4 times is abnormal → Conclusion: Increased nocturia. Similarly, inferring shortness of breath after activity from "becoming breathless after walking just a few steps" follows this reasoning chain: Observing the patient experiences difficulty breathing with slight activity → Normal people do not have this symptom under the same activity → Conclusion: Shortness of breath after activity.
[0246] In this embodiment, the first model 401 directly processes the high-confidence matching results to generate structured medical record data blocks, and the second model 402 performs chain reasoning processing on the low-confidence results and scenarios requiring logical reasoning, and then merges the reasoning results of the second model 402 with the structured medical record data of the first model 401.
[0247] In other implementations, terminology standardization can be post-processed and calibrated using an external medical knowledge base, and implicit information mining can introduce more clinical reasoning rules as auxiliary constraints for the second model's reasoning. Furthermore, in scenarios requiring only simple semantic understanding (such as a single-round consultation), the first model 401 can independently complete the structure extraction, omitting the reasoning stage of the second model 402. In this simplified approach, the first model 401 still performs the three stages of intelligent slot filling, terminology standardization, and negative information normalization, only omitting the implicit information mining stage of the second model 402. The confidence level of the matching score is based solely on the cosine similarity of the semantic vectors, without considering the implicit information reasoning weight.
[0248] The key information extraction mechanism based on the dual-model collaboration described above solves the problems of terminology conversion errors, missed detection of negative information, and missing implicit information in existing technologies. The technical effects of this mechanism are specifically reflected in the following aspects: First, the BIO method of sequence labeling achieves precise delineation of medical entity boundaries, avoiding the problem of matching failure due to colloquial expressions in traditional regular expressions, and can correctly identify the field attribution for different expressions of the same measurement value; Second, the two-level terminology conversion strategy of ICD-11 and medical thesaurus mapping table plus model backoff ensures rapid standardization of common colloquial expressions (table lookup hit) and intelligent reasoning of novel expressions (model backoff), covering the entire scenario of colloquial-terminology mapping; Third, the double negation identification strategy of negation triggering lexicon plus syntactic dependency analysis, explicit negation is quickly hit through the lexicon, and implicit negation is identified through syntactic structure analysis, which can accurately distinguish between negative signs with negation modification and positive signs without negation; Fourth, CoT chain reasoning introduces a three-step reasoning mode of "observation → comparison with normal values → reasoning clinical meaning". Compared with directly outputting conclusions, the reasoning chain is traceable and verifiable, and doctors can quickly judge the rationality of the reasoning basis during review.
[0249] Step S6: Perform medical logic verification on the extracted structured medical record data according to the template rules to generate structured outpatient medical records.
[0250] The dual-model collaborative service module 400 and the structured data generation module 500 are used to execute step S6. This step takes the structured medical record data generated in step S5 as input, and the structured data generation module 500 performs multi-dimensional medical logic verification on the structured medical record data according to the verification rules defined in the template. For the results generated by the second model 402 under the low-confidence path, the second model 402 adopts a different inference configuration than the implicit information mining in step S5—specifically, it adopts an independent verification Prompt template and different temperature parameters to re-analyze the structured medical record data with an independent configuration, reducing the risk of bias in a single inference path; for the results generated by the first model 401 under the high-confidence path, the structured data generation module 500 performs verification according to the template verification rules.
[0251] In this embodiment, the second model 402 can perform multi-dimensional medical logic verification on the structured generation results according to the verification rules defined in the template. Verification may include three levels:
[0252] Integrity check: Check whether all fields marked as required in the template have been filled with content, and generate warning information for missing required fields;
[0253] Consistency check: Logical contradictions in the medical history are detected through the second model 402 reasoning, such as consistency check between the chief complaint of fever for three days and the normal body temperature on physical examination, and causal relationship check between symptom description and diagnosis conclusion;
[0254] Reasonableness check: Determine whether the values of physiological indicators are within the preset reasonable range, such as body temperature within the range of 35 to 42 degrees Celsius and systolic blood pressure within the range of 60 to 300 mmHg. If they are outside the range, they are marked as abnormal.
[0255] For items that fail validation, an anomaly warning and a list of missing information are generated for doctors to review and correct. In this implementation, only validation items with a severity level of error will cause the structured results to be returned for reprocessing. After validation, the structured data generation module 500 concatenates the validated structured medical record data into a complete medical record text according to the template structure, while retaining the original dialogue text and model processing log as traceability information. The generated medical record text can be archived by connecting to the hospital information system through medical and health information exchange standards such as HL7 (HealthLevel 7) and FHIR (Fast Healthcare Interoperability Resources). The FHIR resource mapping rules are as follows: the chief complaint and present illness are mapped to Diagnostic Report resources, the vital signs and numerical measurement results are mapped to Observation resources, and the medication history is mapped to Medication Statement resources. In this embodiment, the medical record generation process includes: rendering structured medical record data into medical record text according to the column order and field definition of the template; converting the original dialogue into JSON format and saving it as medical record metadata; and attaching log information such as the confidence score and processing timestamp of the model processing to the medical record.
[0256] In other implementations, verification rules can be customized by the hospital through a template configuration system, such as adding exclusive verification rules for specific departments; medical record data can be interfaced through the Rapid Medical Interoperability Resource Standard or other hospital information system interface protocols.
[0257] Please continue reading. Figure 1The data transfer relationships between the various modules of the system are as follows: The template management module 100 sends the template definition data (including medical record column structure, field mapping rules, and validation rules) matched for the current visiting department to the semantic matching module 300 and the structured generation module 500, respectively. The dialogue preprocessing module 200 sends the preprocessed dialogue text, which has undergone role separation, noise reduction and cleaning, text normalization, and context window construction, to the semantic matching module 300. After receiving the template definition and the preprocessed dialogue text, the semantic matching module 300 calls the first model 401 to perform semantic vector encoding on the dialogue content and calculates the cosine similarity with the vectors of each column of the template. The matching result (including the ID of each candidate column, cosine similarity confidence, and dialogue text after context referencing resolution) is sent to the dual-model collaborative service module 400. The dual-model collaborative service module 400 determines the processing path based on the confidence information in the matching results: high-confidence matching results are processed by the first model 401 using BIO sequence labeling, negative word recognition, and ICD-11 terminology mapping; low-confidence matching results are processed by the second model 402 using CoT implicit information inference; the structured medical record data resulting from the fusion module 403, after being merged by the outputs of the first model 401 and the second model 402, is sent to the structured generation module 500. After receiving the structured medical record data, the structured generation module 500 performs integrity, consistency, and rationality checks on the received structured medical record data according to the verification rules provided by the template management module 100. Once the checks pass, the final structured outpatient medical record is generated by rendering according to the template format.
[0258] The Dual-Model Collaborative Service Module 400 supports both vLLM (virtual LLM, Virtual Large Model Inference and Service Engine) and llama.cpp dual inference backends, adapting to deployments across all scenarios, from pure CPUs to lightweight GPUs. Models communicate via a shared context window, avoiding redundant coding overhead.
[0259] In other implementations, the training data construction and incremental iteration mechanism rely on the collaborative efforts of various system modules. The training data construction employs a three-dimensional hierarchical sampling strategy based on department, disease type, and dialogue turn number to ensure balanced samples at each level. During the sampling process, difficult samples with low model confidence are prioritized and oversampled, and semantic embedding-based clustering is used for deduplication to ensure sample diversity.
[0260] The training data is constructed through the following channels:
[0261] Supervised fine-tuning of the training set, with dialogues and templates as inputs and structured medical record JSON as outputs, covers four core tasks: semantic matching, negation recognition, terminology conversion, and slot filling.
[0262] Terminology alignment sets, containing mapping pairs between spoken expressions and standard medical terms from ICD-11 and medical thesaurus; direct preference optimization preference pairs, each containing the preferred and rejected answers for the same dialogue;
[0263] The evaluation set randomly selects a portion of the data to cover various departments and difficulty levels. The evaluation metrics include BLEU score, semantic matching F1 score, and entity-level F1 score. The BLEU score measures the n-gram overlap between the generated medical record text and the standard medical record. The semantic matching F1 score measures the harmonic mean of precision and recall for slot filling. The entity-level F1 score measures the harmonic mean of precision and recall for medical entity extraction. The field filling rate is used as a supplement to measure the complete filling ratio of required fields.
[0264] During clinical use, the system continuously accumulates training data through a weakly supervised self-annotation mechanism: Structured medical record data output by the first model 401 with a confidence level higher than a preset training threshold (e.g., 0.95) are automatically labeled as new training samples. The self-labeled data undergoes quality filtering, retaining only high-quality samples that pass consistency checks and adding them to the training set. Consistency checks involve multi-level consistency comparisons between the new training samples and the verification results of the structured medical record data from the second model 402. The comparison dimensions include structural consistency, value consistency, and semantic consistency.
[0265] Structural consistency: The structured medical record data output by the first model 401 and the review results of the second model 402 are respectively parsed into hierarchical field trees. The medical record column set, field set and field hierarchy relationship of the two are compared level by level to see if they are consistent. If the medical record column or field name is inconsistent, it is determined that the structure is inconsistent and does not meet the structural consistency requirement.
[0266] Value consistency: Based on the successful structural consistency comparison, each corresponding field is compared one by one. When the values of each corresponding field are consistent, it is determined that the value consistency is met. Among them, numerical fields are considered consistent within a preset tolerance range (e.g., body temperature 38.5 and 38.6 are considered consistent within a 0.1 degree Celsius tolerance). Text fields are considered consistent after normalization and exact matching (e.g., after removing spaces and full-width / half-width differences, "cough" and "cough" are consistent). Enumerated fields (e.g., negation markers, units) must be completely consistent.
[0267] Semantic consistency: For fields with inconsistent values but semantic equivalent, semantic similarity scores are used to determine whether they belong to the same medical meaning (e.g., "fever" and "heat" have a semantic similarity higher than a preset semantic threshold and are considered semantically equivalent). Semantically equivalent fields are considered consistent.
[0268] The consistency rate was calculated based on the above comparison results:
[0269] Consistency rate = Number of fields with consistent data at the field level ÷ Total number of fields compared × 100%
[0270] The total number of comparison fields is the union of the columns and fields in the output of the first model 401 and the verification result of the second model 402. The number of fields with consistent values is the total number of fields with consistent values or semantic equivalence. Only high-quality samples with a consistency rate of not less than a preset quality threshold (such as 90%) are added to the training set.
[0271] For example, in a dialogue where "the patient reports a cough for 3 days accompanied by fever," Model 401 outputs structured medical record data with a confidence level of 0.97.
[0272] Chief complaint: {"Symptoms": "Cough", "Duration": "3 days"}, Present illness: {"Temperature": 38.5°C}}
[0273] Since the confidence level of 0.97 is not lower than the second preset threshold of 0.95, the result is automatically labeled as a candidate training sample.
[0274] The output of the second model 402 after reviewing the dialogue is as follows:
[0275] {"Chief Complaint": {"Symptoms": "Cough", "Duration": "3 days"}, "Present Illness": {"Temperature": 38.5}}.
[0276] The consistency comparison process is as follows: Structural comparison: Both have the same column set {chief complaint, present illness} and the field set is consistent, so the structural consistency is passed; Value comparison: Chief complaint-symptom (cough and cough) are exactly consistent after normalization, chief complaint-duration (3 days and 3 days) are consistent, present illness-body temperature (38.5 and 38.5) are consistent within the tolerance range, and all field values are consistent, with a consistency rate of 100%, which is not lower than the quality threshold of 90%. This sample is added to the training set after quality filtering.
[0277] For example, if the second model 402 verification output is:
[0278] Chief complaint: {"Symptoms": "Coughing up sputum", "Duration": "3 days"}, Present illness: {"Temperature": 38.5°C}}
[0279] If the chief complaint-symptom field is inconsistent (cough and sputum are not semantically equivalent), and the other fields are consistent, the consistency rate is 3 / 4 = 75%, which is lower than the quality threshold of 90%. Therefore, this sample does not pass the quality filter and will not be added to the training set.
[0280] LoRA incremental fine-tuning is performed periodically (e.g., daily or weekly) using newly added samples. Incremental training employs an experience replay strategy to prevent forgetting; a portion of historical samples are sampled from the historical data buffer and mixed with the newly added samples for training. The new model's effectiveness is validated through A / B testing; if validation fails, it automatically rolls back to the previous version. The trigger condition for incremental training is set to automatically trigger when the number of newly added samples exceeds a preset threshold (e.g., 100 samples) or manually triggered by the hospital administrator. The proportion of experience replay is adjusted within the range of 20% to 40%.
[0281] Through the aforementioned online incremental iteration mechanism, the system's accuracy continues to improve in clinical use, enhancing semantic matching accuracy, terminology conversion accuracy, and negative identification recall rate during the cold start phase.
[0282] In summary, the outpatient doctor-patient dialogue automatic column structured method and system provided by this invention, through the collaborative architecture of medical model understanding semantics and configurable template definition structure, combined with small sample lightweight training and online incremental iteration mechanism, achieves automatic generation of outpatient medical records with dynamic adaptation across all departments, accurate understanding of medical semantics, and autonomous iterative optimization of the model with extremely low implementation threshold.
[0283] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for automatically structuring outpatient doctor-patient dialogue into columns, characterized in that, include: Construct a three-level configurable template library across departments. The template library includes one or more templates. Each template contains one or more of the following layers: basic layer, specialty layer, and institutional layer. The basic layer, specialty layer, and institutional layer contain medical record columns, mapping rules, and / or validation rules. Obtain outpatient doctor-patient dialogue data, perform role separation and text normalization preprocessing on the dialogue data to obtain one or more dialogue contents; The one or more dialogue contents are semantically vector-encoded, and the cosine similarity between each dialogue content and each medical record column in the loaded template is calculated to determine the medical record column corresponding to each dialogue content. Based on the dialogue content corresponding to each medical record section, the structured medical record data of each dialogue content is extracted through the first model and / or the second model, and the results extracted by the first model and / or the second model are merged and output through the fusion module. The first model performs semantic understanding and terminology conversion, and the second model performs implicit information reasoning and logical verification. Based on the template rules, the merged structured medical record data is subjected to medical logic verification to generate structured outpatient medical records.
2. The method according to claim 1, characterized in that, The basic layer conforms to the national electronic medical record standards; the specialty layer inherits from the basic layer and also includes standardized extended fields covering clinical specialties; the institution layer supports hospital-defined medical record templates and inherits the standard fields of the specialty layer; the mapping rules include column-level mapping, field-level mapping, and terminology-level mapping, wherein the column-level mapping defines the correspondence between the dialogue content and the medical record column, the field-level mapping defines the correspondence between entities within the medical record column and the fields contained in the medical record column, and the terminology-level mapping defines the correspondence between colloquial expressions and standard terminology.
3. The method according to claim 1, characterized in that, Before calculating the cosine similarity between each dialogue content and each medical record section of the loaded template, the following steps are included: The optimal template is automatically matched based on the department, disease, and hospital identifier to obtain the loaded template. The hospital identifier belongs to the institutional layer, and the department and disease belong to the specialty layer, including: Determine whether all three conditions—hospital identifier, department, and disease—are met. If so, load the personalized template corresponding to the hospital identifier, department, and disease from the institution layer. If not, determine whether the two conditions of the department and disease type are met; if yes, load the standardized extended template corresponding to the department and disease type in the specialty layer. If not, determine whether the condition for the visiting department matches; if yes, load the general template corresponding to the department in the specialty layer. If not, load the general template corresponding to the basic layer that conforms to the national electronic medical record standard.
4. The method according to claim 1, characterized in that, The first model serves as a semantic understanding engine, performing one or more operations among semantic vector encoding, terminology standardization, negative information normalization, and intelligent slot filling; the second model serves as a medical reasoning engine, performing one or more operations among implicit information mining, medical history logical consistency verification, physiological indicator rationality judgment, and complex multi-turn dialogue reasoning. The method further includes: Controlling the first and second models to perform two-stage training includes: Control the first model to perform LoRA-supervised fine-tuning; Based on labeled preference data containing preferred and rejected answers, the first and second models are controlled to perform a second stage of direct preference optimization alignment, wherein the loss function f of the direct preference optimization alignment is... DPO for: f DPO = -E[log σ(β(log π_θ(y_w|x) - log π_ref(y_w|x)) - β(log π_θ(y_l|x) -log π_ref(y_l|x)))], Where y_w is the preferred answer, y_l is the rejected answer, π_θ is the strategy model, π_ref is the reference model, and β is the temperature parameter.
5. The method according to claim 4, characterized in that, The extraction of structured medical record data from each dialogue content based on each medical record section, using a first model and / or a second model, includes: The first model is used for fast semantic processing, and the semantic understanding results and confidence scores are output. Determine whether the confidence level of the first model output is lower than a preset confidence level threshold. If so, semantic understanding results below the confidence threshold are routed to the second model for deep inference; If not, after the semantic understanding result is output by the fusion module, the extracted structured medical record data is subjected to medical logic verification based on the template rules to generate structured outpatient medical records.
6. The method according to claim 4, characterized in that, The intelligent slot filling method uses sequence labeling to fill the symptoms, signs, time, and numerical information in the dialogue content into the corresponding medical record fields; the terminology standardization is based on ICD-11 and a medical thesaurus to convert colloquial expressions into standard medical terms; the implicit information mining uses a negation trigger word list and syntactic dependency analysis to uniformly identify explicit and implicit negations and convert them into a standardized format.
7. The method according to claim 1, characterized in that, The verification rules include integrity verification, consistency verification, and rationality verification. The integrity verification checks whether required fields are missing, the consistency verification detects logical contradictions in medical history, and the rationality verification determines whether physiological indicators are within a preset range.
8. The method according to claim 1, characterized in that, The method further includes: The structured medical record data output by the first model with a confidence level higher than the preset training threshold are automatically labeled as new training samples; The newly added training samples are compared with the verification results of the second model on the structured medical record data. Samples with a consistency rate not lower than a preset quality threshold are added to the training set. The consistency comparison includes structural consistency, value consistency, and semantic consistency. The structural consistency includes parsing the structured medical record data output by the first model and the review results of the second model into hierarchical field trees, and comparing the medical record column set, field set and field hierarchy relationship of the two at each level. When the medical record column or field name is inconsistent, it is determined that it does not meet the structural consistency. Based on the passing of the structural consistency comparison, the value consistency includes comparing the values of each corresponding field one by one. When the values of each corresponding field are consistent, it is determined that the value consistency is met. Among them, numerical fields are considered to be consistent within a preset tolerance range, text fields are considered to be consistent after normalization and precise matching, and enumerated fields must be completely consistent. For fields that do not conform to the aforementioned value consistency, a semantic similarity score is used to determine whether they belong to the same medical meaning. If so, they are deemed to conform to semantic consistency. The consistency rate is calculated based on the comparison results of structural consistency, value consistency, and semantic consistency. Consistency rate = Number of fields with consistent data at the field level ÷ Total number of fields compared × 100% The total number of fields to be compared is the union of the medical record columns and fields in the output of the first model and the review results of the second model. The number of fields with consistent field-level values is the total number of fields with consistent values or semantic equivalence.
9. The method according to claim 1, characterized in that, The process of acquiring outpatient doctor-patient dialogue data and performing role separation and text normalization preprocessing on the dialogue data includes: Role separation is performed based on speaker identification tags in the dialogue; Regular expression matching is used to filter noise; Text normalization is performed using a unified text processing rule base; The preprocessed dialogue content for each round is used to construct a sliding window context according to a preset window size.
10. A structured, automatically segmented outpatient doctor-patient dialogue system, characterized in that, It includes at least one processor and a memory communicatively connected to the at least one processor, the memory storing a computer program executable by the at least one processor, wherein the processor, when executing the program, implements the following modules: The template management module is used to build a three-level configurable template library across departments. The template library includes one or more templates, and each template contains one or more of the following layers: basic layer, specialty layer, and institutional layer. The basic layer, specialty layer, and institutional layer contain medical record columns, mapping rules, and / or validation rules. The dialogue preprocessing module is used to acquire outpatient doctor-patient dialogue data, perform role separation and text normalization preprocessing on the dialogue data, and obtain one or more dialogue contents. The semantic matching module is used to encode the one or more dialogue contents into semantic vectors, calculate the cosine similarity between each dialogue content and each medical record column in the loaded template, and determine the medical record column corresponding to each dialogue content. The dual-model collaborative service module extracts structured medical record data from each dialogue content based on the dialogue content corresponding to each medical record column through the first model and / or the second model, and outputs the results extracted by the first model and / or the second model through the fusion module. The first model performs semantic understanding and terminology conversion, and the second model performs implicit information reasoning and logical verification. The structured generation module is used to perform medical logic verification on the merged structured medical record data according to template rules, and generate structured outpatient medical records.
