Electronic medical record-oriented data query method, device and equipment and medium
By automatically generating SQL statements using a large language model and medical record knowledge tree, the problem of non-professionals having difficulty querying electronic medical record databases has been solved, achieving efficient and accurate information retrieval, lowering the barrier to entry and improving the success rate of queries.
Patent Information
- Application Number
- CN202511559482.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-29
- Publication Date
- 2026-02-10
AI Technical Summary
Non-professionals find it difficult to efficiently and accurately retrieve the information they need from the complex electronic medical record database. Existing technologies suffer from low query efficiency, low accuracy, inability to handle multi-table join queries, and limitations in user knowledge.
The system identifies user query intent using a pre-trained large language model, generates SQL statements, and performs database queries. It then uses a medical record knowledge tree to traverse layer by layer to automatically generate SQL statements and prompts the user for missing information to complete the data when the query fails.
It improves the convenience and efficiency of non-professionals in querying information from electronic medical record databases, lowers the barrier to entry, avoids SQL errors and manual intervention, and increases the success rate of queries.
Smart Images

Figure CN121506346A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent medical technology, and in particular to a data query method, apparatus, device, and medium for electronic medical records. Background Technology
[0002] Against the backdrop of rapid development in digital healthcare, electronic medical records have become a core data resource for hospitals, containing patient diagnosis and treatment information that is of significant value for clinical research, medical quality assessment, and hospital management decisions. However, healthcare professionals, as the primary data users, typically lack professional database querying skills and struggle to directly extract necessary information from structured databases. Current data query processes rely on manual processing by the IT department, resulting in long response times and low efficiency, severely hindering data-driven medical decision-making and research progress. Therefore, there is an urgent need to develop an intelligent data query technology capable of understanding natural language and automatically generating query statements to lower the barrier to entry, improve data acquisition efficiency, and support real-time response and scientific decision-making in healthcare.
[0003] Currently, existing technologies still have significant limitations in data querying for electronic medical records. For example, some methods rely on multiple rounds of interaction and supervised fine-tuning, resulting in low query efficiency and accuracy; other methods, while supporting single-table queries, lack multi-table join mechanisms, making it difficult to handle complex cross-table join queries in real-world medical scenarios; furthermore, some solutions do not fully consider the cognitive limitations of non-professional users when generating query statements, requiring users to understand database structure or metadata information, leading to difficulties in effective interaction in practical applications and limiting the technology's widespread adoption and practical value. Summary of the Invention
[0004] This invention provides a data query method, apparatus, device, and medium for electronic medical records, which can solve the problem that non-professionals find it difficult to efficiently and accurately query the required information from a complex electronic medical record database.
[0005] In a first aspect, embodiments of the present invention provide a data query method for electronic medical records, including:
[0006] The user query statement is obtained, and the intent of the user query statement is recognized by a pre-trained large language model to obtain query entity information.
[0007] Based on the query entity information, the pre-constructed medical record knowledge tree is traversed layer by layer to generate the corresponding SQL statement; wherein, the medical record knowledge tree is constructed based on the table structure and metadata of the preset electronic medical record database;
[0008] According to the SQL statement, a data query is performed on the electronic medical record database to obtain the data query results;
[0009] If the SQL statement execution fails, the large language model will generate a corresponding user prompt statement to ask the user for the missing data.
[0010] This invention transforms user natural language requests into standardized entities recognizable by the system through a large language model, solving the problem of non-standard user language and difficulty in direct system parsing. By leveraging the structured characteristics of knowledge trees, it accurately matches corresponding SQL templates, avoiding SQL errors caused by rule-based generation, while ensuring database storage logic is adapted to medical scenarios. Automatically generated SQL statements execute data retrieval, directly responding to user queries and replacing the cumbersome process of traditional manual approval combined with IT personnel execution. By proactively completing key information, it solves the problem of query failures due to incomplete user input, improving the query success rate. Compared with existing technologies, this invention improves the convenience and efficiency for non-professionals to retrieve required information from complex medical record databases.
[0011] Furthermore, the process of using a pre-trained large language model to perform intent recognition on the user query statement and obtain query entity information specifically involves:
[0012] Based on the user's query and the preset node options in the medical record knowledge tree, a prompt is constructed for the current query; wherein, the node options include: doctor, nurse, patient, hospital, and department;
[0013] Using the large language model, the user query statement is standardized and semantically mapped according to the prompt to obtain the query entity information.
[0014] This invention provides a clear parsing standard for the large language model by generating corresponding prompts based on user queries, avoiding the generation of irrelevant entities and ensuring the standardization of entity extraction. By performing standardized mapping through the large language model, it unifies the expression methods of different users, making subsequent knowledge tree traversal and SQL generation more accurate.
[0015] Furthermore, the step of traversing the pre-constructed medical record knowledge tree layer by layer based on the queried entity information to generate the corresponding SQL statement specifically involves:
[0016] The query entity information is matched and judged layer by layer with the child nodes of the medical record knowledge tree in order to reach the corresponding target node from the root node of the medical record knowledge tree, and the corresponding SQL template is extracted from the target node.
[0017] Based on the query entity information, the SQL template is used to generate the corresponding SQL statement.
[0018] This invention utilizes the hierarchical structure of a knowledge tree to accurately locate suitable scenarios, ensuring that the SQL template is highly matched with user needs and avoiding template misuse. By embedding standardized entities in the SQL template, executable SQL statements can be quickly generated without requiring user participation in SQL writing, thus lowering the barrier to entry.
[0019] Furthermore, the step of generating corresponding user prompt statements through the large language model to ask the user for follow-up information on the missing data specifically involves:
[0020] When the SQL statement does not meet the preset query conditions, the node options of the traversed nodes and the node options of the current node are backtracked according to the current node of the medical record knowledge tree to obtain the relevant node option set.
[0021] Obtain historical interaction information and SQL error information, and determine the user's missing information based on the relevant node option set, historical interaction information, and SQL error information;
[0022] Based on the missing user information, the large language model generates corresponding user prompt statements.
[0023] This invention, through obtaining relevant node options, locates the scope of missing information and clarifies the type of information that needs to be supplemented, avoiding untargeted follow-up questions; it accurately judges missing content by comprehensively considering multi-dimensional information, avoiding misjudgment; and it generates user-friendly language through a large language library to initiate follow-up questions, ensuring that non-IT professionals can clearly understand the direction for supplementation and improving the interactive experience.
[0024] Furthermore, it also includes:
[0025] The system obtains supplementary query information and historical user query statements entered by the user again, and regenerates SQL statements based on the supplementary query information and historical user query statements using the large language model and the medical record knowledge tree, so as to perform data query based on the regenerated SQL statements.
[0026] This invention avoids information loss by using user query statements, improves query conditions by combining supplementary information, and ensures that the regenerated SQL meets user needs, forming a complete interactive loop.
[0027] Secondly, embodiments of the present invention provide a data query device for electronic medical records, including an intent recognition module, an SQL statement generation module, a query result acquisition module, and a prompt statement generation module, wherein...
[0028] The intent recognition module is used to acquire user query statements and perform intent recognition on the user query statements using a pre-trained large language model to obtain query entity information.
[0029] The SQL statement generation module is used to traverse the pre-built medical record knowledge tree layer by layer according to the query entity information to generate the corresponding SQL statement; wherein, the medical record knowledge tree is constructed according to the table structure and metadata of the preset electronic medical record database;
[0030] The query result acquisition module is used to perform data query on the electronic medical record database according to the SQL statement in order to obtain data query results;
[0031] The prompt statement generation module is used to generate a corresponding user prompt statement through the large language model if the SQL statement execution fails, so as to ask the user for the corresponding missing data.
[0032] This invention employs an intent recognition module, utilizing a large language model to transform user natural language requests into standardized entities recognizable by the system, addressing the issues of non-standard user language and difficulty in direct system parsing. An SQL statement generation module leverages the structured characteristics of knowledge trees to accurately match corresponding SQL templates, avoiding SQL errors caused by rule-based generation while ensuring compatibility with database storage logic in medical scenarios. A query result retrieval module automatically generates SQL statements to perform data retrieval, directly responding to user query requests and replacing the cumbersome process of traditional manual approval combined with IT personnel execution. Finally, a prompt statement generation module proactively completes key information, resolving query failures due to incomplete user input and improving query success rates.
[0033] Furthermore, the intent recognition module includes a prompt word generation unit and a normalization mapping unit, wherein,
[0034] The prompt generation unit is used to construct a prompt for the current query based on the user query and preset node options in the medical record knowledge tree; wherein, the node options include: doctor, nurse, patient, hospital, and department;
[0035] The standardized mapping unit is used to perform standardized semantic mapping on the user query statement based on the prompt, using the large language model, to obtain query entity information.
[0036] This invention provides a prompt word generation unit that generates corresponding prompts based on user queries, providing a clear parsing standard for the large language model, avoiding the generation of irrelevant entities, and ensuring the standardization of entity extraction. Through a standardization mapping unit, the large language model is used for standardized mapping, unifying the expression methods of different users, and making subsequent knowledge tree traversal and SQL generation more accurate.
[0037] Furthermore, the SQL statement generation module includes an SQL template acquisition unit and an SQL generation unit, wherein,
[0038] The SQL template acquisition unit is used to match and judge the query entity information with the child nodes of the medical record knowledge tree layer by layer, so as to reach the corresponding target node from the root node of the medical record knowledge tree, and extract the corresponding SQL template from the target node.
[0039] The SQL generation unit is used to generate corresponding SQL statements based on the query entity information using the SQL template.
[0040] This invention provides an embodiment of the SQL template acquisition unit that uses the hierarchical structure of a knowledge tree to accurately locate suitable scenarios, ensuring that the SQL template is highly matched with user needs and avoiding template misuse. The SQL generation unit embeds standardized entities into the SQL template to quickly generate executable SQL statements without requiring user participation in SQL writing, thus lowering the barrier to entry.
[0041] Thirdly, embodiments of the present invention provide a terminal device, including: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus;
[0042] The memory is used to store at least one executable instruction that causes the processor to perform the operation of the data query method for electronic medical records as described in any of the above.
[0043] Fourthly, embodiments of the present invention provide a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device or apparatus containing the computer-readable storage medium to perform the data query method for electronic medical records as described in any of the preceding claims.
[0044] The above description is merely an overview of the technical solutions of the embodiments of the present invention. In order to better understand the technical means of the embodiments of the present invention and to implement them in accordance with the contents of the specification, and to make the above and other objects, features and advantages of the embodiments of the present invention more apparent and understandable, specific embodiments of the present invention are described below. Attached Figure Description
[0045] Figure 1 This is a schematic diagram of a data query method for electronic medical records provided in an embodiment of the present invention;
[0046] Figure 2 This invention provides a data query model architecture diagram for electronic medical records.
[0047] Figure 3 This is a structural diagram of a data query device for electronic medical records provided in an embodiment of the present invention. Detailed Implementation
[0048] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0049] Example 1:
[0050] like Figure 1 As shown, an embodiment of the present invention provides a data query method for electronic medical records, comprising the following steps:
[0051] S101, Obtain the user's query statement, and use a pre-trained large language model to perform intent recognition on the user's query statement to obtain query entity information;
[0052] In this embodiment, the step of using a pre-trained large language model to perform intent recognition on the user query statement to obtain query entity information specifically involves: constructing a prompt for the current query based on the user query statement and preset node options in the medical record knowledge tree; wherein, the node options include: doctor, nurse, patient, hospital, and department; and using the large language model, performing standardized semantic mapping on the user query statement based on the prompt to obtain query entity information.
[0053] In one specific embodiment, a user-friendly interface is provided for medical staff, who can input their data query needs on the interface;
[0054] Furthermore, the large language model layer parses the user input based on the promise, identifies the user's intent, extracts relevant entity information such as roles, diagnoses, and surgeries, as well as time information, and passes it to the next layer.
[0055] Specifically, this involves reading the standard options required by the knowledge tree nodes, embedding these standard options into the LLM prompts, and then using standardized prompts to require the LLM to extract options based on the user's input text. This ensures both standardized use of the knowledge base and flexible recognition of the patient's intent.
[0056] For example, the form of the prompt generated by the prompt is as follows:
[0057] prompt = f"""Refer to the example below, extract the time range mentioned in the input, and select the entities and their names mentioned in the input from the options. Answers other than those in the options are not allowed.
[0058] <Options>
[0059] Doctor, nurse, patient, hospital, department
[0060] <Example>
[0061] Input: How many femtosecond LASIK surgeries did Dr. Li Si perform in May 2018?
[0062] Output: May 1, 2018 to May 31, 2018 @ Doctors, Surgeons
[0063] Input: How many patients did the cataract department treat in the first quarter of 2019?
[0064] Output: January 1, 2019 to April 30, 2019 @Department, Patient
[0065] Input: Who am I?
[0066] Output: @
[0067] <Question>
[0068] Input: {user_input}
[0069] Output:
[0070] """
[0071] S102, based on the query entity information, the pre-constructed medical record knowledge tree is traversed layer by layer to generate the corresponding SQL statement; wherein, the medical record knowledge tree is constructed based on the table structure and metadata of the preset electronic medical record database;
[0072] In this embodiment, the step of traversing the pre-constructed medical record knowledge tree layer by layer according to the query entity information to generate the corresponding SQL statement specifically involves: matching the query entity information layer by layer with the child nodes of the medical record knowledge tree to reach the corresponding target node from the root node of the medical record knowledge tree, and extracting the corresponding SQL template from the target node; and generating the corresponding SQL statement according to the query entity information using the SQL template.
[0073] In one specific embodiment, the SQL generation and execution layer adopts a SQL generation strategy that combines template-based and knowledge tree-based methods. Based on the SQL template predefined by the system, the time information and entity information extracted in the previous step are used as input. The knowledge tree is traversed step by step from the main branch to the branches until the SQL template corresponding to the terminal node is reached. Finally, the time information and entity information are filled in according to the template, the search conditions are established, and the SQL statement is generated.
[0074] For example, if the extracted time information is from January 1, 2019 to April 30, 2019, and the entity information includes the department (Cataract Department) and the patient, then the knowledge tree is traversed starting from the root node. The branch of the child node that matches the first entity "department" is found. Then, the branch of the child node is moved down to the next level of child nodes to find the node that matches the second entity "patient". At this point, the matching of all entities has been completed. Then, the SQL template (SELECT COUNT(*) FROM TABLE WHERE KESHI='{DepartmentName}' AND STARTTIME>='{startdate}' AND ENDTIME<='{enddate}') in the current node can be called to insert the time information, entity name and other filtering conditions to generate the SQL statement (SELECT COUNT(*) FROM TABLE WHERE KESHI='Cataract Department' AND STARTTIME>='2019-1-1' AND ENDTIME<='2019-4-30').
[0075] S103, perform a data query on the electronic medical record database according to the SQL statement to obtain the data query results;
[0076] In one specific embodiment, a query operation is performed in the electronic medical record database using the generated SQL statement to obtain the query results. The database stores detailed information about the electronic medical record data, mainly including basic patient information, diagnostic information, surgical information, etc.
[0077] S104. If the SQL statement execution fails, the corresponding user prompt statement is generated through the large language model to ask the user for the missing data.
[0078] In this embodiment, generating corresponding user prompt statements through the large language model to ask the user for corresponding missing data specifically involves: when the SQL statement does not meet the preset query conditions, based on the current node of the medical record knowledge tree, tracing back the node options of the traversed nodes and the node options of the current node to obtain the relevant node option set; acquiring historical interaction information and SQL error information, and determining the user's missing information based on the relevant node option set, historical interaction information, and SQL error information; and generating corresponding user prompt statements based on the user's missing information through the large language model.
[0079] In this embodiment, the method further includes: obtaining supplementary query information and historical user query statements input by the user again, and regenerating SQL statements based on the supplementary query information and historical user query statements using the large language model and the medical record knowledge tree, so as to perform data query based on the regenerated SQL statements.
[0080] In one specific embodiment, if the SQL execution fails, the process returns to the Large Language Model layer. The LLM determines whether valid time information has been extracted or whether the generated SQL statement is complete based on the error message, and generates follow-up questions about time information or entity information. These questions are then posed to the user through the user interface layer, requesting the user to supplement the missing information, and the aforementioned steps are repeated.
[0081] Specifically, when an SQL execution error message appears, the system will traverse all nodes currently visited in the knowledge tree, extracting relevant options selected at previous nodes and available options for the current node. Simultaneously, it will combine the user's dialogue history with the node options and the SQL error message to form a unified prompt. The LLM (Local Management Module) will then refer to the error message, node options, and dialogue history to determine the missing key information in the user's input and conduct follow-up questions. After the user responds, the system will again extract the missing information based on the error message, node options, and dialogue history, and continue the original system flow. If the system flow cannot continue, the execution error will be extracted again, and follow-up questions will be repeated, up to three rounds.
[0082] For example, if the error message is "local variable STARTTIME referenced before assignments.", the LLM will parse the error message and generate a follow-up question: "Time information not recognized. What are the start and end dates of the data you are querying?".
[0083] In one specific embodiment, if the SQL is executed correctly and returns query results, the query results are displayed to the user in an intuitive way through the user interface layer.
[0084] To better illustrate the working principle and steps of this method, see [link / reference]. Figure 2 One example, Figure 2 This is a data query model architecture diagram for electronic medical records provided in an embodiment of the present invention.
[0085] This invention transforms user natural language requests into standardized entities recognizable by the system through a large language model, solving the problem of non-standard user language and difficulty in direct system parsing. By leveraging the structured characteristics of knowledge trees, it accurately matches corresponding SQL templates, avoiding SQL errors caused by rule-based generation, while ensuring database storage logic is adapted to medical scenarios. Automatically generated SQL statements execute data retrieval, directly responding to user queries and replacing the cumbersome process of traditional manual approval combined with IT personnel execution. By proactively completing key information, it solves the problem of query failures due to incomplete user input, improving the query success rate. Compared with existing technologies, this invention improves the convenience and efficiency for non-professionals to retrieve required information from complex medical record databases.
[0086] Example 2:
[0087] like Figure 3 As shown, this embodiment provides a data query device for electronic medical records, including an intent recognition module 201, an SQL statement generation module 202, a query result acquisition module 203, and a prompt statement generation module 204, wherein...
[0088] The intent recognition module 201 is used to acquire the user's query statement and perform intent recognition on the user's query statement through a pre-trained large language model to obtain query entity information.
[0089] In this embodiment, the intent recognition module 201 includes a prompt word generation unit 2011 and a standardization mapping unit 2012. The prompt word generation unit 2011 is used to construct a prompt for the current query based on the user query and preset node options in the medical record knowledge tree. The node options include: doctor, nurse, patient, hospital, and department. The standardization mapping unit 2012 is used to perform standardized semantic mapping on the user query based on the prompt using the large language model to obtain query entity information.
[0090] The SQL statement generation module 202 is used to traverse the pre-built medical record knowledge tree layer by layer according to the query entity information to generate the corresponding SQL statement; wherein, the medical record knowledge tree is constructed according to the table structure and metadata of the preset electronic medical record database.
[0091] In this embodiment, the SQL statement generation module 202 includes an SQL template acquisition unit 2021 and an SQL generation unit 2022. The SQL template acquisition unit 2021 is used to match and judge the query entity information layer by layer with the child nodes of the medical record knowledge tree to reach the corresponding target node from the root node of the medical record knowledge tree, and extract the corresponding SQL template from the target node. The SQL generation unit 2022 is used to generate the corresponding SQL statement based on the query entity information using the SQL template.
[0092] The query result acquisition module 203 is used to perform data query on the electronic medical record database according to the SQL statement in order to obtain data query results;
[0093] The prompt statement generation module 204 is used to generate a corresponding user prompt statement through the large language model if the SQL statement execution fails, so as to ask the user for the corresponding missing data.
[0094] For a more detailed explanation of the working principle and procedures of this embodiment, please refer to the relevant description in Embodiment 1.
[0095] This invention, through its intent recognition module 201, uses a large language model to transform user natural language requests into standardized entities recognizable by the system, solving the problem of non-standard user language and difficulty in direct system parsing. Through its SQL statement generation module 202, it utilizes the structured characteristics of a knowledge tree to accurately match corresponding SQL templates, avoiding SQL errors caused by rule-based generation while ensuring database storage logic is compatible with medical scenarios. Through its query result acquisition module 203, it automatically generates SQL statements to perform data retrieval, directly responding to user query requests and replacing the cumbersome process of traditional manual approval combined with IT personnel execution. Through its prompt statement generation module 204, it proactively completes key information, solving the problem of query failures due to incomplete user input and improving the query success rate.
[0096] Example 3:
[0097] This embodiment provides a terminal device, including: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus;
[0098] The memory is used to store at least one executable instruction that causes the processor to perform the operation of the data query method for electronic medical records as described in any of the above.
[0099] Example 4:
[0100] This invention provides a computer-readable storage medium comprising a stored computer program, wherein, when the computer program is executed, it controls the device or apparatus containing the computer-readable storage medium to perform a data query method for electronic medical records as described above.
[0101] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0102] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. In particular, it should be noted that any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention for those skilled in the art.
Claims
1. A data query method for electronic medical records, characterized in that, include: The user query statement is obtained, and the intent of the user query statement is recognized through a pre-trained large language model to obtain query entity information; Based on the query entity information, the pre-constructed medical record knowledge tree is traversed layer by layer to generate the corresponding SQL statement; wherein, the medical record knowledge tree is constructed based on the table structure and metadata of the preset electronic medical record database; According to the SQL statement, a data query is performed on the electronic medical record database to obtain the data query results; If the SQL statement execution fails, the large language model will generate a corresponding user prompt statement to ask the user for the missing data.
2. The data query method for electronic medical records as described in claim 1, characterized in that, The process of using a pre-trained large language model to perform intent recognition on the user's query statement and obtain query entity information specifically involves: Based on the user's query and the preset node options in the medical record knowledge tree, a prompt is constructed for the current query; wherein, the node options include: doctor, nurse, patient, hospital, and department; Using the large language model, the user query statement is standardized and semantically mapped according to the prompt to obtain the query entity information.
3. The data query method for electronic medical records as described in claim 1, characterized in that, The step of traversing the pre-constructed medical record knowledge tree layer by layer based on the queried entity information to generate the corresponding SQL statement is as follows: The query entity information is matched and judged layer by layer with the child nodes of the medical record knowledge tree in order to reach the corresponding target node from the root node of the medical record knowledge tree, and the corresponding SQL template is extracted from the target node. Based on the query entity information, the SQL template is used to generate the corresponding SQL statement.
4. The data query method for electronic medical records as described in claim 1, characterized in that, The process of generating corresponding user prompt statements using the large language model to ask the user for follow-up information on missing data is as follows: When the SQL statement does not meet the preset query conditions, the node options of the traversed nodes and the node options of the current node are backtracked according to the current node of the medical record knowledge tree to obtain the relevant node option set. Obtain historical interaction information and SQL error information, and determine the user's missing information based on the relevant node option set, historical interaction information, and SQL error information; Based on the missing user information, the large language model generates corresponding user prompt statements.
5. A data query method for electronic medical records as described in claim 4, characterized in that, Also includes: The system obtains supplementary query information and historical user query statements entered by the user again, and regenerates SQL statements based on the supplementary query information and historical user query statements using the large language model and the medical record knowledge tree, so as to perform data query based on the regenerated SQL statements.
6. A data query device for electronic medical records, characterized in that, It includes an intent recognition module, an SQL statement generation module, a query result retrieval module, and a prompt statement generation module, among which, The intent recognition module is used to acquire user query statements and perform intent recognition on the user query statements using a pre-trained large language model to obtain query entity information. The SQL statement generation module is used to traverse the pre-built medical record knowledge tree layer by layer according to the query entity information to generate the corresponding SQL statement; wherein, the medical record knowledge tree is constructed according to the table structure and metadata of the preset electronic medical record database; The query result acquisition module is used to perform data query on the electronic medical record database according to the SQL statement in order to obtain data query results; The prompt statement generation module is used to generate a corresponding user prompt statement through the large language model if the SQL statement execution fails, so as to ask the user for the corresponding missing data.
7. A data query device for electronic medical records as described in claim 6, characterized in that, The intent recognition module includes a prompt word generation unit and a normalization mapping unit, wherein, The prompt generation unit is used to construct a prompt for the current query based on the user query and preset node options in the medical record knowledge tree; wherein, the node options include: doctor, nurse, patient, hospital, and department; The standardized mapping unit is used to perform standardized semantic mapping on the user query statement based on the prompt, using the large language model, to obtain query entity information.
8. A data query device for electronic medical records as described in claim 6, characterized in that, The SQL statement generation module includes an SQL template acquisition unit and an SQL generation unit, wherein, The SQL template acquisition unit is used to match and judge the query entity information with the child nodes of the medical record knowledge tree layer by layer, so as to reach the corresponding target node from the root node of the medical record knowledge tree, and extract the corresponding SQL template from the target node. The SQL generation unit is used to generate corresponding SQL statements based on the query entity information using the SQL template.
9. A terminal device, characterized in that, include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction that causes the processor to perform the operation of the data query method for electronic medical records as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device or apparatus containing the computer-readable storage medium to perform the data query method for electronic medical records as described in any one of claims 1 to 7.