Patient characterization method and drug recommendation system based on semantic enhanced causal diagram

By constructing a patient representation method based on semantically enhanced causal graphs, the shortcomings of existing drug recommendation systems in patient entity coding structure and causal relationship modeling are addressed, thereby improving the accuracy and safety of drug recommendations and meeting clinical needs.

CN121011306APending Publication Date: 2025-11-25CHONGQING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511114714.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-11
Publication Date
2025-11-25

AI Technical Summary

Technical Problem

Existing drug recommendation systems have shortcomings in patient entity coding structure representation and relation modeling. They fail to effectively integrate the multi-level classification and subordinate dependency relationships of the medical coding system and ignore the causal dependencies between entities, resulting in insufficient accuracy and safety of drug recommendations.

Method used

We employ a patient representation method based on semantically enhanced causal graphs. By constructing fine-grained coding structures for diagnosis, surgery, and medication, we optimize the causal graph using Bayesian equivalence scoring functions and greedy intervention equivalence search algorithms. Combined with gating mechanisms and multi-label classifiers, we generate more accurate drug recommendations.

Benefits of technology

It significantly improves the accuracy and safety of drug recommendations, meets clinical needs for drug safety and interpretability, and achieves more precise drug recommendations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121011306A_ABST
    Figure CN121011306A_ABST
Patent Text Reader

Abstract

The invention discloses a patient characterization method based on a semantic enhanced causal diagram and a drug recommendation system, and relates to the technical field of digital medical treatment. According to the system, the advantages of a hierarchical structure of ICD and ATC medical coding systems are fully utilized, and a structure-guided entity semantic representation learning model is constructed by designing a mask language model, so that real semantic embedding representation which is more fit with diagnosis, operation and drug entities is generated; an entity causal graph model based on causal inference is constructed, a causal graph reflecting a clinical real dependency relationship is obtained, and the expression ability and rationality of patient characterization are enhanced. Based on this, a classification iteration update function is constructed according to node access degree features, and a dynamic patient representation model is constructed by means of a gating mechanism to capture time sequence features of the patient representation model. And finally, a multi-label classification prediction model is constructed, and a multi-view loss function is designed to optimize a drug combination strategy and warn adverse reactions among drugs, so that the accuracy of drug recommendation, the drug use safety and the interpretability are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a patient representation method and drug recommendation system based on semantically enhanced causal graphs, and is applicable to patient representation learning and medication prediction based on personal medical datasets (such as electronic health records, EHRs). Background Technology

[0002] With the continuous increase in the scale and availability of EHR (Experience, Health, and Renal) data, deep learning-based predictive models have achieved significant results in improving the accuracy and safety of clinical decision support. These models are applicable to online / networked disease diagnosis systems, especially combination drug recommendation systems. For example, EHR-based drug recommendation methods and systems can provide appropriate drug combination schemes based on patients' past medical information, warn of adverse drug interactions, assist doctors in prescribing safe and effective medications, avoid drug interactions, and improve treatment outcomes. Researchers are using artificial intelligence technologies such as deep learning to learn representations of medical entities (such as patients, diagnoses, surgeries, and drugs) in patient EHR data, thereby selecting the combination with the lowest overall drug risk from multiple alternatives. This direction has become a research hotspot in the healthcare field and has shown broad application prospects in clinical practice. However, despite the significant achievements in drug recommendation accuracy and medication safety in existing research, the following two shortcomings remain.

[0003] First, in terms of patient entity coding structure representation, existing methods mostly use multi-hot coding or recurrent neural networks (RNNs) to directly encode entities such as diagnoses, surgeries, and drugs. These methods ignore the inherent explicit hierarchical structure and semantic expression capabilities of entities during the modeling process, and fail to effectively integrate the multi-level classification and dependency relationships of medical coding systems (such as ICD and ATC), resulting in insufficient structural representation modeling capabilities based on real semantics.

[0004] Secondly, in modeling relationships between patient entities, existing research mainly relies on techniques such as graph neural networks and utilizes co-occurrence information in the EHR (Employment History Relationship) to model the relationships between diagnosis, surgery, and medication. However, these methods often neglect the potential causal dependencies between entities, fail to fully consider the confounding bias introduced by the distribution of patients' past medical data, and lack entity relationship models based on causal explanations. Furthermore, existing drug recommendation systems typically focus on modeling the temporal features of patient visit sequences, lacking joint modeling of entity semantic encoding structures and potential causal mechanisms, thus limiting improvements in the accuracy and expressive power of patient representations.

[0005] Clearly, existing patient representation methods and drug recommendation systems struggle to fully capture the causal relationships and complex semantic structures between diseases when dealing with their diversity, complexity, and complications, thus affecting medication safety and recommendation accuracy. Therefore, there is an urgent need to construct a new patient representation learning framework capable of simultaneously capturing the semantic structure and causal relationships between entities. This would allow for more accurate and personalized patient representation characterization, providing safe and interpretable drug recommendation support for clinical practice. Summary of the Invention

[0006] To address the aforementioned problems, the purpose of this invention is to propose a patient representation method and drug recommendation system based on semantically enhanced causal graphs. This method models the semantic structure and causal relationships of three entities—diagnosis, surgery, and medication—in the EHR dataset to enhance the expressive power and rationality of patient representations, thereby improving the accuracy, safety, and interpretability of drug recommendations. The key technologies of this system mainly include four modules, as follows:

[0007] ① The patient entity information acquisition and semantic representation module is used to collect and preprocess the patient's EHR data, extract diagnostic, surgical, and drug information according to the time sequence of visits, and construct the patient's multivariate visit sequence; adopting medical coding systems (ICD, ATC), it constructs fine-grained coding structure representations of diagnosis, surgery, and drugs; based on this, a BERT mask language model is designed to generate embedding vector representations that are more in line with the true semantics of diagnosis, surgery, and drugs.

[0008] ② The causal graph learning module is used to generate causal graphs from the patient's historical medical records dataset. This module uses diagnosis, surgery, and medication information from the EHR to construct an initial causal graph, evaluates the rationality of its graph structure using a Bayesian equivalence scoring function, and optimizes it using the Greedy Intervention Equivalence Search (GIES) algorithm to generate a directed acyclic graph that reflects the causal relationships between entities.

[0009] ③ The patient representation module is used to generate patient representations with temporal features. This module takes the semantic embeddings of diagnosis, surgery, and previous medication in each visit as input and constructs their respective causal graphs. Based on this, according to the out-degree and in-degree features of nodes in the causal graph, it constructs their classification function and completes the iterative update for each patient visit. Then, a gating mechanism is used to capture the temporal features of the patient's visits and generate the current patient representation.

[0010] ④ The drug prediction and optimization module is used to integrate patient representations to generate a drug recommendation list. This module first inputs the patient representations into a multi-label classifier to calculate the recommendation probability of each drug; then, from the perspective of multiple loss functions, it constructs a weighted joint loss function to enhance the accuracy of drug recommendations and medication safety.

[0011] To better understand this drug recommendation system, the main steps involved in the above modules will be explained in detail below:

[0012] (1) The patient entity information acquisition and semantic representation module of the present invention specifically includes the following steps:

[0013] S1: Patient entity information collection and representation process. From the acquired EHR dataset, extract three types of entities for each patient: diagnosis (D), surgery (P), and medication (M). Organize these entities chronologically to construct a multivariate patient visit time series H = {v1, v2, ..., v...} T}. Where, v t The diagnosis D corresponding to the patient's t-th visit. t Surgery P t With drug M t A triple consisting of three types of entities, i.e., v t =(D t ,P t M t ).

[0014] S2: The standard coding process for patient entities, extracting v from each patient's medical record. t The corresponding diagnostic codes, surgical codes, and drug codes are mapped in a standardized manner according to medical coding standards (ICD, ATC) to construct unified coding sets for diagnosis, surgery, and drugs respectively.

[0015] S3: The hierarchical coding structure modeling process for patient entities combines the unified coding set of the three types of entities with the ICD and ATC coding systems in the medical knowledge base to construct tree structures for diagnosis, surgery, and drug coding respectively, realizing fine-grained coding structure representation of diagnosis, surgery, and drugs. At the same time, it explicitly models the semantic relationships and contextual dependencies between diagnosis, surgery, and drugs.

[0016] S4: The semantic association masking training process designs a masked language model based on the constructed entity hierarchical encoding representation sequence. By randomly masking part of the entity's encoding representation and using the BERT model to predict the masked content, the model is guided to capture the semantic associations between entities while preserving contextual dependencies.

[0017] S5: Semantic embedding vector generation process. The BERT model is used to semantically model the hierarchical encoding sequence of patient entities. By fusing the contextual information and hierarchical structure of the entities, embedding vector representations that better reflect the true semantics of the entities are generated, namely, diagnostic semantic representations. Surgical semantic representation Drug semantic representation

[0018] (2) The causal graph learning module of the present invention specifically includes the following steps:

[0019] S1: Causal graph initialization process. For entities of the same type in EHR (including diagnosis, surgery and drugs), the causal graph structure is randomly initialized as the initial graph G for the causal discovery process.

[0020] S2: The causal equivalence score calculation process, combined with the distribution characteristics of entities in the EHR, uses a Bayesian equivalence score function to evaluate the current causal graph structure, thereby quantifying the degree to which the graph structure fits the data. The expression for this score function is:

[0021]

[0022] Where X i For the i-th entity, Let f(·) represent the set of parent nodes in graph G. The function f(·) is used to evaluate the Bayesian dependency between a node and its causal parent node.

[0023] S3: The causal iterative optimization process, based on the current graph structure and scoring results, uses the GIES algorithm for iterative optimization. A greedy strategy is employed to search for the optimal graph structure in the equivalence class space, continuously updating the causal graph G' until the model structure converges, i.e., G' = G. Wherein,

[0024] G' = GIES(F,G).

[0025] S4: The causal graph output process obtains the finally converged causal graph G', which serves as a structured expression of causal relationships between entities of the same type.

[0026] S5: Apply the above process to each visit to generate a series of causal graphs containing all visits for the patient's historical visit dataset. Specifically, it is expressed as follows:

[0027]

[0028] Where *∈{d,p,m} represents a certain type of entity in diagnosis, surgery, and drugs, and |*| represents the number of entities *. This represents the causal graph corresponding to entity *'s t-th visit.

[0029] (3) The patient representation learning module of the present invention specifically includes the following steps:

[0030] S1: Extract the diagnosis D for the current medical visit (t-th visit). t Surgery P t And the medication M from the previous visit (t-1th visit) t-1 (If this is the first visit, it is recorded as an empty set).

[0031] S2: Based on diagnostic D t Corresponding causal subgraph Construct its graph model with semantic embeddings corresponding to nodes. As input for node features. Similarly, construct surgical P. t and drug M t-1 The graphical model (if M) t-1 If the set is empty, then the zero vector is used as the feature input for the node.

[0032] S3: Based on the causal position of the diagnostic node in the corresponding graph model, it is divided into: causal nodes (No in-degree, but has out-degree), intermediate nodes (With in-degree and out-degree), fruit node (with in-degree, no out-degree) and isolated nodes (No in-degree, no out-degree). Then, the node embedding is updated based on the node type, and the update method is as follows:

[0033]

[0034]

[0035] Where Classify(·) is the node d i In the classification process, W and b are learnable weights and bias terms, respectively. D represents j Embedding of class nodes and Represents node d i The corrected embeddings are then used. Finally, all the updated embeddings are summed to obtain the patient's diagnosis representation for the t-th time.

[0036] S4: Repeat the method in S3 to obtain the patient's surgical representation for the t-th time. and the drug expression at time t-1

[0037] S5: Combine the diagnosis, surgery, and medication data from the t-th time to form the patient representation for the t-th time:

[0038]

[0039] S6: Use a gating mechanism (GRU) to capture the temporal relationships between patients' historical medical records and obtain the output variable of the gating unit at the t-th time. As a patient, h H .

[0040]

[0041] (4) The main steps of the drug prediction and optimization module of the present invention are as follows:

[0042] S1: Based on the patient's description h H A multilayer perceptron (MLP) with an activation function σ is used to obtain drug m. i The recommendation probability score is calculated, and drugs with a recommendation probability of not less than δ are selected as recommended drugs, specifically:

[0043] score=σ(MLP(h H )),

[0044]

[0045] in, Indicates recommended medication m i .

[0046] S2: To enhance the accuracy of the model's prediction results, a binary cross-entropy loss function and a multi-label boundary loss function are constructed respectively, namely...

[0047]

[0048]

[0049] S3: To control potential drug interaction risks and improve medication safety, a medication safety loss function is constructed based on the DDI relationship between drug pairs, i.e.

[0050]

[0051] in Indicates drug m i With m j Are there any drug interactions?

[0052] S4: While improving medication safety, ensure the accuracy of drug recommendations. Construct the final optimization objective function from the perspective of multiple loss functions:

[0053] L=αL bce +βL multi +γL ddi ,

[0054] Where α, β, and γ are dynamic adjustment factors.

[0055] This invention proposes a patient representation method and drug recommendation system based on semantically enhanced causal graphs, aiming to address the shortcomings of existing drug recommendation systems in terms of the encoded structure representation and relational modeling of patient entities. This method effectively integrates the hierarchical semantic information of the medical coding system with the causal dependencies between entities. By jointly modeling the semantic encoding structure and causal relationships of patient entities, it significantly improves the accuracy and rationality of patient representation. Based on this, the constructed drug recommendation system can achieve safer and more accurate drug recommendations, meeting the key clinical needs for medication safety and interpretability of drug recommendations. Attached Figure Description

[0056] Figure 1 This is a schematic diagram of the semantic hierarchy of the present invention.

[0057] Figure 2 This is a schematic diagram illustrating the causal relationship of the present invention.

[0058] Figure 3 This is a flowchart of the overall drug recommendation method of the present invention.

[0059] Figure 4 This is a framework diagram of the drug recommendation system of the present invention.

[0060] Figure 5 This paper compares the performance of the present invention with other methods on the MIMIC-III dataset using evaluation metrics such as Jaccard, PRAUC, F1-Score, and DDI Rate. Detailed Implementation

[0061] The patient representation method and drug recommendation system based on semantically enhanced causal graphs proposed in this invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific implementation methods described herein are merely illustrative of the invention and are not intended to limit the invention. Any changes, modifications, additions, alterations, or substitutions made by those skilled in the art within the scope of this invention should be covered by the claims of this invention.

[0062] Figure 1 This is a schematic diagram of the semantic hierarchy structure proposed in this invention. Figure 1 Medical coding systems in China (such as ICD and ATC) employ a tree-like hierarchical structure to encode medical entities. Parent nodes represent broad categories, while child nodes are progressively refined into specific diagnosis, surgery, or drug categories. This structure effectively reflects the semantic hierarchy and subordinate relationships between entities, providing a theoretical basis for fine-grained and semantically rich coding representations.

[0063] Figure 2 This is a schematic diagram illustrating the causal relationship proposed in this invention. From... Figure 2As can be seen, the causal relationship constructed in this invention is a directed acyclic graph (DAG) used to represent causal dependencies between entities. Its nodes represent specific medical entities, and directed edges represent causal influence paths, revealing the direction of causal influence. This structure can intuitively reveal the causal mechanism between variables, supporting analysis and decision-making based on causal inference.

[0064] Figure 3 This is an overall flowchart of the patient representation method and drug recommendation system based on semantically enhanced causal graphs proposed in this invention. Figure 3 This system framework first collects and preprocesses patients' EHR data, extracting diagnostic, surgical, and medication information according to the time series of visits. Then, it designs a BERT model based on the medical coding system to construct a fine-grained semantic coding representation. Next, it constructs an initial causal graph using the patient's historical visit dataset, optimizing the graph structure using a Bayesian scoring function and a greedy intervention equivalence search algorithm to generate a directed acyclic graph reflecting the causal relationships between entities. Subsequently, it combines the semantic embeddings of diagnosis, surgery, and medication with the causal graph, iteratively updating the patient representation for each visit based on the in-degree and out-degree features of nodes using a classification function, and capturing the patient's temporal features using a gating mechanism to form the patient representation at the current moment. Finally, it inputs the generated patient representation into a multi-label classifier to calculate the recommendation probability of each medication, and constructs a weighted joint loss function to integrate multiple optimization objectives, improving the accuracy and safety of medication recommendations, thereby outputting personalized and reasonable medication recommendations.

[0065] Figure 4This is a framework diagram of the patient representation method and drug recommendation system based on semantically enhanced causal graphs proposed in this invention. As shown in the figure, the drug recommendation system includes a patient entity information acquisition and semantic representation module, a causal graph learning module, a patient representation module, and a drug prediction and optimization module. ① The patient entity information acquisition and semantic representation module is used to collect and preprocess the patient's EHR data, extract diagnosis, surgery, and drug information according to the time sequence of visits, and construct the patient's multivariate visit sequence; it uses the ICD and ATC medical coding systems to construct fine-grained coding structure representations of diagnosis, surgery, and drugs; based on this, a BERT mask language model is designed to generate embedding vector representations that better fit the true semantics of diagnosis, surgery, and drugs. ② The causal graph learning module is used to generate causal graphs from the patient's historical visit dataset. This module uses the diagnosis, surgery, and drug information in the EHR to construct an initial causal graph, evaluates the rationality of its graph structure through a Bayesian equivalence scoring function, and optimizes it using the Greedy Intervention Equivalence Search (GIES) algorithm to generate a directed acyclic graph that reflects the causal relationships between entities. ③ The patient representation module is used to generate patient representations with temporal characteristics. This module takes the semantic embeddings of diagnosis, surgery, and previous medication from each visit as input and constructs its causal graph. Based on this, it constructs a classification function according to the out-degree and in-degree features of nodes in the causal graph and completes iterative updates for each patient visit. Then, a gating mechanism is used to capture the temporal features of the patient's visits and generate the current patient representation. The ④ Drug prediction and optimization module is used to fuse the patient representation and generate a drug recommendation list. This module first inputs the patient representation into a multi-label classifier to calculate the recommendation probability of each drug. Then, from the perspective of multiple loss functions, a weighted joint loss function is constructed to enhance the accuracy of drug recommendations and medication safety.

[0066] Figure 5 This demonstrates the superior performance of the present invention on clinical datasets. From Figure 5 As can be seen, the drug recommendation system proposed in this invention achieves significant improvements in both recommendation accuracy metrics (such as Jaccard coefficient, PRAUC, and F1 score) and medication safety metrics (such as DDI rate). The performance and advantages of this invention will be explained in detail below using the MIMIC-III dataset as an example.

[0067] Using the MIMIC-III dataset as input, we extract three types of entities—diagnosis (D), surgery (P), and medication (M)—from each patient's historical medical records and organize them chronologically to construct a multivariate medical time series H = {v1, v2, ..., v...} T}. Where, v t The diagnosis D corresponding to the patient's t-th visit. t Surgery P t With drug M tA triple consisting of three types of entities is denoted as v. t =(D t ,P t M t ), where D t P t and M t Both use multi-hot encoding with combinations of 0s and 1s. The model output is denoted as... It is for v t Predicted drug combinations. The specific implementation process of this invention will now be described using the EHR data of a patient from the MIMIC-III dataset as an example.

[0068] S1: Patient entity information acquisition and semantic representation module, which collects and preprocesses patient EHR data and constructs semantic embeddings. Specifically, it includes the following steps:

[0069] 1) The standard coding process for patient entities involves extracting v from each patient's medical record. t The corresponding diagnostic codes, surgical codes, and drug codes are mapped in a standardized manner according to the ICD and ATC medical coding standards, and a unified coding set for diagnosis, surgery, and drugs is constructed respectively.

[0070] 2) The hierarchical coding structure modeling process of patient entities combines the unified coding set of the three types of entities and the ICD and ATC coding systems in the medical knowledge base to construct tree structures for diagnosis, surgery and drug coding respectively, realize fine-grained coding structure representation of diagnosis, surgery and drug, and explicitly model the semantic relationships and contextual dependencies between diagnosis, surgery and drug.

[0071] 3) The semantic association masking training process involves designing a masked language model based on the constructed entity hierarchical encoding representation sequence. By randomly masking partial encoding representations of entities and using the BERT model to predict the masked content, the model is guided to capture semantic associations between entities while preserving contextual dependencies.

[0072] 4) Semantic embedding vector generation process: The BERT model is used to perform semantic modeling on the hierarchical encoding sequence of patient entities. By fusing the contextual information and hierarchical structure of entities, embedding vector representations that better fit the true semantics of the entities are generated, namely, diagnostic semantic representations. Surgical semantic representation Drug semantic representation

[0073] S2: Causal Graph Learning Module, which constructs and optimizes causal relationship graphs based on Bayesian scoring and the GIES algorithm for patient historical medical data. Specifically, it includes the following steps:

[0074] 1) The causal graph initialization process randomly initializes the causal graph structure for entities of the same type in the EHR (including diagnosis, surgery and drugs) as the initial graph G for the causal discovery process.

[0075] 2) The causal equivalence score calculation process, combined with the distribution characteristics of entities in the EHR, uses a Bayesian equivalence score function to evaluate the current causal graph structure, thereby quantifying the degree to which the graph structure fits the data. The expression for this score function is:

[0076]

[0077] Where X i For the i-th entity, Let f(·) represent the set of parent nodes in graph G. The function f(·) is used to evaluate the Bayesian dependency between a node and its causal parent node.

[0078] 3) The causal iterative optimization process, based on the current graph structure and scoring results, employs the GIES algorithm for iterative optimization. A greedy strategy searches for the optimal graph structure in the equivalence class space, continuously updating the causal graph G' until the model structure converges, i.e., G' = G. Wherein,

[0079] G' = GIES(F,G).

[0080] 4) The causal graph output process yields the final converged causal graph G', which serves as a structured representation of causal relationships between entities of the same type.

[0081] 5) Apply the above process to each visit to generate a series of causal graphs containing all visits for the patient's historical visit dataset. Specifically, it is expressed as follows:

[0082]

[0083] Where *∈{d,p,m} represents a certain type of entity in diagnosis, surgery, and drugs, and |*| represents the number of entities *. This represents the causal graph corresponding to entity *'s t-th visit.

[0084] S3: Patient representation module, which combines causal graph structure and temporal gating mechanism to generate temporal representation reflecting patient status.

[0085] 1) Extract the diagnosis D of the current visit (t-th visit). t Surgery P t And the medication M from the previous visit (t-1th visit) t-1 (If this is the first visit, it is recorded as an empty set).

[0086] 2) Based on diagnosis D t Corresponding causal subgraph Construct its graph model with semantic embeddings corresponding to nodes. As input for node features. Similarly, construct surgical P. t and drug M t-1 The graphical model (if M) t-1 If the set is empty, then the zero vector is used as the feature input for the node.

[0087] 3) Based on the causal position of the diagnostic nodes in the corresponding graph model, they are divided into: causal nodes (No in-degree, but has out-degree), intermediate nodes (With in-degree and out-degree), fruit node (with in-degree, no out-degree) and isolated nodes (No in-degree, no out-degree). Then, the node embedding is updated based on the node type, and the update method is as follows:

[0088]

[0089]

[0090] Where Classify(·) is the node d i In the classification process, W and b are learnable weights and bias terms, respectively. D represents j Embedding of class nodes and Represents node d i The corrected embeddings are then used. Finally, all the updated embeddings are summed to obtain the patient's diagnosis representation for the t-th time.

[0091] 4) Repeat method S3 to obtain the patient's surgical representation for the t-th time. and the drug expression at time t-1

[0092] 5) Combine the diagnosis, surgery, and medication data from the t-th time to form the patient representation for the t-th time:

[0093]

[0094] 6) Use a gating mechanism (GRU) to capture the temporal relationships between patients' historical medical records and obtain the output variable of the gating unit at the t-th time. As a patient, h H .

[0095]

[0096] S4: Drug prediction and optimization module, which makes multi-label drug recommendations based on patient representations and improves the accuracy and safety of recommendations through weighted joint loss.

[0097] 1) Based on the patient's description h H A multilayer perceptron (MLP) with an activation function σ is used to obtain drug m. i The recommendation probability score is calculated, and drugs with a recommendation probability of not less than δ are selected as recommended drugs, specifically:

[0098] score=σ(MLP(h H )),

[0099]

[0100] in, Indicates recommended medication m i .

[0101] 2) To enhance the accuracy of the model's prediction results, a binary cross-entropy loss function and a multi-label boundary loss function are constructed respectively, i.e.

[0102]

[0103] 3) To control potential drug interaction risks and improve medication safety, a medication safety loss function is constructed based on the DDI relationship between drug pairs, i.e.

[0104]

[0105] in Indicates drug m i With m j Are there any drug interactions?

[0106] 4) While improving medication safety, ensure the accuracy of drug recommendations by constructing the final optimization objective function from the perspective of multiple loss functions:

[0107] L=αL bce +βL multi +γL ddi ,

[0108] Where α, β, and γ are dynamic adjustment factors.

Claims

1. A patient representation method and drug recommendation system based on semantically enhanced causal graphs, used to mine medical entity information in electronic health records (EHRs), utilize hierarchical semantic enhancement and causal inference to construct fine-grained representations of entity information, achieving accurate drug recommendations while ensuring medication safety, characterized in that... The key technologies of this system mainly include four modules: 1) The patient entity information acquisition and semantic representation module is used to collect and preprocess the patient's EHR data, extract diagnostic, surgical and drug information according to the time sequence of visits, and construct the patient's multivariate visit sequence; adopt medical coding system (ICD, ATC) to construct fine-grained coding structure representation of diagnosis, surgery and drugs; based on this, the BERT mask language model is designed to generate embedding vector representations that are more in line with the true semantics of diagnosis, surgery and drugs. 2) The causal graph learning module is used to generate causal graphs from the patient's historical medical records dataset. This module uses diagnostic, surgical, and drug information from the EHR to construct an initial causal graph, evaluates the rationality of its graph structure using a Bayesian equivalence scoring function, and optimizes it using the Greedy Intervention Equivalence Search (GIES) algorithm to generate a directed acyclic graph that reflects the causal relationships between entities. 3) Patient representation module, used to generate patient representations with temporal features. This module takes the semantic embeddings of diagnosis, surgery, and previous medication in each visit as input and constructs their causal graphs respectively; Based on this, a classification function is constructed according to the out-degree and in-degree features of nodes in the causal graph, and iterative updates are completed for each patient visit. Then, a gating mechanism is used to capture the temporal features of the patient's visit and generate the current patient representation. 4) The drug prediction and optimization module is used to integrate patient representations to generate a drug recommendation list. This module first inputs the patient representations into a multi-label classifier to calculate the recommendation probability of each drug; then, from the perspective of multiple loss functions, it constructs a weighted joint loss function to enhance the accuracy of drug recommendations and medication safety.

2. The main steps of the patient entity information acquisition and semantic representation module as described in claim 1 are as follows: S1: Patient entity information collection and representation process. From the acquired EHR dataset, extract the three types of entities—diagnosis (D), surgery (P), and medication (M)—from each patient's historical medical records, organize them chronologically, and construct the patient's multivariate medical time series H = {v1, v2, ..., v...} T }.in, v t The diagnosis D corresponding to the patient's t-th visit. t Surgery P t With drug M t A triple consisting of three types of entities, i.e., v t =(D t ,P t M t ). S2: The standard coding process for patient entities, extracting v from each patient's medical record. t The corresponding diagnostic codes, surgical codes, and drug codes are mapped in a standardized manner according to medical coding standards (ICD, ATC) to construct unified coding sets for diagnosis, surgery, and drugs respectively. S3: The hierarchical coding structure modeling process for patient entities combines the unified coding set of the three types of entities and the coding system in the medical knowledge base (ICD / ATC hierarchy) to construct tree structures for diagnosis, surgery and drug coding respectively, realizing fine-grained coding structure representation of diagnosis, surgery and drugs, while explicitly modeling the semantic relationships and contextual dependencies between diagnosis, surgery and drugs. S4: The semantic association masking training process designs a masked language model based on the constructed entity hierarchical encoding representation sequence. By randomly masking part of the entity's encoding representation and using the BERT model to predict the masked content, the model is guided to capture the semantic associations between entities while preserving contextual dependencies. S5: Semantic embedding vector generation process. The BERT model is used to semantically model the hierarchical encoding sequence of patient entities. By fusing the contextual information and hierarchical structure of the entities, embedding vector representations that better reflect the true semantics of the entities are generated, namely, diagnostic semantic representations. Surgical semantic representation Drug semantic representation 3. The main steps of the cause-effect graph learning module as described in claim 1 are as follows: S1: Causal graph initialization process. For entities of the same type in EHR (including diagnosis, surgery and drugs), the causal graph structure is randomly initialized as the starting graph G for the causal discovery process. S2: The causal equivalence score calculation process, combined with the distribution characteristics of entities in the EHR, uses a Bayesian equivalence score function to evaluate the current causal graph structure, thereby quantifying the degree to which the graph structure fits the data. The expression for this score function is: Where X i For the i-th entity, Let f(·) represent the set of parent nodes in graph G. The function f(·) is used to evaluate the Bayesian dependency between a node and its causal parent node. S3: The causal iterative optimization process, based on the current graph structure and scoring results, uses the GIES algorithm for iterative optimization. A greedy strategy is employed to search for the optimal graph structure in the equivalence class space, continuously updating the causal graph G' until the model structure converges, i.e., G' = G. Wherein, G' = GIES(F,G). S4: The causal graph output process obtains the finally converged causal graph G', which serves as a structured expression of causal relationships between entities of the same type. S5: Apply the above process to each visit to generate a series of causal graphs containing all visits for the patient's historical visit dataset. Specifically, it is expressed as follows: Where *∈{d,p,m} represents a certain type of entity in diagnosis, surgery, and drugs, and |*| represents the number of entities *. This represents the causal graph corresponding to entity *'s t-th visit.

4. The patient representation learning module as described in claim 1, its main steps are as follows: S1: Extract the diagnosis D for the current medical visit (t-th visit). t Surgery P t And the medication M from the previous visit (t-1th visit) t-1 (If this is the first visit, it is recorded as an empty set). S2: Based on diagnostic D t Corresponding causal subgraph Construct its graph model with semantic embeddings corresponding to nodes. As input for node features. Similarly, construct surgical P. t and drug M t-1 The graphical model (if M) t-1 If the set is empty, then the zero vector is used as the feature input for the node. S3: Based on the causal position of the diagnostic node in the corresponding graph model, it is divided into: causal nodes (No in-degree, but has out-degree), intermediate nodes (With in-degree and out-degree), fruit node (with in-degree, no out-degree) and isolated nodes (No in-degree, no out-degree). Then, the node embedding is updated based on the node type, and the update method is as follows: Where Classify(·) is the node d i In the classification process, W and b are learnable weights and bias terms, respectively. D represents j Embedding of class nodes and Represents node d i The corrected embeddings are then used. Finally, all the updated embeddings are summed to obtain the patient's diagnosis representation for the t-th time. S4: Repeat the method in S3 to obtain the patient's surgical representation for the t-th time. and the drug expression at time t-1 S5: Combine the diagnosis, surgery, and medication data from the t-th time to form the patient representation for the t-th time: S6: Use a gating mechanism (GRU) to capture the temporal relationships between patients' historical medical records and obtain the output variable of the gating unit at the t-th time. As a patient, h H .

5. The main steps of the drug prediction and optimization module as described in claim 1 are as follows: S1: Based on the patient's description h H A multilayer perceptron (MLP) with an activation function σ is used to obtain drug m. i The recommendation probability score is calculated, and drugs with a recommendation probability of not less than δ are selected as recommended drugs, specifically: score=σ(MLP(h H )), in, Indicates recommended medication m i . S2: To enhance the accuracy of the model's prediction results, a binary cross-entropy loss function and a multi-label boundary loss function are constructed respectively, namely... S3: To control potential drug interaction risks and improve medication safety, a medication safety loss function is constructed based on the DDI relationship between drug pairs, i.e. in Indicates drug m i With m j Are there any drug interactions? S4: While improving medication safety, ensure the accuracy of drug recommendations. Construct the final optimization objective function from the perspective of multiple loss functions: L=αL bce +βL multi +γL ddi , Where α, β, and γ are dynamic adjustment factors.