Triage method and system for emergency electronic medical records
Through the deep learning method of multi-modal data fusion, combined with the embedding layer, attention module and Transformer encoder, it solves the problems of slow response speed and single display method in the emergency electronic medical record triage method, and achieves efficient and accurate triage. The results showed that the triage error rate was significantly reduced.
Patent Information
- Application Number
- CN202410736901.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-07
- Publication Date
- 2024-09-06
AI Technical Summary
Existing emergency electronic medical record triage methods have slow response times when facing a sudden large number of emergency patients and cannot provide real-time decision support. Moreover, the display method of triage results is single and lacks intuitiveness and ease of use, resulting in a high triage error rate. .
Using the deep learning method of multi-modal data fusion, by obtaining the patient's electronic medical records, disease history and physiological characteristics, a pre-trained triage model is used to generate multiple triage results and corresponding probabilities, and are displayed in the form of graphics and tables. , combining the embedding layer, attention module, multi-layer perceptron module and encoder module to build the Transformer encoder to achieve efficient processing and in-depth analysis of data.
It significantly improves the efficiency and accuracy of triage in the emergency department, provides an intuitive way to display triage results, helps doctors quickly understand and apply triage results, and reduces the rate of triage errors.
Smart Images

Figure CN118609779A
Abstract
Description
Technical Field
[0001] The present invention relates to the medical field, and in particular to a triage method and system for emergency electronic medical records. Background Art
[0002] The emergency electronic health record (EHR) is an electronic medical record of patients in the emergency department, including the patient's basic physical information, clinical history, diagnosis results, medication status, etc. In this paper, EHR is used to construct multimodal joint indicators and analyze and predict them through deep learning models. The triage method of EHR is crucial in the field of medical information processing, especially in the prediction and management of admission of patients in the emergency department. In hospital operations, it takes about 4 minutes to create an emergency electronic medical record for each patient, which creates a huge time burden. In the emergency department, the influx of patients often leads to overcrowding, especially during major disasters. When medical resources are tight, it becomes particularly important to manage and assess the severity of patients. Therefore, automated EHR processes can greatly improve the triage efficiency of the emergency department.
[0003] In the existing technology, emergency triage mostly relies on machine learning methods, mainly through the classification model based on Bidirectional Encoder Representations from Transformers (BERT) to process emergency electronic medical records. BERT is a pre-trained language model based on the Transformer architecture for natural language processing tasks. In this paper, BERT is used to encode and extract features from medical record text data.
[0004] Although these methods have improved triage efficiency to a certain extent, there are still some shortcomings. For example, the current system fails to fully utilize the comprehensive data of electronic medical records, disease history, and physiological characteristics, resulting in low accuracy of triage results. In addition, traditional triage methods and simple machine learning models are slow to respond to a large number of emergency patients and cannot provide real-time decision support. The display method of triage results is also relatively simple, lacking intuitiveness and ease of use, making it difficult for doctors to quickly understand and apply triage results.
[0005] In summary, the existing technology lacks a triage method for emergency electronic medical records that can build an intelligent triage system based on multimodal data, achieve efficient data processing and in-depth analysis, and display the triage results in an intuitive manner. Summary of the invention
[0006] The present invention aims to provide a triage method and system for emergency electronic medical records, which can solve the problem of high triage error rate of emergency electronic medical records in related technologies.
[0007] According to one aspect of the present invention, a method for triage of emergency electronic medical records is provided, comprising: obtaining the patient's electronic medical record, disease history and physiological characteristics, wherein the electronic medical record includes diagnostic prescriptions, treatment plans and treatment results in digital form, the disease history includes chronic diseases, allergic reactions and surgical records, and the physiological characteristics include age, gender, height and weight; generating multiple triage results and corresponding probabilities for the patient using a pre-trained triage model based on the electronic medical record, the disease history and the physiological characteristics; and presenting the multiple triage results and corresponding probabilities in the form of graphs and tables.
[0008] Preferably, the triage model includes: an embedding layer module, which is used to convert the electronic medical record and the disease history into an embedding vector, wherein the electronic medical record is converted into a representation of a hidden dimension through a first fully connected layer and a first position embedding is added, and the disease history is converted through a second fully connected layer and a second position embedding is added; an attention module, which includes three linear transformations of query, key, and value, respectively mapping the electronic medical record, the disease history, and the physiological characteristics and calculating the attention weights, and performing weighted summation of the electronic medical record, the disease history, and the physiological characteristics according to the calculated attention weights to obtain an output result; a multi-layer perceptron module, which is used to perform a nonlinear transformation on the output result; an encapsulation module, which includes an attention layer and a multi-layer perceptron layer, which is used to realize the hierarchical structure of a Transformer by multiple stacking, wherein the interaction between the electronic medical record and the disease history is realized between the stacked second encapsulation module and the third encapsulation module; and an encoder module, which is used to constitute the encoder part of the Transformer by stacking multiple encapsulation modules.
[0009] Preferably, before using the pre-trained triage model to generate multiple triage results and corresponding probabilities for the patient, the triage model is also trained through the following steps: defining the path data_path of the data set, the directory path cc_dir of the electronic medical record, and the directory path lab_dir of the disease history; using the AdamW optimizer for parameter optimization, and using the cross-entropy loss function nn.CrossEntropyLoss() as the loss function; looping through each epoch, wherein each batch in the data loader train / testloader is traversed in each epoch, and wherein for each batch, the data is transferred to the triage model, and the gradient of the AdamW optimizer is cleared; calling the triage model for forward propagation, calculating the loss value according to the loss function and back-propagating, and then updating the parameters of the triage model; recording the average loss value and prediction result of each epoch, and calculating the corresponding AUC evaluation index.
[0010] Preferably, the loss function of the triage model is:
[0011] Where N is the number of samples, y i is the actual label of the i-th sample, is the predicted probability of the i-th sample, λ is the regularization coefficient, W j are the parameters of the triage model.
[0012] Preferably, updating the parameters of the triage model includes the following steps: Step 1, initializing the parameters θ of the triage model and calculating the initial prediction results Step 2: Calculate the loss function L(θ) of the triage model:
[0013] Step 3: Update the loss function L(θ) by gradient descent:
[0014] Where η is the learning rate, is the loss function with respect to the parameter θ t The gradient of Step 4: If L(θ) does not decrease significantly in k consecutive epochs, adjust the learning rate to η·γ, where γ is the reduction factor of the learning rate and 0<γ<1. Step 5, iterate step 2 to step 4 until the loss function L(θ) converges.
[0015] Preferably, before updating the parameters of the triage model, the method further includes updating the adaptive learning rate optimizer, specifically including: initializing parameters, defining the initial learning rate α0, the first-order moment estimation parameter β1 and the second-order moment estimation parameter β2 of the adaptive learning rate optimizer; updating the gradient estimation m at each time step t according to the following formula: t and v t :
[0016] The corrected gradient estimate is calculated according to the following formula:
[0017] And according to the following formula, calculate and update the parameters of the adaptive learning rate optimizer:
[0018] Here, ∈ is a small constant used to prevent division by zero errors.
[0019] According to another aspect of the present invention, there is provided an emergency electronic medical record triage system, comprising: a data acquisition module for acquiring a patient's electronic medical record, disease history and physiological characteristics, wherein the electronic medical record includes diagnostic prescriptions, treatment plans and treatment results in digital form, the disease history includes chronic diseases, allergic reactions and surgical records, and the physiological characteristics include age, gender, height and weight; a triage model module for generating multiple triage results and corresponding probabilities for the patient based on the electronic medical record, the disease history and the physiological characteristics using a pre-trained triage model; and a display module for displaying the multiple triage results and corresponding probabilities in the form of graphics and tables.
[0020] Preferably, the triage model module includes: an embedding layer unit, which is used to convert the electronic medical record and the disease history into an embedding vector, wherein the electronic medical record is converted into a representation of a hidden dimension through a first fully connected layer and a first position embedding is added, and the disease history is converted through a second fully connected layer and a second position embedding is added; an attention unit, which includes three linear transformations of query, key, and value, respectively mapping the electronic medical record, the disease history, and the physiological feature and calculating the attention weight, and performing weighted summation on the electronic medical record, the disease history, and the physiological feature according to the calculated attention weight to obtain an output result; a multi-layer perceptron unit, which is used to perform a nonlinear transformation on the output result; an encapsulation unit, which includes an attention layer and a multi-layer perceptron layer, which is used to realize the hierarchical structure of a Transformer by multiple stacking, wherein the interaction between the electronic medical record and the disease history is realized between the stacked second encapsulation module and the third encapsulation module; and an encoder unit, which is used to form the encoder part of the Transformer by stacking multiple of the encapsulation modules.
[0021] Preferably, before generating multiple triage results and corresponding probabilities for the patient, the triage model module also includes a training module for training the triage model, and the training module includes: a data path definition unit, used to define the path data_path of the data set, the directory path cc_dir of the electronic medical record, and the directory path lab_dir of the disease history; an optimizer unit, using the AdamW optimizer for parameter optimization, and using the cross-entropy loss function nn.CrossEntropyLoss() as the loss function; a training loop unit, used to loop through each epoch, wherein each batch in the data loader train / testloader is traversed in each epoch, and wherein for each batch, the data is transferred to the triage model, and the gradient of the AdamW optimizer is cleared; a forward propagation unit, used to call the triage model for forward propagation; a loss calculation unit, used to calculate the loss value according to the loss function and back-propagate; a parameter updating unit, used to update the parameters of the triage model; a recording unit, used to record the average loss value and prediction result of each epoch, and calculate the corresponding AUC evaluation index.
[0022] Preferably, the loss function of the triage model module is:
[0023] Where N is the number of samples, y i is the actual label of the i-th sample, is the predicted probability of the i-th sample, λ is the regularization coefficient, W j are the parameters of the triage model.
[0024] The present invention provides a triage method and system for emergency electronic medical records. Specifically, it constructs a data processing, data acquisition and loading test process for real-world medical record text data and clinical numerical data, and realizes the automation of real-world data loading; by creating a new multimodal fusion method and using a custom attention fusion module mechanism, efficient information interaction between medical record text and clinical data is realized; by proposing a deep learning method based on multimodal data fusion, fast and accurate patient triage prediction is achieved. The present invention can solve the problem of high triage error rate of emergency electronic medical records in the prior art, and has economic value in scientific research and practical application in related medical fields. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0026] Figure 1 is a flow chart of a method for triaging emergency electronic medical records according to an embodiment of the present invention;
[0027] Figure 2 is a data import flow chart according to an embodiment of the present invention;
[0028] Figure 3 is a flow chart of data acquisition and loading test according to an embodiment of the present invention;
[0029] Figure 4 is a model architecture diagram according to an embodiment of the present invention;
[0030] Figure 5 is a flow chart of model training according to an embodiment of the present invention;
[0031] Figure 6 is a flow chart of model loading and use according to an embodiment of the present invention; and
[0032] Figure 7 It is a module flow chart of the emergency electronic medical record triage system according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present invention will be described in detail below in conjunction with the embodiments.
[0034] The embodiment of the present invention provides a triage method for emergency electronic medical records, such as Figure 1 As shown, it includes: obtaining the patient's electronic medical record, disease history and physiological characteristics, wherein the electronic medical record includes diagnostic prescriptions, treatment plans and treatment results in digital form, the disease history includes chronic diseases, allergic reactions and surgical records, and the physiological characteristics include age, gender, height and weight; based on the electronic medical record, the disease history and the physiological characteristics, using a pre-trained triage model to generate multiple triage results and corresponding probabilities for the patient; and displaying the multiple triage results and corresponding probabilities in the form of graphics and tables.
[0035] In the related art, in the process of emergency triage, the traditional triage method and some simple machine learning models have a relatively high triage error rate. In the embodiment of the present invention, multimodal data such as electronic medical records, disease history and physiological characteristics are combined to fully capture the patient's medical information and provide more accurate triage results. This multimodal data fusion method overcomes the limitations of traditional single data processing methods and significantly improves the triage efficiency and accuracy of the emergency department.
[0036] According to an embodiment of the present invention, the triage model includes: an embedding layer module, which is used to convert the electronic medical record and the disease history into an embedding vector, wherein the electronic medical record is converted into a representation of a hidden dimension through a first fully connected layer and a first position embedding is added, and the disease history is converted through a second fully connected layer and a second position embedding is added; an attention module, which includes three linear transformations of query, key, and value, respectively mapping the electronic medical record, the disease history, and the physiological characteristics and calculating the attention weights, and performing weighted summation of the electronic medical record, the disease history, and the physiological characteristics according to the calculated attention weights to obtain an output result; a multi-layer perceptron module, which is used to perform a nonlinear transformation on the output result; an encapsulation module, which includes an attention layer and a multi-layer perceptron layer, which is used to realize the hierarchical structure of a Transformer by multiple stacking, wherein the interaction between the electronic medical record and the disease history is realized between the stacked second encapsulation module and the third encapsulation module; and an encoder module, which is used to constitute the encoder part of the Transformer by stacking multiple encapsulation modules.
[0037] In the related art, the processing of emergency electronic medical records and disease histories usually cannot make full use of multimodal data, resulting in inaccurate embedding vector conversion, which in turn affects the accuracy of the model. In addition, when calculating the attention weight, the existing system lacks a comprehensive mapping of electronic medical records, disease history and physiological characteristics, and the attention weight calculation is not accurate enough, resulting in insufficient reliability of the triage results. When the multi-layer perceptron module processes the nonlinear transformation of the output results, it is difficult to effectively improve the model performance, and when the encapsulation module implements the stacking of the Transformer hierarchical structure, the effective interaction between the electronic medical records and the disease history is lacking, which affects the comprehensive analysis ability of the model. When the encoder module constructs the encoder part of the Transformer, the stacking method of the encapsulation module is not flexible enough, resulting in the overall performance of the model being limited. In the embodiment of the present invention, the electronic medical record and the disease history are converted into an embedding vector through the embedding layer module, wherein the electronic medical record is converted into a representation of the hidden dimension through the first fully connected layer and the first position embedding is added, and the disease history is converted through the second fully connected layer and the second position embedding is added, which effectively improves the accuracy of the embedding vector. The attention module maps the electronic medical record, disease history and physiological characteristics through three linear transformations of query, key and value, and calculates the attention weight. According to the calculated attention weight, the electronic medical record, disease history and physiological characteristics are weighted and summed to obtain a more accurate output result. The multi-layer perceptron module performs nonlinear transformation on the output results, which significantly improves the performance of the model. The encapsulation module includes an attention layer and a multi-layer perceptron layer. The hierarchical structure of the Transformer is realized through multiple stacking, and the interaction between the electronic medical record and the disease history is realized between the second encapsulation module and the third encapsulation module, which improves the comprehensive analysis ability of the model. The encoder module forms the encoder part of the Transformer by stacking multiple encapsulation modules, which significantly improves the overall performance of the model.
[0038] According to an embodiment of the present invention, before using a pre-trained triage model to generate multiple triage results and corresponding probabilities for the patient, the triage model is also trained through the following steps: defining the path data_path of the data set, the directory path cc_dir of the electronic medical record, and the directory path lab_dir of the disease history; using the AdamW optimizer to optimize parameters, and using the cross-entropy loss function nn.CrossEntropyLoss() as the loss function; looping through each epoch, wherein each batch in the data loader train / testloader is traversed in each epoch, and wherein for each batch, the data is transferred to the triage model, and the gradient of the AdamW optimizer is cleared; calling the triage model for forward propagation, calculating the loss value according to the loss function and back-propagating, and then updating the parameters of the triage model; recording the average loss value and prediction result of each epoch, and calculating the corresponding AUC evaluation index.
[0039] In the related technologies, the training process of existing triage models often lacks systematic path definition and optimization steps, resulting in inefficient model training and poor results. In particular, the definition of dataset paths, electronic medical records and disease history directory paths is unclear, the selection of optimizers and loss functions is unreasonable, and model parameters are not updated in time, which will affect the accuracy and stability of the triage model. In an embodiment of the present invention, by defining the data set path data_path, the electronic medical record directory path cc_dir, and the disease history directory path lab_dir, the clarity and consistency of the data source are ensured; the AdamW optimizer is used for parameter optimization, and the cross entropy loss function nn.CrossEntropyLoss() is used as the loss function to improve the efficiency and accuracy of model training; each epoch is looped through, each batch in the data loading train / testloader is looped through, the data is transferred to the triage model, and the gradient of the AdamW optimizer is cleared, the triage model is called for forward propagation, the loss value is calculated and back-propagated, and then the model parameters are updated to ensure timely updating and optimization of the model parameters; the average loss value and prediction result of each epoch are recorded, and the AUC evaluation index is calculated, which improves the effect of model training and the accuracy and reliability of the triage results.
[0040] According to an embodiment of the present invention, the loss function of the triage model is: Where N is the number of samples, y i is the actual label of the i-th sample, is the predicted probability of the i-th sample, λ is the regularization coefficient, W j are the parameters of the triage model.
[0041] In an embodiment of the present invention, a dynamic adjustment mechanism is introduced and a loss function including a cross entropy loss and an L2 regularization term is defined, so that the triage model can perform parameter optimization according to real-time data during the reasoning process, thereby improving the accuracy and real-time performance of the prediction, adapting to the complex and changeable emergency environment, avoiding overfitting, and improving the generalization ability of the model.
[0042] According to an embodiment of the present invention, updating the parameters of the triage model includes the following steps: Step 1, initializing the parameters θ of the triage model, and calculating the initial prediction result Step 2: Calculate the loss function L(θ) of the triage model:
[0043] Step 3: Update the loss function L(θ) by gradient descent:
[0044] Where η is the learning rate, is the loss function with respect to the parameter θ t Gradient of the learning rate; Step 4, if L(θ) does not decrease significantly in k consecutive epochs, adjust the learning rate to η·γ, where γ is the reduction factor of the learning rate and 0<γ<1. Step 5, iterate step 2 to step 4 until the loss function L(θ) converges.
[0045] In the related art, the loss function design of the existing triage model often lacks a dynamic adjustment mechanism. In addition, the traditional loss function fails to fully consider the regularization process, which easily leads to overfitting or underfitting of the model. The update process of the model parameters also lacks flexibility and is difficult to adapt to the needs of continuous multiple iterative training. In the embodiment of the present invention, by introducing a dynamic adjustment mechanism, the triage model can optimize parameters according to real-time data during the reasoning process, improve prediction accuracy and real-time performance, and adapt to the complex and changeable emergency environment, thereby enhancing the adaptability and prediction accuracy of the model in the emergency environment, and ensuring the reliability and practicality of the triage results.
[0046] According to an embodiment of the present invention, before updating the parameters of the triage model, the method further includes updating the adaptive learning rate optimizer, specifically including: initializing parameters to define the initial learning rate α0, the first-order moment estimation parameter β1, and the second-order moment estimation parameter β2 of the adaptive learning rate optimizer; updating the gradient estimation m at each time step t according to the following formula: t and v t :
[0047] The corrected gradient estimate is calculated according to the following formula:
[0048] And according to the following formula, calculate and update the parameters of the adaptive learning rate optimizer:
[0049] Here, ∈ is a small constant used to prevent division by zero errors.
[0050] In the related art, the existing triage model usually adopts a fixed learning rate optimizer during the training process, and is unable to dynamically adjust the learning rate according to the progress of the model training, resulting in inefficient parameter updates, slow model convergence, and limited final performance. A fixed learning rate may cause the parameters to update too quickly in the early stages of training, and too slowly in the later stages of training, making it difficult to achieve the optimal training effect. In an embodiment of the present invention, by using an adaptive learning rate optimizer, the triage model can dynamically adjust the learning rate during the training process, improve the efficiency and stability of the model parameter update, and thus improve the convergence speed and final performance of the model.
[0051] According to another embodiment of the present invention, a triage system for emergency electronic medical records is provided. Figure 7 As shown, it includes: a data acquisition module, which is used to obtain the patient's electronic medical record, disease history and physiological characteristics, wherein the electronic medical record includes diagnostic prescriptions, treatment plans and treatment results in digital form, the disease history includes chronic diseases, allergic reactions and surgical records, and the physiological characteristics include age, gender, height and weight; a triage model module, which is used to generate multiple triage results and corresponding probabilities of the patient based on the electronic medical record, the disease history and the physiological characteristics using a pre-trained triage model; and a display module, which is used to display the multiple triage results and corresponding probabilities in the form of graphics and tables.
[0052] In the related art, the existing emergency electronic medical record triage system is usually unable to effectively integrate and utilize the patient's electronic medical record, disease history and physiological characteristics, resulting in insufficient accuracy and reliability of the triage results. In addition, the display method of the triage results is single, and it is difficult to intuitively present the patient's overall health status and urgency, which limits the doctor's comprehensive understanding of the patient's condition and timely decision-making. In the embodiment of the present invention, the patient's electronic medical record, disease history and physiological characteristics are obtained through the data acquisition module, and a variety of patient information is comprehensively utilized, which significantly improves the accuracy and comprehensiveness of the triage results; through the intuitive display method, doctors can understand and apply the triage results more quickly, thereby improving the efficiency and effectiveness of emergency treatment.
[0053] According to an embodiment of the present invention, the triage model module includes: an embedding layer unit, which is used to convert the electronic medical record and the disease history into an embedding vector, wherein the electronic medical record is converted into a representation of a hidden dimension through a first fully connected layer and a first position embedding is added, and the disease history is converted through a second fully connected layer and a second position embedding is added; an attention unit, which includes three linear transformations of query, key, and value, respectively mapping the electronic medical record, the disease history, and the physiological feature and calculating the attention weight, and performing weighted summation on the electronic medical record, the disease history, and the physiological feature according to the calculated attention weight to obtain an output result; a multi-layer perceptron unit, which is used to perform a nonlinear transformation on the output result; an encapsulation unit, which includes an attention layer and a multi-layer perceptron layer, which is used to realize the hierarchical structure of a Transformer by multiple stacking, wherein the interaction between the electronic medical record and the disease history is realized between the stacked second encapsulation module and the third encapsulation module; and an encoder unit, which is used to form the encoder part of the Transformer by stacking multiple encapsulation modules.
[0054] In the embodiment of the present invention, accurate conversion of multimodal data is achieved through embedding layer units, the attention unit comprehensively calculates the weights of electronic medical records, disease history and physiological characteristics, the multi-layer perceptron unit performs nonlinear transformation, the encapsulation unit and the encoder unit realize the hierarchical structure and data interaction of the Transformer, which significantly improves the performance of the model and the accuracy of the triage results, and adapts to complex emergency environments.
[0055] According to an embodiment of the present invention, before generating multiple triage results and corresponding probabilities for the patient, the triage model module also includes a training module for training the triage model, and the training module includes: a data path definition unit, used to define the path data_path of the data set, the directory path cc_dir of the electronic medical record, and the directory path lab_dir of the disease history; an optimizer unit, using the AdamW optimizer for parameter optimization, and using the cross-entropy loss function nn.CrossEntropyLoss() as the loss function; a training loop unit, used to loop through each epoch, wherein each batch in the data loader train / testloader is traversed in each epoch, and wherein for each batch, the data is transferred to the triage model, and the gradient of the AdamW optimizer is cleared; a forward propagation unit, used to call the triage model for forward propagation; a loss calculation unit, used to calculate the loss value according to the loss function and back-propagate; a parameter updating unit, used to update the parameters of the triage model; a recording unit, used to record the average loss value and prediction result of each epoch, and calculate the corresponding AUC evaluation index.
[0056] In the related art, the existing triage models often lack systematic data path definition and effective parameter optimization methods during the training process, resulting in low model training efficiency and unstable model performance. In addition, the data batches of each epoch cannot be effectively managed and recorded during the training process, and there is a lack of dynamic adjustment and optimization mechanisms, which affects the final triage results and the reliability of the model. In the embodiment of the present invention, by defining the data path and directory path, using the AdamW optimizer and the cross entropy loss function for parameter optimization, the training loop unit traverses the data batches of each epoch, the forward propagation and loss calculation unit performs calculations, the parameter update unit updates the model parameters in real time, and the recording unit records the loss value and AUC evaluation index of each epoch, thereby ensuring efficient training and stable optimization of the model, significantly improving the accuracy of the triage results and the overall performance of the model, and adapting to the complex and changing emergency environment.
[0057] According to an embodiment of the present invention, the loss function of the triage model module is:
[0058] Where N is the number of samples, y i is the actual label of the i-th sample, is the predicted probability of the i-th sample, λ is the regularization coefficient, W j are the parameters of the triage model.
[0059] In the related art, the loss function design of the existing triage model usually fails to fully consider the difference between the actual label and the predicted probability, as well as the impact of regularization on the model, which makes the model prone to overfitting or underfitting during the training process, affecting the accuracy and reliability of the triage results. In the embodiment of the present invention, by introducing an improved loss function, it is possible to better balance the accuracy and complexity of the model, effectively reduce overfitting and underfitting phenomena, and improve the generalization ability and stability of the model.
[0060] Figure 2 The data import flow chart is shown. First, the data is imported, all the required libraries are imported, and the specific path for data input is set. Then all parameter configurations are defined, and the EHR data set is initialized. Finally, the preprocessing paradigm and data feature extraction are defined in detail in the data set acquisition method to realize the automatic import of the data required by the model. This step ensures the accurate acquisition of electronic medical records, disease history, and physiological characteristics, providing a reliable data foundation for the subsequent training and reasoning of the triage model.
[0061] Figure 3The data acquisition and loading test process is shown. After defining the required data modules, the data acquisition test is implemented by encapsulating a test function. First, we define the data acquisition function and all parameters. Then we implement the class instantiation (dataset instance) according to the dataset class encapsulated in the first step, and then set the data loader (DataLoader) to control the number of output data each time, as well as whether to randomize and preprocess. Finally, the data loader is used to iteratively obtain data. This process realizes the data acquisition and loading of the triage model through the combination of data path definition and data loader, ensuring the data fluency and consistency during the training process.
[0062] Data input and processing play a key role in machine learning models, especially when processing and training deep learning models. Specifically, it includes: 1. Loading configuration files, using the "get_ULTRA_config" method to obtain settings such as data path and BERT model path; 2. Metadata reading, using the Pandas library to read Excel or CSV files, containing key information for training and testing; 3. Preprocessing and encoding of text data, using the BERT model's Tokenizer to process text data; 4. Feature extraction, using the BERT model to process the encoded text and extract the deep semantic features of the text. These steps improve the training effect and prediction accuracy of the triage model through precise data processing and feature extraction.
[0063] Related functions: 1. Flexible data processing: support reading information from multiple types of data files; 2. Deep extraction of text features: use the BERT model to process text data and capture complex language features; 3. Data preparation for model training: effectively batch process data through the combination of DataLoader and Dataset; 4. Improve model performance: accurate data preprocessing and feature extraction improve the model's ability to understand and classify complex input patterns. These functions improve the overall performance and reliability of the triage system through comprehensive data processing and feature extraction.
[0064] This form of data input and related processing mechanisms ensure that the model receives the correct format and useful information, thereby achieving high accuracy and efficiency in prediction and classification tasks, ensuring the efficient operation of the emergency electronic medical record triage system.
[0065] Figure 4The model architecture diagram is shown. The model is mainly composed of five different modules, multi-layer perceptron (MLP), embedding layer (Embeddings), encapsulation module (Block), attention mechanism (Attention) and encoder (Encoder). The data will first be processed by the embedding layer and then enter the encoder. The encoder consists of multiple modules, each of which contains multiple attention mechanism layers and multi-layer perceptrons, which together constitute the Transformer. Finally, a classification head composed of a fully connected layer performs classification prediction. The model architecture design is mainly divided into five modules, which eventually form the overall ERGEN model:
[0066] Embeddings module: responsible for converting the input clinical data and medical record text data into embedding vectors.
[0067] For clinical data, a fully connected layer is used to transform it into a representation of the hidden dimension and add position embedding.
[0068] For medical record text data, a fully connected layer is also used for conversion and position embedding is added.
[0069] Finally, the transformed embedding vector is added to the position embedding and subjected to dropout.
[0070] Attention module: implements the attention mechanism for interacting with inputs in the Transformer. It includes three linear transformations: query, key, and value, which map the inputs respectively. If medical record text data is input, additional attention calculation related to the medical record text is performed. Finally, the value is weighted and summed according to the calculated attention weight to obtain the output.
[0071] Mlp module: implements a multi-layer perceptron for further nonlinear transformation of the attention mechanism output. It includes two fully connected layers, activation functions, and dropout layers.
[0072] Block module: It is a basic unit in Transformer, including attention layer and MLP layer. By stacking this module multiple times, the hierarchical structure of Transformer is realized.
[0073] Encoder module: Multiple Block modules are stacked to form the encoder part of Transformer. Between the second and third blocks, the medical record text and clinical data are interacted.
[0074] ERGEN model: By integrating all modules to form the various parts of the Transformer model, the final model is formed. It includes components such as Transformer, attention head, and fully connected layer, and finally outputs classification results or attention weights.
[0075] For text preprocessing, in addition to using the BERT framework, you can also use different models for targeted preprocessing according to different languages. In addition to the cross-attention mechanism, model fusion can also use splicing fusion, similarity fusion and other methods. The activation function in the model architecture design can be equivalently replaced with other similar activation functions.
[0076] Figure 5 The model training flow chart is shown. Model training consists of three main parts: dataset, model, and metrics. The dataset is the EHR dataset, the model is ERGEN, and the metrics are the area under the curve AUC, sensitivity, and specificity. The model is connected to Data Parallel, which means that the model runs in parallel on multiple GPUs to speed up the training process. Data Parallel is further connected to the optimizer and loss function components, which are responsible for adjusting the model parameters and the loss function that defines the model performance, respectively. Finally, TrainLoop represents the training process of the model, which will iteratively improve the model through the optimizer and loss function.
[0077] Model training process:
[0078] 1. Import libraries and modules: The necessary Python libraries and modules are imported at the beginning of the code, including os, torch, torch.nn, torch.utils.data.DataLoader, sklearn.metrics.roc_auc_score, as well as the custom modules PRIEN and CONFIGS, and the dataset module Multi_Dataset.
[0079] 2. Define the training function: The train function is the main function for model training. It accepts a parameter args, which is used to pass training-related parameters.
[0080] 3. Set devices and parameters: Use torch.device to detect whether there is an available GPU. If so, use the GPU, otherwise use the CPU. Set model-related parameters, such as the number of categories num_classes and the image feature size img_feature_size. Obtain the model configuration information from CONFIGS and initialize the model ERGEN based on the configuration information.
[0081] 4. Model parallel processing: If multiple GPUs are available, use nn.DataParallel to process the model in parallel and use multiple GPUs to accelerate training.
[0082] 5. Data preparation: Define the dataset path data_path, clinical data directory path cc_dir, and medical record text directory path lab_dir. Use the custom EHR_Dataset class to load the dataset, and use DataLoader to batch process and load the data.
[0083] 6. Optimizer and loss function: AdamW optimizer is used for parameter optimization, and learning rate and weight decay are obtained from config. Cross entropy loss function nn.CrossEntropyLoss() is used as the loss function of the model.
[0084] 7. Model training: Enter the training phase of the model and use model.train() to set the model to training mode. Loop through each epoch and iterate through each batch in the data loader train / testloader in each epoch. For each batch, transfer the data to the device and clear the gradient of the optimizer. Call the model for forward propagation, calculate the loss value and backpropagate, and then update the model parameters. Record the average loss value and prediction result of each epoch, and calculate the AUC evaluation indicator.
[0085] 8. Output results: After each epoch, print the training loss and AUC value of the current epoch. After the training is completed, the prompt message "Finished Training" is output.
[0086] Figure 6 The flow chart of model loading and use is shown. When a patient is admitted to the hospital, the corresponding data will be obtained according to the patient's specific situation. After intelligent data processing, these data can be directly loaded into the model for real-time reasoning. Finally, the final prediction probability and patient score are obtained through the visual interactive system.
[0087] The final system of the present invention is divided into three main modules, which are, from top to bottom, the loading of emergency electronic medical record data, the intelligent triage model of emergency electronic medical record, and the visual interaction system.
[0088] First, the emergency electronic medical record data loading module is the foundation of the system, which is responsible for collecting and integrating various information of patients. This module consists of three sub-parts:
[0089] Electronic medical record: This is a digitized version of all of a patient’s medical records, including their previous diagnoses, treatments, and outcomes.
[0090] Patient medical history: Record the patient's past medical history, including chronic diseases, allergic reactions, surgical records, etc.
[0091] Patient physiological characteristics: including the patient's basic physiological data, such as age, gender, height, weight, etc., which are very important for diagnosis and treatment.
[0092] Once loaded, the data will be transferred to the next module: the intelligent triage model of emergency electronic medical records.
[0093] The second module is the emergency electronic medical record intelligent triage model, which is the core of the system and is responsible for analyzing and processing the data provided by the previous module. This module also includes two sub-parts:
[0094] Model loading: The system will load pre-trained intelligent triage models, which are trained based on a large amount of historical data and can identify various diseases and conditions.
[0095] Real-time model reasoning: After the model is loaded, the system will perform real-time reasoning based on the input medical record data to generate triage results. This process includes comprehensive analysis of the patient's symptoms and historical data to obtain the most likely triage results and recommended decisions.
[0096] Finally, the system passes the inference results to the visualization interaction system, which is the main part of the user interface and user interaction. The visualization interaction system consists of three sub-parts:
[0097] Visualization of medical record structure: The structure of medical records is displayed in the form of graphics and tables, allowing doctors to view the patient's detailed medical record information at a glance.
[0098] Predict the probability of the corresponding triage: The system will display the model's predicted probability for each possible diagnosis, helping doctors better understand and evaluate the model's reasoning results.
[0099] Doctors’ evaluation and scoring: Doctors can evaluate and score the model’s inference results, and this feedback will be used to further improve and optimize the model’s performance.
[0100] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A triage method for emergency electronic medical records, characterized in that: include: Obtaining the patient's electronic medical records, medical history, and physiological characteristics, wherein the electronic medical records include diagnosis prescriptions, treatment plans, and treatment results in digital form, the medical history includes chronic diseases, allergic reactions, and surgical records, and the physiological characteristics include age, gender, height, and weight; Generate multiple triage results and corresponding probabilities for the patient using a pre-trained triage model based on the electronic medical record, the disease history, and the physiological characteristics; and The multiple triage results and corresponding probabilities are displayed in the form of graphs and tables.
2. The method according to claim 1, characterized in that The triage model includes: An embedding layer module, configured to convert the electronic medical record and the disease history into an embedding vector, wherein the electronic medical record is converted into a representation of a hidden dimension by a first fully connected layer and a first position embedding is added, and the disease history is converted by a second fully connected layer and a second position embedding is added; An attention module, including three linear transformations of query, key, and value, respectively mapping the electronic medical record, the disease history, and the physiological characteristics and calculating attention weights, and performing weighted summation of the electronic medical record, the disease history, and the physiological characteristics according to the calculated attention weights to obtain an output result; A multi-layer perceptron module, used for performing nonlinear transformation on the output result; An encapsulation module, including an attention layer and a multi-layer perceptron layer, for realizing a hierarchical structure of a Transformer by multiple stacking, wherein the interaction between the electronic medical record and the disease history is realized between the second encapsulation module and the third encapsulation module of the stack; and The encoder module is used to form the encoder part of the Transformer by stacking multiple of the encapsulation modules.
3. The method according to claim 2, characterized in that Before using the pre-trained triage model to generate a plurality of triage results and corresponding probabilities for the patient, the triage model is trained by the following steps: Define the path data_path of the data set, the directory path cc_dir of the electronic medical record and the directory path lab_dir of the disease history; Use AdamW optimizer for parameter optimization, and use cross entropy loss function nn.CrossEntropyLoss as loss function; Loop through each epoch, wherein in each epoch, each batch in the data loader train / testloader is traversed, and wherein for each batch, data is transferred to the triage model and the gradient of the AdamW optimizer is zeroed; Calling the triage model to perform forward propagation, calculating the loss value according to the loss function and performing back propagation, and then updating the parameters of the triage model; Record the average loss value and prediction result of each epoch, and calculate the corresponding AUC evaluation index.
4. The method according to claim 3, characterized in that The loss function of the triage model is: Where N is the number of samples, y i is the actual label of the i-th sample, is the predicted probability of the i-th sample, λ is the regularization coefficient, W j are the parameters of the triage model.
5. The method according to claim 4, characterized in that Updating the parameters of the triage model includes the following steps: Step 1: Initialize the parameters θ of the triage model and calculate the initial prediction results Step 2, calculate the loss function L(θ) of the triage model: Step 3: Update the loss function L(θ) by gradient descent: Where η is the learning rate, is the loss function with respect to the parameter θ t The gradient of Step 4: If L(θ) does not decrease significantly in k consecutive epochs, adjust the learning rate to η·γ, where γ is a reduction coefficient of the learning rate and 0<γ<1. Step 5, iterate step 2 to step 4 until the loss function L(θ) converges.
6. The method according to claim 5, characterized in that Before updating the parameters of the triage model, the method further includes updating an adaptive learning rate optimizer, specifically including: Initialization parameters, define the initial learning rate α0, first-order moment estimation parameter β1, and second-order moment estimation parameter β2 of the adaptive learning rate optimizer; At each time step t, the gradient estimate m is updated according to the following formula: t and v t : The corrected gradient estimate is calculated according to the following formula: as well as According to the following formula, the parameters of the adaptive learning rate optimizer are calculated and updated: Here, ∈ is a small constant used to prevent division by zero errors.
7. An emergency electronic medical record triage system, characterized in that: include: A data acquisition module, for acquiring the patient's electronic medical records, disease history and physiological characteristics, wherein the electronic medical records include diagnosis prescriptions, treatment plans and treatment results in digital form, the disease history includes chronic diseases, allergic reactions and surgical records, and the physiological characteristics include age, gender, height and weight; A triage model module, for generating a plurality of triage results and corresponding probabilities of the patient using a pre-trained triage model according to the electronic medical record, the disease history and the physiological characteristics; as well as The display module is used to display the multiple triage results and corresponding probabilities in the form of graphics and tables.
8. The system according to claim 7, characterized in that The triage model module includes: An embedding layer unit, configured to convert the electronic medical record and the disease history into an embedding vector, wherein the electronic medical record is converted into a representation of a hidden dimension by a first fully connected layer and a first position embedding is added, and the disease history is converted by a second fully connected layer and a second position embedding is added; An attention unit, including three linear transformations of query, key, and value, respectively mapping the electronic medical record, the disease history, and the physiological characteristics and calculating attention weights, and performing weighted summation of the electronic medical record, the disease history, and the physiological characteristics according to the calculated attention weights to obtain an output result; A multi-layer perceptron unit, used for performing nonlinear transformation on the output result; An encapsulation unit, including an attention layer and a multi-layer perceptron layer, for realizing a hierarchical structure of a Transformer by multiple stacking, wherein the interaction between the electronic medical record and the disease history is realized between the second encapsulation module and the third encapsulation module of the stack; and The encoder unit is used to form the encoder part of the Transformer by stacking multiple of the encapsulation modules.
9. The system according to claim 8, characterized in that Before generating the multiple triage results and corresponding probabilities of the patient, the triage model module further includes a training module for training the triage model, wherein the training module includes: A data path definition unit, used to define a path data_path of a data set, a directory path cc_dir of the electronic medical record, and a directory path lab_dir of the disease history; The optimizer unit uses the AdamW optimizer for parameter optimization and the cross entropy loss function nn.CrossEntropyLoss as the loss function; A training loop unit, for looping through each epoch, wherein in each epoch each batch in the data loader train / testloader is looped through, and wherein for each batch, data is transferred to the triage model and the gradient of the AdamW optimizer is cleared; A forward propagation unit, used for calling the triage model to perform forward propagation; A loss calculation unit, used to calculate the loss value according to the loss function and back-propagate; A parameter updating unit, used for updating the parameters of the triage model; The recording unit is used to record the average loss value and prediction result of each epoch and calculate the corresponding AUC evaluation index.
10. The system according to any one of claims 7 to 9, characterized in that: The loss function of the triage model module is: Where N is the number of samples, y i is the actual label of the i-th sample, is the predicted probability of the i-th sample, λ is the regularization coefficient, W j are the parameters of the triage model.
