Method and device for extracting medical variables in medical record text, equipment and storage medium
Through hierarchical sampling and python regular expression matching combined with negative word processing, the representativeness and logical flexibility of sample data extracted by traditional Chinese medical variables in medical record text are solved, and high accuracy and efficient medical variable extraction are achieved.
Patent Information
- Application Number
- CN202411237245.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2024-10-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the traditional Chinese medicine variable extraction in the prior art, there are problems such as unrepresentative sample data, high labor cost, poor extraction logic flexibility and high error in the extraction text.
Acquire sample data through hierarchical sampling, configure extraction rules and logic, match medical record text using python regular expressions, combine negative word modification processing, and calibrate extraction rules to improve extraction accuracy and scalability.
It improves the accuracy and efficiency of medical variable extraction, reduces errors, enhances the configurability and accuracy of extraction logic, and simplifies the maintenance process.
Smart Images

Figure CN118760757A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of medical data processing, and in particular to a method, device, equipment and storage medium for extracting medical variables from medical record text. Background Art
[0002] With the rapid development of medical informatization and the popularization of electronic medical records and paperless office, medical institutions have accumulated a large amount of unstructured text data in electronic medical records, such as admission records, discharge records, first medical records and daily medical records. These medical record texts are usually long and in various formats. They are stored in large fields of database tables in different text forms based on their respective production systems, which is very inconvenient to access and affects the efficiency of obtaining effective information. Some historical archived medical records are no longer maintained, lacking systematic, standardized and unified management.
[0003] Medical records in medical institutions are usually stored in CLOB type large text fields in each business table of the electronic medical record system. To extract medical variables from medical record texts, the most common solution is to use a medical big data model to identify medical variables by manually annotating a large amount of medical record texts, and use the annotated data for machine learning to train the big data model to maturity. During production, a number of sample data are randomly selected, and extraction rules with a high to low priority are set for each medical variable to be extracted, and the extraction rules are matched in sequence. Combined with the recognition results of the big data model, the content of the medical variable is extracted.
[0004] There are the following problems in extracting variables through the medical big data model: 1. The sample data of medical record texts formed by random sampling is not representative, and it is difficult to cover the description methods of medical variables in most medical record texts, resulting in large errors. 2. The medical big data model requires a large amount of manually annotated data as support, which consumes a lot of manpower and investment in the early stage, and cannot achieve good results in a short period of time. 3. The descriptions of medical variables are diverse, and there is uncertainty in natural language. They are extracted in descending order according to the extraction rules. If the descriptions in the medical record text that meet the low-priority rules are in front and the descriptions that meet the high-priority rules are in the back, the previous descriptions will be skipped, which is prone to deviations and omissions. 4. The general medical variable extraction logic does not distinguish by variable type, has low flexibility and poor scalability, and the extraction granularity of the general logic is coarse, which is more likely to produce errors. Summary of the invention
[0005] In view of this, the present application provides a method, device, equipment and storage medium for extracting medical variables from medical record texts, so as to improve the efficiency and convenience of extracting medical variables from medical record texts.
[0006] In a first aspect, the technical solution of the present invention provides a method for extracting medical variables from medical record text, comprising the following steps: Obtain the source data of each case text and determine the basic screening conditions of the case text; Conduct stratified sampling on the source data of each case text, and extract several pieces of data as sample data; Configure extraction rules and extraction logic to extract medical variables from sample data in batches; Verify the extraction results of sample data and calibrate the extraction rules; Extracting medical variables from all case text source data based on the calibrated extraction rules and according to the extraction logic; After processing the extracted results, the values of each medical variable are obtained.
[0007] As a further limitation of the technical solution of the present invention, the steps of obtaining the source data of each case text and determining the basic screening conditions of the case text include: Determine the source table and source field of the medical variables to be extracted, and obtain the text source data of each case; Maintaining the correspondence between medical variables and their medical descriptions by presetting a medical variable keyword dictionary; Use the medical variable names to perform fuzzy search in the corresponding relationships to find keywords that describe the medical variables as the basic screening criteria for the case text.
[0008] As a further limitation of the technical solution of the present invention, the steps of performing stratified sampling on the source data of each case text and extracting a plurality of data as sample data include: Classify case text source data according to the source table of each medical variable; All types of source data are stratified according to departments, and each layer is then stratified according to the character length range of the medical record text; The basic screening conditions are adapted to perform a set number of random sampling on each layer of source data to obtain stratified sampling source data samples as sample data.
[0009] As a further limitation of the technical solution of the present invention, after the step of performing stratified sampling on the source data of each case text and extracting a number of data as sample data, the method further comprises: preprocessing the sample data; specifically, the method comprises: Use Python to process text, normalize the symbols in the sample data and remove XML tags, use set characters to segment or sentence the sample data, and store them in a list.
[0010] As a further limitation of the technical solution of the present invention, the step of configuring extraction rules and extraction logic to extract medical variables from sample data in batches includes: Analyze the sample data of stratified sampling one by one, find the description method of each medical variable to be extracted in each sample data, derive the extraction rules of medical variables, and then derive the Python regular expression of the extraction rules. When there are multiple extraction rules, the rules are connected by setting symbols; Match the medical record text according to the Python regular expression of the extraction rule to obtain the matching result set; Configure extraction logic according to the Boolean medical variables and character medical variables in the matching result set; The extraction logic is executed on the preprocessed sample data using the Python regular expression of the extraction rule to obtain the extraction results of each medical variable in the sample data.
[0011] As a further limitation of the technical solution of the present invention, in the step of configuring the extraction logic according to the Boolean medical variables and the character medical variables in the matching result set, the extraction logic includes: Determine whether there is a negative word in front of or in the middle of the matching result in the matching result set to modify it; If there is a negative word modification, for the Boolean medical variable, this matching result will be excluded, and the search will continue until there is no result modified by a negative word. At this time, the value of the Boolean medical variable is set to 1. If all the results are modified by negative words, the value of the Boolean medical variable is set to 0. For a character-type medical variable, if it is modified by a Boolean-type medical variable, only when the value of the Boolean-type medical variable is 1, the Python regular expression extraction rule corresponding to the character-type medical variable is used to match the medical record text to obtain the value of the character-type medical variable.
[0012] As a further limitation of the technical solution of the present invention, the steps of verifying the extraction results of the sample data and calibrating the extraction rules include: Compare the original text of the sample data medical record to verify whether the extracted results of the medical variables are consistent with the original text of the sample data; If there are any inconsistent results, the Python regular expression of the extraction rule is updated according to the expression of the medical variable corresponding to the original text.
[0013] In a second aspect, the technical solution of the present invention provides a device for extracting medical variables from medical record text, including a screening condition determination module, a layer processing module, an extraction processing module, a verification module, a variable extraction module and a result processing module; The screening condition determination module is used to obtain the source data of each case text and determine the basic screening conditions of the case text; A stratified processing module is used to perform stratified sampling on the source data of each case text and extract several pieces of data as sample data; An extraction processing module is used to configure extraction rules and extraction logic to extract medical variables from sample data in batches; Verification module, used to verify the extraction results of sample data and calibrate the extraction rules; A variable extraction module, used to extract medical variables from all case text source data based on the calibrated extraction rules and the extraction logic; The result processing module is used to process the extraction results to obtain the values of various medical variables.
[0014] As a further limitation of the technical solution of the present invention, the screening condition determination module is specifically used to determine the source table and source field of the medical variables to be extracted, and obtain the source data of each case text; maintain the correspondence between the medical variables and their medical descriptions by means of a preset medical variable keyword dictionary; use the medical variable name to perform fuzzy search in the correspondence to find the keywords of the description method of the medical variables as the basic screening conditions for the case text.
[0015] As a further limitation of the technical solution of the present invention, the stratified processing module includes a classification unit, a stratified processing unit and a sampling unit; A classification unit is used to classify case text source data according to the source table of each medical variable; The layered processing unit is used to layer various source data according to departments, and then layer each layer according to the character length range of the medical record text; The sampling unit is used to adapt the basic screening conditions to perform a set number of random sampling on each layer of source data to obtain stratified sampling source data samples as sample data.
[0016] As a further limitation of the technical solution of the present invention, the device also includes a preprocessing module for preprocessing the sample data; specifically, it is used to process text using Python, normalize the symbols in the sample data and remove XML tags, use set characters to segment or sentence the sample data, and store them in a list.
[0017] As a further limitation of the technical solution of the present invention, the extraction processing module includes an extraction rule configuration unit, an extraction logic configuration unit and a variable extraction unit; An extraction rule configuration unit is used to analyze the sample data of stratified sampling one by one, find the description method of each medical variable to be extracted in each sample data, obtain the extraction rule of the medical variable, and then obtain the Python regular expression of the extraction rule. When there are multiple extraction rules, the rules are connected by setting symbols; An extraction logic configuration unit is used to match the medical record text according to the Python regular expression of the extraction rule to obtain a matching result set; and configure the extraction logic according to the Boolean medical variables and character medical variables in the matching result set; The variable extraction unit is used to execute the extraction logic on the preprocessed sample data using the Python regular expression of the extraction rule to obtain the extraction results of each medical variable in the sample data.
[0018] As a further limitation of the technical solution of the present invention, the extraction logic includes: Determine whether there is a negative word in front of or in the middle of the matching result in the matching result set to modify it; If there is a negative word modification, for the Boolean medical variable, this matching result will be excluded, and the search will continue until there is no result modified by a negative word. At this time, the value of the Boolean medical variable is set to 1. If all the results are modified by negative words, the value of the Boolean medical variable is set to 0. For a character-type medical variable, if it is modified by a Boolean-type medical variable, only when the value of the Boolean-type medical variable is 1, the Python regular expression extraction rule corresponding to the character-type medical variable is used to match the medical record text to obtain the value of the character-type medical variable.
[0019] As a further limitation of the technical solution of the present invention, the verification module is specifically used to compare the original text of the sample data medical record text to verify whether the extraction results of the medical variables are consistent with the original text expression of the sample data; if there are inconsistent results, the Python regular expression of the extraction rule is updated according to the expression of the original text corresponding to the medical variable.
[0020] In a third aspect, the technical solution of the present invention also provides an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; the memory stores computer program instructions executable by the at least one processor, and the computer program instructions are executed by the at least one processor so that the at least one processor can execute the method for extracting medical variables in medical record text as described in the first aspect.
[0021] In a fourth aspect, the technical solution of the present invention also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions enable the computer to execute the method for extracting medical variables from medical record text as described in the first aspect.
[0022] It can be seen from the above technical solutions that the present invention has the following advantages: 1. Medical record texts are divided into multiple types. The medical record texts are divided into several layers for stratified sampling, which can obtain more accurate sample data and help improve the accuracy of medical variable extraction. 2. Combined with the various descriptions of medical variables in the medical record texts, several applicable extraction rules are summarized and summarized, and these extraction rules are integrated to eventually form a unique extraction rule corresponding to a medical variable. Compared with the configuration of extraction rules that distinguish priorities, it will produce smaller errors and is less likely to miss data. 3. Different extraction logics are configured according to different types of medical variables, so that the entire extraction logic forms a unified whole, and its internal structure is divided into more precise front and back levels according to the variable type, so that it has high configurability and high precision, and can be uniformly configured and easy to maintain.
[0023] In addition, the invention has a reliable design principle, a simple structure and a very broad application prospect. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0025] Figure 1 is a schematic flow chart of a method according to an embodiment of the present invention.
[0026] Figure 2 is a schematic flow chart of a method according to another embodiment of the present invention.
[0027] Figure 3 is a schematic block diagram of an apparatus according to an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. 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 ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0029] like Figure 1 As shown, an embodiment of the present invention provides a method for extracting medical variables from a medical record text, comprising the following steps: S1: Obtain the source data of each case text and determine the basic screening conditions of the case text; This step specifically includes: S11: The steps of obtaining the source data of each case text and determining the basic screening conditions of the case text include: S12: Determine the source table and source field of the medical variables to be extracted, and obtain the text source data of each case; S13: Maintaining the correspondence between the medical variables and their medical descriptions by presetting a medical variable keyword dictionary; S14: Use the medical variable name to perform fuzzy search in the corresponding relationship to find the keywords of the description method of the medical variable as the basic screening condition of the case text.
[0030] S2: Perform stratified sampling on the source data of each case text and extract several pieces of data as sample data; It should be noted that this step specifically includes: S21: Classify the case text source data according to the source table of each medical variable; S22: All types of source data are stratified according to departments, and each layer is then stratified according to the character length range of the medical record text; S23: Adapting the basic screening conditions to perform a set number of random sampling on each layer of source data to obtain stratified sampling source data samples as sample data.
[0031] S3: Configure extraction rules and extraction logic to extract medical variables from sample data in batches; In this embodiment, it specifically includes: S31: Analyze the sample data of stratified sampling one by one, find the description method of each medical variable to be extracted in each sample data, obtain the extraction rule of the medical variable, and then obtain the Python regular expression of the extraction rule. When there are multiple extraction rules, the rules are connected by setting symbols; S32: Match the medical record text according to the Python regular expression of the extraction rule to obtain a matching result set; S33: configuring extraction logic according to the Boolean medical variables and the character medical variables in the matching result set; S34: Using the Python regular expression of the extraction rule to execute the extraction logic on the preprocessed sample data to obtain the extraction results of each medical variable in the sample data.
[0032] It should be noted that the extraction logic includes: determining whether there is a negative word in front of or in the middle of the matching result in the matching result set to modify it; If there is a negative word modification, for the Boolean medical variable, this matching result will be excluded, and the search will continue until there is no result modified by a negative word. At this time, the value of the Boolean medical variable is set to 1. If all the results are modified by negative words, the value of the Boolean medical variable is set to 0. For a character-type medical variable, if it is modified by a Boolean-type medical variable, only when the value of the Boolean-type medical variable is 1, the Python regular expression extraction rule corresponding to the character-type medical variable is used to match the medical record text to obtain the value of the character-type medical variable.
[0033] S4: Verify the extraction results of the sample data and calibrate the extraction rules; the specific verification process includes: comparing the original text of the sample data medical record text, verifying whether the extraction results of the medical variables are consistent with the original text expression of the sample data; if there are inconsistent results, update the Python regular expression of the extraction rules according to the expression of the medical variables corresponding to the original text.
[0034] S5: extracting medical variables from all case text source data based on the calibrated extraction rules and the extraction logic; S6: After processing the extraction results, the values of each medical variable are obtained.
[0035] like Figure 2 As shown, the embodiment of the present invention also provides a method for extracting medical variables from a medical record text, and the process is as follows: Step 1: Determine the source table and source field of the medical variables to be extracted. For example, the variable "menopausal signs" comes from the paragraph describing "menstrual history" in the "medical record content" field of the "admission record form". The system has a built-in list of commonly used paragraphs, such as "chief complaint", "current medical history", "menstrual history", "physical examination", "course of disease description", "examination conclusion", etc., as well as the corresponding python regular expression method for extracting paragraphs.
[0036] Step 2: List the commonly used medical description methods of the medical variables to be extracted, summarize the keywords, and obtain the basic source data screening conditions. In the embodiment of the present invention, the corresponding system has a built-in medical variable keyword dictionary, and medical professionals maintain the corresponding relationship between various common medical variables and their medical descriptions in advance. When summarizing the keywords, use the medical variable name for fuzzy search to find the keywords of its description method as the screening conditions for the sample data. When searching, it is allowed to add description methods or medical variables to the keyword dictionary according to actual conditions. If the medical variable to be extracted must appear in the paragraph of step 1, the keyword of the medical variable may not be set. For example, the keywords of "menopause sign" are "menopause", "amenorrhea", and "menstruation", that is, "menopause", "amenorrhea", and "menstruation" can be used as keywords, and "menopause" can also be added as a keyword to preliminarily screen the source data, narrow the sampling range, and improve the validity of the sample data. Different keywords of the same medical variable are in an "or" relationship in the sql screening conditions. Medical variables with exactly the same keywords are merged when extracting sample data, and the same sample data is applicable.
[0037] Step 3: According to the source table of each medical variable, the source data is classified into admission record source, discharge record source, medical history record source, etc. Various types of source data are stratified according to departments, and representative departments are selected, such as internal medicine, surgery, ENT, gynecology, obstetrics, pediatrics, critical care medicine, and other departments to obtain representative sample data in medical institutions. Because there may be multiple different writing templates for the same type of medical records in the electronic medical record system, and the writing habits of medical workers are different, after stratifying various types of source data by department, each layer is stratified according to the character length range of the medical record text. Finally, the keyword screening conditions described in step 2 are adapted to perform a specified number of random sampling of each layer of source data to obtain a representative source data sample of stratified sampling.
[0038] Stratified sampling uses Python to configure the vertica-python database driver and operate SQL to retrieve the vertica database. When stratified sampling is performed, specify the source table, source field, medical record category, sampling department, character length interval, number of samples per layer, keywords of the search conditions, and other parameters, then use vertica-python to call the SQL template to pass in the above parameters, retrieve the data, and obtain the sample data of stratified sampling.
[0039] Step 4: Preprocess the sample data obtained in step 3, use Python to process the text, such as replacing English commas with Chinese commas, replacing English colons with Chinese colons, removing blank lines and blank characters, using Python's xml.etree.ElementTree library to remove XML tags, and intercept the specific paragraphs of the medical record text where the medical variables are located according to writing habits to obtain more standardized and more accurate sample data. Use ".", ";", "\n" to segment or sentence the sample data and store them in a list to match all the expressions in the original text that meet the rules.
[0040] Step 5: Analyze the sampled data obtained through stratified sampling one by one, find the description methods of each medical variable to be extracted in the sampled data, summarize the rules for extracting medical variables, and obtain the Python regular expressions for the extraction rules. The rules for extracting medical variables are the linguistic expressions of medical variables in the text, presented in the form of writing Python regular expressions using the re library. That is, one regular expression is a rule, and each Python regular expression can locate the position of the medical variable. For example, if the original text is "lost two pounds in weight within one month", the Python regular expression "re.compile(r'体重(?:下降|减轻|增加)')" can be written as the extraction rule for the medical variable "weight change". If there are multiple extraction rules, the rules are connected using the "|" or operator. For example, if the original text is "gained two pounds in 30 days", the Python regular expression "re.compile(r'[胖瘦].{1,2}斤')" can be written as another extraction rule for the medical variable "weight change". The above two Python regular expression extraction rules are automatically integrated into a new rule using "|" as the final extraction rule for "weight change", that is, "re.compile(r'体重(?:下降|减轻|增加)|[胖瘦].{1,2}斤')".
[0041] 6. According to the definition of each medical variable, the extraction results are divided into Boolean and character types. In the extraction program, different extraction logics are configured for Boolean and character medical variables. The two are not independent of each other, but interdependent and interconnected, forming a unified extraction logic. The entire extraction logic is implemented in Python code. According to the Python regular expression extraction rules in step 5, after matching the medical record text with methods such as "findall", "search", and "match", a matching result set is obtained. Then, Python regular expressions are used to determine whether there are negative words such as "none", "deny", and "unaccompanied" in front of or in the middle of the matching results. For Boolean medical variables, if there are negative words to modify them, this matching result is excluded, and the results are checked until there are no negative words to modify them. At this time, the value of the Boolean medical variable is "1". If all the results are modified by negative words, the value of the Boolean medical variable is "0". For character-type medical variables, if they are modified by Boolean-type medical variables, only when the value of the Boolean-type medical variable is "1", the python regular expression extraction rule corresponding to the character-type medical variable is used to match the medical record text to obtain the value of the character-type medical variable. For example, if the original text is "headache for 3 days", "whether headache" is a Boolean-type medical variable, and its value is "1", and "headache time" is a character-type medical variable. Only when the value of "whether headache" is "1", the value of "headache time" will be "3 days". If the original text is "without headache", the value of "whether headache" is "0", and the python regular expression extraction rule of "headache time" will not be matched for the expression "without headache", and the value of "headache time" is empty.
[0042] Step 7: Use a custom function written in Python to extract medical variables from medical record texts. Regular expressions are used in the form of findall, search, match, etc. to adapt the extraction rules of each medical variable configured in step 5, adapt the extraction logic configured in step 6, debug the extraction program, and perform batch extraction of each medical variable for each sample data to obtain the extraction results of each medical variable in the sample data. The specific extraction steps of the extraction program are: Step 3 obtains the sample data, Step 4 performs preliminary processing on the sample data, and uses the python regular expression extraction rules in Step 5 to execute the extraction logic in Step 6 on the sample data preprocessed in Step 4 to obtain the extraction results of each medical variable in the sample data.
[0043] Step 8: Compare the original text of the sample data medical record text, verify the extraction results of the medical variables, adjust the extraction rules of each medical variable to make it more accurate, and obtain the Python regular expression of the fine-tuned extraction rules. After the extraction program in step 7 is executed, the extraction results obtained in step 7 and the sample data obtained in step 4 will be displayed side by side. It is necessary to manually verify whether the extraction results are consistent with the expression of the original sample data. If there is any inconsistency, a new Python regular expression extraction rule can be summarized based on the expression of the original text, and the Python regular expression extraction rule in step 5 can be modified to obtain a more accurate extraction rule.
[0044] Step 9: Use the debugged Python program for extracting medical variables from medical record text, adapt the screening conditions in step 2, extract various medical variables from all preprocessed medical record text data, and obtain the result set.
[0045] Step 10: Perform data post-processing such as merging and splitting on the result set to finally obtain the values of each medical variable. The result set is in the form of a list or dictionary. If there is only one value in the result set, no processing is required. If there are multiple values in the result set, deduplication is performed according to the actual situation. In the case where multiple medical variables are extracted into one result set, the result set needs to be split to obtain the values of multiple medical variables. For non-standard expressions in the result set, they must also be converted into standardized values. This is also processed through Python code.
[0046] like Figure 3 As shown, an embodiment of the present invention provides a device for extracting medical variables from medical record text, including a screening condition determination module, a layer processing module, an extraction processing module, a verification module, a variable extraction module and a result processing module; The screening condition determination module is used to obtain the source data of each case text and determine the basic screening conditions of the case text; A stratified processing module is used to perform stratified sampling on the source data of each case text and extract several pieces of data as sample data; An extraction processing module is used to configure extraction rules and extraction logic to extract medical variables from sample data in batches; Verification module, used to verify the extraction results of sample data and calibrate the extraction rules; A variable extraction module, used to extract medical variables from all case text source data based on the calibrated extraction rules and the extraction logic; The result processing module is used to process the extraction results to obtain the values of various medical variables.
[0047] In some embodiments, the screening condition determination module is specifically used to determine the source table and source field of the medical variables to be extracted, and obtain the source data of each case text; maintain the correspondence between the medical variables and their medical descriptions by means of a preset medical variable keyword dictionary; use the medical variable name to perform fuzzy search in the correspondence, and find the keywords of the description method of the medical variables as the basic screening conditions for the case text.
[0048] In some embodiments, the stratified processing module includes a classification unit, a stratified processing unit, and a sampling unit; A classification unit is used to classify case text source data according to the source table of each medical variable; The layered processing unit is used to layer various source data according to departments, and then layer each layer according to the character length range of the medical record text; The sampling unit is used to adapt the basic screening conditions to perform a set number of random sampling on each layer of source data to obtain stratified sampling source data samples as sample data.
[0049] In some embodiments, the device also includes a preprocessing module for preprocessing the sample data; specifically, it is used to process text using python, normalize the symbols in the sample data and remove XML tags, use set characters to segment or sentence the sample data, and store them in a list.
[0050] In some embodiments, the extraction processing module includes an extraction rule configuration unit, an extraction logic configuration unit, and a variable extraction unit; An extraction rule configuration unit is used to analyze the sample data of stratified sampling one by one, find the description method of each medical variable to be extracted in each sample data, obtain the extraction rule of the medical variable, and then obtain the Python regular expression of the extraction rule. When there are multiple extraction rules, the rules are connected by setting symbols; An extraction logic configuration unit is used to match the medical record text according to the Python regular expression of the extraction rule to obtain a matching result set; and configure the extraction logic according to the Boolean medical variables and character medical variables in the matching result set; The variable extraction unit is used to execute the extraction logic on the preprocessed sample data using the Python regular expression of the extraction rule to obtain the extraction results of each medical variable in the sample data.
[0051] The extraction logic includes: determining whether there is a negative word in front of or in the middle of the matching result in the matching result set to modify it; If there is a negative word modification, for the Boolean medical variable, this matching result will be excluded, and the search will continue until there is no result modified by a negative word. At this time, the value of the Boolean medical variable is set to 1. If all the results are modified by negative words, the value of the Boolean medical variable is set to 0. For a character-type medical variable, if it is modified by a Boolean-type medical variable, only when the value of the Boolean-type medical variable is 1, the Python regular expression extraction rule corresponding to the character-type medical variable is used to match the medical record text to obtain the value of the character-type medical variable.
[0052] In some embodiments, the verification module is specifically used to compare the original text of the sample data medical record text to verify whether the extraction results of the medical variables are consistent with the original text expression of the sample data; if there are inconsistent results, the Python regular expression of the extraction rule is updated according to the expression of the medical variables corresponding to the original text.
[0053] The embodiment of the present invention also provides an electronic device, which includes: a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus. The communication bus can be used for information transmission between the electronic device and the sensor. The processor can call the logic instructions in the memory to execute the following method: S1: obtain the source data of each case text and determine the basic screening conditions of the case text; S2: perform stratified sampling on the source data of each case text and extract several pieces of data as sample data; S3: configure the extraction rules and extraction logic to extract medical variables from the sample data in batches; S4: verify the extraction results of the sample data and calibrate the extraction rules; S5: extract medical variables from all the source data of the case text according to the extraction logic based on the calibrated extraction rules; S6: obtain the values of each medical variable after processing the extraction results.
[0054] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product.
[0055] An embodiment of the present invention provides a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions enable a computer to execute the method provided by the above method embodiment, for example, including: S1: obtaining the source data of each case text and determining the basic screening conditions of the case text; S2: performing stratified sampling on the source data of each case text, and extracting a number of data as sample data; S3: configuring extraction rules and extraction logic to extract medical variables from the sample data in batches; S4: verifying the extraction results of the sample data and calibrating the extraction rules; S5: extracting medical variables from all the case text source data based on the calibrated extraction rules and the extraction logic; S6: obtaining the values of each medical variable after processing the extraction results.
[0056] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0057] An embodiment of the device for extracting medical variables from medical record text provided in an embodiment of the present invention belongs to the same inventive concept as the method for extracting medical variables from medical record text in the above-mentioned embodiments. For details not described in detail in the embodiment of the device for extracting medical variables from medical record text, reference can be made to the embodiment of the method for extracting medical variables from medical record text in the above-mentioned embodiments.
[0058] Although the present invention has been described in detail with reference to the accompanying drawings and in combination with the preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, a person of ordinary skill in the art may make various equivalent modifications or substitutions to the embodiments of the present invention, and these modifications or substitutions shall be within the scope of the present invention. Any person of ordinary skill in the art may easily think of changes or substitutions within the technical scope disclosed by the present invention, and these shall be within the scope of protection of the present invention.
Claims
1. A method for extracting medical variables from medical record text, It is characterized in that The steps include: Obtain the source data of each case text and determine the basic screening conditions of the case text; Conduct stratified sampling on the source data of each case text, and extract several pieces of data as sample data; Configure extraction rules and extraction logic to extract medical variables from sample data in batches; Verify the extraction results of sample data and calibrate the extraction rules; Extracting medical variables from all case text source data based on the calibrated extraction rules and according to the extraction logic; After processing the extracted results, the values of each medical variable are obtained.
2. The method for extracting medical variables from medical record text according to claim 1, It is characterized in that The steps of obtaining the source data of each case text and determining the basic screening conditions of the case text include: Determine the source table and source field of the medical variables to be extracted, and obtain the text source data of each case; Maintaining the correspondence between medical variables and their medical descriptions by presetting a medical variable keyword dictionary; Use the medical variable names to perform fuzzy search in the corresponding relationships to find keywords that describe the medical variables as the basic screening criteria for the case text.
3. The method for extracting medical variables from medical record text according to claim 2, It is characterized in that The steps of performing stratified sampling on the source data of each case text and extracting a number of data as sample data include: Classify case text source data according to the source table of each medical variable; All types of source data are stratified according to departments, and each layer is then stratified according to the character length range of the medical record text; The basic screening conditions are adapted to perform a set number of random sampling on each layer of source data to obtain stratified sampling source data samples as sample data.
4. The method for extracting medical variables from medical record text according to claim 3, It is characterized in that After performing stratified sampling on the source data of each case text and extracting a number of data as sample data, the step includes: preprocessing the sample data; specifically including: Use Python to process text, normalize the symbols in the sample data and remove XML tags, use set characters to segment or sentence the sample data, and store them in a list.
5. The method for extracting medical variables from medical record text according to claim 4, It is characterized in that The steps of configuring extraction rules and extraction logic to extract medical variables from sample data in batches include: Analyze the sample data of stratified sampling one by one, find the description method of each medical variable to be extracted in each sample data, derive the extraction rules of medical variables, and then derive the Python regular expression of the extraction rules. When there are multiple extraction rules, the rules are connected by setting symbols; Match the medical record text according to the Python regular expression of the extraction rule to obtain the matching result set; Configure extraction logic according to the Boolean medical variables and character medical variables in the matching result set; The extraction logic is executed on the preprocessed sample data using the Python regular expression of the extraction rule to obtain the extraction results of each medical variable in the sample data.
6. The method for extracting medical variables from medical record text according to claim 5, It is characterized in that In the step of configuring the extraction logic according to the Boolean medical variables and the character medical variables in the matching result set, the extraction logic includes: Determine whether there is a negative word in front of or in the middle of the matching result in the matching result set to modify it; If there is a negative word modification, for the Boolean medical variable, this matching result will be excluded, and the search will continue until there is no result modified by a negative word. At this time, the value of the Boolean medical variable is set to 1. If all the results are modified by negative words, the value of the Boolean medical variable is set to 0. For a character-type medical variable, if it is modified by a Boolean-type medical variable, only when the value of the Boolean-type medical variable is 1, the Python regular expression extraction rule corresponding to the character-type medical variable is used to match the medical record text to obtain the value of the character-type medical variable.
7. The method for extracting medical variables from medical record text according to claim 6, It is characterized in that The steps of verifying the extraction results of sample data and calibrating the extraction rules include: Compare the original text of the sample data medical record to verify whether the extracted results of the medical variables are consistent with the original text of the sample data; If there are any inconsistent results, the Python regular expression of the extraction rule is updated according to the expression of the medical variable corresponding to the original text.
8. A device for extracting medical variables from medical record text, It is characterized in that It includes a screening condition determination module, a layer processing module, an extraction processing module, a verification module, a variable extraction module and a result processing module; The screening condition determination module is used to obtain the source data of each case text and determine the basic screening conditions of the case text; A stratified processing module is used to perform stratified sampling on the source data of each case text and extract several pieces of data as sample data; An extraction processing module is used to configure extraction rules and extraction logic to extract medical variables from sample data in batches; Verification module, used to verify the extraction results of sample data and calibrate the extraction rules; A variable extraction module, used to extract medical variables from all case text source data based on the calibrated extraction rules and the extraction logic; The result processing module is used to process the extraction results to obtain the values of various medical variables.
9. An electronic device, It is characterized in that The electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; the memory stores computer program instructions executable by the at least one processor, and the computer program instructions are executed by the at least one processor so that the at least one processor can execute the method for extracting medical variables in the medical record text as described in any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium, It is characterized in that The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions enable the computer to execute the method for extracting medical variables from medical record text according to any one of claims 1 to 7.
Citation Information
Patent Citations
NLP-based electronic medical record data quality management method
CN108447534A
Chinese electronic case text analysis method and system
CN108831559A
Data processing method and system, electronic equipment and storage medium
CN110399209A
Systems and methods for analysis of surgical videos
CN113748468A
Code analysis method based on regular expression
CN113778852A
