Method, apparatus, and program product for structured conversion of electronic medical records
By combining a large language model with a medical word segmentation dictionary and a dynamic text segmentation method with a self-attention mechanism, the accuracy and generalization issues in the structured extraction of electronic medical record texts are resolved, more efficient medical entity and relationship recognition is achieved, and the quality and application potential of medical data are improved.
Patent Information
- Application Number
- CN202510071370.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2045-01-16
AI Technical Summary
Existing technologies for structured extraction of electronic medical record text have problems such as low recognition accuracy, reliance on manual feature engineering, poor generalization ability, and difficulty in capturing long-distance dependencies, which limits the quality of medical data and its application potential.
A method based on a large language model is adopted. Through dynamic text word segmentation matching and self-attention mechanism, combined with a medical word segmentation dictionary and sliding window method, the word segmentation path is optimized, medical terms are dynamically matched, and structured data is extracted using large language model training.
It improves the extraction accuracy of electronic medical record text and adapts to diverse needs, realizes temporal dynamic matching and structural dynamics, reduces misidentification, and enhances the model's generalization ability and ability to capture long-distance dependencies.
Smart Images

Figure CN119988519B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent medical care, and more specifically, to a method, device, medium and program product for structured conversion of electronic medical records. Background Art
[0002] Electronic Medical Records (EMRs) are a core component of modern medical information management, containing crucial medical data such as patient medical histories, clinical examination results, diagnostic information, treatment plans, and physician orders. With the advancement of healthcare informatization, EMRs have gained widespread adoption worldwide. However, EMR data currently exists in unstructured text format, posing significant challenges to data retrieval, analysis, and application.
[0003] Currently, there are three main methods for extracting structured information from electronic medical record text: (1) Rule-based methods: Rule-based methods mainly parse and extract electronic medical record text through predefined rules and templates. For example, regular expressions are used to match specific medical terms and relationships. This method works well when processing structured and semi-structured data, but for unstructured text, especially electronic medical records with complex and changing semantics, the adaptability and scalability of rule-based methods are poor. (2) Machine learning methods: Machine learning methods are mainly based on feature engineering and traditional machine learning algorithms (such as SVM and random forest). By extracting features such as word frequency, part of speech, and context from the text, classifiers or regression models are constructed to identify medical entities and relationships. Although machine learning methods have better generalization capabilities than rule-based methods, they rely on manual feature engineering and have limited effectiveness in processing large-scale and complex semantic relationships. (3) Deep learning-based methods: Deep learning methods that have emerged in recent years, especially neural network-based models (such as RNN and CNN), have made significant progress in the field of text processing. These methods automatically extract features from text to perform named entity recognition and relationship extraction. Although the performance of text processing has been improved to a certain extent, traditional deep learning methods still have limitations in capturing long-distance dependencies and complex semantic relationships.
[0004] Electronic medical record text is a text record that is closer to human language. Traditional text recognition technologies face challenges in extracting structured information from electronic medical record text, including accuracy, feature engineering complexity, model generalization, processing long-range dependencies, and the usability of structured results. These issues not only impact the quality and effective use of medical data but also limit the potential of related technologies for medical decision support and clinical research.
[0005] The main problems currently exist include: (1) Low accuracy and high misidentification rate: When traditional methods process unstructured electronic medical record text, due to the diversity of text formats and complex medical terminology, the accuracy of identifying medical entities and relationships is low, and misidentification is prone to occur. (2) Dependence on manual feature engineering: Machine learning methods usually rely on manual design and extraction of features. These features not only require a lot of knowledge from domain experts, but also are complex processes with subjectivity and consistency issues. (3) Poor generalization ability: Existing methods are unstable in different data sets and application scenarios, have limited generalization ability, and are difficult to adapt to the diverse medical information entry methods and text styles. (4) Difficulty in capturing long-distance dependencies: Traditional models such as RNN and CNN have limitations in capturing long-distance dependencies and complex semantics in text, resulting in poor results in extracting complex medical entities and relationships. Summary of the Invention
[0006] Existing methods for processing the large amounts of text data generated by electronic medical record systems have limitations and inconveniences. This paper proposes a method for extracting structured text from electronic medical records based on a large language model, aiming to overcome these shortcomings. By incorporating the latest large language model technology, it can more accurately identify and extract medical entities and relationships in electronic medical records and convert them into structured data.
[0007] This application (first aspect) discloses a method for structured conversion of electronic medical records, comprising:
[0008] S1: Obtain medical record text and medical word segmentation dictionary;
[0009] S2: Perform dynamic text segmentation and matching on the medical record text to obtain an indicator vector sequence, specifically including:
[0010] S21: performing dynamic text segmentation on the medical record text to obtain a potential segmentation matrix composed of potential segmentations, S22: obtaining a matching cost matrix based on the matching costs of the potential segmentations in the potential segmentation matrix and the index directory in the medical segmentation dictionary,
[0011] S23: Using a sliding window method to compare the matching cost matrix to obtain indicator directory segmentation words and corresponding starting points, all indicator directory segmentation words constitute an indicator directory sequence;
[0012] S24: determining a neighborhood according to the position of the indicator catalog segmentation word in the medical record text, performing dynamic text segmentation on the neighborhood and matching the value range corresponding to the indicator catalog in the medical segmentation dictionary to obtain the value of the indicator catalog;
[0013] S25: The indicator directory and the value of the indicator directory constitute an indicator vector, and all indicator vectors constitute an indicator vector sequence;
[0014] S3: The indicator vector is input into the electronic medical record structured conversion model to obtain a structured electronic medical record. The method for obtaining the electronic medical record conversion model is as follows: the indicator vector obtained based on the training set is input into the electronic medical record conversion model obtained by training the large language model.
[0015] Furthermore, the matching cost in S22 is calculated as follows: the matching cost of each indicator directory in the medical word segmentation dictionary is calculated in turn for each element in the potential word segmentation matrix, and the minimum value of the matching cost of each indicator directory is selected as the matching cost corresponding to the element in the potential word segmentation matrix;
[0016] Optionally, the medical record text is segmented to obtain possible segmentations, and the potential segmentation matrix is formed by the possible segmentations.
[0017] Optionally, the dynamic text segmentation further includes performing sparsity constraints on the matching costs of the various indicator directories to obtain a minimum matching cost after the constraints, and taking the possibility of the minimum matching cost after the constraints as the segmentation result;
[0018] Optionally, the matching cost is constrained as follows:
[0019]
[0020] Where S represents a sequence of medical record text strings or a sequence of possible word segments; cost(S[i:i+j],t k ) represents the potential segmentation S[i:i+j] and the index directory t in the medical segmentation dictionary k The matching cost, γ is the sparsity weight parameter, and sparsity() represents the sparsity penalty function;
[0021] Optionally, the matching cost is calculated as edit distance;
[0022] Optionally, the sliding window method in S23 is as follows: first, the minimum value of the matching cost matrix is taken according to the row to obtain the minimum matching cost of each starting point, and the sliding window method is used to determine the minimum matching cost and the corresponding starting and ending points within a certain window. If the starting and ending points overlap, the starting and ending points corresponding to the smaller matching cost are used as the starting and ending points of the index directory segmentation;
[0023] Optionally, sparse processing is performed on the matching cost matrix, and the matching cost exceeding the set matching range is set to ∞;
[0024] Optionally, S21 is: the medical record text is represented by S, the potential word segmentation matrix is represented by D, and the element D[i,j]=S[i:i+j] in the potential word segmentation matrix represents the potential word segmentation from the i-th character to the i+j-th character of the medical record text S, where i∈[1,length(S)], j∈[0,L)], and L represents the maximum length of the indicator directory in the medical word segmentation dictionary.
[0025] Furthermore, the matching cost is calculated as follows:
[0026]
[0027] Among them, editdistance(S[j:j+i],t k )Measure the word segmentation S[j:j+i] and the word t in the medical word segmentation dictionary k The edit distance, f t (S[j:j+i],t k )Measure the word segmentation S[j:j+i] and the word t in the medical word segmentation dictionary k The time feature difference, λ is the weight of the time feature difference, W t is the weight of the edit distance;
[0028] Optionally, the matching cost is calculated as follows:
[0029]
[0030] Among them, f s (S[j:j+i],t k )Measure the word segmentation S[j:j+i] and the word t in the medical word segmentation dictionary k The spatial distance, f t (S[j:j+i],t k )Measure the word segmentation S[j:j+i] and the word t in the medical word segmentation dictionary k The time distance, λ1 is the weight of the spatial distance, and λ2 is the weight of the time distance;
[0031] Optionally, the spatial distance is Jaccard distance;
[0032] Optionally, the time distance is Levenshtein distance.
[0033] Optionally, the medical word segmentation dictionary includes an indicator directory and a value range under the indicator directory.
[0034] Furthermore, the indicator vector sequence is subjected to a self-attention mechanism to obtain a TF-IDF vector; the indicator vector sequence is summarized to obtain an embedding vector, the TF-IDF vector and the embedding vector are fused to obtain a fused indicator vector, and the fused indicator vector is input into a second electronic medical record structured conversion model to obtain a structured electronic medical record;
[0035] The second electronic medical record structured conversion model is obtained by inputting an indicator vector obtained based on a training set into a large language model to obtain a second electronic medical record conversion model.
[0036] Furthermore, the TF-IDF vector is expressed as:
[0037] WV(t,d,D)=tf(t,d)×idf(t,D)
[0038]
[0039] Wherein, WV(t,d,D) represents the TF-IDF vector, t represents the indicator name in the indicator vector sequence, d represents a single medical record text, and D represents the electronic medical record document to be matched; f t,d It is the frequency of occurrence of indicator name t in a single electronic medical record text d; t' represents the synonyms, related words or other different forms of indicator name t appearing in text d.
[0040] P(t|w) is the conditional probability of the indicator name t appearing when the word w appears in the medical record text; P topic (t|w) is the conditional probability of classification based on medical record text; α is the weight parameter that balances the medical record text and indicator vector; Weight(w) is the weight coefficient of word w.
[0041] Furthermore, the fused index vector is expressed as:
[0042] v fusion =α i WV·v i h sequence +α iembedding ·v iembedding
[0043] h sequence =Pooling(h1,h2,...,h n )
[0044] Among them, α i is the attention weight for each TF-IDF vector; v i is the attention weight for each embedding vector; h1 represents the output of the first attention head in the attention mechanism, and n represents the number of vectors, that is, the number of elements in the sequence or set. represents the attention weight of each embedding vector, reflecting the importance of the i-th embedding vector in the overall context. Represents the continuous vector representation that maps words or phrases to high-dimensional space. These vectors can capture the semantic information and contextual relationships of the words. sequence Represents the sequence representation after average pooling. hi represents all indicator vector sequences; Pooling() means applying the average pooling method to summarize the representations of all indicator vector sequences.
[0045] Further, using a word segmentation model to obtain possible word segmentations based on the medical record text;
[0046] Optionally, the word segmentation model is a conditional random field model, and the conditional random field model uses characteristic functions and weights to divide word boundaries.
[0047] A second aspect of the present application discloses a system for structured conversion of electronic medical records, comprising:
[0048] Acquisition module: used to obtain medical record text and medical word segmentation dictionary;
[0049] Matching module: used to perform dynamic text segmentation matching on the medical record text to obtain an indicator vector sequence. The matching module is specifically used to execute the method steps S21-S25:
[0050] S21: performing dynamic text segmentation on the medical record text to obtain a potential segmentation matrix composed of potential segmentations, S22: obtaining a matching cost matrix based on the matching costs of the potential segmentations in the potential segmentation matrix and the index directory in the medical segmentation dictionary,
[0051] S23: Using a sliding window method to compare the matching cost matrix to obtain indicator directory segmentation words and corresponding starting points, all indicator directory segmentation words constitute an indicator directory sequence;
[0052] S24: determining a neighborhood according to the position of the indicator catalog segmentation word in the medical record text, performing dynamic text segmentation on the neighborhood and matching the value range corresponding to the indicator catalog in the medical segmentation dictionary to obtain the value of the indicator catalog;
[0053] S25: The indicator directory and the value of the indicator directory constitute an indicator vector, and all indicator vectors constitute an indicator vector sequence;
[0054] Conversion module: used for obtaining module 201: used for obtaining medical record text and medical word segmentation dictionary;
[0055] Matching module 202: used to perform dynamic text segmentation matching on the medical record text to obtain an indicator vector sequence. The matching module is specifically used to execute the method steps S21-S25:
[0056] S21: performing dynamic text segmentation on the medical record text to obtain a potential segmentation matrix composed of potential segmentations, S22: obtaining a matching cost matrix based on the matching costs of the potential segmentations in the potential segmentation matrix and the index directory in the medical segmentation dictionary,
[0057] S23: Using a sliding window method to compare the matching cost matrix to obtain indicator directory segmentation words and corresponding starting points, all indicator directory segmentation words constitute an indicator directory sequence;
[0058] S24: determining a neighborhood according to the position of the indicator catalog segmentation word in the medical record text, performing dynamic text segmentation on the neighborhood and matching the value range corresponding to the indicator catalog in the medical segmentation dictionary to obtain the value of the indicator catalog;
[0059] S25: The indicator directory and the value of the indicator directory constitute an indicator vector, and all indicator vectors constitute an indicator vector sequence;
[0060] Conversion module 203: used to input the indicator vector into the electronic medical record conversion model to obtain a structured electronic medical record. The electronic medical record conversion model is obtained by inputting the indicator vector obtained based on the training set into the electronic medical record conversion model obtained by training the large language model.
[0061] The third aspect of the present application discloses a computer device, which includes: a memory and a processor; the memory is used to store program instructions; the processor is used to call the program instructions, and when the program instructions are executed, it is used to perform the steps of the above method.
[0062] In a fourth aspect, the present application discloses a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above-mentioned method when the computer program is executed by a processor.
[0063] In a fifth aspect, the present application discloses a computer program product, comprising a computer program, which implements the steps of the above method when executed by a processor.
[0064] This application has the following beneficial effects:
[0065] Compared with existing methods, the present invention has significant advantages in processing unstructured text, improving extraction accuracy and adapting to diverse needs;
[0066] The present invention realizes dynamic time matching: when matching with a medical word segmentation dictionary, time-weighted matching is performed to give priority to words with closer temporal sequences;
[0067] The present invention realizes structural dynamics: through sparsity regularization, the word segmentation path is dynamically optimized to avoid over-dense word segmentation of medical record texts. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0069] Figure 1 This is a schematic diagram of the method flow provided by the first aspect of the embodiment of the present invention;
[0070] Figure 2 is a schematic diagram of a program product provided by the second aspect of an embodiment of the present invention;
[0071] Figure 3 is a schematic diagram of a computer device provided by an embodiment of the present invention;
[0072] Figure 4 is a schematic diagram of the architecture of an exemplary computing device provided by an embodiment of the present invention;
[0073] Figure 5 is a schematic diagram of a storage medium provided by an embodiment of the present invention;
[0074] Figure 6 This is a technical solution roadmap provided by an embodiment of the present invention;
[0075] Figure 7 This is a schematic diagram of a key word segmentation standard comparison dictionary structure provided by an embodiment of the present invention;
[0076] Figure 8 This is a schematic diagram of obtaining a structured medical record by applying an electronic medical record structured conversion model provided by an embodiment of the present invention;
[0077] Figure 9 This is a flowchart for constructing an electronic medical record structured conversion model provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0078] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0079] In some of the processes described in the specification and claims of the present invention and the above-mentioned figures, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or may be executed in parallel. The serial numbers of the operations, such as S101, S102, etc., are only used to distinguish between different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., and do not represent the order of precedence, nor do they limit "first" and "second" to be different types.
[0080] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making any creative efforts shall fall within the scope of protection of the present invention.
[0081] Figure 1 The following is a flow chart of a method for structural conversion of electronic medical records provided by an embodiment of the present invention. Specifically, the method includes the following steps:
[0082] S101: Obtain medical record text and medical word segmentation dictionary;
[0083] S102: Perform dynamic text segmentation matching on the medical record text to obtain an indicator vector sequence, specifically including:
[0084] S21: performing dynamic text segmentation on the medical record text to obtain a potential segmentation matrix composed of potential segmentations, S22: obtaining a matching cost matrix based on the matching costs of the potential segmentations in the potential segmentation matrix and the index directory in the medical segmentation dictionary,
[0085] S23: Using a sliding window method to compare the matching cost matrix to obtain indicator directory segmentation words and corresponding starting points, all indicator directory segmentation words constitute an indicator directory sequence;
[0086] S24: determining a neighborhood according to the position of the indicator catalog segmentation word in the medical record text, performing dynamic text segmentation on the neighborhood and matching the value range corresponding to the indicator catalog in the medical segmentation dictionary to obtain the value of the indicator catalog;
[0087] S25: The indicator directory and the value of the indicator directory constitute an indicator vector, and all indicator vectors constitute an indicator vector sequence;
[0088] S103: The indicator vector is input into an electronic medical record conversion model to obtain a structured electronic medical record. The method for obtaining the electronic medical record conversion model is as follows: the indicator vector obtained based on the training set is input into the electronic medical record conversion model obtained by training a large language model.
[0089] The present invention provides a structured extraction method for electronic medical record text based on a large language model, aiming to overcome the problems of existing technologies in accuracy, feature engineering complexity, model generalization ability, long-distance dependency processing and structured availability of results in unstructured electronic medical record processing.
[0090] The program includes:
[0091] (1) Obtaining the user's content extraction requirements (including extraction indicators and the value range of each indicator);
[0092] (2) Preprocessing and content evaluation of electronic medical record text data (including cleaning, denoising, and formatting);
[0093] (3) Apply word segmentation algorithm to perform text segmentation,
[0094] (4) Compare the text segmentation results with the extracted indicators and value ranges of the medical segmentation dictionary, match the segmentation results with the indicators in the comparison dictionary, and identify the indicator instances that appear in the text. For the identified indicators, further analyze the surrounding text to determine their values, and convert the extracted values into a standard format; for example, standardize "mild", "moderate", and "severe" into "mild", "moderate", and "severe".
[0095] (5) Based on the results obtained after word segmentation, a large language model is used to perform named entity recognition (NER) on the electronic medical record text data to extract medical entities.
[0096] (6) Entity-relationship model training is performed on the annotated electronic medical record dataset to extract structured entities and relationships, and then converted into structured data based on user needs (e.g., attached Figure 6 shown).
[0097] The detailed process is described as follows:
[0098] 1. Obtain user content extraction requirements, including extraction indicators and the value range of each indicator.
[0099] The user inputs the indicators to be extracted, and the extracted indicators are standardized and converted through the medical word segmentation dictionary, including the indicator name, value range, indicator unit, etc.
[0100] In some embodiments, the medical word segmentation dictionary is developed by performing word frequency statistics on the collected medical record data set, combined with the electronic medical record structuring requirements of medical experts, and reviewed and revised by medical experts.
[0101] Figure 7 The following are some examples of medical word segmentation dictionaries, including extraction indicators and the corresponding value ranges for each indicator. The extraction indicators are the first-level directories and the corresponding value ranges for the indicators.
[0102] In some embodiments, during the construction of the electronic medical record structured conversion model, the dynamic matching algorithm involves and the corresponding algorithm formula is as follows:
[0103] Text preprocessing: Clean the electronic medical record text, including removing punctuation, special symbols, redundant spaces, etc. Combined with a word segmentation dictionary, the text is divided into individual words for subsequent processing.
[0104] Text and dictionary initialization: Build a vocabulary based on the preprocessed text words, initialize the input medical record text and dictionary, and form a text character sequence S and an indicator directory T in the candidate dictionary as the input of the subsequent dynamic matching algorithm.
[0105] S={s1,s2,…,s n}
[0106] T={t1,t2,…,t k ,…,t m}
[0107] m represents the total number of indicators in the indicator list T in the candidate dictionary.
[0108] Dynamic programming table definition: Construct dynamic programming table D j [i], represents the word segmentation from character j in S to character i,
[0109] At the same time, the minimum segmentation cost (i.e., minimum matching cost) corresponding to the dynamic programming table is recorded. j represents the starting position of the segmentation, j <i,cost(S[j:i],t k ) represents the cost of matching a substring with a key term in the dictionary. γ is the sparsity regularization parameter, which controls the weight of the sparsity term. A sparsity penalty function, sparsity(S[j:i]), is also introduced to add a sparsity constraint to the dynamic programming. This encourages shorter segmentation paths, reduces meaningless segmentations, and thus reduces the probability of matching noisy words, favoring the generation of sparse but efficient segmentation sequences.
[0110]
[0111] Among them, C j [i] indicates Dj [i] corresponds to the minimum matching cost.
[0112] Dynamic matching of word segmentation sequence and dictionary
[0113] Using dynamic programming combined with a dictionary, we traverse each character and dynamically calculate the word segmentation cost of the substring S[j:i]. We calculate the edit distance or similarity, evaluate the degree of match between the substring and the dictionary, find matching candidate words in the dictionary, and calculate the optimal matching cost.
[0114]
[0115] W t =e -α·Δt
[0116]
[0117] Introducing the time weighting factor W into the matching cost t , prioritize matching phrases with higher temporal relevance. The more recent the data information, the higher the weight. This reduces word segmentation errors caused by missing or mismatched time attributes. Where S[j:i] represents the substring from j to i. k The term that matches S[j:i]. Refers to the weight coefficient of the edit distance. λ is the regularization parameter used to control the time weighting factor W t The impact of t is the time feature difference function, which is used to quantify the difference in time information. Δt is the time difference, and α is the attenuation coefficient.
[0118] Backtracking word segmentation path
[0119] Through dynamic programming table D j [i] The recorded path is traced back from the end point to obtain the optimal word segmentation path, thereby determining the word segmentation sequence.
[0120] Find the optimal cost C for the last character position i from the dynamic programming table j [i], get the optimal segmentation endpoint P end .
[0121] From position P end Backtrack forward and find its corresponding starting position P start , that is, the optimal matching segmentation starting point P of the segmentation fragment start .
[0122]
[0123] Each time the P end and P startAfter that, the corresponding text segment is recorded in the word segmentation path and stored in the path set P. The backtracking process continues until the starting position P of the text is reached. start =0.
[0124] P←P∪{S[P start :P end ]}
[0125] The word segmentation results are mapped into a sequence of indicator vectors
[0126] Map the word segmentation result P into a vector representing a specific medical indicator. Use one-hot encoding or word embedding to convert each word segmentation result into a vector that can be used for calculations.
[0127] V={v1,v2,…,v m},v i =encode(P[i])
[0128] encode(P[i]) is a vectorized encoding of the word segment P[i] based on the embedding model, mapping the text into a high-dimensional vector.
[0129] In some embodiments, the medical record text is structured as follows:
[0130] (1) Obtain medical record text and medical word segmentation dictionary;
[0131] (2) Dynamic text segmentation is performed on the medical record text to obtain a potential segmentation matrix composed of potential segmentations, such as the potential segmentation matrix D composed of "Preoperative diagnosis: The patient suffered from hypertension 3 years ago"
[0132]
[0133] By matching with the indicators in the medical word segmentation dictionary, the indicators in the medical word segmentation dictionary include "preoperative diagnosis" and "hypertension"; the element [1,3] in the potential word segmentation matrix D has a preoperative diagnosis word segmentation cost of 0; D[13,2] = "hypertension", the matching cost is 0;
[0134] The minimum matching cost of the first row of the potential segmentation matrix D is 0; the minimum matching cost of the 13th row is 0; and the indicators that match the indicators of the medical segmentation dictionary are determined by sliding the window along i: preoperative diagnosis and hypertension;
[0135] Continue to match the neighborhood of "preoperative diagnosis" and "hypertension" to obtain the corresponding value of the indicator. Thus, the indicator vector sequence composed of the indicator vector is converted.
[0136] In some embodiments, the medical record text is firstly segmented using word segmentation software to obtain possible word segments, thereby obtaining an initial word segmentation sequence: "preoperative / diagnosis / patient / 3 years / ago / suffering from / high / blood pressure":
[0137] The potential segmentation matrix D is expressed as follows:
[0138] i\j 0 1 2 3 1 Before surgery Preoperative diagnosis Preoperative diagnosis of patients Patients diagnosed 3 years before surgery 2 diagnosis Diagnosing patients Patients diagnosed 3 years ago Patient diagnosed 3 years ago 3 patient Patient 3 years Patient 3 years ago The patient had 4 3 years 3 years ago 3 years ago, I had 3 years ago, I had high 5 forward Previous Previous high Previously suffered from hypertension 6 Suffering from Suffering from high Suffering from high blood pressure - 7 high hypertension - - 8 blood pressure - - -
[0139] The calculated matching cost matrix C is shown as follows:
[0140] i\j 0 1 2 3 1 1 0 2 3 2 0.5 2 3 4 3 6 9 9 14 4 6 9 12 14 5 1 3 6 3 6 2 3 2 - 7 1 0 - - 8 0.5 - - -
[0141] Remove the lowest value of the matching cost matrix C row by row
[0142] C[1]=C[1,1]=0, the corresponding element is D[1,1]=preoperative diagnosis
[0143] C[2]=0.5,
[0144] C[3]=6,
[0145] C[4]=6,
[0146] C[5]=1,
[0147] C[6]=2
[0148] C[7]=0, the corresponding element is C[7,1]=hypertension
[0149] By truncating the adaptation range of the matching cost to [0,1), the matching cost is converted to:
[0150] C[1]=C[1,1]=0, the corresponding element is D[1,1]=preoperative diagnosis
[0151] C[2]=0.5,
[0152] C[3]=∞,
[0153] C[4]=∞,
[0154] C[5]=∞,
[0155] C[6]=∞
[0156] C[7]=0, the corresponding element is C[7,1]=hypertension
[0157] Among them, C[1] and C[2] intersect, and through time weighting, C[1] with a smaller cost and closer time sequence is prioritized, so as to obtain "preoperative diagnosis" and "hypertension" that match the indicators in the medical record; the indicator vector sequence is ["preoperative diagnosis", "hypertension"].
[0158] Then, based on the location of the catalog segmentation word in the medical record text, the neighborhood is determined, dynamic text segmentation is performed on the neighborhood and the value range corresponding to the indicator catalog in the medical segmentation dictionary is matched to obtain the value of the indicator catalog; and the relevant time vector is obtained,
[0159] The final indicator vector of the above example includes
[0160] Indicators - Preoperative Diagnosis:
[0161] Time vector - "3 years ago"
[0162] The value of preoperative diagnosis - "hypertension",
[0163] Determined type of hypertension (matched with hypertension as an indicator) - "primary hypertension".
[0164] The indicator directory and the value of the indicator directory constitute an indicator vector, and all indicator vectors constitute an indicator vector sequence;
[0165] The indicator vector is input into a large language model for training to obtain an electronic medical record structured conversion model.
[0166] A dynamic matching algorithm is established based on the indicators that users need to extract, and the indicators that users need to extract are matched with the text features and expected output results of the pre-trained large language model to ensure that the model can process text based on the indicators that users need to extract.
[0167] Dynamic matching algorithm:
[0168]
[0169] Where: θ i is a model parameter, each parameter θ i Corresponding to different indicators and value ranges. and is the range of values for the i-th indicator provided by the user. Δ is the normalization scale of the model parameters. β is an offset that is adjusted based on factors such as unit conversion. θ′ i It is a parameter adjusted according to user needs.
[0170] The algorithm can automatically learn and extract useful features from large amounts of text. By learning and adapting to different medical record text styles and data sets, it improves its generalization ability on diverse medical data. It can more accurately identify and match medical terms and indicators in electronic medical records, reducing mismatches and missed matches.
[0171] Using a dynamic matching algorithm, the segmented results of the electronic medical record text are matched against each indicator variable in the standard dictionary, and the segmented content is mapped to the indicator variable. Dynamic matching is then performed based on the indicator variable's value range. The matching score between the segmented word and each value range is calculated, and the result with the highest score is selected as the matching result. For example, if the segmented content of the electronic medical record text matches the variable "myasthenia gravis," dynamic matching is performed based on the text segmented word and the five value ranges of "myasthenia gravis." The result with the highest score is selected as the final matching result.
[0172] 2. Preprocess and prepare electronic medical record text data based on user content extraction requirements.
[0173] Collect electronic medical record data from different sources, including hospital information systems (HIS), electronic medical record (EMR) systems, etc. The data format may include structured data (such as database tables) and unstructured data (such as text files, PDF files, etc.).
[0174] Import the collected electronic medical record text data into the preprocessing system.
[0175] Unify the terminology and format in the text, such as converting synonyms to standard terms, unifying date formats, etc.
[0176] Processes common abbreviations and abbreviations, expanding them to their full forms.
[0177] Remove data noise. Remove noise characters and irrelevant information from electronic medical record text, such as extra spaces, special characters, formatting errors, etc.
[0178] 3. Combined with medical dictionary and other knowledge, apply word segmentation algorithm to perform text segmentation
[0179] Prepare one or more specialized dictionaries containing medical terminology, namely the keyword standard reference dictionaries mentioned above, to ensure that the vocabulary in the dictionaries covers common medical terms, symptoms, drugs and other medical terminology information.
[0180] The medical-specific dictionary is loaded into the Jieba word segmenter tool so that these special words can be recognized first during the word segmentation process.
[0181] The Conditional Random Field (CRF) model is used for word segmentation, and word boundaries are predicted through feature functions and weights.
[0182]
[0183] Where X is the input sequence, Y is the label sequence, and f k is the characteristic function, λ k is the feature weight, and Z(X) is the normalization factor.
[0184] In some embodiments, Jieba is first used for rapid word segmentation to obtain preliminary segmentation results. Based on Jieba's word segmentation, a professional medical dictionary is loaded, and the conditional random field model is used to refine and correct Jieba's word segmentation results. This combined algorithm can fully leverage the speed advantages of Jieba's word segmentation and the precision advantages of the CRF model, improving word segmentation efficiency while ensuring accuracy. It is suitable for processing complex and highly specialized electronic medical record texts.
[0185] The importance of the indicator in a single electronic medical record text.
[0186]
[0187] where f t,d is the frequency of occurrence of indicator t in a single electronic medical record text d.
[0188] In electronic medical records, document length varies across different types of medical records. This can affect the significance of the TF value. To mitigate this effect, this paper optimizes the traditional TF algorithm by performing a logarithmic transformation on medical record text to normalize its length, reducing word frequency variations in long texts. This approach achieves smooth optimization of the traditional TF algorithm based on the characteristics of electronic medical record text.
[0189] The indicator is measured to measure the prevalence of importance in the patient's electronic medical record text collection during the current hospitalization.
[0190]
[0191] Where t is the target medical word, D is the electronic medical record document to be matched, P(t|w) is the conditional probability of word t appearing when word w appears in the document; P topic (t|w) is the conditional probability of electronic medical record document classification; α is a mixing parameter used to balance the weights based on content and topic; and Weight(w) is the weight coefficient of word w, which is dynamically adjusted based on its importance or frequency. This matching algorithm can dynamically adjust the extraction priority and weight of medical terms based on the content of the electronic medical record document, improving the accuracy and applicability of medical term extraction from electronic medical record documents.
[0192] We use topic models to analyze the structure of electronic medical records and calculate the conditional probability of medical terms within specific topics. We also introduce weighting factors to adjust the matching weights of different terms based on their importance or specific segmentation requirements, making the algorithm more tailored to specific needs.
[0193] To address situations where the IDF of a word in electronic medical record text appears infinitely or reaches zero when the corresponding word appears in most documents or not at all, a probabilistic smoothing method is used to optimize the traditional IDF algorithm. By calculating the probability distribution of the word in the electronic medical record text, a smoothing parameter of -1 and ∈ is used to avoid situations where the probability is high or zero. This makes the optimized algorithm more accurate and stable for information retrieval and text mining.
[0194] Convert electronic medical record text data into weight vectors.
[0195] WV(t,d,D)=tf(t,d)×idf(t,D)
[0196] The indicators that the user needs to extract are converted into weight vectors, and vector matching is performed with the electronic medical record text data to identify the indicator content in the electronic medical record text.
[0197] 4. Apply a large language model to text representation. Compare text segmentation results with extraction indicators and value ranges to establish a standard dictionary for key segmentation (creating a dictionary containing medical entities, their synonyms, and variants). This standard dictionary is constructed based on specialized medical terminology and common vocabulary. It includes not only common disease names, drug names, and examination items, but also synonyms, abbreviations, and other variants of these terms.
[0198] The electronic medical record text data is input into the pre-trained large language model and trained to obtain the electronic medical record conversion model ( Figure 9 shown).
[0199] The constructed electronic medical record conversion model can be used for the structured processing of electronic medical record texts ( Figure 8 shown).
[0200] The present invention has established a set of standardized medical word segmentation reference dictionaries, which are similar to medical structured knowledge bases, and realize the standardized definition of content that needs to be structured extracted. For example, to extract the marital status in the medical record, the medical word segmentation in the electronic medical record text can be matched with the medical word segmentation in the reference dictionary, and the marital status in the electronic medical record text can be extracted by word segmentation and converted into a standard value range (single, married, divorced, widowed), so as to realize the structuring of the medical record text content. Some contents of the standard reference dictionary are as follows: Figure 7 As shown:
[0201] The input text sequence is converted into a corresponding indicator vector representation, and each indicator vector is mapped to its corresponding word embedding vector. An indicator vector is a numerical representation of an indicator feature. This representation method allows algorithms to process and analyze previously unstructured text data.
[0202] Self-attention calculation is performed on the input indicator vector sequence to generate context-dependent representation of the electronic medical record text.
[0203]
[0204] Where Q, K, V are weight matrices, d k is the dimension of the attention head.
[0205] Q represents the query vector, which usually represents the element currently being processed. Here, it represents a sequence of indicator vectors. In some contexts, it may represent a specific feature or query extracted from the sequence of indicator vectors. K represents the key vector, which is usually associated with each element in the dataset and is used to compare with the query vector. When processing a sequence of indicator vectors, it may represent the key representation of each indicator in the sequence, which is used to match the query vector. V represents the value vector, which represents the actual content or features of each element in the dataset. In the context of a sequence of indicator vectors, V may directly correspond to the indicator vectors in the sequence, or it may be a representation obtained by further processing based on these indicator vectors. The core advantage of the attention mechanism is that it can dynamically adjust the attention to V based on the degree of match between Q and K, thereby capturing the importance of different elements in the sequence. d k Represents the dimension of the key vector K. This parameter is used to scale the dot product to prevent T When the dimension is too high, the dot product result is too large, thus avoiding excessively large gradient values. This scaling helps stabilize model training and can be seen as a form of regularization that controls the magnitude of the gradient. Softmax() is used to convert the dot product scores between Q and K into weights, which are then used in the weighted summation.
[0206] The model is processed through multiple layers of Transformers, usually using the hidden state of the last layer of Transformers as the final representation of each token.
[0207] The average pooling method is applied to aggregate the representations of all indicator vectors to obtain the embedding vector of the entire electronic medical record text sequence.
[0208] h sequence =Pooling(h1,h2,...,h n )
[0209] The attention mechanism is used to perform a weighted fusion of the TF-IDF vector and the embedding vector to obtain a fused index vector. The attention weight is calculated by transforming the input vector.
[0210]
[0211] where α iis the attention weight for each indicator vector; v i is the attention weight for each embedding vector.
[0212] The WV weight vector is combined with the embedding vector generated by the large language model for entity recognition, where the embedding vector refers to a continuous vector representation that maps terms in the text (such as disease names, symptoms, drugs, etc.) to a high-dimensional space.
[0213] In some embodiments, mapping refers to the process of converting entities and relationships extracted from electronic medical record text into a structured data format through a series of predefined rules and templates, wherein entities (such as diseases, drugs) are identified and classified into corresponding parts of the medical record (such as diagnosis, treatment), and relationships (such as the association between patients and diagnoses) are clearly recorded to reflect the logical connection between medical data, ultimately forming a structured medical record that can be systematically managed and analyzed.
[0214] In some embodiments, the training and fine-tuning of the large language model are as follows: first, indicator vectors are extracted from the medical record text set, named entity recognition (NER) is performed on the indicator vector sequence, and the recognized data set is input into the large language model for training.
[0215] In some embodiments, the fused vector contains both word frequency information and contextual semantic information, and uses a bidirectional long short-term memory network algorithm to capture the contextual information of the text sequence.
[0216] Perform global annotation on the labeled sequences, considering the dependencies between sequences.
[0217] Input the prepared labeled data into the model for backpropagation and parameter optimization.
[0218] Use negative log likelihood loss or CRF loss function to minimize the error of label prediction.
[0219] Use labeled data for training and fine-tuning, perform entity recognition and annotation prediction on unlabeled text, and extract medical entities from electronic medical record text.
[0220] Task-specific model training and prediction, named entity recognition (NER)
[0221] Operation: Fine-tune the model using the NER task to extract medical entities from the text.
[0222] Algorithms: BiLSTM-CRF, BERT-CRF, etc.
[0223] Use labeled data to train large language models and optimize model parameters.
[0224] Relationship extraction: Train the model on annotated electronic medical record datasets to extract structured entities and relationships.
[0225] By associating with the standard reference dictionary, all possible entities, including diseases, drugs, symptoms, etc., are extracted from the electronic medical record text as candidates for relation extraction and entity pairs are generated.
[0226]
[0227] Pr(y|x; θ) is the conditional probability of the labeled sequence y given the input text sequence x, calculated by the CRF layer. θ is the parameter of the model. R(θ) is the regularization term used to prevent overfitting. λ is the regularization parameter used to balance the importance of the negative log-likelihood loss and the regularization term.
[0228] Features are extracted for each entity pair and used as input to the relation classification model.
[0229] Apply large language models such as BERT to fine-tune entity pair features and obtain contextual representations between entity pairs.
[0230] Classify the relationship of each entity pair and determine its relationship type, including treatment relationship, complication relationship, drug effect relationship, symptom relationship, disease family relationship, etiology relationship, diagnosis relationship, etc.
[0231] Classify the extracted entity pairs and relationships
[0232] Convert the preprocessed text into feature vectors that can be processed by the machine learning model.
[0233] Result conversion and structured output: Based on user needs, the results are converted into structured forms and mapped to the electronic medical record system (generating structured data in a unified format based on user needs).
[0234] Obtain named entities and their relations from named entity recognition (NER) and relation extraction (RE).
[0235] Integrate entity pairs and their corresponding relationship types into a structured data format, with each row representing a relationship, such as a triple (Xiaoming, diagnosis, diabetes) or a graph structure.
[0236] Define the target structured output format, support JSON, CSV, XML and other formats, and facilitate data storage, query and analysis applications.
[0237] This method uses pre-trained large language models, such as BioBERT or ClinicalBERT, pre-trained on large-scale medical text data through self-supervised learning. Unlike traditional methods, this method leverages the powerful representation learning capabilities of large language models to deeply understand and encode the rich semantic information and complex relationships in electronic medical record text, significantly improving the ability to accurately extract medical entities and relationships.
[0238] This invention implements an end-to-end automated process, encompassing data preprocessing, application of a large language model, medical entity recognition, relationship extraction, and structured output. Compared to traditional manual feature engineering and rule-based approaches, this automated process not only simplifies the workflow and improves efficiency, but also reduces human error and subjective intervention, resulting in greater reliability and stability.
[0239] By fine-tuning a large language model, this paper achieves accurate recognition and extraction of complex medical entities and long-range dependencies. This is particularly true in the medical field, where entity names are diverse and easily confused, and relationships are complex and ever-changing. By leveraging the model's deep learning capabilities, this paper effectively addresses the limitations of traditional methods in addressing these challenges.
[0240] Figure 3 is a schematic diagram of a computer device provided by an embodiment of the present invention, such as Figure 3 As shown, the device may include: one or more processors, and one or more memories; wherein the memories store computer-readable codes, and when the computer-readable codes are run by the one or more processors, the method described above may be executed.
[0241] The processor in this embodiment can be an integrated circuit chip with signal processing capabilities. The above-mentioned processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component. It can implement or execute the various methods, operations, and logic block diagrams disclosed in the embodiments of the present disclosure. The general-purpose processor can be a microprocessor or any conventional processor, etc., and can be an X86 architecture or an ARM architecture.
[0242] In general, various example embodiments of the present disclosure may be implemented in hardware or dedicated circuitry, software, firmware, logic, or any combination thereof. Certain aspects may be implemented in hardware, while other aspects may be implemented in firmware or software that may be executed by a controller, microprocessor, or other computing device. When various aspects of the disclosed embodiments are illustrated or described as block diagrams, flow charts, or using some other graphical representation, it will be understood that the blocks, devices, systems, techniques, or methods described herein may be implemented, as non-limiting examples, in hardware, software, firmware, dedicated circuitry or logic, general-purpose hardware or a controller or other computing device, or some combination thereof.
[0243] For example, the method or apparatus according to the embodiment of the present disclosure may also be implemented by Figure 4 The architecture of the computing device 3000 shown in FIG. Figure 4 As shown, the computing device 3000 may include a bus 3010, one or more CPUs 3020, a read-only memory (ROM) 3030, a random access memory (RAM) 3040, a communication port 3050 connected to a network, an input / output component 3060, a hard disk 3070, etc. The storage device in the computing device 3000, such as the ROM 3030 or the hard disk 3070, may store various data or files used for processing and / or communication of the method provided in the present disclosure, as well as program instructions executed by the CPU. The computing device 3000 may also include a user interface 3080. Of course, Figure 4 The architecture shown is only exemplary and can be omitted according to actual needs when implementing different devices. Figure 4 One or more components of a computing device are shown.
[0244] The embodiment of the present invention further provides a computer-readable storage medium, such as Figure 5As shown, it is a schematic diagram of a storage medium provided in an embodiment of the present invention, and computer-readable instructions 4010 are stored on the computer storage medium 4020. When the computer-readable instructions 4010 are executed by the processor, the method according to the embodiment of the present disclosure described with reference to the above figures can be executed. The computer-readable storage medium in the embodiment of the present disclosure can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. The non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM) or a flash memory. The volatile memory can be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus random access memory (DR RAM). It should be noted that the memory of the methods described herein is intended to include, but is not limited to, these and any other suitable types of memory. It should be noted that the memory of the methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0245] The present disclosure also provides a computer program product or a computer program, which implements the steps of the above method when executed by a processor, such as Figure 2 As shown, the computer program product or computer program includes:
[0246] Acquisition module 201: used to acquire medical record text and medical word segmentation dictionary;
[0247] Matching module 202: used to perform dynamic text segmentation matching on the medical record text to obtain an indicator vector sequence. The matching module is specifically used to execute the method steps S21-S25:
[0248] S21: performing dynamic text segmentation on the medical record text to obtain a potential segmentation matrix composed of potential segmentations, S22: obtaining a matching cost matrix based on the matching costs of the potential segmentations in the potential segmentation matrix and the index directory in the medical segmentation dictionary,
[0249] S23: Using a sliding window method to compare the matching cost matrix to obtain indicator directory segmentation words and corresponding starting points, all indicator directory segmentation words constitute an indicator directory sequence;
[0250] S24: determining a neighborhood according to the position of the indicator catalog segmentation word in the medical record text, performing dynamic text segmentation on the neighborhood and matching the value range corresponding to the indicator catalog in the medical segmentation dictionary to obtain the value of the indicator catalog;
[0251] S25: The indicator directory and the value of the indicator directory constitute an indicator vector, and all indicator vectors constitute an indicator vector sequence;
[0252] Conversion module 203: used to input the indicator vector into the electronic medical record conversion model to obtain a structured electronic medical record. The electronic medical record conversion model is obtained by inputting the indicator vector obtained based on the training set into the electronic medical record conversion model obtained by training the large language model.
[0253] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architectures, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the boxes can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified functions or operations, or can be implemented using a combination of dedicated hardware and computer instructions.
[0254] In general, various example embodiments of the present disclosure may be implemented in hardware or dedicated circuitry, software, firmware, logic, or any combination thereof. Certain aspects may be implemented in hardware, while other aspects may be implemented in firmware or software that may be executed by a controller, microprocessor, or other computing device. When various aspects of the disclosed embodiments are illustrated or described as block diagrams, flow charts, or using some other graphical representation, it will be understood that the blocks, devices, systems, techniques, or methods described herein may be implemented, as non-limiting examples, in hardware, software, firmware, dedicated circuitry or logic, general-purpose hardware or a controller or other computing device, or some combination thereof.
[0255] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0256] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0257] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0258] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0259] The exemplary embodiments of the present disclosure described in detail above are merely illustrative and not restrictive. Those skilled in the art will appreciate that various modifications and combinations may be made to these embodiments or their features without departing from the principles and spirit of the present disclosure, and such modifications should fall within the scope of the present disclosure.
Claims
1. A method for structural conversion of electronic medical records, characterized in that: The method comprises: S1: Obtain medical record text and medical word segmentation dictionary; S2: Perform dynamic text segmentation and matching on the medical record text to obtain an indicator vector sequence, specifically including: S21: performing dynamic text segmentation on the medical record text to obtain a potential segmentation matrix composed of potential segmentations, S22: obtaining a matching cost matrix based on the matching costs of the potential segmentations in the potential segmentation matrix and the index directory in the medical segmentation dictionary, S23: Using a sliding window method to compare the matching cost matrix to obtain indicator directory segmentation words and corresponding starting points, all indicator directory segmentation words constitute an indicator directory sequence; S24: determining a neighborhood according to the position of the indicator catalog segmentation word in the medical record text, performing dynamic text segmentation on the neighborhood and matching the value range corresponding to the indicator catalog in the medical segmentation dictionary to obtain the value of the indicator catalog; S25: The indicator directory and the value of the indicator directory constitute an indicator vector, and all indicator vectors constitute an indicator vector sequence; S3: After the indicator vector sequence is input into the electronic medical record conversion model, a structured electronic medical record is obtained. The method for obtaining the electronic medical record conversion model is: the indicator vector sequence obtained based on the training set is input into the electronic medical record conversion model obtained by training the large language model.
2. The method for structural conversion of electronic medical records according to claim 1, characterized in that: The matching cost is calculated as follows: the elements in the potential segmentation matrix are sequentially calculated with the matching costs of each indicator directory in the medical segmentation dictionary, and the minimum value of the matching cost of each indicator directory is selected as the matching cost corresponding to the element in the potential segmentation matrix; the medical record text is segmented to obtain possible segmentations, and the potential segmentation matrix is composed of the possible segmentations.
3. The method for structural conversion of electronic medical records according to claim 1, characterized in that: The dynamic text segmentation further includes performing sparsity constraints on the matching costs of each indicator directory to obtain the minimum matching cost after the constraints, and taking the possibility of the minimum matching cost after the constraints as the segmentation result.
4. The method for structural conversion of electronic medical records according to claim 1, characterized in that: The matching cost is constrained as follows: Where S represents a sequence of medical record text strings or a sequence of possible word segments; Represents potential participles Index directory in the medical word segmentation dictionary The matching cost, is the sparsity weight parameter, represents the sparsity penalty function.
5. The method for structural conversion of electronic medical records according to claim 4, characterized in that: The matching cost is calculated as edit distance.
6. The method for structural conversion of electronic medical records according to claim 1, characterized in that: The sliding window method is compared as follows: first, the minimum value of the matching cost matrix is taken according to the row to obtain the minimum matching cost of each starting point, and the sliding window method is used to determine the minimum matching cost and the corresponding starting and ending points within a certain window. If the starting and ending points overlap, the starting and ending points corresponding to the smaller matching cost are used as the starting and ending points of the indicator directory segmentation.
7. The method for structural conversion of electronic medical records according to claim 1, characterized in that: The matching cost matrix is sparsely processed, and the matching cost exceeding the set matching range is set to .
8. The method for structural conversion of electronic medical records according to claim 1, characterized in that: The S21 is: the medical record text is represented by S, the potential word segmentation matrix is represented by D, and the element D[i,j]= S[i:i+j] in the potential word segmentation matrix represents the potential word segmentation from the i-th character to the i+j-th character of the medical record text S, where i∈[1,length(S)], j∈[0,L)], and L represents the maximum length of the indicator directory in the medical word segmentation dictionary.
9. The method for structural conversion of electronic medical records according to claim 1, characterized in that: The matching cost is calculated as follows: in, Measurement Participle and words in the medical word dictionary The edit distance, Measurement Participle and words in the medical word dictionary The time characteristic difference of is the weight of the time feature difference, is the weight of the edit distance.
10. The method for structural conversion of electronic medical records according to claim 1, characterized in that: The matching cost is calculated as follows: in, Measurement Participle and words in the medical word dictionary The spatial distance, Measurement Participle and words in the medical word dictionary time distance, is the weight of spatial distance, is the weight of the time distance; the spatial distance is the Jaccard distance; and the time distance is the Levenshtein distance.
11. The method for structural conversion of electronic medical records according to claim 1, characterized in that: The indicator vector sequence is subjected to a self-attention mechanism to obtain a TF-IDF vector; the indicator vector sequence is summarized to obtain an embedding vector, the TF-IDF vector and the embedding vector are fused to obtain a fused indicator vector, and the fused indicator vector is input into a second electronic medical record structured conversion model to obtain a structured electronic medical record; The second electronic medical record structured conversion model is obtained by inputting an indicator vector obtained based on a training set into a large language model to obtain a second electronic medical record conversion model.
12. The method for structural conversion of electronic medical records according to claim 11, characterized in that: The TF-IDF vector is represented as: in, represents a TF-IDF vector, t represents the indicator name in the indicator vector sequence, d represents a single medical record text, and D represents the current electronic medical record document to be matched; Is the indicator name In a single electronic medical record text The frequency of occurrence in ; t' represents the synonyms, related words or other different forms of the indicator name t in the text d, is the vocabulary in the medical record text In case of occurrence, the indicator name Conditional probability of occurrence; It is the conditional probability based on the classification of medical record text; is the weight parameter that balances the medical record text and the indicator vector; It's vocabulary The weight coefficient of .
13. The method for structural conversion of electronic medical records according to claim 11, characterized in that: The fused index vector is expressed as: Among them, is the attention weight for each TF-IDF vector; is the attention weight for each embedding vector; Represents the output of the first attention head in the attention mechanism, n represents the number of vectors, that is, the number of elements in the sequence or set, represents the attention weight of each embedding vector, reflecting the importance of the i-th embedding vector in the overall context, Represents the continuous vector representation of mapping words or phrases into high-dimensional space. These vectors can capture the semantic information and contextual relationships of words. Represents the sequence representation after average pooling, hi represents all indicator vector sequences; Pooling() means applying the average pooling method to summarize the representations of all indicator vector sequences.
14. The method for structural conversion of electronic medical records according to claim 2, characterized in that: A word segmentation model is used to obtain possible word segments based on the medical record text.
15. The method for structural conversion of electronic medical records according to claim 2, characterized in that: The word segmentation model is a conditional random field model, which uses characteristic functions and weights to divide word boundaries.
16. A computer device, characterized in that: The device comprises: a memory and a processor; the memory is used to store a computer program; and the processor executes the computer program to implement the steps of the method according to any one of claims 1 to 15.
17. A computer-readable storage medium, characterized in that A computer program is stored thereon, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 15 are implemented.
18. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 15 are implemented.
Citation Information
Patent Citations
Word segmentation method and system for Chinese electronic medical record
CN113095074A
Traditional Chinese medicine text entity relationship joint extraction method
CN115510242A