Knowledge base-based medical scheme recommendation method, system, device and storage medium

Through a knowledge-based medical plan recommendation method, a multidimensional evaluation system is constructed using drug attribute weight values ​​and a pre-trained random forest model, which solves the confusion problem of treatment plan recommendations in existing technologies and achieves personalized differentiated recommendations and safety improvements.

CN119864121BActive Publication Date: 2025-10-17NORTH CHINA DIGITAL HEALTH TECHNOLOGY CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510336672.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-21
Publication Date
2025-10-17
Estimated Expiration
2045-03-21

AI Technical Summary

Technical Problem

The existing medical knowledge graph has not established a multi-dimensional evaluation system in the recommendation of diagnosis and treatment plans, resulting in the mixed presentation of high-value plans and conventional plans. It also fails to integrate individualized patient data and cannot achieve differentiated recommendations.

Method used

The knowledge base-based medical plan recommendation method obtains the priority of symptoms and generates drug attribute weight values. It uses a pre-trained random forest model to generate recommended plans based on the medicinal properties of the drug group, combines the drug knowledge graph and drug dictionary to build a multidimensional evaluation system, and dynamically adjusts the weight values ​​to adapt to individualized data.

Benefits of technology

The establishment of a multi-dimensional evaluation system has been achieved, which has improved the safety of drug combinations and differentiated recommendations for diagnosis and treatment plans, reduced doctors' screening time, and improved the accuracy and safety of recommendations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119864121B_ABST
    Figure CN119864121B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of large models, and particularly provides a medical scheme recommendation method, system and device based on a knowledge base and a storage medium, which comprises the following steps: acquiring a first disease and a second disease, wherein the priority of the first disease is higher than that of the second disease; generating a weight value for a drug attribute in a pre-constructed drug knowledge graph according to a user attention degree input from a front end; querying a first drug group corresponding to the first disease and a second drug group corresponding to the second disease from the knowledge graph based on the weight value; and generating a recommended scheme based on drug property characteristics of drug entities in the first drug group and the second drug group by using a pre-trained random forest model. The application establishes a multidimensional evaluation system through drug attributes and weight values, and the dynamic weight value adapts to individualized data of patients, thereby realizing differentiated recommendation.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of large models, and particularly relates to a medical scheme recommendation method, system, device and storage medium based on a knowledge base. BACKGROUND

[0002] Current mainstream medical knowledge graphs take disease as an entry node and diagnosis and treatment schemes as associated nodes, and construct a recommendation system through simple edge connection. When a disease is diagnosed, the system will mechanically return all associated schemes (such as a cancer treatment scheme containing 10+ options such as surgery, chemotherapy and targeted drugs) based on historical data. With the annual number of cases in hospitals breaking through the million level, the recommendation results often show exponential growth, and doctors need to spend a lot of time for preliminary screening of schemes.

[0003] The diagnosis and treatment scheme recommendation method has the following disadvantages:

[0004] The diagnosis and treatment scheme recommendation does not establish a multi-dimensional evaluation system (such as efficacy, cost and adverse reaction rate), resulting in a mixture of high-value schemes and conventional schemes.

[0005] Individualized patient data is not integrated, and differential recommendation cannot be achieved. SUMMARY

[0006] In view of the above disadvantages of the prior art, the application provides a medical scheme recommendation method, system, device and storage medium based on a knowledge base to solve the above technical problems.

[0007] In a first aspect, the application provides a medical scheme recommendation method based on a knowledge base, comprising:

[0008] Obtaining a first disease and a second disease, the priority of the first disease being higher than that of the second disease;

[0009] Generating a weight value for a drug attribute in a pre-constructed drug knowledge graph according to a user attention degree input from the front end;

[0010] Querying a first drug group corresponding to the first disease and a second drug group corresponding to the second disease from the knowledge graph based on the weight value respectively;

[0011] Generating a recommended scheme based on the drug properties of the drug entities in the first drug group and the second drug group by using a pre-trained random forest model.

[0012] In an optional embodiment, the construction method of the drug knowledge graph comprises:

[0013] Obtaining case data and extracting cure time and cure duration from the case data;

[0014] performing clustering analysis on the cure duration of the case data to generate a duration identifier for the case data according to the clustering clusters;

[0015] extracting drug entities and disease entities from the case data, constructing a treatment triple of the drug entities and the disease entities, and constructing a combination triple for the drug entities in the same case data;

[0016] constructing a knowledge graph based on the treatment triple and the combination triple, taking the number of repetitions of the triple as the number of references of the corresponding edge in the knowledge graph, and setting the duration identifier of the case data as the duration attribute of the corresponding drug entity;

[0017] extracting drug attributes and drug property characteristics from a pre-constructed drug dictionary, the drug attributes including price, adverse reaction severity level, and indication, and the drug property characteristics including drug contraindication information, chemical structure, and metabolic enzyme target;

[0018] setting the drug attributes and the drug property characteristics as node attribute values of the corresponding drug entities in the knowledge graph.

[0019] In an optional embodiment, the method for constructing the drug dictionary comprises:

[0020] obtaining identity information of the drug, the identity information including name, manufacturer, and batch;

[0021] calculating a hash value of the identity information, and taking the hash value as an identity code of the drug;

[0022] extracting indication, adverse reaction information, drug contraindication information, chemical structure, and metabolic enzyme target from the specification of the drug by using natural language processing technology;

[0023] generating the adverse reaction severity level of the drug according to a pre-set corresponding relationship between adverse reaction severity level and adverse reaction information, and the adverse reaction of the drug;

[0024] storing the identity code, indication, adverse reaction level, drug contraindication information, chemical structure, and metabolic enzyme target of the drug to the drug dictionary.

[0025] In an optional embodiment, a weight value is generated for a drug attribute in a pre-constructed drug knowledge graph according to user attention degree input from the front end, comprising:

[0026] generating a quantitative value for the drug attribute, and performing normalization processing on the quantitative value to obtain an attribute quantitative value;

[0027] obtaining user attention degree for the attribute, and setting a weight factor of the corresponding attribute quantitative value according to the attention degree;

[0028] The weighted sum of the quantitative values of the calculated properties is obtained to obtain a weight value of the drug entity.

[0029] In an optional implementation, based on the weight value, a first drug group corresponding to the first disease and a second drug group corresponding to the second disease are queried from the knowledge graph respectively, including:

[0030] A plurality of main drug entities corresponding to the target disease are queried from the knowledge graph, the target disease being the first disease or the second disease, and the plurality of main drug entities having the highest weight value and indications matching the target disease;

[0031] A drug entity set corresponding to the target disease is queried from the knowledge graph, and the drug entity set includes all drug entities connected by the first disease;

[0032] A secondary drug entity having an association edge with the main drug entity is obtained, and a reference number of the association edge reaches a set reference number threshold;

[0033] A drug entity having a time length attribute that does not match the main drug entity is removed from the secondary drug entity;

[0034] The updated drug entity and the main drug entity are stored as a drug group corresponding to the target disease.

[0035] In an optional implementation, removing a drug entity having a time length attribute that does not match the main drug entity from the secondary drug entity includes:

[0036] The time length attribute of the main drug entity is obtained;

[0037] The secondary drug entity having a time length attribute greater than the time length attribute of the main drug entity is removed.

[0038] In an optional implementation, a recommendation scheme is generated based on drug property features of drug entities in the first drug group and the second drug group by using a pre-trained random forest model, including:

[0039] A reference number of an association edge between a drug entity in the first drug group and a drug entity in the second drug group is obtained;

[0040] If it is confirmed that there is no association edge between the first drug entity and the second drug entity or the reference number of the association edge does not reach a set reference number threshold, drug property features of the first drug entity and the second drug entity are obtained, the first drug entity belonging to the first drug group and the second drug entity belonging to the second drug group;

[0041] The drug property features of the first drug entity and the second drug entity are input into the pre-trained random forest model to confirm whether the first drug entity and the second drug entity can be used together;

[0042] if the first drug entity and the second drug entity are not combinable, the second drug entity is eliminated;

[0043] the first drug group and the second drug group after eliminating the non-combinable drug entity are outputted.

[0044] In a second aspect, the present application provides a medical scheme recommendation system based on a knowledge base, comprising:

[0045] an acquisition module, configured to acquire a first disease and a second disease, wherein the first disease has a higher priority than the second disease;

[0046] a first processing module, configured to generate a weight value for a drug attribute in a pre-constructed drug knowledge graph according to a user attention degree inputted in a front end;

[0047] a query module, configured to query a first drug group corresponding to the first disease and a second drug group corresponding to the second disease from the knowledge graph respectively based on the weight value;

[0048] a second processing module, configured to generate a recommendation scheme based on drug property features of drug entities in the first drug group and the second drug group by using a pre-trained random forest model.

[0049] In a third aspect, an apparatus is provided, comprising:

[0050] a memory, configured to store a medical scheme recommendation program based on a knowledge base;

[0051] a processor, configured to implement steps of the medical scheme recommendation method based on the knowledge base when the medical scheme recommendation program based on the knowledge base is executed.

[0052] In a fourth aspect, a computer readable storage medium is provided, and the storage medium stores a medical scheme recommendation program based on a knowledge base, and steps of the medical scheme recommendation method based on the knowledge base are implemented when the medical scheme recommendation program based on the knowledge base is executed by a processor.

[0053] The present application has the following beneficial effects: the medical scheme recommendation method, system, apparatus and storage medium based on the knowledge base provided by the present application can dynamically generate a weight value for a drug attribute in a knowledge graph according to a user attention degree, and the dynamically generated weight value is used in subsequent diagnosis and treatment scheme retrieval, so that a multi-dimensional evaluation system can be established by using the drug attribute and the weight value, and the dynamic weight value is adapted to individualized data of a patient, thereby realizing differentiated recommendation. In addition, the drug attribute contains a citation frequency, and the combination relationship between drugs can be represented by the citation frequency, which can improve the safety of drug combination. When there are multiple diseases, a pre-trained random forest model is used to check the feasibility of combined drugs, thereby further eliminating the risk caused by incorrect combination of drugs.

[0054] In addition, the application has reliable design principles, simple structure and very wide application prospects. BRIEF DESCRIPTION OF DRAWINGS

[0055] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.

[0056] Figure 1 is a schematic flow chart of the method of one embodiment of the present application.

[0057] Figure 2 is another schematic flow chart of the method of one embodiment of the present application.

[0058] Figure 3 is a schematic block diagram of the system of one embodiment of the present application.

[0059] Figure 4 is a structural schematic diagram of an apparatus provided by the embodiment of the present application. DETAILED DESCRIPTION

[0060] In order to make the person skilled in the art better understand the technical solutions in the present application, the following will combine the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should belong to the protection scope of the present application.

[0061] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terms used in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application.

[0062] The key terms appearing in the present application will be explained below.

[0063] Random forest is an ensemble learning algorithm composed of multiple decision trees, which realizes classification, regression and anomaly detection tasks through voting or mean calculation. Its core idea is to improve the stability and prediction accuracy of the model through the cooperative decision of multiple trees.

[0064] The knowledge base-based medical scheme recommendation method provided by the embodiment of the present application is executed by a computer device, and correspondingly, the knowledge base-based medical scheme recommendation system runs in the computer device.

[0065] Figure 1 is a schematic flowchart of the method of one embodiment of the present application. In this embodiment, Figure 1 The execution subject can be a knowledge base-based medical treatment recommendation system. The order of the steps in the flowchart can be changed according to different needs, and some can be omitted.

[0066] As Figure 1 shown, the method comprises:

[0067] S1. Obtain a first disease and a second disease, the priority of the first disease being higher than that of the second disease.

[0068] The first disease and the second disease can be directly input from the front end by a doctor, such as the main disease and the patient's basic disease.

[0069] The output of the diagnosis model can also be connected, such as inputting the first disease and the second disease output by the diagnosis model into the system.

[0070] In addition, the first disease and the second disease can be extracted from the patient's medical record data by using natural language processing technology. When limiting the priority of the disease, the setting of the priority of the disease is based on a set of pre-prepared medical rules and clinical experience. For example, a life-threatening disease such as a severe heart attack (first disease) must have a higher priority than a relatively mild chronic disease such as mild arthritis (second disease). This priority judgment plays a key role in the subsequent process, ensuring that high-priority diseases are prioritized for treatment when resources are limited or conflicts exist.

[0071] S2. According to the user's attention degree input from the front end, generate a weight value for the drug attributes in the pre-constructed drug knowledge graph.

[0072] The pre-constructed drug knowledge graph is a structured database containing a large amount of drug-related information, in which drug attributes cover multiple aspects such as efficacy, side effects, price, and suitable population. When the user expresses concern for certain aspects in the front-end interface, such as paying more attention to the size of drug side effects, the system will convert this attention into a corresponding weight value.

[0073] In the specific implementation process, through front-end interaction design, the user can select the degree of attention to different attributes through sliders, radio boxes, etc. These choices will be converted into numerical signals and passed to the back end. The back-end algorithm quantifies the importance of each drug attribute in the knowledge graph according to these signals. For example, if the user pays a very high degree of attention to drug side effects, the weight value of the side effect attribute will be set to 0.8, and the weight value of other attributes such as price will be reduced to 0.2 accordingly.

[0074] S3. Query the first drug group corresponding to the first disease and the second drug group corresponding to the second disease from the knowledge graph based on the weight values respectively.

[0075] Using the weight values generated in the previous step, the system conducts targeted queries in the drug knowledge graph. The query process uses the query language of the graph database, such as Cypher (for Neo4j graph database). Taking the query of the first drug group corresponding to the first disease as an example, the system will find all drug nodes associated with the first disease in the knowledge graph, and calculate the weight of each drug node attribute according to the set weight value.

[0076] For example, for a drug that treats heart disease (the first disease), its efficacy attribute weight is higher, and the system will focus on considering the effectiveness score of the drug in treating heart disease, and combine the scores of other attributes such as side effects (at this time the weight is lower) to comprehensively evaluate whether the drug should be included in the first drug group. In the same way, similar query operations are performed for the second disease to generate the second drug group.

[0077] S4. Generate a recommended scheme based on the drug properties of the drug entities in the first drug group and the second drug group using a pre-trained random forest model.

[0078] The pre-trained random forest model is an ensemble learning algorithm based on decision trees. In this step, the model first extracts the drug properties of the drug entities in the first drug group and the second drug group, including drug ingredients, mechanisms of action, metabolic pathways, etc.

[0079] The model uses these features as input and uses the classification and regression operations of numerous decision trees in the random forest to evaluate the suitability of each drug. For example, the decision tree will judge whether the ingredients of the drug conflict with the patient's allergy history, whether the mechanism of action is suitable for the patient's physical condition, etc. Finally, the model synthesizes the results of all decision trees to generate personalized drug recommendation schemes for the first disease and the second disease, which may include the types of drugs, usage doses, and detailed information such as the time of taking.

[0080] In one embodiment of the present application, based on step S2, the following embodiment will be given to non-limitingly describe the specific implementation thereof.

[0081] Specifically, the method for constructing a drug knowledge graph comprises:

[0082] 1. Obtain case data, and extract cure time and cure duration from the case data;

[0083] Read case data from an electronic medical record system (EMR) or other database. Assuming the use of the pandas library in Python to process data, the example code to connect to a database is as follows (using a MySQL database as an example):

[0084] import pandas as pd# Import the pandas library for data processing and analysis;

[0085] import mysql.connector# Import the mysql.connector library to connect to a MySQL database;

[0086] # Connect to the MySQL database, providing the host, username, password, and database name;

[0087] mydb = mysql.connector.connect(

[0088] host="your_host",

[0089] user="your_user",

[0090] password="your_password",

[0091] database="your_database");

[0092] # Define the SQL query statement to select all data from the medical_records table;

[0093] query = "SELECT * FROM medical_records"

[0094] # Use the pandas read_sql function to execute the SQL query and store the results in a DataFrame;

[0095] df = pd.read_sql(query, mydb);

[0096] There is a field in the case data that records the treatment end time, treatment_end_time, and the treatment start time, treatment_start_time. You can use the pandas library to do the following:

[0097] Convert the treatment_end_time field to datetime type and store it in a new column, cure_time:

[0098] df['cure_time'] = pd.to_datetime(df['treatment_end_time']);

[0099] Convert the treatment_start_time field to datetime type and store it in a new start_time column:

[0100] df['start_time'] = pd.to_datetime(df['treatment_start_time']);

[0101] Calculate the cure duration, which is the difference between cure_time and start_time, and convert it into days and store it in the cure_duration column:

[0102] df['cure_duration']=(df['cure_time']-df['start_time']).dt.days.

[0103] 2. Perform cluster analysis on the cure time of case data and generate a duration identifier for the case data based on the clustering clusters.

[0104] The K-Means clustering algorithm is used to cluster the healing time. The K-Means algorithm is a distance-based clustering algorithm that aims to divide data points into K clusters so that the sum of the distances between each data point and the centroid of its cluster is minimized.

[0105] Use Python's scikit-learn library to implement K-Means clustering. The code is as follows:

[0106] from sklearn.cluster import KMeans# Import the KMeans clustering algorithm from the scikit-learn library;

[0107] import numpy as np# Import the numpy library for numerical calculations;

[0108] # Extract the healing time data and convert it into a shape suitable for clustering algorithm input (two-dimensional array);

[0109] cure_duration = df['cure_duration'].values.reshape(-1, 1);

[0110] # Initialize the K-Means model with 3 clusters (adjust as needed) and a random seed of 0 for reproducibility;

[0111] kmeans = KMeans(n_clusters = 3, random_state = 0).fit(cure_duration);

[0112] # Add the cluster labels to the original DataFrame in a new column called 'duration_label';

[0113] df['duration_label'] = kmeans.labels_.

[0114] 3. Extract drug entities and disease entities from the case data, construct treatment triples of drug entities and disease entities, and construct combination triples for drug entities in the same case data.

[0115] Use the Named Entity Recognition (NER) method in Natural Language Processing (NLP) technology to extract drug entities and disease entities. For example, use the Conditional Random Field (CRF) based NER model, which can be implemented in Python using the sklearn-crfsuite library.

[0116] There is a trained NER model ner_model. The example code for entity extraction on the medical_note field in the case data is as follows:

[0117] import sklearn_crfsuite# Import the sklearn - crfsuite library for CRF-based NER model;

[0118] from sklearn_crfsuite import metrics# Import the evaluation metrics module from sklearn - crfsuite library;

[0119] # Assume medical_note is the text description field in the case data, convert it to a list form;

[0120] texts = df['medical_note'].tolist();

[0121] extracted_entities = []# Initialize an empty list to store the extracted entities;

[0122] for text in texts:

[0123] # Use the trained NER model to predict each text and get the entity annotation result;

[0124] entities = ner_model.predict([text]);

[0125] # Add the annotation result to the extracted_entities list;

[0126] extracted_entities.append(entities)。

[0127] The treatment triple format is (drug entity, treatment, disease entity), and the co-use triple format is (drug entity 1, co-use, drug entity 2).

[0128] treatment_triples = []# Initialize an empty list to store treatment triples;

[0129] co_use_triples = []# Initialize an empty list to store co-use triples;

[0130] for index, row in df.iterrows():

[0131] # Assume that the drug entity list drug_entities and the disease entity list disease_entities have been extracted;

[0132] drug_entities = extracted_entities[index]['drug'];

[0133] disease_entities= extracted_entities[index]['disease'];

[0134] for drug in drug_entities:

[0135] for disease in disease_entities:

[0136] # Construct the treatment triple and add it to the treatment_triples list;

[0137] treatment_triples.append((drug,'treatment',disease));

[0138] for i in range(len(drug_entities)):

[0139] for j in range(i + 1, len(drug_entities)):

[0140] # Build a co-use triple and add it to the co_use_triples list;

[0141] co_use_triples.append((drug_entities[i], 'combination', drug_entities[j])).

[0142] 4. Construct a knowledge graph based on the treatment triples and the combination triples, use the number of repetitions of the triples as the number of references of the corresponding edge in the knowledge graph, and set the duration identifier of the case data as the duration attribute of the corresponding drug entity;

[0143] Build knowledge graphs in Python using the networkx library.

[0144] import networkx as nx# Import the networkx library for building and manipulating graph structures;

[0145] # Create a directed multigraph object to represent the knowledge graph;

[0146] kg = nx.MultiDiGraph();

[0147] # Add treatment triplet;

[0148] for triple in treatment_triples:

[0149] # If there is no edge from triple[0] to triple[2] in the knowledge graph, add the edge and set the relationship and reference count to 1;

[0150] if not kg.has_edge(triple[0], triple[2]):

[0151] kg.add_edge(triple[0], triple[2], relation = triple[1], count = 1);

[0152] else:

[0153] # If the edge already exists, add 1 to the reference count of the edge;

[0154] kg[triple[0]][triple[2]][0]['count'] += 1;

[0155] # Add the co-use triple;

[0156] for triple in co_use_triples:

[0157] # If the edge from triple[0] to triple[1] does not exist in the knowledge graph, add the edge and set the relation and reference count to 1;

[0158] if not kg.has_edge(triple[0], triple[1]):

[0159] kg.add_edge(triple[0], triple[1], relation = triple[1], count = 1);

[0160] else:

[0161] # If the edge already exists, add 1 to the reference count of the edge;

[0162] kg[triple[0]][triple[1]][0]['count'] += 1;

[0163] # Set the duration attribute for the drug entity;

[0164] for drug in kg.nodes():

[0165] # Filter the records containing the current drug entity from the original DataFrame and extract its duration_label;

[0166] relevant_duration_labels = df[df['drug_entities'].str.contains(drug)]['duration_label'];

[0167] if not relevant_duration_labels.empty:

[0168] # If the screening result is not empty, set the first duration_label as the duration attribute of the drug entity in the knowledge graph;

[0169] kg.nodes[drug]['duration_label']= relevant_duration_labels.iloc[0]。

[0170] 5. Extract drug attributes and drug property characteristics from the pre-constructed drug dictionary, including price, adverse reaction severity level, indications; drug property characteristics include drug contraindication information, chemical structure, metabolic enzyme target.

[0171] Assume that the pre-constructed drug dictionary is a JSON file with the following format:

[0172] {"drug1": {

[0173] "price": 10.0,

[0174] "adverse_reaction_severity": "low",

[0175] "indications": "disease1, disease2",

[0176] "drug_contraindications": "contraindication1",

[0177] "chemical_structure": "structure1",

[0178] "metabolic_enzyme_targets": "target1"},

[0179] "drug2": {

[0180] ...}}。

[0181] Use Python code to extract attributes and characteristics:

[0182] import json# Import the json library to process JSON format data;

[0183] # Open and read the JSON file of the drug dictionary;

[0184] with open('drug_dictionary.json', 'r') as f:

[0185] drug_dict = json.load(f);

[0186] drug_attributes = {}# Initialize an empty dictionary to store the extracted drug attributes and features;

[0187] for drug, info in drug_dict.items():

[0188] attributes = {

[0189] "price": info["price"], # Extract drug prices;

[0190] "adverse_reaction_severity": info["adverse_reaction_severity"], # Extract the severity level of adverse reactions;

[0191] "indications": info["indications"], # Extract indications;

[0192] "drug_contraindications": info["drug_contraindications"], # Extract drug contraindications information;

[0193] "chemical_structure": info["chemical_structure"], # Extract chemical structure;

[0194] "metabolic_enzyme_targets": info["metabolic_enzyme_targets"]# Extract metabolic enzyme targets};

[0195] # Store the extracted attributes and features into the drug_attributes dictionary, with the key being the drug name;

[0196] drug_attributes[drug] = attributes.

[0197] 6. Set the drug attributes and medicinal properties as the node attribute values ​​of the corresponding drug entity in the knowledge graph.

[0198] Property settings:

[0199] for drug, attrs in drug_attributes.items():

[0200] if drug in kg.nodes():

[0201] for attr, value in attrs.items():

[0202] # Set the drug attributes and features to the attribute values ​​of the corresponding drug entity nodes in the knowledge graph;

[0203] kg.nodes[drug][attr]= value.

[0204] The method for constructing the drug dictionary in step 5 includes:

[0205] 5.1 Obtain the identity information of the drug, including name, manufacturer, and batch.

[0206] Drug identity information can be obtained from multiple channels, such as the hospital's drug management system, electronic data sheets provided by drug suppliers, and label information on drug packaging (extracted using optical character recognition (OCR) technology).

[0207] Get data from the hospital's drug management database using Python's pandas library and a corresponding database connection library (such as psycopg2 for PostgreSQL). The following is sample code for reading data from a PostgreSQL database:

[0208] import pandas as pd# Import the pandas library for data processing and analysis;

[0209] import psycopg2# Import the psycopg2 library for connecting to the PostgreSQL database;

[0210] # Connect to the PostgreSQL database. You need to provide the database host, name, username, password, and port.

[0211] conn = psycopg2.connect(

[0212] host="your_host",

[0213] database="your_database",

[0214] user="your_user",

[0215] password="your_password",

[0216] port="your_port")

[0217] # Define the SQL query statement to select drug name, manufacturer, and batch number information from the table named 'drugs';

[0218] query = "SELECT drug_name, manufacturer, batch_number FROM drugs"

[0219] # Execute the SQL query using the read_sql function of pandas and store the results in a DataFrame;

[0220] df = pd.read_sql(query, conn)。

[0221] The read data may have missing values, inconsistent formats, etc. For example, drug names may have different abbreviations or aliases, and manufacturer names may have multiple expressions. Therefore, use the method of pandas to clean the data.

[0222] # Remove the leading and trailing spaces of each value in the drug_name field and convert it to lowercase;

[0223] df['drug_name'] = df['drug_name'].str.strip().str.lower();

[0224] # Delete rows with missing values in the drug_name, manufacturer, and batch_number fields in the DataFrame;

[0225] df = df.dropna(subset=['drug_name','manufacturer', 'batch_number'])。

[0226] 5.2 Calculate the hash value of the identity information and use it as the identity code of the drug.

[0227] Commonly used hash algorithms include MD5, SHA-1, SHA-256, etc. In this application, choose SHA-256 algorithm because it is relatively high in security. In Python, you can use the hashlib library to implement hash calculation.

[0228] import hashlib# Import hashlib library for hash calculation;

[0229] # Define a function to generate the hash value of drug identity information;

[0230] def generate_hash(drug_name, manufacturer, batch_number):

[0231] # Concatenate the drug name, manufacturer and batch information into a string;

[0232] data = f"{drug_name}{manufacturer}{batch_number}"

[0233] # Use the SHA-256 algorithm to perform hash calculation on the concatenated string;

[0234] hash_object = hashlib.sha256(data.encode());

[0235] # Returns the hexadecimal representation of the hash value;

[0236] return hash_object.hexdigest();

[0237] # For each row of data in the DataFrame, apply the generate_hash function to generate the identity code and store the result in a new identity_code column;

[0238] df['identity_code'] = df.apply(lambda row: generate_hash(row['drug_name'], row['manufacturer'], row['batch_number']), axis = 1).

[0239] 5.3 Use natural language processing technology to extract indications, adverse reaction information, drug contraindications, chemical structure, and metabolic enzyme targets from drug instructions.

[0240] Drug instructions are usually in PDF, text, and other formats. For instructions in PDF format, you can use the pymupdf library to convert them to text. The following is a sample code to convert PDF to text:

[0241] import fitz#Import pymupdf library, here using the alias fitz;

[0242] # Define a function to convert drug instructions in PDF format into text;

[0243] def pdf_to_text(pdf_path):

[0244] # Use fitz library to open PDF file;

[0245] doc = fitz.open(pdf_path);

[0246] text = ""# Initialize an empty string to store the converted text;

[0247] # Traverse each page of the PDF file;

[0248] for page in doc:

[0249] # Append the text content of each page to the text string;

[0250] text+=page.get_text();

[0251] # Return the converted complete text;

[0252] return text.

[0253] To extract indications, adverse reactions, and contraindications, rule-based methods or machine learning / deep learning models can be used. Rule-based methods can use regular expressions to match key phrases. For example, the following regular expression example for extracting indications:

[0254] import re# Import re library for regular expression operations;

[0255] # Define a function to extract indication information from text;

[0256] def extract_indications(text):

[0257] # Define a regular expression pattern to match the content after "Indications:" until a period is encountered;

[0258] pattern = r'Indications: ([^.]*)'

[0259] # Search for matching patterns in text;

[0260] match = re.search(pattern, text);

[0261] # If a match is found, return the matched content (i.e., indication information);

[0262] if match:

[0263] return match.group(1) (i.e., return the data of matched group (1));

[0264] # If no match is found, return None;

[0265] return None.

[0266] For more complex extraction tasks, such as extracting chemical structures and metabolic enzyme targets, deep learning models such as those based on the Transformer architecture (e.g., BERT, GPT, etc.) may be required for training and prediction. In Python, the transformers library can be used to implement this. Here is a simple example code framework using BERT for text classification (which can be used here to classify whether it is a chemical structure related text):

[0267] from transformers import AutoTokenizer, AutoModelForSequenceClassification# Import the automatic tokenizer and sequence classification model from the transformers library;

[0268] import torch# Import the torch library for deep learning calculations;

[0269] # Load the tokenizer from the pre-trained BERT model;

[0270] tokenizer = AutoTokenizer.from_pretrained('bert - base - uncased');

[0271] # Load the sequence classification model from the pre-trained BERT model;

[0272] model = AutoModelForSequenceClassification.from_pretrained('bert -base - uncased');

[0273] # Define a function to classify the input text;

[0274] def classify_text(text):

[0275] # Use the tokenizer to encode the text and return the data in PyTorch tensor format;

[0276] inputs = tokenizer(text, return_tensors='pt');

[0277] # Input the encoded data into the model for forward propagation;

[0278] outputs = model(**inputs);

[0279] # Get the unnormalized prediction scores (logits) output by the model;

[0280] logits = outputs.logits;

[0281] # Perform argmax operation on logits to get the predicted category index;

[0282] prediction = torch.argmax(logits, dim = 1);

[0283] # Return the predicted category index;

[0284] return prediction.item().

[0285] 5.4 Based on the pre-set correspondence between the adverse reaction severity level and the adverse reaction information, and the adverse reaction of the drug, the adverse reaction severity level of the drug is generated.

[0286] The preset correspondence between the severity level of adverse reactions and adverse reaction information can be stored in a dictionary. For example:

[0287] severity_mapping = {

[0288] "Mild rash": "Low", # Mild rash corresponds to low severity level

[0289] "Severe allergic reaction": "High",# Severe allergic reaction corresponds to high severity level

[0290] "Nausea and vomiting": "Medium" # Nausea and vomiting corresponds to the medium severity level};

[0291] Assuming that the adverse reaction information of the drug has been extracted as adverse_reaction, the severity level is generated by the following code:

[0292] def get_severity(adverse_reaction):

[0293] # Traverse the pre-set correspondence dictionary;

[0294] for key, value in severity_mapping.items():

[0295] # If the adverse reaction information in the dictionary is contained in the extracted adverse reaction information of the drug;

[0296] if key in adverse_reaction:

[0297] # Return the corresponding severity level;

[0298] return value;

[0299] # If no matching adverse reaction information is found, return "unknown";

[0300] return "unknown".

[0301] 5.5 Store the identity code of the drug, indications, adverse reaction level, drug contraindication information, chemical structure, and metabolic enzyme target to the drug dictionary.

[0302] Integrate all the extracted required information into a dictionary, and then save this dictionary as a JSON format drug dictionary.

[0303] drug_dict = {}# Initialize an empty dictionary to store drug information;

[0304] for index, row in df.iterrows():

[0305] drug_info = {

[0306] "identity_code": row['identity_code'],# Drug identity code

[0307] "indications": extract_indications(row['instruction_text']),# Extracted indications information

[0308] "adverse_reaction_severity": get_severity(row['adverse_reaction_text']),# generated adverse reaction severity level

[0309] "drug_contraindications": extract_contraindications(row['instruction_text']),# extracted drug contraindication information

[0310] "chemical_structure": extract_chemical_structure(row['instruction_text']),# extracted chemical structure information

[0311] "metabolic_enzyme_targets": extract_metabolic_enzyme_targets(row['instruction_text'])# extracted metabolic enzyme target information};

[0312] # Add the drug information dictionary to the total drug dictionary with the drug name as the key;

[0313] drug_dict[row['drug_name']] = drug_info;

[0314] import json# import the json library to handle JSON format data;

[0315] # Open the file named drug_dictionary.json in write mode;

[0316] with open('drug_dictionary.json', 'w') as f:

[0317] # Write the drug dictionary in JSON format to the file with an indentation of 4 to make the file more readable;

[0318] json.dump(drug_dict, f, indent = 4)。

[0319] In one embodiment of the present application, based on step S2, the following will give a non-limiting description of a specific embodiment thereof.

[0320] S201. Generate a quantified value for the drug attribute, and normalize the quantified value to obtain an attribute quantified value.

[0321] Drug attributes can have different data types and value ranges. For example, price is numerical, and adverse reaction severity level is categorical (e.g., "low", "medium", "high"). For numerical attributes such as price, you can directly use their numerical values as the basis for quantified values. For categorical attributes, encoding is required. For example, using one-hot encoding to encode adverse reaction severity levels "low", "medium", "high" as [1, 0, 0], [0, 1, 0], [0, 0, 1].

[0322] For example, a DataFrame drug_df containing drug attributes, with "price" and "adverse_reaction_severity" columns, the following is an example code:

[0323] import pandas as pd;

[0324] import numpy as np;

[0325] # Assuming drug_df is a DataFrame containing drug attributes;

[0326] # Extract the price column as the quantified value;

[0327] drug_df['price_quantified'] = drug_df['price'];

[0328] # One-hot encoding of adverse reaction severity level;

[0329] adverse_severity_dummies = pd.get_dummies(drug_df['adverse_reaction_severity']);

[0330] drug_df = pd.concat([drug_df, adverse_severity_dummies], axis = 1)。

[0331] The purpose of normalization is to convert quantified values of different ranges to the same range, usually [0, 1]. For numerical attributes such as price, the min-max normalization method can be used. The formula is: x_{norm}=\frac{x - x_{min}}{x_{max}-x_{min}}, where x is the original value, x_{min} and x_{max} are the minimum and maximum values of the attribute, respectively.

[0332] # Min-max normalization on price quantified values;

[0333] price_min = drug_df['price_quantified'].min();

[0334] price_max = drug_df['price_quantified'].max();

[0335] drug_df['price_normalized'] = (drug_df['price_quantified']- price_min) / (price_max - price_min);

[0336] # For one-hot encoded adverse reaction severity levels, they are already in the 0-1 range and do not need additional normalization.

[0337] S202. Obtain the user's attention to the attribute, and set the weight factor of the corresponding attribute quantified value according to the attention.

[0338] Through the design of the front-end interface, the user can express the attention to the attribute in multiple ways. For example, use a slider, the value range of the slider is 0-100, representing the user's attention to the attribute from low to high. Suppose the user's attention to the price is set to 80 through the slider, and the attention to the adverse reaction severity level is set to 60.

[0339] Convert the user's attention to the weight factor, which needs to normalize the attention value to the range of 0-1. For example, the weight factor of the price is \frac{80}{100}=0.8, and the weight factor of the adverse reaction severity level is \frac{60}{100}=0.6. Store these weight factors in a dictionary weight_factors.

[0340] # Suppose the user's attention to the price is 80, and the attention to the adverse reaction severity level is 60;

[0341] weight_factors = {

[0342] 'price': 80 / 100,

[0343] 'adverse_reaction_severity': 60 / 100}.

[0344] S203. Calculate the weighted sum of the attribute quantization values ​​to obtain the weight value of the drug entity.

[0345] For each drug entity, calculate the weighted sum of its attribute values ​​based on the configured weight factors. Assume that the attribute values ​​of the drug entity are stored in drug_df and the weight factors are stored in weight_factors. Taking price and adverse reaction severity as examples, the weight value of the drug entity is calculated as: weight = price_{normalized} \times weight_{price} + adverse_{normalized} \times weight_{adverse}.

[0346] # Calculate the weight value of the drug entity;

[0347] drug_df['weight'] = (

[0348] drug_df['price_normalized'] * weight_factors['price']+

[0349] drug_df['low'] * weight_factors['adverse_reaction_severity']+

[0350] drug_df['medium'] * weight_factors['adverse_reaction_severity']+

[0351] drug_df['high'] * weight_factors['adverse_reaction_severity']).

[0352] In an embodiment of the present invention, based on step S3, an example is given below to illustrate its specific implementation scheme in a non-limiting manner.

[0353] S301. Query the knowledge graph for multiple main drug entities whose weight values ​​corresponding to the target disease are the highest and whose indications match the target disease, wherein the target disease is the first disease or the second disease.

[0354] Assuming the knowledge graph is built using the NetworkX library and the node attributes include "weight" and "indications," we first need to traverse all drug entity nodes connected to the target condition.

[0355] Here is a sample code using the networkx library to query:

[0356] import networkx as nx;

[0357] def find_main_drugs(kg, target_disease):

[0358] main_drugs = [];

[0359] for drug in kg.nodes():

[0360] # Check if there is an edge from the drug node to the target disease node;

[0361] if kg.has_edge(drug, target_disease):

[0362] # Get the weight value and indication of the drug;

[0363] weight = kg.nodes[drug].get('weight')

[0364] Indications= kg.nodes[drug].get('indications');

[0365] # Check if the indication matches the target condition;

[0366] if target_disease in indications:

[0367] main_drugs.append((drug, weight));

[0368] # Sort by weight from high to low;

[0369] main_drugs.sort(key = lambda x: x[1], reverse = True);

[0370] # Assume that the top 5 drug entities with the highest weight values ​​are taken as the main drug entities;

[0371] top_main_drugs = [drug for drug, _ in main_drugs[:5]];

[0372] return top_main_drugs.

[0373] S302. Query the drug entity set corresponding to the target disease from the knowledge graph, where the drug entity set includes all drug entities connected to the first disease.

[0374] Also based on the networkx library, first find all drug entity nodes connected to the first disease, and then filter out the drug entities connected to the target disease (first disease or second disease).

[0375] def find_drug_set(kg, target_disease):

[0376] all_drugs_connected_to_first_disease = [];

[0377] for drug in kg.nodes():

[0378] if kg.has_edge(drug, 'First symptom'):

[0379] all_drugs_connected_to_first_disease.append(drug);

[0380] drug_set = [];

[0381] for drug in all_drugs_connected_to_first_disease:

[0382] if kg.has_edge(drug, target_disease):

[0383] drug_set.append(drug);

[0384] return drug_set.

[0385] S303. Obtain a secondary drug entity having an associated edge with the primary drug entity, wherein the number of citations of the associated edge reaches a set citation threshold.

[0386] The edge attribute of the knowledge graph contains "count" (reference times). For each main drug entity (main drug entity), traverse all its outgoing edges to find secondary drug entities whose reference times reach a certain threshold.

[0387] def find_secondary_drugs(kg, main_drugs, threshold):

[0388] secondary_drugs = [];

[0389] for main_drug in main_drugs:

[0390] for neighbor in kg.neighbors(main_drug):

[0391] edge_data = kg.get_edge_data(main_drug, neighbor);

[0392] for data in edge_data.values():

[0393] count = data.get('count', 0);

[0394] if count>= threshold:

[0395] secondary_drugs.append(neighbor);

[0396] return secondary_drugs。

[0397] S304. Remove drug entities from secondary drug entities whose duration attributes do not match the main drug entities.

[0398] The knowledge graph node attribute contains "duration_label" (duration attribute). For each main drug entity, compare its duration attribute with the duration attribute of the secondary drug entity, and perform the corresponding removal. Get the duration attribute of the main drug entity; remove the secondary drug entity whose duration attribute is greater than the duration attribute of the main drug entity.

[0399] def filter_secondary_drugs(kg, main_drugs, secondary_drugs):

[0400] filtered_secondary_drugs = [];

[0401] for main_drug in main_drugs:

[0402] main_duration = kg.nodes[main_drug].get('duration_label')

[0403] for secondary_drug in secondary_drugs:

[0404] secondary_duration = kg.nodes[secondary_drug].get('duration_label')

[0405] if secondary_duration == main_duration and secondary_duration <= main_duration:

[0406] filtered_secondary_drugs.append(secondary_drug)

[0407] return filtered_secondary_drugs

[0408] S305. Store the updated drug entities with the main drug entity as a drug group corresponding to the target disease.

[0409] Store the main drug entity and the updated secondary drug entities in a dictionary with the target disease as the key and the list of drug entities as the value.

[0410] def store_drug_group(target_disease, main_drugs, filtered_secondary_drugs):

[0411] drug_group = {

[0412] target_disease: main_drugs + filtered_secondary_drugs}

[0413] return drug_group

[0414] In a specific example, the method is executed as follows:

[0415] # Assume the knowledge graph kg has been constructed;

[0416] # Assume the target disease is 'target_disease';

[0417] # Assume the reference count threshold is set to 10;

[0418] main_drugs = find_main_drugs(kg, target_disease);

[0419] drug_set = find_drug_set(kg, target_disease);

[0420] secondary_drugs = find_secondary_drugs(kg, main_drugs, 10);

[0421] filtered_secondary_drugs = filter_secondary_drugs(kg, main_drugs, secondary_drugs);

[0422] drug_group = store_drug_group(target_disease, main_drugs, filtered_secondary_drugs).

[0423] In an embodiment of the present application, based on step S4, an embodiment will be given below to illustrate the specific implementation thereof.

[0424] S401. Obtain the reference count of the association edge between the drug entities in the first drug group and the drug entities in the second drug group.

[0425] Using the Cypher query language of the graph database (such as Neo4j), traverse all the association edges between the first drug group (Group_A) and the second drug group (Group_B) in the knowledge graph, and extract the reference_count attribute value of the edge.

[0426] MATCH (a:DrugGroup {id: "Group_A"})-[r:CO_USE]->(b:DrugGroup {id: "Group_B"});

[0427] RETURN r.reference_count.

[0428] The number of references is derived from the co-occurrence frequency of "combined triples" in the knowledge graph construction process.

[0429] S402. Confirm that there is no association edge between the first drug entity and the second drug entity or the reference count of the association edge does not reach the set reference count threshold, and obtain the drug property characteristics of the first drug entity and the drug property characteristics of the second drug entity; the first drug entity belongs to a first drug group, and the second drug entity belongs to a second drug group.

[0430] If the association edge does not exist or reference_count < threshold (threshold is set according to clinical data, such as < 10 times), the drug property feature extraction process is triggered.

[0431] Obtain the drug property characteristics from the knowledge graph node attributes:

[0432] ‌Chemical structure: SMILES code (parsed through RDKit library);

[0433] ‌Metabolic enzyme target: CYP450 enzyme family number (such as CYP3A4);

[0434] ‌Drug contraindication: For example, aspirin cannot be used at the same time as an anticoagulant.

[0435] S403. Input the drug property characteristics of the first drug entity and the drug property characteristics of the second drug entity into the pre-trained random forest model to confirm whether the first drug entity and the second drug entity can be combined.

[0436] Input the drug property characteristics of the first drug entity and the drug property characteristics of the second drug entity extracted in step S402 as a feature vector into the pre-trained random forest model.

[0437] Use the scikit-learn library to build a random forest classifier:

[0438] 1. Install necessary Python libraries such as scikit-learn, pandas, numpy, etc.

[0439] 2. Use RandomForestClassifier to build a random forest model and set n_estimators=100 and max_depth=5.

[0440] # Build a random forest classifier model = RandomForestClassifier(n_estimators=100, max_depth=5, random_state=42);

[0441] n_estimators=100: indicates the number of decision trees in the random forest is 100.

[0442] max_depth=5: indicates the maximum depth of each decision tree is 5.

[0443] random_state=42: sets the random seed to ensure the results of the model are reproducible each time the code is run.

[0444] The training process of the random forest model includes using 200,000 historical drug combination records (from the clinical pharmacology database) with labels as "combinable" (adverse reaction rate <5%) or "incombinable" (adverse reaction rate ≥5%).

[0445] The parameter configuration of the random forest model includes:

[0446] model = RandomForestClassifier(

[0447] n_estimators=200, # number of trees (balance accuracy and computational cost):ml-citation{ref="1"data="citationList"}

[0448] max_depth=15, # control overfitting, limit tree complexity:ml-citation{ref="1" data="citationList"}

[0449] criterion='gini', # splitting standard (Gini impurity):ml-citation{ref="1" data="citationList"}

[0450] class_weight='balanced' # handle class imbalance (fewer samples of incombinable):ml-citation{ref="1" data="citationList"}).

[0451] Input the feature vector to the random forest model:

[0452] # Example feature vector (after standardization)

[0453] features = [

[0454] tanimoto_score, # chemical structure similarity:ml-citation{ref="1" data="citationList"}

[0455] enzyme_competition_flag, # Metabolic enzyme competition flag (1 / 0):ml-citation{ref="1"data="citationList"}

[0456] contraindication_flag # Contraindication flag (1 / 0):ml-citation{ref="1"data="citationList"}.

[0457] Then, feature engineering is established:

[0458] Chemical structure features:

[0459] ‌SMILES encoding analysis‌: Using the RDKit library to convert the SMILES encoding of the two drugs into molecular descriptors (such as the number of atoms, bond types, ring structures, etc.), and calculate the‌ Tanimoto coefficient‌ (based on molecular fingerprint chemical similarity score).

[0460] ‌Key pharmacophore matching‌: Identify the structural fragments in the drug molecules related to pharmacological activity (such as the 3,5-dihydroxy carboxylic acid fragment of hydroxymethylglutaryl coenzyme A reductase inhibitors), and determine whether there is a pharmacophore conflict between the two drugs.

[0461] ‌Metabolic enzyme target features‌:

[0462] ‌CYP450 enzyme family interaction analysis‌: If the metabolic enzyme targets of the two drugs belong to the same CYP family (such as CYP3A4 and CYP2D6), mark as "metabolic competition"; if there is no intersection, mark as "no competition".

[0463] ‌Metabolic pathway conflict detection‌: According to the enzyme kinetics parameters (such as Km value) to assess whether the metabolic rate is inhibited by each other.

[0464] ‌Drug contraindication features‌:

[0465] ‌Contraindication conflict flag‌: Based on the known contraindication database (such as DrugBank), determine whether the two drugs belong to the contraindication combination (such as anticoagulants and aspirin), generate a binary feature (1= exists contraindication, 0= no contraindication).

[0466] In a specific example, the prediction process includes:

[0467] Input two drug feature vectors, the model outputs the combination probability (0~1). Set the threshold value to 0.7:

[0468] ‌Probability ≥ 0.7‌: Determine as "can be combined" (high confidence).

[0469] ‌Probability <0.7: Determine as "not co-use" (manual review is required).

[0470] S404. If the first drug entity and the second drug entity are not co-use, remove the second drug entity.

[0471] If the model prediction result is "not co-use", remove the corresponding entity from the second drug group (Group_B) and record the reason for removal (such as "CYP3A4 metabolic conflict").

[0472] Dynamically update the knowledge graph, and mark the removed co-use relationship as a high-risk edge.

[0473] S405. Output the recommended scheme for the first drug group and the second drug group after removing the non-co-use drug entity.

[0474] Perform Cartesian product combination on Group_A and filtered Group_B to generate the final recommendation list.

[0475] Output format:

[0476] { "group_a": ["Drug_A1", "Drug_A2"],

[0477] "group_b": ["Drug_B3", "Drug_B5"],

[0478] "co_use_score": [0.89, 0.76]# Associated edge reference frequency weighted value}.

[0479] Use the cache mechanism to store high-frequency co-use combinations to reduce real-time calculation load.

[0480] Please refer to Figure 2 , in an embodiment, the diagnosis and treatment scheme recommendation process includes:

[0481] 1. Obtain case data.

[0482] 100,000 cases of a certain third-grade hospital (format: JSON), including disease, medication record, and cure duration (days).

[0483] 2. Construct treatment triples and co-use triples based on case data.

[0484] Use the BERT-NER model to identify disease entities (such as "hypertension") and drug entities (such as "amlodipine").

[0485] Extract the treatment triple <hypertension, treatment drug, amlodipine>.

[0486] ‌Cure duration clustering:

[0487] K-means clustering (n_clusters=3) on the duration of cure for "hypertension" cases, generating duration identifiers (short / medium / long-term).

[0488] ‌Triplet statistics:

[0489] Statistical combination of drugs used in the same case (such as "amlodipine + hydrochlorothiazide"), recording the number of co-occurrences as the number of references.

[0490] 3. Build a drug dictionary.‌

[0491] Obtain drug instructions (PDF / TXT) and drug batch data (name, manufacturer, batch number).

[0492] Generate‌ identity code‌, calculate SHA-256 hash value for drug name + manufacturer + batch number (example: a3f5...d89).

[0493] Extract‌ attributes‌, use BioBERT model to extract indications, contraindications (such as "contraindicated for patients with severe liver damage") from the instructions. Match adverse reaction severity levels (such as "3-fold increase in liver enzymes" → level 2) by rules.

[0494] Store‌ data‌, store hash values, indications, contraindications, etc. in MongoDB, and index the field as hash value.

[0495] 4. Build a knowledge graph.‌

[0496] Define‌ graph structure‌: node types include disease, drug (attributes: price, adverse reaction level, duration identifier); edge types include treatment (attributes: reference count), combination (attributes: reference count).

[0497] Use Neo4j's LOAD CSV command to import triples into the graph structure, example:

[0498] CREATE (:Disease {name: 'hypertension'});

[0499] CREATE (:Drug {name: 'amlodipine', duration:'medium', price: 50});

[0500] MATCH (d:Disease {name: 'hypertension'}), (dr:Drug {name: 'amlodipine'});

[0501] CREATE (d)-[:TREAT {references: 1200}]->(dr).

[0502] 5. Generate dynamic weights.

[0503] User inputs focus on "price" and "ADR level" (weight distribution: price = 0.6, ADR = 0.4).

[0504] Normalize attributes, for example:

[0505] Price: Min-Max normalization (assuming price range 50-200 yuan -> 0.0-1.0).

[0506] ADR level: Direct mapping (level 1 -> 0.2, level 2 -> 0.5, level 3 -> 1.0).

[0507] Calculate weights:

[0508] drug_score = (normalized_price * 0.6) + (normalized_adr_level * 0.4).

[0509] 6. Query drug groups.

[0510] Target diseases: "hypertension" (first disease), "diabetes" (second disease).

[0511] Query logic (take hypertension as an example):

[0512] Retrieve the top 10 drugs from the knowledge graph (sorted by drug_score).

[0513] Filter associated drugs:

[0514] MATCH (d:Disease {name: 'hypertension'})-[t:TREAT]->(main:Drug);

[0515] OPTIONAL MATCH (main)-[r:CO_USE]->(sub:Drug);

[0516] WHERE r.references > 10 AND sub.duration <= main.duration;

[0517] RETURN main, COLLECT(sub) AS subs.

[0518] Output the first drug group: [amlodipine, hydrochlorothiazide] and related drugs [atorvastatin].

[0519] 7. Verify the combination of drugs.

[0520] A random forest model was used to predict whether drugs with citation counts below the threshold could be used in combination. Taking amlodipine and metformin as an example, the characteristics of the two drugs are shown in Table 1.

[0521] Table 1 Input characteristics of amlodipine + metformin

[0522]

[0523] Model output: Combination probability = 0.83 (> threshold 0.7 → can be combined).

[0524] When querying drug entities, we filter for secondary drug entities that have an edge associated with the primary drug entity, meaning their citation counts meet the citation threshold. Consequently, the citation counts between drug entities in the first group and those in the second group often fail to meet the threshold. Therefore, we need to perform a threshold check on the citation counts of drug entities in the first and second groups, and perform a joint verification on any drug entities that fail the check. This eliminates the need to traverse all drug entity relationships, reducing computational complexity.

[0525] When it is predicted that two drug entities cannot be used in combination, the drug entity belonging to the second group (corresponding to the secondary disease) will be eliminated from the second group to prioritize the therapeutic effect of the primary disease.

[0526] Generate recommendations based on prediction results:

[0527] Drug group after filtration:

[0528] Group 1 (hypertension): amlodipine, hydrochlorothiazide, atorvastatin;

[0529] Group 2 (diabetes): metformin, sitagliptin;

[0530] Final recommendation (Cartesian product combination):

[0531] {"recommendations": [

[0532] {"hypertension": "amlodipine", "diabetes": "metformin", "score": 0.83},

[0533] {"hypertension": "amlodipine", "diabetes": "sitagliptin", "score":0.79}]}.

[0534] Implementation effects: In a pilot hospital, the adverse reaction rate of recommended solutions decreased from 12% to 4%.

[0535] Accuracy: In a pilot hospital, the adverse reaction rate of recommended solutions decreased from 12% to 4%.

[0536] Efficiency: Single recommendation response time < 400ms (Neo4j + Redis cache).

[0537] Customized recommendations: Combined with weight value dynamic adjustment and primary and secondary entity separate query, customized recommendations are realized to meet user needs.

[0538] In some embodiments, the knowledge base-based medical solution recommendation system can include a plurality of functional modules composed of computer program segments. The computer programs of each program segment in the knowledge base-based medical solution recommendation system can be stored in the memory of the computer device and executed by at least one processor to perform the functions of knowledge base-based medical solution recommendation (see Figure 1 Description).

[0539] In this embodiment, the knowledge base-based medical solution recommendation system can be divided into a plurality of functional modules according to the functions it performs, as shown in Figure 3 The functional modules of the system can include an acquisition module, a first processing module, a query module, and a second processing module. The module referred to by the present application refers to a series of computer program segments that can be executed by at least one processor and can complete a fixed function, which is stored in the memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0540] The acquisition module is configured to acquire a first disease and a second disease, wherein the priority of the first disease is higher than that of the second disease.

[0541] The first processing module is configured to generate a weight value for a drug attribute in a pre-constructed drug knowledge graph according to a user attention degree input from the front end.

[0542] The query module is configured to query a first drug group corresponding to the first disease and a second drug group corresponding to the second disease from the knowledge graph based on the weight value.

[0543] The second processing module is configured to generate a recommended solution based on the drug property characteristics of the drug entities in the first drug group and the second drug group using a pre-trained random forest model.

[0544] Figure 4The method for recommending medical treatment plan based on knowledge base provided by the embodiments of the present application can be applied to a device. Those skilled in the art can understand that the device structure involved in the embodiments of the present application does not constitute a limitation on the device, and the device can include more or fewer components than the illustration, or combine certain components, or different component arrangements. In the embodiments of the present application, the device includes but is not limited to a laptop computer, a desktop computer, a workstation, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The device can also represent various forms of mobile devices, such as a personal digital processor, a cellular phone, a smart phone, a wearable device, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are merely examples, and are not intended to limit the implementation of the embodiments of the present application described herein and / or claimed.

[0545] The device 400 can include a processor 410, a memory 420, and a communication unit 430. These components communicate through one or more buses, and those skilled in the art can understand that the structure of the server shown in the figure does not constitute a limitation on the present application, and it can be a bus structure or a star structure, and can include more or fewer components than the illustration, or combine certain components, or different component arrangements.

[0546] The memory 420 can be used to store the execution instructions of the processor 410, and the memory 420 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk. When the execution instructions in the memory 420 are executed by the processor 410, the device 400 can execute part or all of the steps in the following method embodiments.

[0547] The processor 410 is the control center of the storage device, connects various parts of the entire electronic device by using various interfaces and lines, and performs various functions of the electronic device and / or processes data by running or executing software programs and / or modules stored in the memory 420 and calling data stored in the memory. The processor can be composed of an integrated circuit (IC), for example, can be composed of a single packaged IC, or can be composed of a plurality of packaged ICs connected together. For example, the processor 410 can only include a central processing unit (CPU). In the embodiments of the present application, the CPU can be a single operation core or can include multiple operation cores.

[0548] The communication unit 430 is configured to establish a communication channel, so that the storage device can communicate with other devices. The communication unit 430 receives user data sent by other devices or sends user data to other devices.

[0549] The present application also provides a computer storage medium, wherein the computer storage medium can store a program, and the program can include some or all steps in the embodiments provided by the present application when executed. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0550] Those skilled in the art can clearly understand that the technology in the embodiments of the present application can be realized by means of software and necessary general hardware platforms. Based on such understanding, the technical solutions in the embodiments of the present application can be embodied in the form of a software product, which is stored in a storage medium such as a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc. The software product includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a second device, a network device, etc.) to execute all or part of the steps of the method described in the embodiments of the present application.

[0551] In the present specification, the same or similar parts among various embodiments can be referred to each other. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the description in the method embodiments.

[0552] In several embodiments provided by the present application, it should be understood that the disclosed system and method can be implemented in other manners. For example, the system embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There can be another division manner for the actual implementation. For example, a plurality of modules or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between different modules can be indirect couplings or communication connections through some interfaces, and electrical, mechanical or other forms.

[0553] The modules illustrated as separated components can or can not be physically separated, and the components illustrated as modules can or can not be physical modules, i.e., can be located in one place, or can be distributed to a plurality of network modules. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.

[0554] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.

[0555] Although the present application has been described in detail by referring to the preferred embodiments thereof, it is to be understood that the present application is not limited to the embodiments described above. Rather, it should be appreciated that those skilled in the art, upon consideration of the disclosure, can make modifications and / or improvements to the embodiments of the application without deviating from the spirit and scope of the application. Any modifications and / or improvements made to the embodiments of the application by those skilled in the art are to be considered within the scope of the application.

Claims

1. A method for recommending medical solutions based on a knowledge base, characterized in that: include: Obtain a first symptom and a second symptom, wherein the first symptom has a higher priority than the second symptom; Generate weight values ​​for drug attributes in the pre-built drug knowledge graph based on user attention input from the front-end; Based on the weight values, respectively querying from the knowledge graph a first drug group corresponding to the first disease and a second drug group corresponding to the second disease; Generate a recommendation based on the medicinal properties of drug entities in the first and second drug groups using a pre-trained random forest model; The method for constructing the drug knowledge graph includes: Obtain case data, and extract cure time and cure duration from the case data; Perform cluster analysis on the cure time of case data and generate a time identifier for the case data based on the clusters; Extract drug entities and disease entities from case data, construct treatment triples for drug entities and disease entities, and construct joint triples for drug entities in the same case data; Constructing a knowledge graph based on the treatment triples and the combination triples, using the number of repetitions of the triples as the number of references of the corresponding edge in the knowledge graph, and setting the duration identifier of the case data as the duration attribute of the corresponding drug entity; Extracting drug attributes and medicinal properties from a pre-built drug dictionary. The drug attributes include price, severity of adverse reactions, and indications. The medicinal properties include drug contraindications, chemical structure, and metabolic enzyme targets. Setting the drug attributes and medicinal properties characteristics as node attribute values ​​of the corresponding drug entities in the knowledge graph; Querying the first drug group corresponding to the first disease and the second drug group corresponding to the second disease from the knowledge graph based on the weight values ​​respectively includes: Querying the knowledge graph for a plurality of main drug entities having the highest weight value corresponding to the target disease and whose indications match the target disease, wherein the target disease is the first disease or the second disease; Querying a drug entity set corresponding to a target disease from the knowledge graph, where the drug entity set includes all drug entities connected to the first disease; Obtaining a secondary drug entity having an associated edge with the primary drug entity, wherein the number of citations of the associated edge reaches a set citation threshold; Eliminate drug entities from secondary drug entities whose duration attributes do not match those of the primary drug entity; The updated drug entity is stored with the main drug entity as a drug group corresponding to the target condition.

2. The method according to claim 1, characterized in that The method for constructing the drug dictionary includes: Obtaining drug identification information, including name, manufacturer, and batch; Calculating a hash value of the identity information and using the hash value as the identity code of the drug; Use natural language processing technology to extract indications, adverse reaction information, drug contraindications, chemical structure, and metabolic enzyme targets from drug instructions; Generate the drug adverse reaction severity level based on the preset correspondence between the adverse reaction severity level and the adverse reaction information and the adverse reaction of the drug; The drug's identity code, indication, adverse reaction level, drug contraindication information, chemical structure and metabolic enzyme target are stored in the drug dictionary.

3. The method according to claim 1, characterized in that Generate weight values ​​for drug attributes in the pre-built drug knowledge graph based on user attention input from the front-end, including: Generate quantitative values ​​for drug attributes and normalize the quantitative values ​​to obtain attribute quantitative values; Obtaining the user's attention to the attribute, and setting a weight factor for the corresponding attribute quantization value according to the attention; Calculate the weighted sum of the attribute quantification values ​​to obtain the weight value of the drug entity.

4. The method according to claim 1, wherein Eliminate drug entities from the secondary drug entity whose duration attributes do not match the primary drug entity, including: Get the duration attribute of the main drug entity; Eliminate secondary drug entities whose duration attribute is greater than the duration attribute of the primary drug entity.

5. The method according to claim 1, wherein A pre-trained random forest model is used to generate recommendations based on the medicinal properties of the drug entities in the first and second drug groups, including: Obtain the number of references of the associated edge between the drug entity in the first drug group and the drug entity in the second drug group; Confirming that there is no association edge between the first drug entity and the second drug entity or the number of citations of the association edge does not reach a set citation number threshold, obtaining the medicinal property characteristics of the first drug entity and the medicinal property characteristics of the second drug entity; the first drug entity belongs to the first drug group, and the second drug entity belongs to the second drug group; Inputting the medicinal property characteristics of the first drug entity and the medicinal property characteristics of the second drug entity into a pre-trained random forest model to determine whether the first drug entity and the second drug entity can be used in combination; If the first drug entity and the second drug entity cannot be used in combination, the second drug entity is eliminated; The first drug group and the second drug group after excluding drug entities that cannot be used in combination are output as recommended solutions.

6. A medical plan recommendation system based on a knowledge base, characterized in that: include: An acquisition module, configured to acquire a first symptom and a second symptom, wherein the priority of the first symptom is higher than that of the second symptom; The first processing module is used to generate weight values ​​for drug attributes in the pre-built drug knowledge graph according to user attention input by the front end; A query module, configured to query a first drug group corresponding to a first symptom and a second drug group corresponding to a second symptom from the knowledge graph based on the weight values; a second processing module for generating a recommendation based on the medicinal properties of the drug entities in the first drug group and the second drug group using a pre-trained random forest model; The method for constructing the drug knowledge graph includes: Obtain case data, and extract cure time and cure duration from the case data; Perform cluster analysis on the cure time of case data and generate a time identifier for the case data based on the clusters; Extract drug entities and disease entities from case data, construct treatment triples for drug entities and disease entities, and construct joint triples for drug entities in the same case data; Constructing a knowledge graph based on the treatment triples and the combination triples, using the number of repetitions of the triples as the number of references of the corresponding edge in the knowledge graph, and setting the duration identifier of the case data as the duration attribute of the corresponding drug entity; Extracting drug attributes and medicinal properties from a pre-built drug dictionary. The drug attributes include price, severity of adverse reactions, and indications. The medicinal properties include drug contraindications, chemical structure, and metabolic enzyme targets. Setting the drug attributes and medicinal properties characteristics as node attribute values ​​of the corresponding drug entities in the knowledge graph; Querying the first drug group corresponding to the first disease and the second drug group corresponding to the second disease from the knowledge graph based on the weight values ​​respectively includes: Querying the knowledge graph for a plurality of main drug entities having the highest weight value corresponding to the target disease and whose indications match the target disease, wherein the target disease is the first disease or the second disease; Querying a drug entity set corresponding to a target disease from the knowledge graph, where the drug entity set includes all drug entities connected to the first disease; Obtaining a secondary drug entity having an associated edge with the primary drug entity, wherein the number of citations of the associated edge reaches a set citation threshold; Eliminate drug entities from secondary drug entities whose duration attributes do not match those of the primary drug entity; The updated drug entity is stored with the main drug entity as a drug group corresponding to the target condition.

7. A medical plan recommendation device based on a knowledge base, characterized in that: include: A memory, used for storing a medical plan recommendation program based on a knowledge base; A processor is configured to implement the steps of the knowledge-based medical plan recommendation method according to any one of claims 1 to 5 when executing the knowledge-based medical plan recommendation program.

8. A computer-readable storage medium storing a computer program, characterized in that: The readable storage medium stores a knowledge-based medical plan recommendation program, which, when executed by a processor, implements the steps of the knowledge-based medical plan recommendation method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method, system and equipment for intelligently recommending antimicrobial drugs

    CN112233745A

  • Drug recommendation method, device and system, electronic equipment and storage medium

    CN114765075A

  • Medication data processing method and device, computer equipment and storage medium

    CN116403674A

  • Untoward drug reaction monitoring and early warning method

    CN118280603A