An automatic parsing method for electronic medical records based on XML

Through the XML-based automatic parsing method, the problems of low manual analysis efficiency and data format differences in the existing technology are solved, and efficient electronic medical record data parsing without manual intervention is realized. It is suitable for all XML electronic medical record data, reducing costs and improving the value of data utilization.

CN114239494BActive Publication Date: 2024-10-11BEIJING YADING INFORMATION TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202111564070.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-20
Publication Date
2024-10-11
Estimated Expiration
2041-12-20

AI Technical Summary

Technical Problem

Existing electronic medical record parsing methods require manual analysis and configuration, are inefficient and can only process plain text data. They cannot adapt to the differences in data formats in different hospitals, resulting in high costs and low efficiency.

Method used

An XML-based automatic parsing method is adopted to automatically parse electronic medical record data through data cleaning, configuration generation and use of parsers, including sorting, XML tree traversal, tiling and nested parsing to generate structured data.

Benefits of technology

It realizes automatic analysis without manual intervention, improves the efficiency and applicability of data analysis, and can process XML electronic medical record data from different hospitals, reducing costs and increasing the value of data utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114239494B_ABST
    Figure CN114239494B_ABST
Patent Text Reader

Abstract

The present invention proposes an automatic parsing method for XML electronic medical records, comprising: step S1, inputting an XML electronic medical record data set D1; step S2, performing data cleaning on the electronic medical record data set to generate a cleaned data set D2; step S3, automatically generating a configuration for the cleaned data set D2; step S4, parsing the electronic medical record data after the configuration is completed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronic medical records, and in particular to an automatic parsing method for electronic medical records based on XML. Background Art

[0002] The current status of electronic medical record analysis has the following problems:

[0003] (1) Different HISs use different data formats to store complete medical record data.

[0004] (2) In the same hospital, the data format template is the same.

[0005] (3) In business application systems, it is usually necessary to convert the data stored in the HIS into structured data to facilitate better utilization of the data value.

[0006] In response to the above situation or demands, the commonly used method for data group analysis is to automatically parse plain text data. The electronic medical record analysis method disclosed in the patent (application number CN202110618183.3, an automated electronic medical record analysis method and device) has the following problems: each hospital needs to manually analyze and configure the data, which has high labor costs; the data formats of different hospitals may have the same rules, but they also need manual analysis and processing; the manual analysis efficiency is low; and it can only process plain text. Summary of the invention

[0007] The object of the present invention is to solve at least one of the technical drawbacks.

[0008] To this end, the purpose of the present invention is to propose an automatic parsing method for electronic medical records based on XML to solve the problems mentioned in the background technology and overcome the shortcomings of the prior art.

[0009] In order to achieve the above object, an embodiment of the present invention provides an automatic parsing method of electronic medical records based on XML, comprising the following steps:

[0010] Step S1, input XML electronic medical record data set D1;

[0011] Step S2, performing data cleaning on the electronic medical record data set to generate a cleaned data set D2;

[0012] Step S3, automatically generating a configuration for the cleaned data set D2, including:

[0013] Sort all rows of data in data set D2 in descending order according to the length of the text content to obtain data set D3;

[0014] Traverse the data set D3, and take the line with the longest text content for the same tuples to form the data set D4;

[0015] Traverse each row of data in data set D4, and parse the text content value of the row of data to obtain an XML tree;

[0016] Count the elements in the list and take the text name value of the nested parsing with the most occurrences, recorded as X1;

[0017] Locate the first element node in the XML tree from X1, take all the sibling leaf nodes of the node, traverse in the order of the sibling leaf nodes, and classify the sibling leaf nodes into two categories: name nodes and content nodes. The classification is based on whether the node text value or attribute value exists in the standard text name dictionary. Repeat this step until all nodes are processed.

[0018] All name nodes and content nodes are counted according to the tag names, and the nodes with the most tag names are selected as flat name nodes and flat content nodes respectively; if the tag names of the flat name node and the flat content node are consistent, the text name, text content location and value selection method of the flat parsing are generated, which are recorded as X3;

[0019] According to the value-taking method of the X3 text content, a nested parsing text content positioning and value-taking method is generated, which is recorded as X2;

[0020] Concatenate X1 and X2 to obtain the text name, text content location and value method of the nested analysis, and then write them into the database together with X3;

[0021] Complete automatic parsing configuration generation;

[0022] Step S4, after the configuration is completed, parse the electronic medical record data, including:

[0023] Obtain the electronic medical record parsing configuration list C1 from the database;

[0024] Traverse each row of data in the data set D2, and process the data by the parser in the parsing configuration list C1, wherein the parser includes a flat parser and a nested parser; select the corresponding parser for parsing according to the configuration information of the data; merge the result list obtained by each parser, and add the result list to the data set D3;

[0025] Write the data set D3 into a csv file and the parsing is complete.

[0026] Preferably, in any of the above schemes, in step S1, the electronic medical record data set D1 includes: medical record number, medical record name, text name and text content.

[0027] Preferably, in any of the above schemes, in step S2, the data cleaning comprises the following steps: deleting data with missing fields, and deleting data whose values ​​are not within the reasonable value range of the fields.

[0028] Preferably, any of the above schemes is that in step S3, the data set D3 is traversed, and for the same medical record name and text name, the line with the longest text content is taken to form the data set D4.

[0029] Preferably, in any of the above solutions, in step S3, traversing each row of data in the data set D4 and parsing the text content value of the row of data to obtain an XML tree comprises the following steps:

[0030] Recursively traverse all non-leaf nodes of the XML tree using depth-first traversal DFS;

[0031] For each node, determine whether all its attribute values ​​exist in the standard text name set. If so, add them to the list L1 and terminate the traversal of all child nodes of the node. If not, continue to recursively traverse the child nodes of the node.

[0032] Repeat the above steps until all nodes are processed.

[0033] Preferably, in any of the above solutions, in step S4, the parsing process of the tile parser is as follows:

[0034] Initialize the tile parser, and get the initial information from the parsing configuration list C1;

[0035] Parse the text content of the row data into an XML tree;

[0036] Search the XML tree through name XPath to obtain all name nodes, recorded as S1; search the XML tree through content XPath to obtain all content nodes, recorded as S2;

[0037] Sequentially traverse the nodes at the same level of the name node, and maintain the name variable Keyname and list L. If the current node is in S1, add Keyname and the concatenated L as the determined parsing result to the parsing result list, update Keyname, and set L to empty; if the current node is in S2, obtain the value of the current node through the content value XPath and append it to L;

[0038] Repeat the above steps until all sibling nodes are processed.

[0039] Preferably, in any of the above solutions, in step S4, the parsing process of the nested parser is as follows:

[0040] Initialize the nested parser, and get the initial information from the parsing configuration list C1;

[0041] Parse the text content of the row data into an XML tree;

[0042] Search the XML tree by name XPath to get all name nodes;

[0043] For each name node, obtain the name value according to the name value XPath, and then obtain the content value according to the content XPath and content value XPath, and add the tuple to the parsing result list;

[0044] Repeat the above steps until all name nodes are processed.

[0045] Preferably, any of the above solutions configures the parser for the data set in the following ways:

[0046] (1) Tiled parser;

[0047] (2) Nested parsers;

[0048] (3) Flat parser and nested parser;

[0049] (4) No parsing required.

[0050] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] The above and / or additional aspects and advantages of the present invention will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:

[0052] Figure 1 The figure is a flowchart of a method for automatic parsing of electronic medical records based on XML according to an embodiment of the present invention. DETAILED DESCRIPTION

[0053] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.

[0054] First, a number of technical terms involved in the present invention are explained below.

[0055] Electronic medical records: Electronic medical records are complete and detailed clinical information resources generated and recorded during a person's visits to medical institutions. They are currently the main component of medical data. However, electronic medical records are currently mainly in text and XML formats and cannot be directly used for analysis and research. Therefore, how to accurately and effectively parse electronic medical records and extract data group content for analysis and research is an urgent problem to be solved in medical data governance.

[0056] XML: Extensible Markup Language (XML) is a markup language mainly composed of tags, elements, and attributes, and is designed to transmit and carry data information.

[0057] XPath: XPath is XML Path Language, which is a computer language used to determine the location of a part in an XML document. XPath is based on the tree structure of XML and provides the ability to find nodes in the data structure tree.

[0058] like Figure 1 As shown, the XML electronic medical record automatic parsing method according to the embodiment of the present invention comprises the following steps:

[0059] Step S1, input XML electronic medical record data set D1.

[0060] In step S1, the electronic medical record data set D1 includes at least the following key fields: medical record number (unique identifier of a single hospitalization), medical record name (such as admission record, discharge record, etc.), text name (such as first medical record, operation record, etc.) and text content (XML data content).

[0061] Step S2, clean the electronic medical record data set to generate a cleaned data set D2.

[0062] Specifically, for data set D1, the key field values ​​are checked for cleaning to obtain data set D2. In an embodiment of the present invention, data cleaning includes the following processes: deleting data with missing fields; deleting data with values ​​that are not within the reasonable value range of the fields.

[0063] Step S3, automatically generate a configuration for the cleaned data set D2, and perform the following operations on the data in the data set D2:

[0064] Step S31, sorting all the rows of data in the data set D2 in descending order according to the length of the text content to obtain a data set D3.

[0065] Step S32, traverse the data set D3, and for the same (medical record name, text name) tuples, take the line with the longest text content to form the data set D4.

[0066] Step S33, traversing each row of data in the data set D4, parsing the text content value of the row of data to obtain an XML tree, includes the following steps:

[0067] Step S331, recursively traverse all non-leaf nodes of the XML tree by depth-first traversal DFS;

[0068] Step S332, for each node, determine whether all its attribute values ​​exist in the standard text name set. If so, add (text name, name XPath, name value XPath) to the list L1, and terminate the traversal of all child nodes of the node. If not, continue to recursively traverse the child nodes of the node.

[0069] Step S333, repeat step S332 until all nodes are processed.

[0070] Step S34, counting the elements in the list L1 according to (name XPath, name value XPath), taking the text name value mode of the (name XPath, name value XPath) with the most occurrences for nested parsing, recorded as X1.

[0071] Step S35, traversing each row of data in the data set D4, parsing the text content value of the row of data to obtain an XML tree, includes the following steps:

[0072] Step S351, locate the first element node in the XML tree from X1, take all the brother leaf nodes of the node, traverse in the order of brother leaf nodes, and classify the brother leaf nodes into two categories: name nodes and content nodes. The basis for classification is to determine whether the node text value or attribute value exists in the standard text name dictionary.

[0073] Step S352, repeat step S351 until all nodes are processed.

[0074] Step S36, all name nodes and content nodes are counted according to the tag name, and the node with the most tag name appearances is selected as the tile name node and tile content node. If the tile name node and the tile content node tag are consistent, the tile parsed text name, text content location and value method are generated, which is recorded as X3.

[0075] Step S37, based on the X3 text content value selection method, generate a nested parsing text content positioning and value selection method, recorded as X2.

[0076] Step S38, concatenate X1 and X2 together to obtain the nested parsed text name, text content location and value-taking method, and write them into the database together with X3.

[0077] Step S39, complete automatic parsing configuration generation.

[0078] In the embodiment of the present invention, the parser mode of configuring the data set includes the following forms:

[0079] (1) Tiled parser;

[0080] (2) Nested parsers;

[0081] (3) Flat parser and nested parser;

[0082] (4) No parsing required.

[0083] Step S4, after the configuration is completed, parse the electronic medical record data, including the following steps:

[0084] Step S41, obtaining the electronic medical record parsing configuration list C1 from the database;

[0085] Step S42, traverse each row of data in the data set D2, perform the following operations, and obtain the data set D3, including the following steps:

[0086] Step S421, each line of data is processed by each parser in the configuration list C1. In the embodiment of the present invention, the parser includes: a flat parser and a nested parser. The processing logic of each parser is described as follows:

[0087] Step S4211, nested parser, the execution process is as follows:

[0088] Step S42111, initialize the nested parser, and obtain the initial information (name XPath, name value XPath, content XPath, content value XPath) from C1;

[0089] Step S42112, parsing the text content of the row data into an XML tree;

[0090] Step S42113, searching the XML tree by name XPath to obtain all name nodes;

[0091] Step S42114, for each name node, obtain the name value according to the name value XPath, and then obtain the content value according to the content XPath and the content value XPath, and add the (name value, content value) tuple to the parsing result list;

[0092] Step S42115, repeat step S42114 until all name nodes are processed.

[0093] Step S4212, tiling the parser, the execution process is as follows:

[0094] Step S42121, initialize the tile parser, and obtain the initial information (name XPath, name value XPath, content XPath, content value XPath) from C1.

[0095] Step S42122, parse the text content of the row data into an XML tree.

[0096] Step S42123, search the XML tree through the name XPath to obtain all name nodes, recorded as S1; search the XML tree through the content XPath to obtain all content nodes, recorded as S2.

[0097] Step S42124, sequentially traverse the nodes at the same level of the name node, and maintain the name variable Keyname and list L. If the current node is in S1, add Keyname and the concatenated L as the determined parsing results to the parsing result list, update Keyname, and set L to empty; if the current node is in S2, obtain the value of the current node through the content value XPath and append it to L.

[0098] Step S42125, repeat step S42121 until all nodes at the same level are processed.

[0099] Step S422, merging the result lists obtained by each parser, and adding the result lists to the data set D3.

[0100] Step S43, write the data set D3 into a csv file, and the parsing is now complete.

[0101] The XML electronic medical record automatic parsing method of the embodiment of the present invention automatically parses XML electronic medical records by combining assumptions and statistical methods, and has the following characteristics: a wide range of applications, applicable to all XML electronic medical record data, high versatility; high deployment efficiency, and no need for manual intervention.

[0102] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0103] It is not difficult for those skilled in the art to understand that the present invention includes any combination of the invention content and specific implementation methods of the above specification and the various parts shown in the drawings. Due to the limited space and to make the specification concise, the various schemes composed of these combinations are not described one by one. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

[0104] Although the embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and cannot be understood as limiting the present invention. Those skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention without departing from the principles and purpose of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for automatic parsing of electronic medical records based on XML, characterized in that: The steps include: Step S1, input XML electronic medical record data set D1; Step S2, performing data cleaning on the electronic medical record data set to generate a cleaned data set D2; Step S3, automatically generating a configuration for the cleaned data set D2, including: Sort all rows of data in data set D2 in descending order according to the length of the text content to obtain data set D3; Traverse the data set D3, and take the line with the longest text content for the same tuples to form the data set D4; Traverse each row of data in data set D4, and parse the text content value of the row of data to obtain an XML tree; Count the elements in the list and take the nested parsed text name value with the largest number of occurrences, recorded as X1; Locate the first element node in the XML tree from X1, take all the sibling leaf nodes of the node, traverse in the order of the sibling leaf nodes, and classify the sibling leaf nodes into two categories: name nodes and content nodes. The classification is based on whether the node text value or attribute value exists in the standard text name dictionary. Repeat this step until all nodes are processed. All name nodes and content nodes are counted according to the tag names, and the nodes with the most tag names are selected as flat name nodes and flat content nodes respectively; if the tag names of the flat name node and the flat content node are consistent, the text name, text content location and value selection method of the flat parsing are generated, which are recorded as X3; According to the value-taking method of the X3 text content, a nested parsing text content positioning and value-taking method is generated, which is recorded as X2; Concatenate X1 and X2 to obtain the text name, text content location and value method of the nested analysis, and then write them into the database together with X3; Complete automatic parsing configuration generation; Step S4, after the configuration is completed, parse the electronic medical record data, including: Obtain the electronic medical record parsing configuration list C1 from the database; Traverse each row of data in the data set D2, and process the data by the parser in the parsing configuration list C1, wherein the parser includes a flat parser and a nested parser; select the corresponding parser for parsing according to the configuration information of the data; merge the result list obtained by each parser, and add the result list to the data set D3; Write the data set D3 into a csv file and the parsing is complete.

2. The method for automatic parsing of electronic medical records based on XML as claimed in claim 1, characterized in that: In the step S1, the electronic medical record data set D1 includes: medical record number, medical record name, text name and text content.

3. The method for automatic parsing of electronic medical records based on XML as claimed in claim 1, characterized in that: In step S2, the data cleaning includes the following steps: deleting data with missing fields and deleting data whose values ​​are not within the reasonable value range of the fields.

4. The method for automatic parsing of electronic medical records based on XML as claimed in claim 1, characterized in that: In step S3, the data set D3 is traversed, and for the same medical record name and text name, the line with the longest text content is taken to form a data set D4.

5. The method for automatic parsing of electronic medical records based on XML as claimed in claim 1, characterized in that: In step S3, traversing each row of data in the data set D4 and parsing the text content value of the row of data to obtain an XML tree includes the following steps: Recursively traverse all non-leaf nodes of the XML tree using depth-first traversal DFS; For each node, determine whether all its attribute values ​​exist in the standard text name set. If so, add them to the list L1 and terminate the traversal of all child nodes of the node. If not, continue to recursively traverse the child nodes of the node. Repeat the above steps until all nodes are processed.

6. The method for automatic parsing of electronic medical records based on XML as claimed in claim 1, characterized in that: In step S4, the tile parser parsing process is as follows: Initialize the tile parser, and get the initial information from the parsing configuration list C1; Parse the text content of the row data into an XML tree; Search the XML tree through name XPath to obtain all name nodes, recorded as S1; search the XML tree through content XPath to obtain all content nodes, recorded as S2; Sequentially traverse the nodes at the same level of the name node, and maintain the name variable Keyname and list L. If the current node is in S1, add Keyname and the concatenated L as the determined parsing result to the parsing result list, update Keyname, and set L to empty; if the current node is in S2, obtain the value of the current node through the content value XPath and append it to L; Repeat the above steps until all sibling nodes are processed.

7. The method for automatic parsing of electronic medical records based on XML as claimed in claim 1, characterized in that: In step S4, the nested parser parsing process is as follows: Initialize the nested parser, and get the initial information from the parsing configuration list C1; Parse the text content of the row data into an XML tree; Search the XML tree by name XPath to get all name nodes; For each name node, obtain the name value according to the name value XPath, and then obtain the content value according to the content XPath and content value XPath, and add the tuple to the parsing result list; Repeat the above steps until all name nodes are processed.

8. The method for automatic parsing of electronic medical records based on XML as claimed in claim 1, characterized in that: The parser configuration for the data set includes the following forms: (1) Tiled parser; (2) Nested parsers; (3) Flat parser and nested parser; (4) No parsing required.

Citation Information

Patent Citations

  • Automatic electronic medical record analysis method and device

    CN113361254A

  • Electronic medical record document editor

    CN103425465A

  • Remote diagnosis and treatment system

    CN106407680A

  • Electronic medical record data analysis method and device, computer and readable storage medium

    CN109036576A

  • XML data reading method and device, computer equipment and storage medium

    CN110110150A