A nutrition prescription generation method based on rule engine and large language model cooperation, a nutrition prescription management system and a storage medium
Patent Information
- Application Number
- CN202610967741.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-30
- Publication Date
- 2026-10-09
AI Technical Summary
[0006]本发明目的在于提供一种基于规则引擎与大语言模型协同的营养处方生成方法、营养处方管理系统及存储介质,以解决现有技术中存在的以下技术问题:AI生成的临床数值指标缺乏确定性计算引擎的约束导致结果不可控,医疗文档的OCR识别缺乏完整的处理管道,处方审批缺乏强制性的多角色签字验证机制,系统集成缺乏可配置的服务提供商切换架构,业务流程缺乏端到端的闭环管理
[0034]本申请能产生的有益效果包括:
Smart Images

Figure CN122889265A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of medical information technology, and in particular to a method for generating nutritional prescriptions based on the collaboration of a rule engine and a large language model, a nutritional prescription management system, and a storage medium. Background Technology
[0002] With the increasing aging of the population, the demand for nutritional management in elderly care institutions is growing. As an important tool for clinical nutritional intervention, nutritional prescriptions require calculation of clinical indicators such as calorie requirements, protein requirements, and upper limits of sodium intake based on the elderly's health status, medical history, and allergy history, and generate personalized nutritional recommendations.
[0003] A Chinese patent with publication number CN 121260359 A discloses a method and system for compliance review of clinical prescriptions. This solution combines a rule base with a rule engine for rigid compliance review of clinical prescriptions, and an AI model for flexible compliance review. However, the AI model directly participates in the generation or review of clinical numerical indicators, leading to uncontrollable numerical generation issues, and the decoupling architecture design between the rule engine and the AI model is not disclosed.
[0004] A Chinese patent with publication number CN 121439100 A discloses a method and system for recommending diets for kidney disease based on knowledge graphs and large language models. In this scheme, the large language model generates preliminary recommendations based on a candidate set of ingredients and recipes, and the knowledge graph sub-engine verifies the initial draft and removes non-compliant ingredients based on rule chains. However, this scheme still involves the large language model in generating the recommendation scheme, fails to clearly distinguish the responsibilities of numerical calculations and textual descriptions in generating the recommendations, and does not disclose the automated recognition and structured processing flow of medical documents.
[0005] Furthermore, in existing technologies, prescription approval processes typically lack a mandatory independent review mechanism, making it difficult to ensure the separation of roles between the issuer and the reviewer; the system architecture is difficult to adapt to the needs of cross-border deployment and lacks the ability to flexibly switch service providers; and business processes such as clinical evaluation, commercial orders, production operations, and financial management are fragmented and lack integrated collaboration. Summary of the Invention
[0006] The purpose of this invention is to provide a nutritional prescription generation method, a nutritional prescription management system, and a storage medium based on the collaboration of a rule engine and a large language model, in order to solve the following technical problems existing in the prior art: the lack of deterministic computing engine constraints on AI-generated clinical numerical indicators leads to uncontrollable results; the lack of a complete processing pipeline for OCR recognition of medical documents; the lack of a mandatory multi-role signature verification mechanism for prescription approval; the lack of a configurable service provider switching architecture for system integration; and the lack of end-to-end closed-loop management of business processes.
[0007] To achieve the above objectives, the present invention adopts the following technical solution: This invention provides a method for generating nutritional prescriptions based on the collaboration of a rule engine and a large language model, comprising the following steps: Step S1: Obtain the health record of the elderly, which includes age, weight, height, medical history, allergy history and test results; Step S2: The deterministic rule engine module of the server calculates clinical indicators according to preset clinical calculation rules. The clinical indicators include calorie requirements, protein requirements, sodium intake limit, IDDSI swallowing texture grade and contraindication list. Step S3: The server encapsulates the clinical indicators into hard constraints of prompt words. The prompt words contain constraint statements that prohibit the generation of numerical values. The prompt words are input into a large language model. The large language model generates a textual description of a nutritional prescription within the constraints of the clinical indicators. The textual description does not contain any clinical numerical indicators. Step S4: The server combines the clinical indicators as numerical parts and the text description as explanatory parts to form a draft nutrition prescription. Step S5: The server sends the draft nutrition prescription to the issuer's terminal for the issuer to review. After the issuer approves the draft, the server sends the draft nutrition prescription to the reviewer's terminal for the reviewer to review independently. Step S6: The server verifies that the issuer and the reviewer are different users. After successful verification, a signature record with encrypted credentials is generated, and the draft nutrition prescription is converted into an official nutrition prescription.
[0008] This application calculates all clinical numerical indicators using a deterministic rule engine. The large language model generates textual descriptions only within the constraints of the rule engine's calculation results, achieving determinism and controllability in clinical numerical generation. Each prescription accurately displays the triggered rule number and calculation result, ensuring prescription security and traceability. A dual-role signature approval process mandates that the issuer and reviewer be different users, generating signature records with encrypted credentials, ensuring that prescriptions undergo independent review and meet medical regulatory requirements.
[0009] Furthermore, the process by which the deterministic rule engine module calculates the clinical indicators includes: The basal metabolic rate is calculated according to the metabolic rate calculation formula, and the calorie requirement is calculated according to the activity coefficient and the disease stress coefficient. The protein requirement value is calculated based on body weight and disease type; The upper limit of sodium intake is determined based on information on hypertension, heart disease, and kidney disease in the medical history. The IDDSI swallowing texture grade is determined based on the swallowing function assessment results; a contraindication list is generated based on the allergy history and medical history. This calculation method, based on medical formulas and clinical standards, ensures the accuracy and scientific rigor of the clinical indicators.
[0010] Furthermore, the deterministic rule engine module generates rule trigger records during the calculation of the clinical indicators. These records include the triggered rule number and the calculation result. The rule trigger records provide complete calculation evidence, facilitating review and traceability by clinical personnel.
[0011] Furthermore, the constraint statement instructs the large language model to generate only nutritional advice descriptions, dietary precautions, and food recommendations, and not to generate any clinical numerical indicators. This explicit constraint mechanism fundamentally avoids the risk of the large language model generating uncontrollable numerical values.
[0012] Furthermore, the encrypted certificate includes an issuer identifier, a reviewer identifier, a hash value of the content of the draft nutrition prescription, and a signature timestamp. The encrypted certificate uses an asymmetric encryption algorithm to generate a digital signature. The encrypted certificate ensures the immutability and verifiability of the signature record.
[0013] Furthermore, before obtaining the elderly person's health record, the process also includes processing the uploaded medical document PDF: The page splitting module splits the medical document PDF into multiple single-page images; the visual AI extraction module performs OCR recognition on the single-page images to extract text content and key information. The structured processing module converts the text content and key information into structured data; The manual review interface module displays the structured data for user verification and correction. The server then writes the corrected structured data into the health record management module. Through a complete OCR recognition pipeline, automated recognition and structured processing of Chinese medical documents are achieved, improving the efficiency of clinical information collection.
[0014] Furthermore, the visual AI extraction module employs a visual model independent of the large language model; the visual model is an independently deployed OCR visual recognition model. This decoupling design between the visual model and the large text language model improves the flexibility and maintainability of the system architecture.
[0015] Furthermore, the structured data includes the test item name, test value, test unit, reference range, test date, and diagnostic conclusion. This structured data provides standardized input for subsequent calculations of clinical indicators.
[0016] Furthermore, when a user orders goods based on the formal nutritional prescription, the server automatically filters the product catalog according to the contraindication list: The product catalog is filtered to remove products containing allergens from the contraindications list, products that conflict with diseases listed in the contraindications list, and products that do not match the IDDSI swallowing texture grade. Only the filtered product catalog is displayed to the user. This automatic contraindications filtering mechanism prevents users from ordering products unsuitable for the elderly's health condition, reducing medical risks.
[0017] Furthermore, it also includes steps for the collaboration of multiple AI capabilities: The nutritional risk assessment AI identifies the risks of malnutrition, protein deficiency, and dysphagia based on the health record, and outputs the risk level and a list of risk factors. The clinical interpretation AI performs medical interpretation of the risk level and the list of risk factors, and generates a clinical interpretation report. The clinical interpretation report is input into the deterministic rule engine module as supplementary information to the health record; The AI-powered nutritionist assistant helps clinical nutritionists optimize the draft nutrition prescriptions; the AI-powered customer service support responds to user inquiries based on the final nutrition prescriptions. This collaborative work of multiple AI capabilities enables intelligent management of the entire process, from risk assessment and clinical interpretation to prescription generation, nutritionist assistance, and customer service support.
[0018] The present invention also provides a nutrition prescription management system, comprising: The health record management module is used to store and manage the health records of the elderly. The health records include age, weight, height, medical history, allergy history and test results. The deterministic rule engine module is connected to the health record management module via a data connection and is used to calculate clinical indicators based on the health record. The clinical indicators include calorie requirements, protein requirements, sodium intake limit, IDDSI swallow texture grade, and a list of contraindications. The large language model interface module is connected to the deterministic rule engine module via a data connection. It is used to receive the clinical indicators as constraints and call the large language model to generate a textual description of the nutritional prescription. The textual description does not contain any clinical numerical indicators. The prescription synthesis module is connected to the deterministic rule engine module and the large language model interface module via data connection, and is used to merge the clinical indicators and the text description to generate a draft nutritional prescription. The dual-role approval module is connected to the prescription synthesis module via a data connection. It is used to manage the approval process of the issuer and the reviewer for the draft nutritional prescription, verify that the issuer and the reviewer are different users, and generate a signature record with encrypted credentials. The service provider abstract interface layer, deployed on the server, is used to define a unified service interface specification; The service provider implementation layer, deployed on the server, connects to the service provider abstract interface layer via a data connection and is used to provide multiple replaceable concrete implementations for the service interface specification; the configuration management layer, deployed on the server, connects to the service provider implementation layer via a data connection and is used to control the switching of service providers through configuration files or environment variables.
[0019] This system achieves decoupling between the rule engine and the large language model through modular design, supports cross-border deployment through a replaceable service provider architecture, and ensures the independence and security of prescription approval through a dual-role approval module.
[0020] Furthermore, the deterministic rule engine module includes: The rule base storage unit is used to store the rules for calculating clinical indicators; The rule execution unit is connected to the rule base storage unit via a data connection and is used to read the clinical indicator calculation rules and perform calculations. The rule triggering and recording unit, connected to the rule execution unit via a data connection, is used to record the triggered rule number and calculation result. The modular design of the rule engine facilitates the maintenance and expansion of clinical rules.
[0021] Furthermore, the rule base storage unit includes a visual rule editor, which comprises a graphical interface display unit, a rule condition configuration unit, a calculation formula editing unit, and a trigger threshold setting unit. This allows clinicians to configure rule conditions, calculation formulas, and trigger thresholds through a graphical interface. The visual rule editor lowers the technical barrier to clinical rule configuration and improves system usability.
[0022] Furthermore, the large language model interface module includes: The prompt word generation unit is connected to the deterministic rule engine module via a data connection, and is used to encapsulate the clinical indicators into prompt word hard constraints; The model calling unit is connected to the prompt word generation unit via a data connection and is used to call the large language model API; The result parsing unit, connected to the model invocation unit via a data connection, is used to parse the textual description returned by the large language model. The modular design of the large language model interface module facilitates switching between large language model service providers.
[0023] Furthermore, the model invocation unit supports switching between different large language model service providers via configuration files. This configurable design improves the system's adaptability to different large language model services.
[0024] Furthermore, the dual-role approval module includes: The role verification unit is used to verify that the issuer and the approver are different users; The signature process control unit is connected to the role verification unit via a data connection and is used to manage the flow of the nutritional prescription draft from the signatory to the reviewer; The encrypted certificate generation unit, connected to the signature process control unit via a data connection, is used to generate an encrypted certificate including the issuer's identifier, the reviewer's identifier, the content hash value of the draft nutrition prescription, and the signature timestamp. The dual-role approval module ensures the compliance and security of the prescription approval process.
[0025] Furthermore, it also includes a medical document OCR recognition module, which is connected to the health record management module via a data connection. The medical document OCR recognition module includes: PDF pagination unit, used to split uploaded medical document PDFs into multiple single-page images; The visual AI extraction unit is connected to the PDF pagination unit via a data connection and is used to perform OCR recognition on the single-page image to extract text content and key information; The structured processing unit is connected to the visual AI extraction unit via a data connection, and is used to convert the text content and the key information into structured data; The manual review interface unit, connected to the structured data processing unit via a data connection, is used to display the structured data for user verification and correction. The medical document OCR recognition module automates the processing of medical documents, improving the system's usability.
[0026] Furthermore, the visual AI extraction unit uses a visual model independent of the large language model in the large language model interface module. The visual model calls the independently deployed OCR visual recognition service through a replaceable interface. The independent deployment of the visual model improves the flexibility of the system architecture.
[0027] Furthermore, the service interface specifications defined in the service provider abstraction interface layer include login authentication service interfaces, payment service interfaces, SMS service interfaces, email service interfaces, logistics service interfaces, and e-invoice service interfaces. A unified service interface specification facilitates integration between different service providers.
[0028] Furthermore, the service provider implementation layer provides social media login and standard OAuth login implementations for the login authentication service interface, third-party payment implementation for the payment service interface, and cloud SMS service implementation for the SMS service interface. Multiple service provider implementations support system deployment in different markets.
[0029] Furthermore, the configuration management layer enables service provider switching by modifying environment variables in the configuration file, without requiring modifications to the business logic code. This configuration-based switching method reduces system maintenance costs and improves the flexibility of cross-border deployments.
[0030] Furthermore, it also includes a business closed-loop management module, which includes: The family member registration unit is used to manage the registration and authentication of family member users; The prescription order unit, connected to the family registration unit and the prescription synthesis module via a data connection, is used to manage family members' orders based on nutritional prescriptions; The kitchen production unit is connected to the prescription order unit via a data connection and is used to manage the kitchen's production tasks; The quality inspection and acceptance unit is connected to the kitchen production unit via a data connection and is used to manage the quality inspection of products. The warehousing and shipping unit is connected to the quality inspection and acceptance unit via a data connection and is used to manage the warehousing and shipping of products; the financial settlement unit is connected to the warehousing and shipping unit via a data connection and is used to manage the financial settlement of orders. The AI customer service unit, connected to the family registration unit via data link, provides knowledge-based AI customer service support. The business closed-loop management module achieves a complete closed loop from clinical assessment to commercial operation, improving overall operational efficiency.
[0031] Furthermore, the various units within the business closed-loop management module exchange data via RESTful API interfaces. User data from the family registration unit flows to the prescription order unit via API, while order data from the prescription order unit flows to the kitchen production unit via API, and subsequently to the quality inspection and acceptance unit, the warehousing and shipping unit, the financial settlement unit, and the AI customer service unit via API. Standardized API interfaces ensure smooth data flow between the various business units.
[0032] Furthermore, it also includes a multi-AI capability integration module, which includes: The nutritional risk assessment AI unit is connected to the health record management module via data connection and is used to identify the risks of malnutrition, protein deficiency, and dysphagia. The clinical interpretation AI unit is connected to the nutritional risk assessment AI unit via data connection and is used to perform medical interpretation of the risk assessment results; The nutrition prescription generation AI unit, namely the large language model interface module, is used to generate a textual description of the nutrition prescription. The nutritionist assistant AI unit is connected to the prescription synthesis module via data connection to assist clinical nutritionists in writing nutrition assessment reports; The customer service support AI unit, corresponding to the AI customer service unit, is used to respond to inquiries from family members. Each AI unit in the multi-AI capability integration module is deployed independently yet works collaboratively. The multi-AI capability integration module achieves intelligent support throughout the entire process, improving the overall intelligence level of the system.
[0033] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described method for generating nutritional prescriptions based on the collaboration of a rule engine and a large language model.
[0034] The beneficial effects that this application can produce include: 1) By employing a deterministic rule engine to calculate all clinical numerical indicators, the large language model generates textual descriptions only within the constraints of the rule engine's calculation results. This solves the problem of uncontrollable AI-generated clinical numerical values, achieving 100% accuracy in clinical indicators. Each prescription can accurately display the triggered rule number, input parameters, calculation results, and trigger timestamp, ensuring the security, auditability, and traceability of the prescription. At the same time, it reduces the cost of calling the large language model and improves the system's response speed.
[0035] 2) By adopting a complete medical document OCR recognition pipeline, including PDF pagination, visual AI extraction, structured processing, and a manual review interface, the difficulties in automated recognition and structured processing of Chinese medical documents are solved, improving the efficiency of clinical information collection. The manual review interface ensures the accuracy of recognition results and avoids clinical risks caused by OCR recognition errors. The decoupling design of the visual model and the large text language model improves the flexibility and maintainability of the system architecture.
[0036] 3) By adopting a dual-role encrypted signature approval process, the issuer and the reviewer are required to be different users, and a signature record with encrypted credentials is generated. This solves the problem of the lack of independent verification in prescription approval, ensures that prescriptions are independently reviewed and meet medical regulatory requirements, and the encrypted credentials ensure the immutability and verifiability of the signature record, providing a compliance foundation for future integration with Internet hospitals.
[0037] 4) By adopting a replaceable service provider architecture, including a service abstraction interface layer, a service provider implementation layer, and a configuration management layer, the problem of the system architecture being difficult to adapt to the needs of cross-border deployment is solved. The service provider can be switched by modifying the environment variables in the configuration file without modifying the business logic code, which reduces the system maintenance cost, improves the flexibility of cross-border deployment, and supports the expansion of the China-US dual market as well as other international markets in the future.
[0038] 5) By adopting a business closed-loop management module, including family registration, prescription orders, kitchen production, quality inspection and acceptance, warehousing and delivery, financial settlement and AI customer service units, the problem of the disconnect between business links such as clinical evaluation, commercial orders, production operation and financial management has been solved, realizing a complete closed loop from clinical evaluation to commercial operation. The standardized API interface ensures smooth data flow between various business units, improving overall operational efficiency and business collaboration capabilities. Attached Figure Description
[0039] Figure 1 This is a flowchart illustrating the nutritional prescription generation method based on the collaboration of a rule engine and a large language model according to the present invention. Figure 2 This is a schematic diagram of the module architecture of the nutrition prescription management system based on the collaboration of a rule engine and a large language model according to the present invention. Detailed Implementation
[0040] The present application is described in detail below with reference to the embodiments, but the present application is not limited to these embodiments.
[0041] This invention provides a method for generating nutritional prescriptions, a nutritional prescription management system, and a storage medium based on the collaboration of a rule engine and a large language model. The invention will be further described in detail below with reference to the accompanying drawings. The core improvement of this invention lies in the fact that, through a deterministic rule engine calculating all clinical numerical indicators (calories, protein, upper limit of sodium intake, IDSI swallowing texture, contraindications), the large language model generates textual descriptions and nutritional recommendations only within the constraints of the rule engine's calculation results. This solves the problem of uncontrollable AI-generated clinical numerical values and achieves security, auditability, consistency, and cost control.
[0042] Example 1 This embodiment describes the basic process of generating nutritional prescriptions based on the collaboration of a rule engine and a large language model. For example... Figure 1-2 As shown, the method includes four core steps: health record acquisition, rule engine calculation, large language model to generate text description, and dual-role signature approval.
[0043] Users upload their health records via a web interface or mobile device. These records include basic information (age, weight, height), medical history (diabetes, hypertension, dysphagia, etc.), allergy history (food allergens, drug allergens), and laboratory indicators (hemoglobin, albumin, blood glucose, kidney function indicators, etc.). After receiving the health records, the system's health record management module parses and verifies the uploaded data, extracting structured fields and storing them in the database.
[0044] The deterministic rule engine module reads the health records of the elderly from the database and performs calculations according to preset clinical calculation rules. Specifically, the rule engine first calculates the basal metabolic rate according to the Harris-Benedict formula, which is: male BEE = 66.47 + 13.75 × weight (kg) + 5.003 × height (cm) - 6.755 × age (years); female BEE = 655.1 + 9.563 × weight (kg) + 1.850 × height (cm) - 4.676 × age (years).
[0045] Then, the rules engine calculates the calorie requirement based on the elderly person's activity coefficient and disease stress coefficient. The activity coefficient is determined based on the elderly person's daily activity level: 1.2 for bedridden, 1.3 for light activity, and 1.5 for moderate activity. The disease stress coefficient is determined based on the type of disease: 1.0 for no stress, 1.2 for mild stress (such as infection), 1.5 for moderate stress (such as surgery), and 2.0 for severe stress (such as burns). Calorie requirement = BEE × Activity coefficient × Disease stress coefficient.
[0046] The rules engine calculates protein requirements based on weight and disease type. For healthy elderly individuals, the protein requirement is 1.0-1.2 g / kg body weight / day; for patients with chronic kidney disease, the protein requirement is 0.6-0.8 g / kg body weight / day; and for malnourished or pressure ulcer patients, the protein requirement is 1.5-2.0 g / kg body weight / day.
[0047] The rule engine determines the upper limit for sodium intake based on information about hypertension, heart disease, and kidney disease in the patient's medical history. For healthy elderly individuals, the upper limit for sodium intake is 2300 mg / day; for patients with hypertension, the upper limit is 1500 mg / day; and for patients with heart failure or renal insufficiency, the upper limit is 1000 mg / day.
[0048] The rule engine determines the IDDSI swallowing texture level based on the swallowing function assessment results. The IDDSI (International Dietary Standardization Initiative for Dysphagia) classifies food texture into eight levels: Level 0 is a thin liquid, Level 1 is a slightly thick liquid, Level 2 is a medium-thick liquid, Level 3 is a very thick liquid, Level 4 is a puree, Level 5 is finely chopped soft food, Level 6 is soft food, and Level 7 is regular food. The rule engine determines the appropriate IDDSI level based on the elderly person's swallowing function assessment report (such as the results of the water swallowing test and repeated saliva swallowing test).
[0049] The rules engine generates a list of contraindications based on allergy and medical history. The list includes allergen contraindications (such as allergies to peanuts, seafood, and dairy products), medical contraindications (such as diabetes patients should avoid high-sugar foods, kidney disease patients should limit high-potassium foods, and gout patients should limit high-purine foods), and drug-food interaction contraindications (such as warfarin patients should limit foods rich in vitamin K).
[0050] The rule engine generates rule trigger records during the calculation process. These records include the triggered rule number, input parameters, calculation result, and trigger timestamp. For example, rule number R001 (calculating BEE using the Harris-Benedict formula), with input parameters of gender = male, weight = 65kg, height = 170cm, and age = 75 years, will result in a BEE = 1350kcal, and the trigger timestamp will be 2026-06-15 10:23:45. These rule trigger records are stored in the database for subsequent auditing and traceability.
[0051] After the rule engine completes its calculations, it outputs the clinical indicators to the large language model interface module. The large language model interface module encapsulates the clinical indicators output by the rule engine into hard constraints for prompt words. The prompt word format is as follows: Please generate a textual description of the nutritional prescription based on the following clinical indicators. Clinical indicators: Caloric requirement 2000kcal / day, protein requirement 80g / day, sodium intake limit 1500mg / day, IDDSI texture grade 5 (finely chopped soft food), contraindications include peanut allergy and high-potassium food restriction. Requirements: Only generate nutritional advice descriptions, dietary precautions, and ingredient recommendations; do not generate any numerical values.
[0052] The prompt explicitly includes a constraint that no numerical values should be generated, ensuring that the large language model only generates textual descriptions. The large language model interface module calls the large language model API (such as DeepSeek or OpenAI) to send the prompt to the large language model server. Within the constraints of clinical indicators, the large language model generates a textual description of the nutritional prescription, which does not contain any clinical numerical indicators.
[0053] For example, the text description generated by the large language model is as follows: A diet high in protein, low in sodium, and consisting of finely chopped, soft foods is recommended. Prioritize high-quality protein sources such as lean meat, fish, and soy products, and avoid processed meats and pickled foods to control sodium intake. Food should be processed into finely chopped, soft pieces for easy swallowing. Avoid peanuts and peanut products, and limit the intake of high-potassium fruits such as bananas and oranges. It is recommended to eat small, frequent meals, 5-6 times a day, and ensure adequate water intake.
[0054] The large language model interface module receives the text description returned by the large language model and sends it to the prescription synthesis module. The prescription synthesis module combines the clinical indicators output by the rule engine as the numerical part and the text description output by the large language model as the explanatory part to generate a draft nutrition prescription. The draft nutrition prescription includes the elderly person's basic information, clinical indicator values, text description, rule trigger records, and generation timestamp.
[0055] The prescription synthesis module sends the draft nutrition prescription to the dual-role approval module. The dual-role approval module first sends the draft prescription to the issuer's terminal for review. The issuer is typically the clinical nutritionist responsible for the elderly person. The issuer reviews the draft prescription on their terminal, verifying the rationality of the clinical indicators, the accuracy of the written descriptions, and the degree of personalization. The issuer can edit and correct the written descriptions, but cannot modify the clinical indicator values (the values are calculated by the rule engine and cannot be manually modified).
[0056] After the issuer approves the prescription, they click the "Submit for Review" button on the terminal. The dual-role approval module records the issuer's user ID and signature timestamp, and then routes the prescription draft to the reviewer's terminal for independent review. The reviewer is usually another senior nutritionist or clinician. The reviewer views the prescription draft and issuer information on the terminal and independently reviews the clinical rationale of the prescription.
[0057] After the reviewer approves the application, they click the "Approve" button on the terminal. The dual-role approval module verifies that the issuer and reviewer are different users by comparing the issuer's user ID with the reviewer's user ID to confirm that they are different. Once the verification is successful, the dual-role approval module generates a signature record with encrypted credentials.
[0058] The encrypted credential includes the issuer's identifier, the reviewer's identifier, the prescription content hash (calculated using the SHA-256 algorithm to calculate the content hash of the prescription draft), and a signature timestamp. The encrypted credential uses the RSA asymmetric encryption algorithm to generate a digital signature. The private key is stored in a secure keystore on the server, while the public key is publicly available for verification. The digital signature ensures the immutability and verifiability of the signed record.
[0059] The dual-role approval module attaches a signature record to the prescription draft, which is then converted into a formal nutrition prescription. The formal nutrition prescription is stored in the database and marked as effective. The system sends a prescription effectiveness notification to the issuer, reviewer, and the senior's family member. Family members can view the formal nutrition prescription in the family portal and order goods based on the prescription.
[0060] Through the above process, this invention achieves collaborative operation between the rule engine and the large language model. The rule engine is responsible for calculating all clinical numerical indicators, ensuring the accuracy and scientific validity of the values; the large language model is responsible for generating textual descriptions, providing personalized nutritional advice and dietary guidance; the dual-role approval process ensures that prescriptions are independently verified and meet medical regulatory requirements. Each prescription can accurately display the triggered rule number, input parameters, calculation results, and trigger timestamp, achieving auditability and traceability.
[0061] Example 2 This embodiment, based on Embodiment 1, adds a medical document OCR intelligent recognition pipeline for automatically recognizing and structuring uploaded medical document PDFs. Medical documents include hospital diagnostic reports, test reports, hospitalization records, etc., and are usually scanned PDF files containing a large amount of unstructured Chinese text and tabular data.
[0062] After a user uploads a medical document PDF via the web interface or mobile device, the system sends the PDF file to the medical document OCR recognition module. The medical document OCR recognition module consists of four processing units: PDF pagination unit, visual AI extraction unit, structured processing unit, and manual review interface unit.
[0063] The PDF pagination unit receives the uploaded PDF document and uses the PyPDF2 library to split the PDF into multiple single-page images. The splitting process is as follows: read the total number of pages in the PDF file, extract each page, convert each page into a PNG image file, and set the image resolution to 300 dpi to ensure OCR recognition accuracy. The single-page image files are stored in a temporary directory, and the file name format is documentID_pagenumber.png.
[0064] The visual AI extraction unit 203 performs OCR recognition on the single-page image to extract text content and key information. The visual model used by the visual AI extraction unit is independent of the large language model and calls localized visual services in China through a replaceable interface. In the Chinese deployment environment, the visual model is either Qwen-VL or GLM-4V, and calls are made via an HTTP API interface. The visual AI extraction unit encodes the single-page image into Base64 format and constructs an API request to send to the visual server.
[0065] The vision server performs OCR recognition on images, extracting text content, table structure, and key information. For test report documents, the vision model recognizes fields such as test item name, test value, test unit, reference range, and test date. For diagnostic report documents, the vision model recognizes text paragraphs such as diagnostic conclusions, medical history descriptions, and medication recommendations. The vision server returns the recognition results in JSON format, containing structured data including text content and key information.
[0066] The structured processing unit receives JSON data extracted by the visual AI and performs further structured processing. For test reports, the structured processing unit parses the JSON data, extracts fields such as test item name, test value, test unit, reference range, and test date, and converts them into a standardized data structure. For example, the original JSON data is {"text":"Hemoglobin 120 g / L (110-160)","date":"2026-05-15"}, and after parsing, the structured processing unit outputs {"exam_item":"Hemoglobin","value":120,"unit":"g / L","reference_range":"110-160","exam_date":"2026-05-15"}.
[0067] The structured processing unit validates and cleans the extracted data. Validation rules include: test values must be numeric, test dates must conform to a date format, and test item names must be in a predefined test item dictionary. Data that does not meet the validation rules is marked by the structured processing unit as requiring manual review. Cleaning rules include: removing spaces and line breaks from text content, standardizing the representation of test units (e.g., unifying "g / L" and "grams per liter" to "g / L"), and standardizing date formats (e.g., unifying "2026-05-15" and "May 15, 2026" to "2026-05-15").
[0068] The manual review interface displays structured data on a web interface for users to verify and correct. The interface presents the recognition results in tabular form, with each row corresponding to a verification item. Columns include the verification item name, verification value, verification unit, reference range, verification date, and recognition confidence level. Data rows requiring manual review are highlighted in red. Users can directly edit field content on the interface to correct OCR recognition errors.
[0069] After the user completes the review and corrections, they click the "Confirm and Submit" button. The system then writes the corrected structured data into the health record management module. This structured data is linked to the senior's health record and stored in the laboratory indicator table of the database. Subsequently, when the rule engine module calculates clinical indicators, it can directly read the laboratory indicator data from the database without manual input.
[0070] This invention solves the problems of automated recognition and structuring of Chinese medical documents through a medical document OCR recognition pipeline, improving the efficiency of clinical information collection. For a test report containing 20 test items, manual entry takes approximately 10 minutes, while the OCR recognition pipeline only takes about 30 seconds, improving efficiency by about 20 times. The manual review interface ensures the accuracy of the recognition results, avoiding clinical risks caused by OCR errors. The decoupling of the visual model and the large text language model improves the flexibility and maintainability of the system architecture; upgrading or replacing the visual model does not affect the use of the large text language model.
[0071] Example 3 This embodiment, based on Embodiment 1, adds a replaceable service provider architecture to support service switching between the Chinese and American markets. The replaceable service provider architecture comprises a three-layer design: a service abstraction interface layer, a service provider implementation layer, and a configuration management layer.
[0072] The service abstract interface layer defines a unified service interface specification. This specification is defined using either an abstract interface or a protocol, with each interface defining a standard method signature. For example, the login authentication service interface `IAuthService` defines a `login` method with the signature `login(username: str, password: str) -> AuthToken`. The input parameters are the username and password, and the return value is an authentication token object `AuthToken`.
[0073] The service interface specifications defined in the service abstraction interface layer include: Login authentication service interface IAuthService, Payment service interface IPaymentService, SMS service interface ISMSService, Email service interface IEmailService, Logistics service interface ILogisticsService, and Electronic invoice service interface IInvoiceService. Each interface defines the standard methods for that service. For example, IPaymentService defines the create_payment method (to create a payment order), the query_payment method (to query the payment status), and the refund_payment method (to issue a refund).
[0074] The service provider implementation layer provides multiple concrete implementations for each abstract interface. Concrete implementation classes inherit from the abstract interface and implement all methods defined in the interface. For example, the IAuthService interface has two concrete implementations: WeChatAuthProvider (WeChat login implementation) and OAuthProvider (standard OAuth login implementation). When WeChatAuthProvider implements the login method, it calls the WeChat Open Platform's OAuth interface to obtain WeChat user information and generates an internal authentication token. When OAuthProvider implements the login method, it calls the authorization server of the standard OAuth 2.0 protocol to obtain an access token and generates an internal authentication token.
[0075] The service provider implementation layer provides two concrete implementations for the IPaymentService interface: WeChatPayProvider (WeChat Pay implementation) and StripePayProvider (US Stripe payment implementation). When WeChatPayProvider implements the create_payment method, it calls the WeChat Pay unified order API to generate a prepayment transaction session identifier (prepay_id) and returns payment parameters for the front-end to invoke WeChat Pay. When StripePayProvider implements the create_payment method, it calls the Stripe Payment Intents API to create a payment intent object (PaymentIntent) and returns the client secret (client_secret) for the front-end to invoke the Stripe payment interface.
[0076] The service provider implementation layer provides two concrete implementations for the ISMSService interface: AliyunSMSProvider (Aliyun SMS implementation) and TwilioSMSProvider (Twilio SMS implementation in the US). When AliyunSMSProvider implements the send_sms method, it calls the Aliyun SMS service API to send an SMS verification code to a Chinese mobile number. When TwilioSMSProvider implements the send_sms method, it calls the Twilio SMS API to send an SMS verification code to a US mobile number.
[0077] The configuration management layer controls service provider switching via configuration files or environment variables. The configuration file is in YAML format, named config.yaml, and includes service provider selections for each service. For example, the configuration file content might be: AUTH_PROVIDER: wechat, PAYMENT_PROVIDER: wechatpay, SMS_PROVIDER: aliyun, EMAIL_PROVIDER: aliyun, LOGISTICS_PROVIDER: sf_express, INVOICE_PROVIDER: fapiao_cn.
[0078] The configuration management layer reads the configuration file at system startup and dynamically loads the corresponding service provider implementation based on the configuration items. For example, if the AUTH_PROVIDER configuration item is read as "wechat", the WeChatAuthProvider class is loaded and instantiated, and the instance is injected into the dependency injection container. The business logic code obtains an instance of the IAuthService interface through dependency injection, but in actual runtime, it obtains a WeChatAuthProvider instance, and executes the WeChat login logic when the login method is called.
[0079] Service provider switching is achieved by modifying environment variables in the configuration file, without requiring changes to the business logic code. For example, when deploying in the Chinese market, the configuration file sets AUTH_PROVIDER=wechat, PAYMENT_PROVIDER=wechatpay, and SMS_PROVIDER=aliyun; when deploying in the US market, the configuration file sets AUTH_PROVIDER=oauth, PAYMENT_PROVIDER=stripe, and SMS_PROVIDER=twilio. The business logic code remains unchanged; only the selection of the service provider is controlled through the configuration file.
[0080] By employing a replaceable service provider architecture, this invention solves the architectural flexibility issue in cross-border deployments. It allows for switching between the Chinese and US markets without system reconstruction, reducing long-term maintenance costs and supporting international expansion. When deployed in the Chinese market, simply modifying the configuration file to switch the service provider to a localized Chinese service (WeChat login, WeChat Pay, Alibaba Cloud SMS, etc.) allows the system to function normally. Similarly, when deployed in the US market, simply modifying the configuration file to switch the service provider to a localized US service (OAuth login, Stripe payment, Twilio SMS, etc.) allows the system to function normally.
[0081] Example 4 This embodiment verifies the technical effectiveness of the method of the present invention through a comparative experiment. The experiment selected 100 real health records of elderly individuals, aged 65-95 years, including those with common diseases such as diabetes, hypertension, dysphagia, and malnutrition. Nutritional prescriptions were generated using the method of the present invention (rule engine + large language model collaboration) and a comparative method (pure large language model generation). The accuracy of clinical indicators, textual description quality, approval rate, average generation time, and average cost of the two methods were compared.
[0082] The comparison method adopts the flexible compliance review method using AI models disclosed in CN121260359A. This involves directly calling a large language model to generate a nutritional prescription (including clinical numerical indicators and textual descriptions), and then conducting post-approval through a rule engine. Specifically, the elderly person's health record is used as input. A prompt is constructed asking the elderly person to generate a nutritional prescription based on the following health record: calorie requirements, protein requirements, sodium intake limit, IDDSI texture grade, contraindication list, and nutritional advice description. The large language model API is then called to generate a complete prescription, which is then submitted to the rule engine to verify the rationality of the values.
[0083] The experimental results are shown in the table below: Table 1 Performance comparison between the method of the present invention and the comparative method
[0084] Clinical indicator accuracy analysis: Because the method of this invention uses a deterministic rule engine for calculation, all clinical numerical indicators conform to medical standards (such as the Harris-Benedict formula, GLIM standard, etc.), achieving 100% accuracy. The comparative method, relying on a large language model to generate numerical values, has a 22% error rate. Error types include: calorie calculation deviating from the basal metabolic rate (e.g., calculating the calorie requirement of a 75-year-old male as 3000 kcal / day, far exceeding the normal range); sodium intake exceeding the safe upper limit (e.g., setting the upper limit of sodium intake for heart failure patients to 2300 mg / day, when it should be 1000 mg / day); and inappropriate selection of IDDSI texture grade (e.g., setting the texture grade of a patient with severe dysphagia to level 7, ordinary food, when it should be level 3-4, pureed).
[0085] Analysis of approval rate: The method of this invention ensures clinical rationality because the values calculated by the rule engine are already clinically sound. Nutritionists only need to focus on the accuracy and personalization of the written description during review, achieving a 95% first-time approval rate. The 5 cases that failed mainly required further personalization adjustments to the written description; the numerical values did not need modification. The comparative method, due to numerical errors, required nutritionists to correct the values and resubmit, resulting in a first-time approval rate of only 68%. Of the 32 cases that failed, 28 had numerical errors requiring correction, and 4 had textual descriptions requiring adjustment.
[0086] Average generation time analysis: The method of this invention has a total time of 3.2 seconds because the rule engine has a fast calculation speed (average 1.5 seconds) and the large language model only generates text descriptions (average 1.7 seconds). The comparative method has a total time of 5.8 seconds because the large language model needs to generate both numerical values and text descriptions (average 4.5 seconds), plus post-event rule review (average 1.3 seconds). The method of this invention improves the generation speed by 44.8%.
[0087] Average Cost Analysis: The method of this invention generates only textual descriptions using a large language model, resulting in a smaller number of input and output tokens. The API call cost is 0.05 yuan per prescription (based on DeepSeek API pricing, approximately 500 input tokens and 300 output tokens). In contrast, the comparative method requires both numerical values and textual descriptions to be generated using a large language model, resulting in a larger number of input and output tokens. The API call cost is 0.12 yuan per prescription (approximately 800 input tokens and 600 output tokens). The method of this invention reduces costs by 58.3%.
[0088] Comparative experiments have demonstrated that the rule engine and large language model collaborative architecture adopted in this invention significantly improves clinical indicator accuracy, approval rate, generation speed, and cost efficiency compared to pure large language model generation methods. In particular, the accuracy of clinical indicators reaches 100%, solving the core problem of uncontrollable AI-generated values and achieving unexpected technical effects.
[0089] Example 5 This embodiment, based on Embodiment 1, adds a multi-AI capability integration module, including five independent AI units: nutritional risk assessment AI, clinical interpretation AI, nutritional prescription generation AI, nutritionist assistant AI, and customer service support AI. Each AI unit is deployed independently yet works collaboratively, achieving intelligent management throughout the entire process from risk assessment, clinical interpretation, prescription generation to nutritionist assistance and customer service support.
[0090] The nutritional risk assessment AI unit identifies risks of malnutrition, protein deficiency, and dysphagia based on the elderly's health records. The unit uses a specially trained classification model, taking into account the elderly's age, weight, BMI, albumin, hemoglobin, lymphocyte count, and weight change rate, and outputting a risk level (high / medium / low) and a list of risk factors.
[0091] The malnutrition risk assessment adopts the GLIM standard (Global Leadership Initiative for the Diagnosis of Malnutrition), and the assessment indicators include: weight loss (more than 5% weight loss in 6 months is moderate, more than 10% is severe), decreased BMI (BMI <20 is moderate, <18.5 is severe), and decreased muscle mass (assessed by grip strength or muscle circumference). The nutritional risk assessment AI unit calculates the malnutrition risk level based on these indicators and outputs a list of risk factors. For example, an 8% weight loss in 6 months, a BMI of 19.2, and an albumin level of 32 g / L indicate a moderate risk of malnutrition.
[0092] Protein deficiency risk assessment is based on biochemical indicators such as serum albumin, prealbumin, and transferrin. Albumin levels <35 g / L indicate protein deficiency, while <30 g / L indicates severe protein deficiency. The nutritional risk assessment AI unit outputs the protein deficiency risk level and risk factors; for example, an albumin level of 28 g / L and a prealbumin level of 150 mg / L indicate a severe protein deficiency risk.
[0093] The risk assessment of dysphagia is based on the results of a swallowing function assessment. Assessment methods include a water swallowing test (choking while drinking, prolonged drinking time suggests dysphagia) and a repeated saliva swallowing test (less than 3 swallows within 30 seconds suggests dysphagia). The nutritional risk assessment AI unit outputs the dysphagia risk level and risk factors, such as a positive water swallowing test or choking while drinking, indicating a high risk of dysphagia.
[0094] The Clinical Interpretation AI unit provides medical interpretation of nutritional risk assessment results, explaining their clinical significance and possible causes. This unit employs a large language model, taking as input the risk level and risk factor list output by the nutritional risk assessment AI unit, and outputting a clinical interpretation report.
[0095] For example, if the input is albumin of 28 g / L and prealbumin of 150 mg / L, indicating a risk of severe protein deficiency, the clinical interpretation AI unit generates an interpretation report: Serum albumin below 30 g / L suggests protein-energy malnutrition, which may be related to the following factors: 1) Increased protein breakdown due to chronic diseases such as cancer, chronic infections, and chronic heart failure; 2) Insufficient intake, such as decreased appetite, difficulty swallowing, or reduced food intake; 3) Malabsorption, such as decreased protein absorption due to gastrointestinal diseases or postoperative malabsorption. It is recommended to increase the intake of high-quality protein, and enteral or parenteral nutrition support should be considered if necessary.
[0096] Clinical interpretation reports serve as supplementary information to health records and are input into the deterministic rule engine module. When calculating clinical indicators, the rule engine refers to risk factors in the clinical interpretation reports and adjusts indicators such as protein and calorie requirements. For example, for elderly individuals at risk of severe protein deficiency, the rule engine increases the protein requirement from the standard 1.0g / kg body weight / day to 1.5-2.0g / kg body weight / day.
[0097] The nutrition prescription generation AI unit, also known as the large language model interface module in Example 1, generates a textual description of a personalized nutrition plan under the constraints of the rule engine's calculation results. The inputs to the nutrition prescription generation AI unit include clinical indicators output by the rule engine and clinical interpretation reports output by the clinical interpretation AI unit; the output is a textual description of the nutrition prescription.
[0098] The Nutritionist Assistant AI unit assists clinical nutritionists in writing nutritional assessment reports, follow-up records, and health education materials. Utilizing a large language model, the Nutritionist Assistant AI unit provides text polishing, medical terminology suggestions, and reference recommendations. When writing a nutritional assessment report, nutritionists can submit a draft to the Nutritionist Assistant AI unit. The AI unit polishes the draft, improving language expression, adding medical terminology, and recommending relevant references. For example, if the nutritionist's initial draft indicates a patient with weight loss and low albumin levels, requiring increased protein intake, the Nutritionist Assistant AI unit, after polishing, outputs that the patient has lost 8% of their body weight in 6 months, with a serum albumin level of 28 g / L, indicating protein-energy malnutrition. It recommends increasing high-quality protein intake to 1.5-2.0 g / kg body weight / day, prioritizing lean meat, fish, and soy products, and considering enteral nutrition supplementation if necessary.
[0099] The AI-powered customer service support unit responds to family members' inquiries regarding products, delivery, and prescriptions. Utilizing a large language model, the unit automatically replies to family members' questions based on a knowledge base (user manual, FAQs). The knowledge base includes product information (nutritional components, target population, usage instructions), delivery information (delivery area, delivery time, delivery cost), and prescription information (prescription interpretation, dietary advice, contraindications), among other things.
[0100] Family members can submit inquiries via the web interface or mobile app, such as, "Why is sodium intake restricted in my father's prescription?" Customer support's AI unit searches the knowledge base, finds relevant information, and generates a response: "Based on your father's health record, he suffers from hypertension and heart failure; therefore, the prescription sets the upper limit for sodium intake at 1000mg / day. High sodium intake can lead to increased blood pressure and fluid retention, worsening heart failure symptoms. It is recommended to avoid processed meats, pickled foods, and other high-sodium foods. Use less salt when cooking and use spices, lemon juice, etc., for seasoning."
[0101] The customer service support AI unit supports automatic Chinese-English translation. For inquiries in English, the AI unit first translates the question into Chinese, retrieves a Chinese response from the knowledge base, and then translates the response back into English. For complex issues, the AI unit escalates the issue to a human customer service representative. The human representative can review the AI unit's initial response and provide supplementary and corrective information.
[0102] By integrating multiple AI capabilities, this invention achieves end-to-end intelligent processing from risk assessment, clinical interpretation, prescription generation to nutritionist assistance and customer service support, thereby enhancing the overall intelligence level of the platform. The independent deployment of AI units improves the system's maintainability and scalability; upgrading or replacing a single AI unit does not affect other units.
[0103] It is understood that the deterministic rule engine in the above embodiments is not limited to Python implementation; it can also be implemented using programming languages such as Java, C++, and Go, for example, using the Java Drools rule engine framework or the Python PyKE rule engine framework. The large language model is not limited to DeepSeek or OpenAI; other large language model services such as Claude, Gemini, Wenxin Yiyan, and Tongyi Qianwen can be used, invoked through replaceable interfaces. The visual AI model is not limited to Qwen-VL or GLM-4V; other visual model services such as Baidu OCR, Tencent OCR, and Google Vision API can be used. The encrypted credentials are not limited to the RSA asymmetric encryption algorithm; other digital signature algorithms such as ECDSA and EdDSA can be used. Dual-role approval is not limited to nutritionists and doctors; it can be extended to multi-role approval, such as a three-level approval process of nutritionist → chief nutritionist → doctor, or dynamically adjusting the number of approval roles based on the prescription risk level. The business loop is not limited to elderly care institutions; it can also be applied to other medical scenarios such as hospital nutrition departments, community health centers, rehabilitation institutions, and home care. The replaceable service provider architecture is not limited to the US and Chinese markets, but can also be extended to other international markets such as Europe and Southeast Asia, supporting more localized service providers in more countries, such as SEPA payments in Europe and GrabPay in Southeast Asia.
[0104] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
[0105] 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 nutritional prescriptions based on the collaboration of a rule engine and a large language model, characterized in that, Includes the following steps: S1. Obtain the health record of the elderly, which includes age, weight, height, medical history, allergy history and test results; S2. The deterministic rule engine module of the server calculates clinical indicators according to preset clinical calculation rules. The clinical indicators include calorie requirements, protein requirements, sodium intake limit, IDDSI swallowing texture grade and contraindication list. S3. The server encapsulates the clinical indicators into hard constraints of prompt words, the prompt words containing constraint statements that prohibit the generation of numerical values, and inputs the prompt words into a large language model. The large language model generates a textual description of a nutritional prescription within the constraints of the clinical indicators. The textual description does not contain any clinical numerical indicators. S4. The server combines the clinical indicators as numerical parts and the text description as explanatory parts to form a draft nutrition prescription. S5. The server sends the draft nutrition prescription to the issuer's terminal for the issuer to review. After the issuer approves the draft, the server sends the draft nutrition prescription to the reviewer's terminal for the reviewer to review independently. S6. The server verifies that the issuer and the reviewer are different users. After the verification is successful, a signature record with encrypted credentials is generated, and the draft nutrition prescription is converted into an official nutrition prescription.
2. The nutritional prescription generation method based on the collaboration of rule engine and large language model according to claim 1, characterized in that, In step S2, the process by which the deterministic rule engine module calculates the clinical indicators includes: The basal metabolic rate is calculated according to the metabolic rate calculation formula, and the calorie requirement is calculated according to the activity coefficient and the disease stress coefficient. The protein requirement value is calculated based on body weight and disease type; The upper limit of sodium intake is determined based on information on hypertension, heart disease, and kidney disease in the medical history. The IDDSI swallow texture grade is determined based on the swallowing function assessment results; the contraindication list is generated based on the allergy history and the medical history. Preferably, the deterministic rule engine module generates a rule trigger record during the calculation of the clinical indicators, and the rule trigger record includes the triggered rule number and the calculation result.
3. The nutritional prescription generation method based on the collaboration of rule engine and large language model according to claim 1, characterized in that, In step S3, the constraint statement instructs the large language model to generate only nutritional advice descriptions, dietary precautions, and food recommendations, and not to generate any clinical numerical indicators. Preferably, in step S6, the encryption certificate includes an issuer identifier, an auditor identifier, a content hash value of the nutritional prescription draft, and a signature timestamp, and the encryption certificate uses an asymmetric encryption algorithm to generate a digital signature.
4. The nutritional prescription generation method based on the collaboration of rule engine and large language model according to claim 1, characterized in that, Prior to step S1, the process also includes processing the uploaded medical document PDF: S01. The page splitting module splits the medical document PDF into multiple single-page images; S02. The visual AI extraction module performs OCR recognition on the single-page image to extract text content and key information; S03. The structured processing module converts the text content and the key information into structured data; S04. The manual review interface module displays the structured data for users to verify and correct, and the server writes the corrected structured data into the health record management module. Preferably, in step S02, the visual AI extraction module uses a visual model independent of the large language model, and the visual model is an independently deployed OCR visual recognition model. Preferably, in step S03, the structured data includes the test item name, test value, test unit, reference range, test date, and diagnostic conclusion.
5. The nutritional prescription generation method based on the collaboration of a rule engine and a large language model according to claim 1, characterized in that, When a user orders goods based on the formal nutritional prescription, the server automatically filters the product catalog according to the contraindication list: The product catalog is filtered to remove products containing allergens from the contraindications list, products that conflict with the contraindications list, and products that do not match the IDDSI swallowing texture grade. Only the filtered product catalog is displayed to the user.
6. The nutritional prescription generation method based on the collaboration of rule engine and large language model according to claim 1, characterized in that, It also includes steps for multi-AI capability collaboration: The nutritional risk assessment AI identifies the risks of malnutrition, protein deficiency, and dysphagia based on the health record, and outputs the risk level and a list of risk factors. The clinical interpretation AI performs medical interpretation of the risk level and the list of risk factors, and generates a clinical interpretation report. The clinical interpretation report is input into the deterministic rule engine module as supplementary information to the health record; AI-powered nutritionist assistants optimize the text of draft nutrition prescriptions for clinical nutritionists. Customer support AI responds to user inquiries based on the official nutritional prescription.
7. A nutrition prescription management system, characterized in that, include: The health record management module is used to store and manage the health records of the elderly. The health records include age, weight, height, medical history, allergy history and test results. The deterministic rule engine module is connected to the health record management module via a data connection and is used to calculate clinical indicators based on the health record. The clinical indicators include calorie requirements, protein requirements, sodium intake limit, IDDSI swallow texture grade, and a list of contraindications. The large language model interface module is connected to the deterministic rule engine module via a data connection. It is used to receive the clinical indicators as constraints and call the large language model to generate a textual description of the nutritional prescription. The textual description does not contain any clinical numerical indicators. The prescription synthesis module is connected to the deterministic rule engine module and the large language model interface module via data connection, and is used to merge the clinical indicators and the text description to generate a draft nutritional prescription. The dual-role approval module is connected to the prescription synthesis module via a data connection. It is used to manage the approval process of the issuer and the reviewer for the draft nutritional prescription, verify that the issuer and the reviewer are different users, and generate a signature record with encrypted credentials. The service provider abstract interface layer, deployed on the server, is used to define a unified service interface specification; The service provider implementation layer, deployed on the server, connects to the service provider abstract interface layer via a data connection and is used to provide multiple replaceable concrete implementations for the service interface specification; The configuration management layer is deployed on the server and establishes a layer connection with the service provider through a data connection. It is used to control the switching of service providers through configuration files or environment variables.
8. The nutrition prescription management system according to claim 7, characterized in that, The deterministic rule engine module includes: The rule base storage unit is used to store the rules for calculating clinical indicators; The rule execution unit is connected to the rule base storage unit via a data connection and is used to read the clinical indicator calculation rules and perform calculations. The rule triggering recording unit is connected to the rule execution unit via a data connection and is used to record the triggered rule number and calculation result; Preferably, the rule base storage unit includes a visual rule editor, which includes a graphical interface display unit, a rule condition configuration unit, a calculation formula editing unit, and a trigger threshold setting unit, supporting clinical personnel to configure rule conditions, calculation formulas, and trigger thresholds through the graphical interface; Preferably, the large language model interface module includes: The prompt word generation unit is connected to the deterministic rule engine module via a data connection, and is used to encapsulate the clinical indicators into prompt word hard constraints; The model calling unit is connected to the prompt word generation unit via a data connection and is used to call the large language model API; The result parsing unit is connected to the model calling unit via a data connection and is used to parse the text description returned by the large language model. Preferably, the model invocation unit supports switching between different large language model service providers via configuration files; Preferably, the dual-role approval module includes: The role verification unit is used to verify that the issuer and the approver are different users; The signature process control unit is connected to the role verification unit via a data connection and is used to manage the flow of the nutritional prescription draft from the signatory to the reviewer; The encrypted certificate generation unit is connected to the signature process control unit via a data connection and is used to generate an encrypted certificate that includes the issuer's identifier, the reviewer's identifier, the content hash value of the nutritional prescription draft, and the signature timestamp.
9. The nutrition prescription management system according to claim 7, characterized in that, It also includes a medical document OCR recognition module, which is connected to the health record management module via a data connection. The medical document OCR recognition module includes: PDF pagination unit, used to split uploaded medical document PDFs into multiple single-page images; The visual AI extraction unit is connected to the PDF pagination unit via a data connection and is used to perform OCR recognition on the single-page image to extract text content and key information; The structured processing unit is connected to the visual AI extraction unit via a data connection, and is used to convert the text content and the key information into structured data; The manual review interface unit is connected to the structured processing unit via a data connection, and is used to display the structured data for users to verify and correct. Preferably, the visual AI extraction unit uses a visual model that is independent of the large language model in the large language model interface module, and the visual model calls an independently deployed OCR visual recognition service through a replaceable interface; Preferably, the service interface specifications defined by the service provider abstract interface layer include login authentication service interface, payment service interface, SMS service interface, email service interface, logistics service interface, and electronic invoice service interface; Preferably, the service provider implementation layer provides social media login and standard OAuth login implementations for the login authentication service interface, third-party payment implementation for the payment service interface, and cloud SMS service implementation for the SMS service interface; Preferably, the configuration management layer switches service providers by modifying environment variables in the configuration file, and the switching of service providers does not require modification of business logic code; Preferably, it further includes a business closed-loop management module, the business closed-loop management module comprising: The family member registration unit is used to manage the registration and authentication of family member users; The prescription order unit, connected to the family registration unit and the prescription synthesis module via a data connection, is used to manage family members' orders based on nutritional prescriptions; The kitchen production unit is connected to the prescription order unit via a data connection and is used to manage the kitchen's production tasks; The quality inspection and acceptance unit is connected to the kitchen production unit via a data connection and is used to manage the quality inspection of products. The warehousing and shipping unit is connected to the quality inspection and acceptance unit via a data connection and is used to manage the warehousing and shipping of products. The financial settlement unit is connected to the warehousing and shipping unit via a data connection and is used to manage the financial settlement of orders; The AI customer service unit is connected to the family registration unit via a data connection to provide AI customer service support based on a knowledge base. Preferably, the data flow between the units in the business closed-loop management module is carried out through a RESTful API interface. The user data of the family registration unit is transferred to the prescription order unit through the API interface, the order data of the prescription order unit is transferred to the kitchen production unit through the API interface, and then sequentially transferred to the quality inspection and acceptance unit, the warehousing and delivery unit, the financial settlement unit and the AI customer service unit through the API interface. Preferably, it further includes a multi-AI capability integration module, the multi-AI capability integration module comprising: The nutritional risk assessment AI unit is connected to the health record management module via data connection and is used to identify the risks of malnutrition, protein deficiency, and dysphagia. The clinical interpretation AI unit is connected to the nutritional risk assessment AI unit via data connection and is used to perform medical interpretation of the risk assessment results; The nutrition prescription generation AI unit, namely the large language model interface module, is used to generate a textual description of the nutrition prescription. The nutritionist assistant AI unit is connected to the prescription synthesis module via data connection to assist clinical nutritionists in writing nutrition assessment reports; The customer service support AI unit, corresponding to the AI customer service unit, is used to respond to inquiries from family members; In the multi-AI capability integration module, each AI unit is deployed independently and works collaboratively.
10. A computer-readable storage medium, characterized in that, The device contains a computer program that, when executed by a processor, implements the steps of the nutritional prescription generation method based on the collaboration of a rule engine and a large language model as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Clinical prescription compliance auditing method and system
CN121260359A
Knowledge graph and large language model-based nephropathy diet recommendation method and system
CN121439100A