Source data acquisition method, system and terminal for rule engine
By generating a rule inference diagram in the rule engine and analyzing the source data of business rules, the problem of lack of inference paths and basis in the rule engine is solved, and the rapid and accurate adjustment of business rules and stability guarantees are achieved.
Patent Information
- Application Number
- CN202410293571.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-14
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2044-03-14
AI Technical Summary
In the prior art, the rule engine lacks the inference path and reasoning basis for business rules, which makes it difficult to adjust business rules, high cost and inability to guarantee accuracy.
By compiling each business rule in the rule engine, a rule inference diagram is generated, including the association between business rules, rule execution results and data retrieval conditions. Based on the input original fact data, business rules are activated and executed, the activated business rules and their data retrieval conditions are determined, and the data retrieval conditions are performed to obtain source data.
It realizes that while executing the rule engine, it obtains and parses the relevant source data for activate business rules in real time, and deeply demonstrates the inference path of business rules, which helps to quickly and accurately adjust business rules, discover noise or design omissions, and ensures the accuracy and stability of business rules.
Smart Images

Figure CN118228813B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer computing, and in particular to a source data acquisition method, system and terminal for a rule engine. Background Art
[0002] With the rapid development of digitalization, informatization and intelligence of modern technology, clinical decision support systems can utilize artificial intelligence technologies such as neural networks, natural language processing and machine learning, and receive patients' clinical data and other multi-dimensional information (such as gene sequencing results, drug allergy history, etc.) based on rule engines, interpret business rules, and intelligently match preset decision logic, so as to provide doctors with accurate and personalized treatment recommendations, as well as provide patients with recommended treatment plans, disease warnings, condition assessment and other information.
[0003] Among them, the rule engine is used to separate business rules from application code and centrally manage business rules. It can support dynamic modification of business rules to quickly adapt to corresponding changes in demand. And the use of rule engines in the medical field can not only improve the efficiency and quality of medical services, but also promote the rational use of medical resources and achieve fairness and accessibility of medical services. Therefore, the rationality and effectiveness of business rules in the rule engine have always been the key challenges faced by the rule engine. The setting of business rules is often based on the authoritative results of clinical research.
[0004] However, in actual clinical practice, business rules usually need to be constantly adjusted according to the specific conditions of patients, the personalized needs of doctors, and the constantly updated medical knowledge. However, in the current standard operating procedures of the rule engine, after the business rules are compiled, the rule engine can only output the corresponding results based on the input data, and cannot clearly display the reasoning path and reasoning basis of the business rules. Due to the complexity of business logic and the increase in the number of business rules, adjusting business rules has become more complicated and difficult. Worse, due to the noise in the input data or omissions in the design of business rules, the actual output results are often very different from expectations. Not only may it affect the stability of business rules, it is more likely to introduce logical errors, thereby affecting the accuracy of the final output medical decision, or misdiagnosis, or affecting the patient's treatment results, and even threatening the patient's health and life.
[0005] At present, the correctness of each rule node is ensured by manual debugging of each rule node, and then the reasoning logic tree of the entire business rule is debugged. The entire adjustment process is heavily dependent on the capabilities of clinical medical personnel and information professionals, with high labor costs and the inability to continuously and accurately complete business rule adjustments. Summary of the invention
[0006] In view of the shortcomings of the prior art described above, the purpose of the present application is to provide a source data acquisition method, system and terminal for a rule engine, so as to solve the problems in the prior art that the rule engine lacks reasoning paths and reasoning basis corresponding to business rules, resulting in difficulty in adjusting business rules, high costs and lack of accuracy.
[0007] To achieve the above-mentioned purpose and other related purposes, the first aspect of the present application provides a source data acquisition method for a rule engine, the source data acquisition method for a rule engine comprising: compiling each business rule in the rule engine and generating a rule reasoning relationship diagram; wherein the rule reasoning relationship diagram comprises: the association relationship between each business rule in the rule engine, the rule execution results corresponding to each business rule, and the data retrieval conditions corresponding to each business rule; based on the input original fact data, activating and executing one or more business rules in the rule engine, and obtaining the corresponding rule execution results; based on the rule reasoning relationship diagram, according to the obtained rule execution results, determining the activated business rules and the corresponding data retrieval conditions in the rule engine; executing the determined data retrieval conditions, and obtaining the source data corresponding to the activated business rules in the rule engine.
[0008] In some embodiments of the first aspect of the present application, the method of generating a rule reasoning relationship graph includes: compiling each business rule in the rule engine and generating structured rule information for each business rule to obtain the rule conditions and rule execution results corresponding to each business rule in the rule engine; taking the association relationship between each business rule in the rule engine and the corresponding rule execution result as a graph node to generate a primary rule reasoning relationship graph; parsing the rule conditions corresponding to each business rule in the rule engine, and generating data retrieval conditions corresponding to each business rule to construct a data retrieval condition relationship table; based on the primary rule reasoning relationship tree and in combination with the constructed data retrieval condition relationship table, taking the association relationship between each business rule in the rule engine, the data retrieval conditions corresponding to each business rule, and the rule execution results corresponding to each business rule as a graph node to generate a final rule reasoning relationship graph.
[0009] In some embodiments of the first aspect of the present application, the method of generating data retrieval conditions corresponding to each business rule includes: parsing the rule conditions corresponding to each business rule in the rule engine, and eliminating one or more logical statements containing aggregation conditions, existence judgments, and unrecognizable sentence patterns in the generated logical statements, to generate data retrieval conditions corresponding to each business rule in the rule engine.
[0010] In some embodiments of the first aspect of the present application, based on the input original fact data, activating and executing one or more business rules in the rule engine, and obtaining corresponding rule execution results include: setting the execution parameters of the rule engine, and querying the database to obtain the original fact data; inputting the obtained original fact data into the rule engine, activating and executing one or more business rules in the rule engine, and obtaining one or more corresponding rule execution results.
[0011] In some embodiments of the first aspect of the present application, determining the business rules activated in the rule engine and the corresponding data retrieval conditions based on the rule reasoning relationship graph and the obtained rule execution results includes: marking the corresponding graph nodes of the rule execution results in the rule reasoning relationship graph in sequence according to the association relationship and dependency order between the business rules in the rule reasoning relationship graph, and obtaining the business rules in the marked graph nodes and the data retrieval conditions corresponding to the business rules, so as to determine the business rules activated in the rule engine and the corresponding data retrieval conditions.
[0012] In some embodiments of the first aspect of the present application, the source data acquisition method for a rule engine further includes: visually rendering the source data corresponding to the business rules activated in the obtained rule engine, and outputting the rendered result data.
[0013] In some embodiments of the first aspect of the present application, the visual rendering of the source data corresponding to the business rules activated in the obtained rule engine and the output of the rendered result data include: determining the source of the source data corresponding to the business rules activated in the obtained rule engine; if the source of the source data is determined to be a data table, outputting the corresponding original data table obtained and marking the matching result data; if the source of the source data is determined to be text, determining the condition type of the data retrieval condition executed by the source data, and outputting the corresponding text output operation based on the determined condition type.
[0014] In some embodiments of the first aspect of the present application, the text output operation corresponding to the output based on the judged condition type includes: if the condition type is judged to be a regular matching condition, output the original text corresponding to the acquired source data, and mark the matching result text; if the condition type is judged to be a formula calculation condition, output the formula text corresponding to the acquired source data and the variable data and result data used for the formula calculation; if the condition type is judged to be a Boolean calculation condition, output the original text corresponding to the acquired source data, and mark the matching result text; if the condition type is judged to be other conditions, output the content of the source data converted into text.
[0015] To achieve the above-mentioned purpose and other related purposes, the second aspect of the present application provides a source data acquisition system for a rule engine, the source data acquisition system for a rule engine comprising: a business rule compilation module, which is used to compile each business rule in the rule engine and generate a rule reasoning relationship diagram; wherein the rule reasoning relationship diagram comprises: the association relationship between each business rule in the rule engine, the rule execution result corresponding to each business rule, and the data retrieval condition corresponding to each business rule; a rule engine execution module, which is used to activate and execute one or more business rules in the rule engine based on the input original fact data, and obtain the corresponding rule execution result; a rule source data acquisition module, which is connected to the business rule compilation module and the rule engine execution module, and is used to determine the activated business rules and corresponding data retrieval conditions in the rule engine based on the rule reasoning relationship diagram and the obtained rule execution results; and execute the determined data retrieval conditions and obtain the source data corresponding to the activated business rules in the rule engine.
[0016] To achieve the above-mentioned purpose and other related purposes, the third aspect of the present application provides an electronic terminal, including: a processor and a memory; the memory is used to store computer programs, and the processor is used to execute the computer programs stored in the memory, so that the terminal executes any of the above-mentioned source data acquisition methods for the rule engine.
[0017] As described above, the present application provides a source data acquisition method, system and terminal for a rule engine, which compiles each business rule in the rule engine while executing the rule engine to obtain the rule execution result, and generates a rule reasoning relationship diagram based on the association between each business rule and the corresponding rule execution result and data retrieval condition, and then determines the activated business rules and corresponding data retrieval conditions in the rule engine based on the generated rule reasoning relationship diagram and the obtained rule execution result, so as to obtain the corresponding source data by executing the determined data retrieval condition; the present invention acquires and parses the relevant source data of the activated business rules in real time while executing the rule engine, deeply displays the reasoning path of the business rules, helps to quickly and accurately adjust the business rules and discover the noise or design omissions in the business rules, and fully guarantees the accuracy and stability of the business rules. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 Shown is a flowchart of a source data acquisition method for a rule engine in one embodiment of the present application.
[0019] Figure 2 Shown is a structural schematic diagram of a rule reasoning relationship diagram in one embodiment of the present application.
[0020] Figure 3Shown is a schematic diagram of a process for generating a rule reasoning relationship diagram in one embodiment of the present application.
[0021] Figure 4 Shown is a structural schematic diagram of a primary rule reasoning relationship diagram in one embodiment of the present application.
[0022] Figure 5 Shown is a schematic diagram of executing a rule engine in one embodiment of the present application.
[0023] Figure 6 Shown is a schematic diagram of determining activated rules and corresponding data retrieval conditions in an embodiment of the present application.
[0024] Figure 7 Shown is a flowchart of a source data acquisition method for a rule engine in a specific embodiment of the present application.
[0025] Figure 8 Shown is a structural diagram of a source data acquisition system for a rule engine in one embodiment of the present application.
[0026] Fig. 9 Shown is a structural diagram of a source data acquisition terminal for a rule engine in one embodiment of the present application. DETAILED DESCRIPTION
[0027] The following describes the embodiments of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. The present application can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict.
[0028] It should be noted that in the following description, with reference to the accompanying drawings, several embodiments of the present application are described in the accompanying drawings. It should be understood that other embodiments may also be used, and mechanical composition, structure, electrical and operational changes may be made without departing from the spirit and scope of the present application. The following detailed description should not be considered restrictive, and the scope of the embodiments of the present application is limited only by the claims of the published patents. The terms used here are only for describing specific embodiments and are not intended to limit the present application. Spatially related terms, such as "upper", "lower", "left", "right", "below", "below", "lower", "above", "upper", etc., may be used in the text to facilitate the description of the relationship between an element or feature shown in the figure and another element or feature.
[0029] In this application, unless otherwise clearly specified and limited, the terms "install", "connect", "connect", "fix", "hold" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0030] Furthermore, as used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless there is an indication to the contrary in the context. It should be further understood that the terms "comprise", "include" indicate the presence of the described features, operations, elements, components, items, kinds, and / or groups, but do not exclude the presence, occurrence or addition of one or more other features, operations, elements, components, items, kinds, and / or groups. The terms "or" and "and / or" used herein are interpreted as inclusive, or mean any one or any combination. Therefore, "A, B or C" or "A, B and / or C" means "any of the following: A; B; C; A and B; A and C; B and C; A, B and C". Exceptions to this definition will only occur when the combination of elements, functions or operations is inherently mutually exclusive in some way.
[0031] A rule engine refers to a component embedded in an application. Its full name is business rule management system, or BRMS (Business Rule Management System). The main idea is to separate business decisions or business rules from application code and write business rules using predefined semantic modules. The rule engine receives data input, interprets business rules, and makes business decisions based on business rules, so that business rules no longer reside in the system in a hard-coded form, but are completely independent of the application, stored in a rule base or knowledge base, and loaded into the rule engine for system calls, so that business personnel can manage business rules in a unified manner like managing data, such as querying, adding, and updating business rules. However, in the actual process of updating or adjusting business rules, the rule engine can only output the corresponding results based on the input data, and cannot clearly display the reasoning path and reasoning basis of the business rules, making it extremely difficult to update or adjust business rules. Not only is the speed slow and inefficient, but it also mainly relies on the business personnel's ability to understand the business and information capabilities, resulting in high labor costs and the inability to control the accuracy of the adjusted business rules.
[0032] Therefore, the present invention provides a source data acquisition method, system and terminal for a rule engine, aiming to solve the problems in the prior art that the rule engine lacks the reasoning path and reasoning basis corresponding to the business rules, which leads to difficulty in adjusting business rules, high cost and lack of accuracy. At the same time, in order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution in the embodiment of the present invention is further described in detail through the following embodiments and in combination with the accompanying drawings. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the invention.
[0033] like Figure 1 As shown, a flow chart of a method for acquiring source data for a rule engine in an embodiment of the present invention is shown. The method for acquiring source data for a rule engine in this embodiment mainly includes the following steps:
[0034] Step S1: Compile each business rule in the rule engine and generate a rule reasoning relationship diagram.
[0035] Among them, the rule reasoning relationship diagram is as follows Figure 2 As shown, each graph node contains a set of associations between business rules and corresponding rule execution results and data retrieval conditions, and associates different business rules based on the same rule execution results, so that after obtaining the corresponding rule execution results through the execution rule engine, it can infer and determine the activated business rules and the corresponding data retrieval conditions, and then obtain the source data of the activated business rules, so that the reasoning path and reasoning basis of the activated business rules can be quickly obtained, which is convenient for accurate adjustment of business rules, and avoids various problems such as difficulty in adjusting rules due to unfamiliarity with business rules, high cost and poor accuracy.
[0036] In one embodiment, if Figure 3 As shown, the methods for generating a rule reasoning relationship diagram include:
[0037] Step S11: compile each business rule in the rule engine and generate structured rule information for each business rule to obtain rule conditions and rule execution results corresponding to each business rule in the rule engine.
[0038] Specifically, each business rule in the rule engine is compiled, and the output information is identified with a specific object name or keyword. Taking variables as business rule output as an example, the output variable name is the keyword identifier of the output information. For example: in the business rule used to determine whether a person is an adult, the output variable name is: whether an adult. The content of the structured rule information obtained is:
[0039]
[0040] Among them, the when condition is actually the rule condition corresponding to the business rule, and the output variable name and the corresponding variable value are generally identified by a specific object name or keyword, which is actually the result obtained after executing the rule engine, that is, the rule execution result. For example, each business rule contains the corresponding rule condition and rule execution result, and the output variable of a business rule may also be the condition variable in the when condition of another business rule. Different business rules are related to each other based on the corresponding rule execution results. Therefore, based on this association relationship, a corresponding relationship diagram can be generated.
[0041] Step S12: The association between each business rule in the rule engine and the corresponding rule execution result is used as a graph node to generate a primary rule reasoning relationship graph, such as Figure 4 shown.
[0042] Step S13: parsing the rule conditions corresponding to each business rule in the rule engine, and generating data retrieval conditions corresponding to each business rule to construct a data retrieval condition relationship table of the rule engine.
[0043] The data retrieval condition relationship table includes each business rule, the data retrieval condition corresponding to each business rule, and the association relationship between them. In one embodiment, the method of generating the data retrieval condition corresponding to each business rule includes: parsing the rule conditions corresponding to each business rule in the rule engine, and removing one or more logical statements containing aggregation conditions, existence judgments, and unrecognizable sentence patterns in the generated logical statements, and generating the data retrieval condition corresponding to each business rule in the rule engine.
[0044] In a specific embodiment, the parts of the logical statements generated based on the rule conditions that contain aggregation conditions, existence judgments, and unrecognizable sentences are eliminated, and the corresponding data retrieval conditions can be generated in different ways according to the different syntax of each business rule of the rule engine.
[0045] For example, if the when condition contains conditional statements such as exists, not, or accumulate, the corresponding statements are removed, and the remaining rule conditions are used to generate data retrieval conditions corresponding to each business rule. For other unrecognizable sentence patterns, only the rule conditions related to the data table and data column are extracted to generate data retrieval conditions.
[0046] Furthermore, based on the data retrieval conditions corresponding to the generated business rules, an association relationship between the business rules and the data retrieval conditions can be established, and a data retrieval condition relationship table of the rule engine can be generated.
[0047] It should be noted that when establishing the association between business rules and data retrieval conditions, each data retrieval condition can be named. The name of each data retrieval condition can be the same as the rule name of the corresponding business rule, or it can be implemented by adding a fixed prefix to the rule name of the business rule. For example, if the rule name of the business rule is abc, the corresponding data retrieval condition is named QUERY_abc. This not only facilitates the maintenance of the correspondence between business rules and data retrieval conditions, but also facilitates subsequent search and execution. In addition, the rule name of the business rule must be unique in the rule package, and there will be no conflict when establishing the association between the business rule and the corresponding data retrieval condition.
[0048] The purpose of the design of the present invention in this embodiment is: by parsing the rules, the rule conditions in the structured rule information are screened, various logics irrelevant to the data are eliminated, and only the conditions related to the data are retained as data retrieval conditions, providing a basis for subsequent acquisition of relevant data, so that the corresponding source data can always be obtained based on the activated business rules, effectively ensuring the stability and accuracy of the source data of the activated business rules, thereby giving the application products using the rule engine the ability to trace the source data and improving the competitiveness of the application products.
[0049] Step S14: Based on the primary rule reasoning relationship tree and in combination with the constructed data retrieval condition relationship table, the association relationship between each business rule in the rule engine, the data retrieval condition corresponding to each business rule, and the rule execution result corresponding to each business rule is used as a graph node to generate a final rule reasoning relationship graph, such as Figure 2 shown.
[0050] Step S2: Based on the input original fact data, activate and execute one or more business rules in the rule engine, and obtain corresponding rule execution results.
[0051] In one embodiment, the step S2 includes:
[0052] Set the execution parameters of the rule engine and query the database to obtain raw fact data;
[0053] The acquired original fact data is input into the rule engine, one or more business rules in the rule engine are activated and executed, and one or more corresponding rule execution results are obtained.
[0054] For example, when the source data acquisition method for the rule engine provided by the present invention is used to obtain the source data corresponding to each business rule of the Drools rule engine in the medical field, the parameters of the Drools rule engine are first input, including the name of the rule package to be executed and the patient's visit ID. Then, all the data of the patient's visit are queried from the database of the medical system through the patient's visit ID, and the data is used as the original fact data, such as the patient's basic information, diagnosis data, doctor's order data, and operation data. The data is input into the Drools rule engine, the Drools rule engine is executed, and one or more business rules are activated, so that a set of executed variable lists can be obtained, that is, the corresponding rule execution results can be obtained. Execution diagram, such as Figure 5 shown.
[0055] It should be noted that step S3 can be performed simultaneously with step S2.
[0056] The purpose of designing the present invention in this embodiment is: by obtaining source data related to the business rules actually activated by the current execution of the rule engine from a large amount of original fact data, as the reasoning basis for the activated business rules, the reasoning path of the activated business rules can be inferred, so that the business logic in the business rules becomes clear, which is conducive to fast and accurate adaptive adjustment of the business rules and data cleaning, and also helps to discover noise or design omissions in the business rules, thereby ensuring the accuracy and stability of the business rules.
[0057] Step S3: Based on the rule reasoning relationship diagram and the obtained rule execution results, the activated business rules and corresponding data retrieval conditions in the rule engine are determined.
[0058] In one embodiment, step S3 includes: marking the corresponding graph nodes of the rule execution results in the rule reasoning relationship graph in sequence according to the association relationship and dependency order between the business rules in the rule reasoning relationship graph, such as Figure 6 As shown, each business rule in the marked graph node and the data retrieval condition corresponding to each business rule are obtained to determine the business rules activated in the rule engine and the corresponding data retrieval condition.
[0059] Step S4: Execute the determined data retrieval condition and obtain the source data corresponding to the business rule activated in the rule engine. That is, using the determined data retrieval condition, perform data query in the database, so as to obtain the corresponding data, that is, the source data corresponding to the business rule activated in the rule engine.
[0060] The present invention not only follows the basic engine execution rules to return accurate results, but also can obtain and parse the relevant source data of the activated rules, and deeply display the results and causes of the rule reasoning; and by reviewing the rule execution results to reversely verify the rationality and correctness of the business rules, it can significantly improve the efficiency and accuracy of formulating and adjusting business rules.
[0061] Moreover, step S3 and step S2 of the present invention can be performed simultaneously, and a rule reasoning relationship diagram is generated while the rule engine is executed to obtain the rule execution result, and then the activated business rules and the corresponding source data are obtained according to the rule execution result and the rule reasoning relationship diagram, thereby completing the traceability of the activated rules while executing the rule engine, which not only gives the rule engine the ability to trace the source, but also has real-time performance, showing extremely high industrial utilization value and significantly improving the competitiveness of application products using the rule engine.
[0062] In one embodiment, the source data acquisition method for a rule engine further includes: visually rendering the acquired source data corresponding to the activated business rules in the rule engine, and outputting the rendered result data.
[0063] Specifically, the obtained source data is visually rendered, mainly based on the data type of the source data, such as data table type or text type, and the corresponding data retrieval conditions executed by the source data, and different forms of visual rendering are performed, and different result data are output. The specific methods include:
[0064] Determine the source data source corresponding to the activated business rules in the obtained rule engine;
[0065] If the source data is determined to be a data table, the corresponding original data table is output and the matching result data is marked;
[0066] If the source data is determined to be text, the condition type of the data retrieval condition executed by the source data is determined, and a corresponding text output operation is output based on the determined condition type.
[0067] The specific method of outputting the text corresponding to the conditional type is as follows:
[0068] If the condition type is determined to be a regular matching condition, the original text corresponding to the acquired source data is output, and the matching result text is marked;
[0069] If the condition type is determined to be a formula calculation condition, output the formula text corresponding to the acquired source data and the variable data and result data used for formula calculation;
[0070] If the condition type is determined to be a Boolean calculation condition, the original text corresponding to the acquired source data is output, and the matching result text is marked;
[0071] If the condition type is determined to be other conditions, the content of the source data converted into text is output.
[0072] The purpose of designing the present invention in this embodiment is to provide users with a more convenient and friendly data viewing interface by further processing and visual rendering the source data of the activated business rules, so that users can quickly see the corresponding source data in a large amount of original factual data, and intuitively display the reasoning process of the business rules and the data status of each key node in the process, helping users to better understand the business rules and adjust the business rules faster and more accurately, thereby enhancing the overall value of the product.
[0073] In order to better describe how to trace the data of each business rule in the rule engine to clarify the reasoning path of each business rule, the present invention is combined with the following specific embodiments and Figure 7 Further details are given.
[0074] Embodiment: A source data acquisition method for a Drools rule engine in the medical field.
[0075] like Figure 7 As shown, the specific implementation steps of the source data acquisition method of the Drools rule engine for the medical field include:
[0076] Step S1: compile and structure each business rule in the Drools rule engine, and generate a primary rule reasoning relationship diagram.
[0077] The Drools rule engine provides a .drl file management method to compile each business rule and store the compiled rule package content in memory cache with the package name as the keyword for query at any time. After successful compilation, the structured information of each business rule can be obtained, including the rule name, the rule condition when part, and the rule execution result then part. Establish the association between business rules and the corresponding rule execution results, and use the association between each set of business rules and their corresponding rule execution results as graph nodes to generate a primary rule reasoning relationship graph.
[0078] Step S2: Generate data retrieval conditions, establish associations between business rules and corresponding data retrieval conditions, and generate a data retrieval condition relationship table and a rule reasoning relationship diagram.
[0079] The aggregation, existence judgment and other logics irrelevant to the data are removed from the structured rule information generated after the Drools rule engine is compiled, and data retrieval conditions related only to the data are generated. The association between each business rule and the corresponding data retrieval condition is established, and a data retrieval condition relationship table is generated.
[0080] It should be noted that, since the syntax of each business rule in the Drools rule engine is different, the method of generating data retrieval conditions also changes accordingly.
[0081] For example, the structured rule information after compiling the business rule of "whether to include hypertension diagnosis" is:
[0082]
[0083] Among them, patient_diagnose represents the diagnosis data table, and the output Var object in the then part is the output variable. If the when condition is met, the variable and variable value of the corresponding name can be output, and this variable and variable value can continue to be used by other rules. Since the when condition contains conditional judgment statements such as exists and not, the existence judgment statements such as exists and not are removed to generate the following data retrieval conditions:
[0084]
[0085] Similarly, for statements with accumulate aggregation, you can remove the accumulate aggregation calculation conditions and accumulate return value conditions; for other unrecognizable sentences, copy the rule conditions related only to the data table and data column to generate data retrieval conditions. The generated Drools rule engine data retrieval condition relationship table is shown in the following table:
[0086] Table 1 Example of data retrieval condition relationship table
[0087]
[0088] Furthermore, the data retrieval condition relationship table is combined with the primary rule reasoning relationship diagram generated in the above step S1 to generate a rule reasoning relationship diagram with each business rule, the rule execution result corresponding to each business rule, and the data retrieval condition corresponding to each business rule as graph nodes.
[0089] Step S3: Input all the original factual data of the patient's current visit and execute the Drools rule engine.
[0090] Among them, all the original factual data include patient basic information, diagnosis data, medical advice data, operation data and other data.
[0091] Furthermore, it should be noted that the step S3 can be performed simultaneously with the step S2.
[0092] Step S4: Obtain rule execution results.
[0093] Step S5: According to the rule reasoning relationship diagram, the activated business rule corresponding to the rule execution result and the data retrieval condition corresponding to the business rule are obtained to perform data query to obtain the source data for activating the business rule.
[0094] According to the obtained rule execution results and the rule reasoning relationship diagram, all graph nodes related to the rule execution results in the rule reasoning relationship diagram are obtained and marked, so as to obtain the corresponding activated business rules and data retrieval conditions. By executing these data retrieval conditions in the database, the source data that meets the rule conditions of the activated business rules can be obtained. In addition, the marked graph nodes in the rule reasoning relationship diagram can also be represented as the reasoning path of the activated business rules, which intuitively and clearly shows the reasoning steps and data support of the activated business rules to the user, so that the user can better understand the business rules, thereby effectively improving the efficiency, accuracy and rationality of business rule design and adjustment, making clinical decisions generated based on the Drools rule engine more scientific and reliable.
[0095] Step 6: Process the source data and render the visualization to output the result data.
[0096] Specifically, the obtained source data is visually rendered, mainly based on the data type of the source data, such as data table type or text type, and the corresponding data retrieval conditions executed by the source data, and different forms of visual rendering are performed, and different result data are output. For example, if the source data of the activated business rule obtained comes from the medical record text, the corresponding medical record text content is output as the result data, and the matching diagnosis content therein is emphasized, such as text highlighting or bolding; if the source data of the activated business rule obtained comes from a data table, such as a test result, the corresponding test data table is output, and the matching test items and test results therein are emphasized.
[0097] According to the above steps, while inputting the original fact data to execute the rule engine, the source data for activating the corresponding business rules can be directly queried and obtained through the obtained rule execution results. This achieves the purpose of obtaining the activated business rule source data in real time and tracing the business rules while executing the rule engine. It effectively solves the problems in the prior art that the rule engine lacks the corresponding reasoning path and reasoning basis for the business rules, which leads to difficulties in adjusting business rules, high costs and lack of accuracy, and demonstrates extremely high industrial utilization value.
[0098] like Figure 8 FIG. 8 is a schematic diagram showing a structure of a source data acquisition system for a rule engine in an embodiment of the present invention. In this embodiment, the source data acquisition system 800 for a rule engine includes:
[0099] The business rule compilation module 801 is used to compile each business rule in the rule engine and generate a rule reasoning relationship diagram; wherein the rule reasoning relationship diagram includes: the relationship between each business rule in the rule engine, the rule execution result corresponding to each business rule, and the data retrieval condition corresponding to each business rule;
[0100] The rule engine execution module 802 is used to activate and execute one or more business rules in the rule engine based on the input original fact data, and obtain corresponding rule execution results;
[0101] The rule source data acquisition module 803 is connected to the business rule compilation module 801 and the rule engine execution module 802, and is used to determine the business rules activated in the rule engine and the corresponding data retrieval conditions based on the rule reasoning relationship diagram and the obtained rule execution results; and to execute the determined data retrieval conditions and obtain the source data corresponding to the business rules activated in the rule engine.
[0102] It should be noted that: the source data acquisition system for the rule engine provided in the above embodiment only uses the division of the above program modules as an example when acquiring the source data corresponding to the rules activated in the rule engine. In actual applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the processing described above. In addition, the source data acquisition system for the rule engine provided in the above embodiment and the source data acquisition method embodiment for the rule engine belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0103] The source data acquisition method for the rule engine provided in the embodiment of the present invention can be implemented on the terminal side or the server side. As for the hardware structure of the source data acquisition terminal for the rule engine, please refer to Fig. 9, is an optional hardware structure diagram of a source data acquisition terminal 900 for a rule engine provided in an embodiment of the present invention. The terminal 900 may be a mobile phone, a computer device, a tablet device, a personal digital processing device, a factory background processing device, etc. The source data acquisition terminal 900 for a rule engine includes: at least one processor 901, a memory 902, at least one network interface 904 and a user interface 906. The various components in the device are coupled together through a bus system 905. It can be understood that the bus system 905 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 905 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, in Fig. 9 In the specification, various buses are labeled as bus systems.
[0104] The user interface 906 may include a display, a keyboard, a mouse, a trackball, a click gun, keys, buttons, a touch pad or a touch screen.
[0105] It is understood that the memory 902 can be a volatile memory or a non-volatile memory, and can also include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM), a programmable read-only memory (PROM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static random access memory (SRAM), synchronous static random access memory (SSRAM). The memory described in the embodiments of the present invention is intended to include but is not limited to these and any other suitable categories of memory.
[0106] The memory 902 in the embodiment of the present invention is used to store various categories of data to support the operation of the source data acquisition terminal 900 for the rule engine. Examples of these data include: any executable program used to operate on the source data acquisition terminal 900 for the rule engine, such as an operating system 9021 and an application 9022; the operating system 9021 includes various system programs, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks. The application 9022 can include various applications, such as a media player (MediaPlayer), a browser (Browser), etc., for implementing various application services. The source data acquisition method for the rule engine provided by the embodiment of the present invention can be included in the application 9022.
[0107] The source data acquisition method for the rule engine disclosed in the above embodiment of the present invention can be applied to the processor 901, or implemented by the processor 901. The processor 901 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 901 or the instruction in the form of software. The above processor 901 may be a general processor, a digital signal processor (DSP, DigitalSignal Processor), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The processor 901 can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiment of the present invention. The general processor 901 can be a microprocessor or any conventional processor, etc. In combination with the steps of the accessory optimization method provided in the embodiment of the present invention, it can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium, which is located in a memory, and the processor reads the information in the memory and completes the steps of the source data acquisition method for the rule engine in combination with its hardware.
[0108] In an exemplary embodiment, the source data acquisition terminal 900 for the rule engine can be one or more application specific integrated circuits (ASIC), DSP, programmable logic device (PLD), complex programmable logic device (CPLD) to execute the above method.
[0109] In summary, the present application provides a source data acquisition method, system and terminal for a rule engine, which compiles each business rule in the rule engine while executing the rule engine to obtain the rule execution result, and generates a rule reasoning relationship diagram based on the association between each business rule and the corresponding rule execution result and the data retrieval condition, and then determines the activated business rules and the corresponding data retrieval condition in the rule engine based on the generated rule reasoning relationship diagram and the obtained rule execution result, so as to obtain the corresponding source data by executing the determined data retrieval condition; the present invention acquires and parses the relevant source data of the activated business rules in real time while executing the rule engine, deeply demonstrates the reasoning path of the business rules, helps to quickly and accurately adjust the business rules and discover the noise or design omissions in the business rules, and fully guarantees the accuracy and stability of the business rules. Therefore, the present application effectively overcomes the various shortcomings in the prior art and has a high industrial utilization value.
[0110] The above embodiments are merely illustrative of the principles and effects of the present application and are not intended to limit the present application. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present application. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed in the present application shall still be covered by the claims of the present application.
Claims
1. A source data acquisition method for a rule engine, characterized in that: include: Compile each business rule in the rule engine and generate a rule reasoning relationship diagram; wherein the rule reasoning relationship diagram includes: the relationship between each business rule in the rule engine, the rule execution result corresponding to each business rule, and the data retrieval condition corresponding to each business rule; Based on the input original fact data, activate and execute one or more business rules in the rule engine, and obtain the corresponding rule execution results; Based on the rule reasoning relationship diagram, according to the obtained rule execution results, determine the business rules activated in the rule engine and the corresponding data retrieval conditions; Execute the determined data retrieval condition and obtain source data corresponding to the business rule activated in the rule engine; The method of generating a rule reasoning relationship graph includes: compiling each business rule in the rule engine and generating structured rule information of each business rule to obtain the rule conditions and rule execution results corresponding to each business rule in the rule engine; using the association between each business rule in the rule engine and the corresponding rule execution results as a graph node to generate a primary rule reasoning relationship graph; parsing the rule conditions corresponding to each business rule in the rule engine and generating data retrieval conditions corresponding to each business rule to construct a data retrieval condition relationship table; based on the primary rule reasoning relationship tree and in combination with the constructed data retrieval condition relationship table, using the association between each business rule in the rule engine, the data retrieval conditions corresponding to each business rule and the rule execution results corresponding to each business rule as graph nodes to generate a final rule reasoning relationship graph; the method of generating the data retrieval conditions corresponding to each business rule includes: parsing the rule conditions corresponding to each business rule in the rule engine, and removing one or more logical statements in the generated logical statements containing aggregation conditions, existence judgments and unrecognizable sentence patterns to generate data retrieval conditions corresponding to each business rule in the rule engine; The method of determining the activated business rules and corresponding data retrieval conditions in the rule engine based on the rule reasoning relationship diagram and the obtained rule execution results includes: marking the corresponding graph nodes of the rule execution results in the rule reasoning relationship diagram in sequence according to the association relationship and dependency order between the business rules in the rule reasoning relationship diagram, and obtaining the business rules in the marked graph nodes and the data retrieval conditions corresponding to the business rules, so as to determine the activated business rules and corresponding data retrieval conditions in the rule engine.
2. The source data acquisition method for a rule engine according to claim 1, characterized in that: The step of activating and executing one or more business rules in the rule engine based on the input original fact data and obtaining corresponding rule execution results includes: Set the execution parameters of the rule engine and query the database to obtain raw fact data; The acquired original fact data is input into the rule engine, one or more business rules in the rule engine are activated and executed, and one or more corresponding rule execution results are obtained.
3. The source data acquisition method for a rule engine according to claim 1, characterized in that: Also includes: The source data corresponding to the activated business rules in the obtained rule engine are visually rendered, and the rendered result data is output.
4. The source data acquisition method for a rule engine according to claim 3, characterized in that: The visual rendering of the source data corresponding to the activated business rules in the obtained rule engine and outputting the rendered result data includes: Determine the source data source corresponding to the activated business rules in the obtained rule engine; If the source data is determined to be a data table, the corresponding original data table is output and the matching result data is marked; If the source data is determined to be text, the condition type of the data retrieval condition executed by the source data is determined, and a corresponding text output operation is output based on the determined condition type.
5. The source data acquisition method for a rule engine according to claim 4, characterized in that: The text output operation corresponding to the output of the judged condition type includes: If the condition type is determined to be a regular matching condition, the original text corresponding to the acquired source data is output, and the matching result text is marked; If the condition type is determined to be a formula calculation condition, output the formula text corresponding to the acquired source data and the variable data and result data used for formula calculation; If the condition type is determined to be a Boolean calculation condition, the original text corresponding to the acquired source data is output, and the matching result text is marked; If the condition type is determined to be other conditions, the content of the source data converted into text is output.
6. A source data acquisition system for a rule engine, characterized in that: include: A business rule compilation module is used to compile each business rule in the rule engine and generate a rule reasoning relationship diagram; wherein the rule reasoning relationship diagram includes: the association relationship between each business rule in the rule engine, the rule execution result corresponding to each business rule, and the data retrieval condition corresponding to each business rule; A rule engine execution module is used to activate and execute one or more business rules in the rule engine based on the input original fact data, and obtain the corresponding rule execution results; A rule source data acquisition module, connected to the business rule compilation module and the rule engine execution module, is used to determine the business rules activated in the rule engine and the corresponding data retrieval conditions based on the rule reasoning relationship diagram and the obtained rule execution results; and to execute the determined data retrieval conditions and obtain the source data corresponding to the business rules activated in the rule engine; The method of generating a rule reasoning relationship graph includes: compiling each business rule in the rule engine and generating structured rule information of each business rule to obtain the rule conditions and rule execution results corresponding to each business rule in the rule engine; using the association between each business rule in the rule engine and the corresponding rule execution results as a graph node to generate a primary rule reasoning relationship graph; parsing the rule conditions corresponding to each business rule in the rule engine and generating data retrieval conditions corresponding to each business rule to construct a data retrieval condition relationship table; based on the primary rule reasoning relationship tree and in combination with the constructed data retrieval condition relationship table, using the association between each business rule in the rule engine, the data retrieval conditions corresponding to each business rule and the rule execution results corresponding to each business rule as graph nodes to generate a final rule reasoning relationship graph; the method of generating the data retrieval conditions corresponding to each business rule includes: parsing the rule conditions corresponding to each business rule in the rule engine, and removing one or more logical statements in the generated logical statements containing aggregation conditions, existence judgments and unrecognizable sentence patterns to generate data retrieval conditions corresponding to each business rule in the rule engine; The method of determining the activated business rules and corresponding data retrieval conditions in the rule engine based on the rule reasoning relationship diagram and the obtained rule execution results includes: marking the corresponding graph nodes of the rule execution results in the rule reasoning relationship diagram in sequence according to the association relationship and dependency order between the business rules in the rule reasoning relationship diagram, and obtaining the business rules in the marked graph nodes and the data retrieval conditions corresponding to the business rules, so as to determine the activated business rules and corresponding data retrieval conditions in the rule engine.
7. A source data acquisition terminal for a rule engine, characterized in that: include: Memory and processor; The memory is used to store computer programs; The processor is used to execute the computer program stored in the memory, so that the source data acquisition terminal for the rule engine implements the source data acquisition method for the rule engine according to any one of claims 1 to 5.
Citation Information
Patent Citations
A rule engine solution for configurable multi-data source adaptation
CN109299150A
Workflow process method and system for iterative and dynamic command generation and dynamic task execution sequencing including external command generator and dynamic task execution sequencer
US20030135384A1