A method and system for generating and checking a nutrition prescription based on cooperation of a rule engine and artificial intelligence

By calculating nutrient target values ​​using a deterministic rule engine and generating natural language suggestions using a large language model, along with dual-role signatures and chain hash verification, the problems of low efficiency in generating nutritional prescriptions, unreproducible values, and unclear permissions are solved, thus achieving traceability and immutability of prescription data.

CN123182912APending Publication Date: 2026-11-27BEIJING HUAXIA CHANGSHOU ELDERLY CARE TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202611122543.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-27
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies have low efficiency and are prone to errors in generating nutritional prescriptions. Large language models lack reproducibility and interpretability in generating numerical values. Furthermore, the authorization boundaries in the prescription issuance process are unclear and there is a lack of effective traceability and verification methods.

Method used

A deterministic rule engine is used to calculate the target values ​​of nutrients, and the basis for the calculation is recorded through a traceability field. Natural language suggestion text is generated by combining a large language model, and dual-role signatures are used and a chain hash structure is adopted for data integrity verification.

Benefits of technology

It achieves 100% reproducibility and interpretability of nutritional prescription values, ensures the non-repudiation and compliance of prescription data, prevents data tampering, and meets the requirements of strict medical regulation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123182912A_ABST
    Figure CN123182912A_ABST
Patent Text Reader

Abstract

The application discloses a kind of nutrition prescription generation and verification method and system based on rule engine and artificial intelligence cooperation.The method comprises the following steps: collecting patient data;Determining the rule engine according to the preset rule to calculate the nutrient target value, output the structured result containing the traceability field;The result is queued to the large language model service layer by asynchronous task, limited by prompt word template layer and output post-check layer, and the large language model only generates natural language nutrition suggestion, does not output numerical value, and inconsistent numerical value is automatically replaced;The prescription data body is signed by chain hash signature by private key by the signature person and the reviewer, and is stored in the form of four-tuple, to realize data non-repudiation and integrity protection.The present application realizes that prescription numerical value is 100% reproducible and interpretable, eliminates the illusion numerical value risk of large language model, and meets the compliance requirements of medical strong supervision scene through chain hash mechanism.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of medical informatics and artificial intelligence, and in particular to a method and system for generating and verifying nutritional prescriptions based on the collaboration of rule engines and artificial intelligence. Background Technology

[0002] The generation of clinical nutrition prescriptions involves calculating target values ​​for multiple nutrients such as calories, protein, and sodium for patients. Traditional methods rely on nutritionists to manually look up tables and calculate, which is cumbersome. When there are many patients or complex parameter combinations, manual calculation is inefficient and carries the risk of numerical errors.

[0003] With the application of artificial intelligence technology in medical scenarios, some systems have begun to directly call Large Language Models (LLMs) to generate prescription values.

[0004] CN118522401A discloses an intelligent drug prescription and management system based on a large language model. This system includes a data format conversion module, a data feature extraction module, a decision generation module, and a drug information update module. It directly processes various forms of input data and generates drug prescriptions through a large language model, improving diagnostic efficiency. However, this system directly relies on the large language model to output prescription values, resulting in a lack of reproducibility and interpretability. Furthermore, it lacks a deterministic rule engine to constrain and verify the values, posing compliance risks in scenarios with stringent medical regulations.

[0005] CN121662420A discloses a prescription review system and its processing method based on generative artificial intelligence. This system adopts a three-layer system architecture combined with a multi-agent collaborative working mechanism to form a closed-loop, controllable automated review pipeline. However, the system focuses on post-prescription review and approval, rather than the prescription generation and issuance stages. Furthermore, it does not address the decoupling mechanism between deterministic rule engines and large language models, nor does it propose a dual-role signature separation and chain hash traceability scheme.

[0006] The existing technology has the following disadvantages: (1) Manual calculation is inefficient and prone to errors: Nutritionists need to manually look up tables to calculate the target values ​​of nutrients such as calories, protein, and sodium. When there are many patients or the parameter combination is complex, numerical errors are very likely to occur, and it is difficult to ensure the consistency of the calculation process; (2) The numerical values ​​generated directly by the large language model lack reproducibility and interpretability: The existing scheme of directly calling the large language model to generate prescription values ​​has random output. The same input may produce different results in different calls, and it is impossible to explain the calculation basis to the reviewing doctor. There is a compliance risk in the scenario of strong medical supervision; (3) The authority boundaries in the signing process are unclear: The existing system mostly adopts single-role signature or simple electronic stamping. The authority boundaries between the signer and the reviewer are unclear. When the prescription data is tampered with in the process of circulation, there is no effective technical means to trace and verify the source, which cannot meet the requirement of non-repudiation of medical data. Summary of the Invention

[0007] The purpose of this invention is to provide a method and system for generating and verifying nutritional prescriptions based on the collaboration of rule engines and artificial intelligence, in order to solve the technical problems in the prior art, such as low efficiency and error-proneness of pure manual calculation, lack of reproducibility and interpretability of output results when large language models directly generate prescription values, and unclear authority boundaries and lack of effective traceability and verification means in the prescription issuance process.

[0008] To achieve the above objectives, the present invention adopts the following technical solution: The first aspect of this invention provides a method for generating and verifying nutritional prescriptions based on the collaboration of a rule engine and artificial intelligence, comprising the following steps: Step 1: Collect structured patient data.

[0009] Step 2: Input the structured data into the deterministic rule engine. The deterministic rule engine performs nutrient target value calculation based on the preset rule node tree and outputs a structured calculation result containing a traceability field. The traceability field records the rule identifier, calculation formula and input basis triggered by each value.

[0010] Step 3: The structured calculation result is passed to the large language model service layer via an asynchronous task queue. The large language model service layer constrains its responsibility boundary through the dual limitations of the prompt word template layer and the output post-validation layer, and only generates natural language nutrition suggestion text without outputting any numerical nutrient targets. If a value inconsistent with the structured calculation result is detected in the output, the inconsistent value is replaced with the corresponding original value in the structured calculation result.

[0011] Step four: The issuer calculates a first hash value on the prescription data body containing the traceability field and generates a first signature by signing it with a private key; after the verification of consistency is passed, the reviewer calculates a second hash value on the combination of the prescription data body and the first signature and generates a second signature by signing it with a private key; the prescription data body, the traceability field, the first signature and the second signature are persistently stored in the form of a quadruple.

[0012] In some implementations, the patient's structured data includes at least one of the following: age, gender, height, weight, weight change trend, clinical diagnostic code (ICD-10), laboratory indicators (including serum creatinine, serum potassium, serum sodium, albumin, etc.), activity level coefficient, and stress coefficient. This patient structured data is obtained through an interface with a Hospital Information System (HIS) or Laboratory Information System (LIS), or is entered by a nutritionist using a structured form.

[0013] In some implementations, each node in the rule node tree includes an input field reference, a calculation formula, upper and lower limit constraints, and a rule trigger identifier (rule_id, a unique code for each rule node used to identify the rule that triggers the node in the tracing field, e.g., RULE_PROTEIN_CKD_001). The calculation formula includes at least one of the basal metabolic rate (BMR) calculation formula and the stress coefficient correction formula. The upper and lower limit constraints include upper limit constraints on the intake of specific nutrients, as well as upper limit constraints dynamically adjusted based on test indicators.

[0014] In some embodiments, the upper and lower limits include upper limits for sodium intake and upper limits for protein intake. The upper limit for sodium intake is set at no more than 1500–2500 mg / day; optionally, the upper limit for sodium intake is selected from any value or a range of any two of the following: 1500 mg / day, 1600 mg / day, 1700 mg / day, 1800 mg / day, 1900 mg / day, 2000 mg / day, 2100 mg / day, 2200 mg / day, 2300 mg / day, 2400 mg / day, and 2500 mg / day. Preferably, the upper limit of sodium intake is limited to no more than 2000 mg / day. The upper limit of protein intake is dynamically adjusted according to the estimated glomerular filtration rate (eGFR) classification; the preset threshold of eGFR is 45-75 mL / min / 1.73 m². Optionally, the preset threshold is selected from any value or a range of any two of the following: 45 mL / min / 1.73 m², 50 mL / min / 1.73 m², 55 mL / min / 1.73 m², 60 mL / min / 1.73 m², 65 mL / min / 1.73 m², 70 mL / min / 1.73 m², and 75 mL / min / 1.73 m². Preferably, the preset threshold is 60 mL / min / 1.73 m²; when the eGFR is lower than the preset threshold, the upper limit of protein intake is adjusted to 0.4–1.0 g / kg / day; Optionally, the upper limit of protein intake is selected from any value or a range of any two of 0.4 g / kg / day, 0.5 g / kg / day, 0.6 g / kg / day, 0.7 g / kg / day, 0.8 g / kg / day, 0.9 g / kg / day, and 1.0 g / kg / day. Preferably, the upper limit of protein intake is 0.6 to 0.8 g / kg / day.

[0015] In some implementations, the prompt word template layer explicitly includes a constraint instruction prohibiting the output of numerical nutrient targets in the prompt words sent to the large language model, and provides the numerical values ​​of the structured calculation results as background information. The output post-validation layer uses regular expressions (e.g., expressions for matching combinations of numbers and units, such as "\d+(\.\d+)?\s) (mg|g|kcal|mL)" etc.) or numerical extraction algorithms detect the numerical content in the output of the large language model, automatically replace the detected numerical values ​​that are inconsistent with the structured calculation results with the corresponding original values, and record the replacement log.

[0016] In some implementations, the traceability field records the calculation process of each nutrient target value in a structured form, including: the triggering rule identifier, the text of the applied calculation formula, the names and values ​​of the input fields involved in the calculation; the traceability field is provided for the issuer and reviewer to review the calculation basis during the review process.

[0017] In some implementations, the natural language nutrition advice text includes dietary advice descriptions and recipe suggestions for patients or their families; the dietary advice descriptions are generated based on the range of nutrient target values ​​from the structured calculation results, but specific nutrient targets are not presented in numerical form in the text.

[0018] In some implementations, the reviewer can only execute the second signature after verifying the consistency between the traceability field and the natural language nutrition advice text. After the quadruple is persistently stored, when performing integrity verification on the stored prescription data, the hash value of the prescription data body is recalculated and compared with the hash value corresponding to the first signature, and the hash value of the combination of the prescription data body and the first signature is recalculated and compared with the hash value corresponding to the second signature. If any comparison is inconsistent, the data integrity verification is determined to have failed.

[0019] In some implementations, the basal metabolic rate is calculated using the Mifflin-St Jeor formula (proposed by Mifflin et al. in 1990, which is currently the widely used formula for estimating basal metabolic rate in the field of clinical nutrition), specifically as follows: Male BMR = a × weight (kg) + b × height (cm) - c × age (years) + d; Female BMR = a × weight (kg) + b × height (cm) - c × age (years) - e. The coefficient 'a' ranges from 8 to 12. Optionally, 'a' is selected from any value or a range of any two of 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, and 12; preferably, 'a' = 10. The coefficient 'b' ranges from 5 to 8. Optionally, b is selected from any value of 5, 5.5, 6, 6.25, 6.5, 7, 7.5, 8 or a range of values ​​consisting of any two of them; Preferably, b = 6.25. The coefficient c ranges from 4 to 6. Optionally, c is selected from any value of 4, 4.5, 5, 5.5, 6, or a range of values ​​consisting of any two of them; Preferably, c=5. The coefficient d ranges from 3 to 7; optionally, d is selected from any value of 3, 4, 5, 6, or 7, or any range of two of them. Preferably, d=5. The coefficient e ranges from 155 to 167; Optionally, e is selected from any value or a range of any two of 155, 157, 159, 161, 163, 165, and 167; preferably, e = 161.

[0020] A second aspect of the present invention also provides a nutritional prescription generation and verification system based on the collaboration of a rule engine and artificial intelligence, comprising: The data acquisition module is used to collect structured patient data; The rule engine module is used to perform nutrient target value calculation on the structured data according to the preset rule node tree, and output the structured calculation result containing the traceability field. The traceability field records the rule identifier, calculation formula and input basis triggered by each value. The large language model service module is used to receive the structured calculation results via an asynchronous task queue, and under the dual constraints of the prompt word template layer and the output post-validation layer, it only generates natural language nutrition suggestion text and does not output any numerical nutrient targets. The verification and interception module is used to detect the numerical content in the output of the large language model service module and replace the numerical values ​​that are inconsistent with the structured calculation results with the corresponding original values. The signature storage module is used to perform dual-role signature separation and persistently store the prescription data body, traceability field, first signature and second signature in the form of a quadruple.

[0021] The beneficial effects that this application can produce include: (1) Prescription values ​​are 100% reproducible and interpretable: The deterministic rule engine ensures that the same input will inevitably produce the same output, and the traceability field makes each value traceable to the specific rule node, calculation formula and input parameters, meeting the compliance requirements of medical supervision scenarios. It has been verified that under the same input conditions, the rule engine's output results for any patient data are 100% consistent and are not affected by random factors such as call time and system load.

[0022] (2) Dual prevention and control of illusion values ​​in large language model: The prompt word template layer provides dual protection from the generation constraint dimension and the output post-validation layer provides output fallback dimension, ensuring that the large language model does not output unreliable values ​​and that the final prescription value comes from the deterministic rule engine. The output post-validation layer can effectively intercept values ​​in the output of large language model that are inconsistent with the results of the rule engine through numerical extraction and comparison, and retain operation records in the form of replacement logs.

[0023] (3) Non-repudiation and integrity protection of prescription data: The chain hash structure locks the data integrity of the two stages of issuance and review. For example, if the value of a nutrient in the prescription data body is tampered with, the hash value of the recalculated prescription data body will be inconsistent with the hash value corresponding to the first signature S1. The system will then determine that the data integrity verification has failed, thereby effectively detecting data tampering behavior at any stage and meeting the non-repudiation requirements of medical data. Attached Figure Description

[0024] Figure 1 This is a flowchart illustrating a method for generating and verifying nutritional prescriptions based on the collaboration of a rule engine and artificial intelligence, according to the present invention. Figure 2 This is a schematic diagram of the rule node tree structure of the present invention; Figure 3 This is a schematic diagram of the dual-role signature separation and chain hash verification mechanism of the present invention. Detailed Implementation

[0025] The present application is described in detail below with reference to the embodiments, but the present application is not limited to these embodiments.

[0026] The main terms and abbreviations used in this application are explained below: Large Language Model (LLM): refers to an artificial intelligence model with natural language understanding and generation capabilities, pre-trained on massive amounts of text data. In this invention, the responsibility of the large language model is strictly limited to generating natural language nutrition suggestion text, and it does not undertake numerical computation.

[0027] Deterministic rule engine: refers to a computing engine that performs deterministic logical operations on input data based on a predefined set of rules. The same input will always produce the same output, and it is not affected by random factors.

[0028] Rule node tree: refers to a tree structure organized by multiple rule nodes in a hierarchical relationship. Each node corresponds to a specific nutrient calculation rule, and there are dependencies between nodes.

[0029] Trace field: refers to the data field attached to the structured calculation results that records the complete calculation process of each nutrient target value in a structured form, including the triggering rule identifier, the text of the applied calculation formula, and the names and values ​​of the input fields involved in the calculation.

[0030] Rule trigger identifier (rule_id): A unique code for each rule node, used to identify the rule that triggers the node in the tracing field. For example, RULE_PROTEIN_CKD_001 represents rule number 001 for protein constraint in chronic kidney disease.

[0031] Asynchronous task queues refer to a middleware mechanism that decouples task producers from task consumers. Producers write tasks to the queue and then return; consumers asynchronously retrieve tasks from the queue for execution, achieving concurrent decoupling between the two processing steps. These asynchronous task queues can be implemented using message queue middleware (such as RabbitMQ, Kafka, etc.).

[0032] Prompt template layer: This refers to the processing layer that constructs prompts according to predefined templates when calling a large language model. In this invention, this layer is responsible for explicitly injecting constraint instructions into the prompts that prohibit the output of numerical nutrient targets.

[0033] Output post-validation layer: This refers to the functional layer that performs post-processing validation on the output text of the large language model. It detects numerical content in the output text using regular expressions or numerical extraction algorithms and performs replacement operations.

[0034] A hash value is a fixed-length digest of data calculated using a hash algorithm. Any change to the data content will result in a change in the hash value, and it can be used for data integrity verification. The hash algorithm can be SHA-256 or the Chinese national cryptographic algorithm SM3.

[0035] Private key signature (digital signature): refers to a signature generated by encrypting a data digest using a private key of an asymmetric encryption algorithm. The signature's legitimacy can be verified using the corresponding public key, achieving data source authentication and non-repudiation protection. The private key is generated using an asymmetric encryption algorithm (such as RSA or the Chinese national standard SM2) and is held and securely stored by each relevant party.

[0036] Quadruple: refers to the data structure used in this invention for persistently storing prescription data, which consists of four components: prescription data body, traceability field, first signature, and second signature.

[0037] HIS (Hospital Information System): Hospital Information System.

[0038] LIS (Laboratory Information System): Laboratory Information System.

[0039] eGFR (estimated Glomerular Filtration Rate): This is an important indicator for assessing kidney function. It is estimated using test data such as serum creatinine and is used for classifying kidney function. Clinically, an eGFR of 60 mL / min / 1.73 m² is usually used as an important threshold for classifying chronic kidney disease.

[0040] BMR (Basal Metabolic Rate): Basal metabolic rate.

[0041] ICD-10 (International Classification of Diseases, 10th Revision): Clinical diagnostic coding standard.

[0042] The Mifflin-St Jeor formula, proposed by Mifflin et al. in 1990, is a widely used formula for estimating basal metabolic rate in the field of clinical nutrition.

[0043] Example 1 Example 1 provides a basic implementation of a nutrition prescription generation and verification method based on the collaboration of a rule engine and artificial intelligence, describing the complete process from patient data collection to persistent prescription storage. See [link to example]. Figure 1 .

[0044] Step S101: The data acquisition module collects structured patient data.

[0045] The collected structured data includes patient age, gender, height, weight, weight change trend, clinical diagnosis code (ICD-10), laboratory indicators (including serum creatinine, serum potassium, serum sodium, albumin, etc.), activity level coefficient, and stress coefficient. This data is obtained through interfaces with the hospital information system (HIS) or laboratory information system (LIS), or entered by nutritionists using structured forms.

[0046] In step S102, the rule engine module performs the calculation of nutrient target values.

[0047] The rule engine module receives the structured data collected in step S101 and performs calculations based on the preset rule node tree. (See below) Figure 2 Each node in the rule node tree contains references to input fields (pointing to specific fields in the patient's structured data, such as body_weight and serum_creatinine), calculation formulas, upper and lower bound constraints, and a rule trigger identifier (rule_id). The rule engine employs deterministic calculation logic; the same input will inevitably produce the same output, and the calculation results are unaffected by random factors. Verification showed that 100 repeated calls to the same patient dataset resulted in completely consistent target values ​​for each nutrient output by the rule engine, achieving 100% consistency. After calculation, the rule engine outputs structured calculation results along with a trace field, recording the rule identifier triggered for each nutrient target value, the applied calculation formula text, and the values ​​of the input fields involved in the calculation, for review in subsequent auditing stages.

[0048] The upper and lower limits include upper limits for sodium intake and upper limits for protein intake. The upper limit for sodium intake is 1500–2500 mg / day. Optionally, the upper limit of sodium intake is selected from any value or a range of any two of 1500 mg / day, 1600 mg / day, 1700 mg / day, 1800 mg / day, 1900 mg / day, 2000 mg / day, 2100 mg / day, 2200 mg / day, 2300 mg / day, 2400 mg / day, and 2500 mg / day. Preferably, the upper limit of sodium intake is limited to no more than 2000 mg / day.

[0049] The upper limit of protein intake is dynamically adjusted according to the eGFR classification: when the eGFR is lower than the preset threshold (the preset threshold range is 45 to 75 mL / min / 1.73 m², preferably 60 mL / min / 1.73 m²), the upper limit of protein intake is adjusted to 0.4 to 1.0 g / kg / day. Optionally, the upper limit of protein intake is selected from any value or a range of any two of 0.4 g / kg / day, 0.5 g / kg / day, 0.6 g / kg / day, 0.7 g / kg / day, 0.8 g / kg / day, 0.9 g / kg / day, and 1.0 g / kg / day. Preferably, the upper limit of protein intake is 0.6 to 0.8 g / kg / day.

[0050] Step S103: The large language model service module generates natural language nutrition suggestion text.

[0051] The structured computation results from the rules engine module are transmitted to the large language model service module via an asynchronous task queue (which can be implemented using message queue middleware such as RabbitMQ or Kafka). The asynchronous task queue decouples the rule engine's computation process from the large language model's generation process, allowing the large language model service module to receive only the computed structured numerical values ​​as context input. The large language model service module sends prompts to the large language model through a prompt word template layer. These prompts explicitly include constraints prohibiting the output of numerical nutrient targets and provide the structured numerical values ​​output by the rules engine as background information. The large language model generates only natural language nutritional advice text and dietary preference recipe suggestions for patients or their families based on the computed structured numerical values, without outputting any numerical nutrient targets.

[0052] Step S104: The verification and interception module performs numerical verification on the output of the large language model.

[0053] The output post-validation layer checks the output of the large language model service module using regular expressions (e.g., expressions for matching combinations of numbers and units, such as "\d+(\.\d+)?\s)". Numerical values ​​(mg, g, kcal, mL, etc.) are extracted from the output text using numerical extraction algorithms and compared with the structured calculation results from the rule engine module. If a numerical value inconsistent with the structured calculation result is detected in the output, the value is automatically intercepted and replaced with the corresponding original value output by the rule engine module, and a replacement log is recorded to ensure that the final values ​​presented to doctors and patients originate from the deterministic rule engine.

[0054] Step S105: The signature storage module performs dual-role separation signing and persistent storage.

[0055] See Figure 3 After a prescription is generated, the issuer (nutritionist or doctor) calculates a first hash value H1 (using SHA-256 or the national cryptographic SM3 algorithm) on the prescription data body containing the traceability field, and digitally signs H1 with the issuer's private key (generated using RSA or the national cryptographic SM2 algorithm), generating a first signature S1. After reviewing the traceability field and confirming the consistency between the rule engine's calculation basis and the natural language nutrition advice text, the reviewer calculates a second hash value H2 on the combination of the prescription data body and S1, and digitally signs H2 with the reviewer's private key, generating a second signature S2. Finally, the prescription data body, traceability field, S1, and S2 are persistently stored in the database as a four-tuple. Subsequent integrity checks on the stored prescriptions are performed by recalculating the hash value of the prescription data body and comparing it with the hash value corresponding to S1, and recalculating the hash value of the combination of the prescription data body and S1 and comparing it with the hash value corresponding to S2. For example, if the value of a nutrient in the prescription data is tampered with, the recalculated hash value will be inconsistent with the hash value corresponding to S1. The system will then determine that the data integrity verification has failed, thus effectively detecting data tampering.

[0056] Example 2 Example 2 focuses on describing the specific implementation of the rule node tree structure and the trace field. See [link to example]. Figure 2 .

[0057] The rule node tree consists of multiple rule nodes, and each rule node contains the following fields: (1) Input field reference: refers to specific fields in the patient's structured data, such as body_weight (weight) and serum_creatinine (serum creatinine). (2) Calculation formula: Basal metabolic rate (BMR) is calculated using the Mifflin-St Jeor formula.

[0058] Male BMR = a × weight (kg) + b × height (cm) - c × age (years) + d; Female BMR = a × weight (kg) + b × height (cm) - c × age (years) - e.

[0059] Wherein, the coefficient 'a' ranges from 8 to 12, optionally, 'a' is selected from any value or a range of any two of 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, preferably 'a' = 10; the coefficient 'b' ranges from 5 to 8, optionally, 'b' is selected from any value or a range of any two of 5, 5.5, 6, 6.25, 6.5, 7, 7.5, 8, preferably 'b' = 6.25; the coefficient 'c' ranges from 4 to 6, optionally, 'c' is selected from... The coefficient c is a range of values ​​from 4, 4.5, 5, 5.5, 6, or any combination of two, preferably c=5; the coefficient d ranges from 3 to 7, optionally d is selected from any value from 3, 4, 5, 6, 7 or any combination of two, preferably d=5; the coefficient e ranges from 155 to 167, optionally e is selected from any value from 155, 157, 159, 161, 163, 165, 167 or any combination of two, preferably e=161; (3) Upper and lower limits: The upper limit of sodium intake is limited to 1500-2500 mg / day, preferably not exceeding 2000 mg / day; the upper limit of protein intake is dynamically adjusted according to the eGFR classification. When the eGFR is lower than the preset threshold (preferably 60 mL / min / 1.73 m²), the upper limit of protein intake is adjusted to 0.6-0.8 g / kg / day. (4) Rule trigger identifier (rule_id): such as RULE_PROTEIN_CKD_001, used to record the rule number that triggers the node in the traceability field.

[0060] After the rule engine performs the calculations, the output trace field records the calculation process of each nutrient target value in a structured format, including: the triggering rule identifier (rule_id), the text of the applied calculation formula, and the names and values ​​of the input fields involved in the calculation. Reviewers can verify the calculation basis of each nutrient target value by consulting the trace field, achieving complete traceability of the prescription values.

[0061] Example 3 Example 3 focuses on describing the specific implementation of the large language model output verification and interception mechanism and the four-tuple storage structure. (See also...) Figure 3 .

[0062] After receiving the structured calculation results from the rule engine, the large language model service module constructs prompt words through the prompt word template layer. The prompt words contain the following constraints: explicitly informing the large language model that the current task is only to generate natural language suggestion text for patients, prohibiting the inclusion of any numerical nutrient targets in the output, and providing the structured numerical values ​​output by the rule engine as background information.

[0063] The output post-validation layer receives the output text from the large language model and then validates it using regular expressions (such as "\d+(\.\d+)?\s The algorithm (mg|g|kcal|mL) or numerical extraction algorithm identifies the numerical content in the output and compares the identified value with the structured calculation result of the rule engine. If there is an inconsistency, an automatic replacement operation is performed to replace the inconsistency value with the original value corresponding to the rule engine, and a replacement log is recorded (including replacement time, original output value, replaced value and corresponding rule identifier).

[0064] The four-tuple persistent storage structure includes: the prescription data body (containing patient structured data, target values ​​of each nutrient calculated by the rule engine, and natural language nutritional advice text), the traceability field (recording the calculation basis of each value), the first signature S1 (signature of the issuer's private key), and the second signature S2 (signature of the reviewer's private key). When performing integrity verification on the stored prescription, the hash value is recalculated and compared with the hash value corresponding to the stored signature. If any comparison is inconsistent, the data integrity verification is deemed to have failed, thus achieving effective detection of data tampering.

[0065] The above description is merely a few embodiments of this application and is not intended to limit this application in any way. Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any changes or modifications made by those skilled in the art without departing from the scope of the technical solution of this application using the disclosed technical content are equivalent to equivalent implementation cases and fall within the scope of the technical solution.

Claims

1. A method for generating and validating nutritional prescriptions based on the collaboration of a rule engine and artificial intelligence, characterized in that, Includes the following steps: Collect structured patient data; The structured data is input into the deterministic rule engine, which calculates the nutrient target value based on the preset rule node tree and outputs a structured calculation result containing a traceability field. The traceability field records the rule identifier, calculation formula and input basis triggered by each value. The structured calculation results are passed to the large language model service layer via an asynchronous task queue. The large language model service layer constrains its responsibility boundaries through the dual limitations of the prompt word template layer and the output post-validation layer, and only generates natural language nutrition suggestion text without outputting any numerical nutrient targets. If a value inconsistent with the structured calculation result is detected in the output, the inconsistent value is replaced with the corresponding original value in the structured calculation result. The issuer calculates a first hash value on the prescription data body containing the traceability field and generates a first signature by signing it with a private key; After the reviewer verifies the consistency, the reviewer calculates the second hash value of the combination of the prescription data body and the first signature and generates a second signature by signing with the private key; The prescription data body, the traceability field, the first signature, and the second signature are persistently stored in the form of a quadruple.

2. The method for generating and verifying nutritional prescriptions according to claim 1, characterized in that, The patient's structured data includes at least one of the following: age, gender, height, weight, weight change trend, clinical diagnosis code, laboratory indicators, activity level coefficient, and stress coefficient. The patient's structured data is obtained through an interface with the hospital information system or laboratory information system, or is entered by a nutritionist through a structured form.

3. The method for generating and verifying nutritional prescriptions according to claim 1, characterized in that, Each node in the rule node tree contains an input field reference, a calculation formula, upper and lower limit constraints, and a rule trigger identifier; The calculation formula includes at least one of the basal metabolic rate calculation formula and the stress coefficient correction formula; The upper and lower limits include upper limits for the intake of specific nutrients, as well as upper limits that are dynamically adjusted based on test indicators.

4. The method for generating and verifying nutritional prescriptions according to claim 3, characterized in that, The upper and lower limit constraints include: Sodium intake should be limited to no more than 1500–2500 mg / day; Preferably, the upper limit of sodium intake is limited to no more than 2000 mg / day; And a protein intake limit constraint that is dynamically adjusted based on glomerular filtration rate grading, wherein the preset threshold of glomerular filtration rate is 45-75 mL / min / 1.73 m², and when the glomerular filtration rate is lower than the preset threshold, the upper limit of protein intake is adjusted to 0.4-1.0 g / kg / day; Preferably, the preset threshold is 60 mL / min / 1.73 m², and the upper limit of protein intake is adjusted to 0.6-0.8 g / kg / day.

5. The method for generating and verifying nutritional prescriptions according to claim 1, characterized in that, The prompt word template layer explicitly includes a constraint instruction prohibiting the output of numerical nutrient targets in the prompt words sent to the large language model, and provides the numerical values ​​of the structured calculation results as background information. The output post-validation layer detects the numerical content in the output of the large language model using regular expressions or numerical extraction algorithms, automatically replaces the detected numerical values ​​that are inconsistent with the structured calculation results with the corresponding original values, and records the replacement log.

6. The method for generating and verifying nutritional prescriptions according to claim 1, characterized in that, The traceability field records the calculation process of each nutrient target value in a structured format, including: The triggering rule's trigger identifier, the text of the applied calculation formula, and the names and values ​​of the input fields involved in the calculation; The traceability field is provided for the issuer and reviewer to access the calculation basis during the review process.

7. The method for generating and verifying nutritional prescriptions according to claim 1, characterized in that, The natural language nutrition advice text includes dietary advice descriptions and recipe suggestions for patients or their families; The dietary recommendations are generated based on the range of nutrient target values ​​from the structured calculation results, but specific nutrient targets are not presented in numerical form in the text.

8. The method for generating and verifying nutritional prescriptions according to claim 1, characterized in that, The reviewer can only execute the second signature after verifying the consistency between the traceability field and the natural language nutrition advice text. After the quadruple is persistently stored, when performing integrity verification on the stored prescription data, the hash value of the prescription data body is recalculated and compared with the hash value corresponding to the first signature, and the hash value of the combination of the prescription data body and the first signature is recalculated and compared with the hash value corresponding to the second signature. If any comparison is inconsistent, the data integrity verification is determined to have failed.

9. The method for generating and verifying nutritional prescriptions according to any one of claims 1 to 8, characterized in that, The basal metabolic rate is calculated using the Mifflin-St Jeor formula: Basal metabolic rate for men = a × weight (kg) + b × height (cm) - c × age (years) + d; Basal metabolic rate for women = a × weight (kg) + b × height (cm) - c × age (years) - e; The value of a ranges from 8 to 12, the value of b ranges from 5 to 8, the value of c ranges from 4 to 6, the value of d ranges from 3 to 7, and the value of e ranges from 155 to 167. Preferably, a=10, b=6.25, c=5, d=5, e=161.

10. A nutritional prescription generation and verification system based on the collaboration of a rule engine and artificial intelligence, characterized in that, include: The data acquisition module is used to collect structured patient data; The rule engine module is used to perform nutrient target value calculation on the structured data according to the preset rule node tree, and output the structured calculation result containing the traceability field. The traceability field records the rule identifier, calculation formula and input basis triggered by each value. The large language model service module is used to receive the structured calculation results via an asynchronous task queue, and under the dual constraints of the prompt word template layer and the output post-validation layer, it only generates natural language nutrition suggestion text and does not output any numerical nutrient targets. The verification and interception module is used to detect the numerical content in the output of the large language model service module and replace the numerical values ​​that are inconsistent with the structured calculation results with the corresponding original numerical values. The signature storage module is used to perform dual-role signature separation and persistently store the prescription data body, traceability field, first signature and second signature in the form of a quadruple.

Citation Information

Patent Citations

  • Intelligent medicine prescription and management system based on large language model

    CN118522401A