Medication recommendation method and system

By processing patient medical data through a code-visit hierarchical attention model, a global health representation is generated. Combined with a medical knowledge base, similar cases are retrieved from a case information database. This solves the problems of limited coverage and neglect of temporal correlation in existing medication recommendation schemes, and achieves more accurate and safer medication recommendations.

CN121617544BActive Publication Date: 2026-04-28SUZHOU YINGDI XINKANG NETWORK INFORMATION TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SUZHOU YINGDI XINKANG NETWORK INFORMATION TECH
Filing Date
2026-02-03
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In existing medication recommendation schemes, rule-based recommendation algorithms have limited coverage and cannot adapt to the needs of individualized diagnosis and treatment, while machine learning-based recommendation algorithms ignore the temporal correlation of patients' medical history, resulting in insufficient accuracy of recommendation results.

Method used

A code-visit dual-level hierarchical attention model is used to process patients' medical data, generate a global health representation, and retrieve similar historical cases from the case information database, combined with a medical professional knowledge base to generate a medication recommendation list.

Benefits of technology

It improves the accuracy and safety of medication recommendations, better reflects the individualized health status and disease progression of patients, and provides reliable clinical evidence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121617544B_ABST
    Figure CN121617544B_ABST
Patent Text Reader

Abstract

The application relates to a medication recommendation method and system, which comprises the following steps: preprocessing original medical data of a current patient into a standardized time sequence diagnosis and treatment sequence; inputting the time sequence diagnosis and treatment sequence and a medical professional knowledge base into a code-visit two-level hierarchical attention model for processing, obtaining code-level aggregated features of each visit and corresponding visit-level attention weights, weighting and aggregating the code-level aggregated features based on the visit-level attention weights, and generating a global health representation of the current patient; searching for similar historical cases as reference cases from a case information base based on at least one of a plurality of medical feature information of the current patient; and generating and outputting a medication recommendation list for the current patient based on at least the global health representation of the current patient and a medication scheme of the reference cases. The application can improve the accuracy and safety of medication recommendations for the current patient, thereby better assisting doctors in making medication decisions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of medical data processing technology, and in particular to a method and system for recommending medication. Background Technology

[0002] With the deepening development of medical informatization, the widespread application of electronic medical records, medical records and various medical databases has led to a continuous expansion of the scale of patient medical data. How to effectively mine this data to assist clinical medication decisions has become a research hotspot.

[0003] Among the existing medication recommendation solutions, rule-based recommendation algorithms rely on clinical guidelines and expert experience to build rule bases. Although they have strong interpretability, the rule coverage is limited and it is difficult to adapt to the needs of individualized diagnosis and treatment. Machine learning-based recommendation algorithms (such as collaborative filtering and deep learning models) mine historical medication patterns through data-driven methods, but most of them only focus on the static features of a single visit, resulting in insufficient accuracy of recommendation results. Summary of the Invention

[0004] In view of this, the present application provides a medication recommendation method and system to solve at least one problem existing in the background art.

[0005] In a first aspect, embodiments of this application provide a method for recommending medication, the method comprising:

[0006] The patient's original medical data is preprocessed into a standardized time-series diagnosis and treatment sequence, which contains multiple medical records arranged in chronological order, with each medical record represented by multiple medical code vectors;

[0007] The time-series diagnosis and treatment sequence and medical professional knowledge base are input into the code-visit two-level hierarchical attention model for processing to obtain the code-level aggregated features and corresponding visit-level attention weights for each visit. The code-level aggregated features are then weighted and aggregated based on the visit-level attention weights to generate the global health representation of the current patient.

[0008] Based on at least one of the multiple medical characteristic information of the current patient, similar historical cases are retrieved from the case information database as reference cases. The case information database stores the medical characteristic information and medication plan of historical cases. The multiple medical characteristic information includes global health representation, code-level aggregated features of each visit and corresponding visit-level attention weights.

[0009] Based at least on the current patient's global health profile and the medication regimen of the reference case, generate and output a medication recommendation list for the current patient.

[0010] In some embodiments, the code-visit two-tiered hierarchical attention model includes:

[0011] The code-level attention layer is used to calculate the temporal correlation degree of each medical code between different medical records based on the occurrence frequency and time interval of each medical code determined based on the temporal diagnosis and treatment sequence, and to perform weighted aggregation of all medical code vectors in each medical record based on the temporal correlation degree to generate the code-level aggregation feature of each medical record.

[0012] The consultation-level attention layer is used to obtain the disease stage weight for each consultation based on whether the consultation is a turning point in the condition and the consultation time interval. It also generates the corresponding consultation-level attention weight based on at least the disease stage weight of the consultation and the feature matrix composed of the code-level aggregated features of all consultations.

[0013] In some embodiments, based on the temporal correlation degree, all medical code vectors in each medical visit record are weighted and aggregated to generate code-level aggregated features for each medical visit, including:

[0014] Based on the temporal correlation of each medical code and the temporal diagnosis and treatment sequence, an attention mechanism is used to determine the attention weight of each medical code in its respective medical record;

[0015] Based on the attention weight of each medical code, all medical code vectors in each medical visit record are weighted and aggregated to obtain the code-level aggregated features of each medical visit.

[0016] In some embodiments, corresponding visit-level attention weights are generated, at least based on the disease stage weight of the current visit and a feature matrix composed of code-level aggregated features of all visits, including:

[0017] Extract the core clinical event set corresponding to the primary diagnosis of the current visit from the medical professional knowledge base, and obtain the clinical event association weight of the current visit based on the matching degree between the clinical event set of the current visit and the core clinical event set.

[0018] Based on the disease stage weight, clinical event association weight, and feature matrix composed of code-level aggregated features of all visits, the attention mechanism is used to calculate the visit-level attention weight corresponding to the current visit.

[0019] In some embodiments, the multiple medical characteristic information further includes a master diagnosis code; the step of retrieving similar historical cases from a case information database as reference cases based on at least one of the multiple medical characteristic information of the current patient includes:

[0020] Based on the current patient's primary diagnosis code and the preset medical code hierarchy table, historical cases whose primary diagnosis codes belong to the same coding level as the current patient are selected from the case information database to form a first candidate case set;

[0021] For each historical case in the first candidate case set, based on the consultation-level attention weight and the knowledge graph in the medical professional knowledge base, the disease course of the current patient and the historical case are divided into multiple disease course stages;

[0022] Based on the code-level aggregation features of each visit and the visit-level attention weight corresponding to each visit, the stage aggregation features of the current patient and the historical cases in each disease stage are calculated respectively, and each disease stage includes at least one visit.

[0023] Based on the stage aggregation characteristics of the current patient and the historical cases in each stage of the disease course, historical cases similar to the current patient are selected from the first candidate case set as reference cases.

[0024] In some embodiments, based on the stage aggregation characteristics of the current patient and the historical cases at each stage of disease progression, historical cases similar to the current patient are selected from the first candidate case set as reference cases, including:

[0025] Obtain the similarity of the stage aggregation features between the current patient and the historical cases at each stage of the disease course, and obtain the stage similarity for each stage of the disease course;

[0026] Based on the stage similarity of each disease stage, calculate the global similarity between the current patient and the historical cases;

[0027] Based on the global similarity between the current patient and each historical case in the first candidate case set, the N historical cases with the highest similarity are selected from the first candidate case set to form a second candidate case set, where N is a positive integer;

[0028] The reference case is determined based on historical cases in the second candidate case set.

[0029] In some embodiments, the multiple medical feature information further includes a diagnosis and treatment scenario label; determining the reference case based on historical cases in the second candidate case set includes:

[0030] For each historical case in the second candidate case set, a preset adaptation coefficient corresponding to the matching degree is determined based on the matching degree between the current patient's treatment scenario label and the treatment scenario label of the historical case;

[0031] Based on the preset adaptation coefficient and the global similarity between the current patient and the historical cases, a similarity score between the current patient and the historical cases is calculated.

[0032] Select the M historical cases with the highest similarity scores from the second candidate case set as reference cases, where M is a positive integer less than N.

[0033] In some embodiments, generating and outputting a medication recommendation list for the current patient, based at least on the current patient's global health profile and the medication regimen of the reference case, includes:

[0034] The pre-trained medication recommendation scoring model generates recommendation scores for each candidate drug in the candidate drug set based on the current patient's global health characteristics, the mean value of code temporal correlation, the mean value of disease stage weights, and the characteristics of each drug in the drug feature library. The medication recommendation list is then generated by sorting the candidate drugs from high to low according to their recommendation scores.

[0035] The mean temporal correlation degree of the code is determined based on the temporal correlation degree of each medical code of the current patient among different medical records, the mean weight of the disease stage is determined based on the weight of the disease stage of each visit of the current patient, and the candidate drug set is constructed based on the medication plan of the reference case.

[0036] In some embodiments, the training process of the medication recommendation scoring model includes:

[0037] Acquire training data, which includes feature data, retrieval data and label data of sample patients. The feature data includes the global health representation of sample patients, the temporal correlation of each medical code between different medical records, and the weight of the disease stage of each medical visit. The retrieval data includes the stage similarity of sample patients and historical cases at each disease stage, similar case scores and candidate drug sets. The label data includes the actual medication regimen of sample patients.

[0038] Obtain auxiliary data that includes drug characteristic data and drug interaction risk data;

[0039] The concatenated vector constructed based on the feature data of the sample patients and the feature data of the drugs is input into the medication recommendation scoring model to generate the initial recommendation score for each candidate drug in the candidate drug set;

[0040] Based on the characteristic data, retrieval data, tag data, initial recommendation score, and auxiliary data of the sample patients, the multi-constraint loss function of the medication recommendation scoring model is calculated;

[0041] The parameters of the medication recommendation scoring model are updated by minimizing the value of the multi-constraint loss function.

[0042] In some embodiments, calculating the multi-constraint loss function of the medication recommendation scoring model based on the feature data, retrieval data, tag data, the initial recommendation score, and the auxiliary data of the sample patients includes:

[0043] Based on the first loss function, the temporal constraint loss between the predicted medication plan and the actual medication plan is calculated by maximizing mutual information, according to the temporal correlation degree of each medical code, the weight of the disease stage of each visit, the global health representation of the sample patients, and the actual medication plan.

[0044] Based on the second loss function, according to the stage similarity, the similar case score, and the initial recommendation score of each candidate drug, the retrieval constraint loss between the initial recommendation score of the candidate drug and the historical scores of similar cases with similar case scores greater than the threshold for the candidate drug at the same disease stage is calculated.

[0045] Based on the third loss function, and according to the drug interaction risk data, the recommended score of the drug combination in the candidate drug set that exceeds the preset level range is constrained to be lower than the safety threshold, thus obtaining the safety boundary loss.

[0046] The time-series constraint loss, retrieval constraint loss, and safety boundary loss are fused to obtain the value of the multi-constraint loss function.

[0047] Secondly, embodiments of this application provide a medication recommendation system, the system comprising:

[0048] The preprocessing module is used to preprocess the current patient's raw medical data into a standardized time-series diagnosis and treatment sequence, which contains multiple medical records arranged in chronological order, with each medical record represented by multiple medical code vectors;

[0049] The representation module is used to input the time-series diagnosis and treatment sequence and the medical professional knowledge base into the code-visit two-level hierarchical attention model for processing, to obtain the code-level aggregated features and corresponding visit-level attention weights for each visit, and to perform weighted aggregation of the code-level aggregated features based on the visit-level attention weights to generate the global health representation of the current patient.

[0050] The retrieval module is used to retrieve similar historical cases as reference cases from the case information database based on at least one of the multiple medical feature information of the current patient. The case information database stores the medical feature information and medication plans of historical cases. The multiple medical feature information includes global health representation, code-level aggregation features of each visit and corresponding visit-level attention weights.

[0051] The recommendation module is used to generate and output a medication recommendation list for the current patient, based at least on the current patient's global health profile and the medication regimen of the reference case.

[0052] Thirdly, embodiments of this application provide an electronic device including a processor, the processor being configured to invoke instructions to cause the electronic device to execute the medication recommendation method as described in any embodiment of the first aspect.

[0053] Fourthly, embodiments of this application provide a storage medium storing an executable program thereon, which, when executed by a processor, implements the medication recommendation method as described in any embodiment of the first aspect.

[0054] This application provides a medication recommendation method and system. It preprocesses the patient's raw medical data into a standardized temporal treatment sequence and combines it with a medical professional knowledge base using a code-visit hierarchical attention model. This obtains code-level aggregated features and corresponding visit-level attention weights for each visit. This allows for the full capture of the temporal correlation and importance of the patient's visit records in the disease development process at both the code and visit levels, resulting in a more accurate global health representation that reflects the patient's individual health status. Furthermore, based on at least one medical feature from the patient's global health representation, code-level aggregated features, and visit-level attention weights, the system can retrieve historical cases with similar disease trajectories from a case database. This is more accurate than single-feature matching or simple rule matching, providing a more reliable clinical basis for medication recommendations. Moreover, since the final medication recommendation list is generated by combining the patient's global health representation with medication plans from similar reference cases, this recommendation method, which integrates individual patient clinical characteristics and real clinical practice, improves the accuracy and safety of medication recommendations for the current patient, thus better assisting doctors in making medication decisions. Attached Figure Description

[0055] Figure 1 One of the schematic flowcharts of a medication recommendation method provided in an embodiment of this application;

[0056] Figure 2 A schematic diagram illustrating the generation process of code-level aggregation features provided in an embodiment of this application;

[0057] Figure 3 A schematic diagram illustrating the process of generating patient-level attention weights according to an embodiment of this application;

[0058] Figure 4 This is a schematic diagram of the process for generating a patient's global health characterization according to an embodiment of this application;

[0059] Figure 5 A second schematic flowchart illustrating a medication recommendation method provided in an embodiment of this application;

[0060] Figure 6 for Figure 5 The flowchart of step S240 is shown below;

[0061] Figure 7 for Figure 6 The flowchart of step S244 is shown below;

[0062] Figure 8 The third schematic flowchart of a medication recommendation method provided in an embodiment of this application;

[0063] Figure 9 A flowchart illustrating the training method of a medication recommendation scoring model provided in an embodiment of this application;

[0064] Figure 10 for Figure 9 The flowchart of step S440 is shown below;

[0065] Figure 11 A schematic diagram of a hierarchical, progressive similarity retrieval process provided in an embodiment of this application;

[0066] Figure 12 This is a schematic diagram of the structure of the medication recommendation system provided in the embodiments of this application. Detailed Implementation

[0067] To make the technical solution and beneficial effects of this application more apparent and understandable, a detailed description is provided below by listing specific embodiments. The accompanying drawings are not necessarily drawn to scale, and local features may be enlarged or reduced to more clearly show the details of the local features; unless otherwise defined, the technical and scientific terms used herein have the same meanings as those in the technical field to which this application pertains.

[0068] The embodiments in this application are not exhaustive, but merely illustrative of some embodiments, and are not intended to limit the scope of protection of this disclosure. Unless otherwise specified, each step in a particular embodiment can be implemented as an independent embodiment, and the steps can be arbitrarily combined. For example, a solution after removing some steps in a particular embodiment can also be implemented as an independent embodiment, and the order of the steps in a particular embodiment can be arbitrarily interchanged. Furthermore, the optional implementation methods in a particular embodiment can be arbitrarily combined; moreover, the embodiments can be arbitrarily combined, for example, some or all steps of different embodiments can be arbitrarily combined, and a particular embodiment can be arbitrarily combined with the optional implementation methods of other embodiments.

[0069] In each embodiment of this application, unless otherwise specified or in case of logical conflict, the terminology and / or descriptions of the embodiments are consistent and can be referenced by each other. Technical features in different embodiments can be combined to form new embodiments based on their inherent logical relationships.

[0070] In the description of the embodiments of this application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, features defined with "first" and "second" may explicitly or implicitly include one or more of the stated features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly specified.

[0071] Among the existing medication recommendation solutions, rule-based recommendation algorithms rely on clinical guidelines and expert experience to build rule bases. Although they are highly interpretable, they have limitations in rule coverage and cannot adapt to individualized treatment needs. Machine learning-based recommendation algorithms (such as collaborative filtering and deep learning models) learn medication patterns through data-driven learning, but they often ignore the temporal correlation of a patient's complete medical history and have poor adaptability to changes in disease stages. In addition, recommendation algorithms based on similar patient retrieval make recommendations by matching medication regimens of similar historical cases, but their core patient representation construction and similarity retrieval mechanisms have significant deficiencies.

[0072] This application provides a medication recommendation method that can be applied to a medication recommendation system. The medication recommendation system can be deployed on a cloud server or a local medical data center, such as a private server or server cluster of a hospital information system.

[0073] Figure 1 This is a schematic flowchart of a medication recommendation method provided in an embodiment of this application, as shown below. Figure 1 As shown, the medication recommendation method includes steps S110 to S140.

[0074] S110: Preprocess the current patient's raw medical data into a standardized time-series diagnosis and treatment sequence. The time-series diagnosis and treatment sequence contains multiple medical records arranged in chronological order, with each medical record represented by multiple medical code vectors.

[0075] Raw medical data may include the patient’s basic information, medical codes corresponding to each visit (e.g., diagnosis codes, surgery codes, medication codes, examination indicators, etc.), and timestamps of each visit, among other key information.

[0076] In step S110, the original medical data of the current patient can be processed sequentially by structured data standardization, time-series data organization, and outlier and missing value processing to obtain a standardized time-series diagnosis and treatment sequence.

[0077] Structured data standardization processing may include mapping various codes in the original medical data to standard codes to eliminate coding differences between different data sources. For example, diagnostic codes are uniformly mapped to ICD-10 standard codes (i.e., standardized codes for diseases and health problems as defined in the International Classification of Diseases, 10th Revision), surgical codes are mapped to ICD-9-CM standard codes (standardized codes for disease diagnosis and surgical procedures as defined in the International Classification of Diseases, 9th Revision, Clinical Revision), and medication codes are mapped to ATC standard codes (i.e., standardized classification codes for drugs as defined in the Anatomical Therapeutic Chemical Classification System); and unit normalization is performed on examination indicators to ensure data format consistency.

[0078] Time-series data processing may include: sorting the patient's past medical records in ascending order based on the timestamp of each visit, constructing a complete time-series medical treatment sequence. Each element in this sequence represents a set of medical codes for one visit, and all elements are arranged chronologically according to the visit time, forming an ordered sequence of medical treatment data.

[0079] The medical codes can be converted into fixed-dimensional vectors through one-hot encoding or embedding layers, which facilitates subsequent model calculations.

[0080] Sorting patients in ascending order by their appointment timestamps, constructing a time-series diagnosis and treatment sequence. ,in Let T represent the vector of n medical codes for the t-th visit, where T is the total number of visits.

[0081] Outlier and missing value handling may include: using the 3σ criterion to screen and filter erroneous diagnostic data that significantly exceeds the physiological range; for missing values ​​in the data, imputation is performed using the mean of the same disease stage to ensure data integrity. The final output is a standardized time-series diagnostic sequence, providing high-quality data input for subsequent feature extraction.

[0082] S120: Input the time-series diagnosis and treatment sequence and medical professional knowledge base into the code-visit two-level hierarchical attention model for processing, obtain the code-level aggregated features and corresponding visit-level attention weights for each visit, and perform weighted aggregation of the code-level aggregated features based on the visit-level attention weights to generate the global health representation of the current patient.

[0083] The medical knowledge base is a structured database containing professional knowledge in the medical field. For example, it may include at least one of the following: clinical knowledge graphs, disease-symptom-drug relationships, and rules for determining disease turning points.

[0084] The code-patient visit dual-level hierarchical attention model is a deep learning model capable of capturing temporal dependencies and importance relationships simultaneously at the medical code level and the patient visit record level. Through a hierarchical attention mechanism, this model can gain a more refined understanding of the patient's treatment process, generating more clinically meaningful feature representations. The code-patient visit dual-level hierarchical attention model can be constructed based on recurrent neural networks (RNNs) and / or long short-term memory networks (LSTMs).

[0085] In step S120, the temporal diagnosis and treatment sequence and the medical professional knowledge base can be input into the code-visit two-level hierarchical attention model to obtain the code-level aggregated features of each visit based on code-level temporal attention processing and the visit-level attention weight of each visit based on visit-level temporal attention processing.

[0086] The code-level aggregated features for each medical visit are obtained by weighted aggregation of all medical code vectors from that visit. These code-level aggregated features reflect the core diagnostic and treatment information for that visit, such as the primary diagnosis, key treatment measures, and medication details.

[0087] The visit-level attention weight can be used to characterize the importance of that visit within the entire temporal treatment sequence. This visit-level attention weight can reflect the degree of impact of that visit on the patient's overall health status or disease progression; for example, visits at disease turning points or key treatments can be assigned higher weights.

[0088] The code-visit two-tiered hierarchical attention model can be trained using self-supervised learning. In some examples, the code-visit two-tiered hierarchical attention model can be used to weight the medical code vector for each visit in a time-series medical treatment sequence using an attention mechanism, generating code-level aggregated features. Then, between different visits, based on the code-level aggregated features of each visit and combined with a medical knowledge base, the visit-level attention weight for each visit is calculated using an attention mechanism. In this way, by using the code-level aggregated features of each visit and incorporating a medical knowledge base, the calculated visit-level attention weights can more accurately reflect the relative importance of each visit in the disease development process.

[0089] In this embodiment, a code-visit dual-level hierarchical attention model is used to not only capture the contribution of code features within the medical record, but also to identify key medical visit nodes that play a crucial role in disease development in the temporal dimension. Furthermore, this code-visit dual-level attention mechanism performs step-by-step computation, first focusing on key information from a single medical visit and then integrating the connections between multiple visits. This avoids complex global calculations, helps reduce computational load, and improves processing efficiency.

[0090] S130: Based on at least one of the current patient's multiple medical characteristic information, retrieve similar historical cases from the case information database as reference cases. The case information database stores the medical characteristic information and medication plans of historical cases. The multiple medical characteristic information includes global health representation, code-level aggregated features of each visit, and corresponding visit-level attention weights.

[0091] Medication regimens may include medication recommendations from doctors regarding the type, dosage, usage, and / or duration of treatment for patients with a history of illness. In some examples, a medication regimen can be transformed into a feature vector in a high-dimensional space.

[0092] In step S130, the current patient's global health profile can be selected from various medical feature information. Based on the global health profile, historical cases with a perfect match or the highest similarity to this feature can be found in the case information database. Alternatively, multiple medical feature information of the current patient (e.g., global health profile and code-level aggregated features of the most recent visit) can be concatenated to form a combined feature vector. The Euclidean distance or cosine similarity between this combined feature vector and the combined feature vectors of all historical cases in the case information database can be calculated, and the top K cases with the highest similarity can be selected as reference cases.

[0093] S140: Generate and output a medication recommendation list for the current patient, based at least on the current patient's global health profile and medication regimens of reference cases.

[0094] The medication recommendation list may include the recommended drugs and their corresponding medication guidance information, which may include key information such as dosage, administration method, timing of administration, and safety tips.

[0095] In step S140, standardized medication records can be extracted from the medication regimen of the reference case. Medication codes are screened based on the frequency of use of each drug in the medication records to form a candidate drug set. Then, the candidate drug set is fused with the current patient's global health profile, and a medical knowledge base is called to perform safety verification on each candidate drug to exclude contraindicated drugs that are not suitable for the current patient. A medication recommendation list that is suitable for the patient's individual condition is generated and output.

[0096] In the medication recommendation method provided in the above embodiments, the original medical data of the current patient is preprocessed into a standardized temporal diagnosis and treatment sequence, and then processed using a code-visit dual-level hierarchical attention model in conjunction with a medical professional knowledge base. This obtains the code-level aggregated features and corresponding visit-level attention weights for each visit. This allows for the full capture of the temporal correlation and importance of the current patient's visit records in the disease development process at both the code and visit levels, thereby enabling the generated global health representation to more accurately reflect the current patient's individual health status. Furthermore, based on at least one of the current patient's global health representation, code-level aggregated features, and visit-level attention weights, the system can retrieve historical cases with similar disease development trajectories from the case information database. This is more accurate than using single feature matching or simple rule matching, thus providing a more reliable clinical basis for medication recommendations. In addition, since the final medication recommendation list is generated by comprehensively considering the current patient's global health representation and medication plans from similar reference cases, this recommendation method, which combines individual patient clinical characteristics and real clinical practice, can improve the accuracy and safety of medication recommendations for the current patient.

[0097] In some embodiments, the code-visit two-tiered hierarchical attention model includes:

[0098] The code-level attention layer is used to calculate the temporal correlation degree of each medical code between different medical records based on the occurrence frequency and time interval of each medical code determined based on the temporal diagnosis and treatment sequence, and to perform weighted aggregation of all medical code vectors in each medical record based on the temporal correlation degree to generate the code-level aggregation feature of each medical record.

[0099] The consultation-level attention layer is used to obtain the disease stage weight for each consultation based on whether the consultation is a turning point in the condition and the consultation time interval. It also generates the corresponding consultation-level attention weight based on at least the disease stage weight of the consultation and the feature matrix composed of the code-level aggregated features of all consultations.

[0100] The temporal correlation of a medical code can be used as the basis for calculating the attention weight of that medical code, so as to reflect the importance of the code.

[0101] The code-level attention layer can calculate the temporal correlation degree based on the frequency of each medical code in all visits of the current patient and the time decay effect of the medical code from the t-th visit to the most recent visit through a non-linear mapping function.

[0102] In some examples, the temporal correlation of the i-th medical code in the t-th visit. The calculation formula can be expressed as:

[0103] ;

[0104] in, Let be the frequency of visits for the i-th medical code. Let α be the time interval between the visit associated with the most recent occurrence of the i-th medical code and the visit associated with the t-th occurrence, and let α and β be the training and fitting parameters, for example... , .

[0105] A disease inflection point represents a critical point in time when a patient's disease state undergoes a significant change, such as the first diagnosis or a visit with a surgical record. Determining whether a particular visit constitutes a disease inflection point can be done using a clinical knowledge graph within a medical professional knowledge base or expert experience rules. For example, by analyzing the diagnostic codes, treatment codes, and examination result codes from the current visit and matching them with rules in the knowledge base, it can be determined whether the current visit is a disease inflection point. The visit interval is the time between the current visit and the most recent visit; recent visits and disease inflection points are given higher weight.

[0106] The weight of the disease stage at a particular visit is a quantitative representation of the importance of that visit within the patient's overall disease course.

[0107] For example, a piecewise function can be designed to obtain the disease stage weight of the current visit based on whether the current visit is a turning point in the disease and the time interval between visits. Then, based at least on the disease stage weight of the current visit and the feature matrix composed of the code-level aggregated features of all visits, the corresponding visit-level attention weight can be generated to evaluate the importance of the current visit in the patient's entire disease course.

[0108] In some examples, the weight of the disease stage at the t-th visit The calculation formula can be expressed as:

[0109] ;

[0110] in, For example, the enhancement coefficient of the inflection point. , For example, the timing decay coefficient. tT represents the time interval between the t-th visit and the most recent visit, and T represents the total number of visits.

[0111] In this embodiment, a code-level attention layer calculates the temporal correlation degree of each medical code across different medical records. Using this temporal correlation degree, all medical code vectors in each medical record are weighted and aggregated to generate a code-level aggregated feature that accurately represents the core information of that medical visit. Since the code-level aggregated feature not only includes static information about the medical visit but also incorporates the dynamic evolution of the code over time, the visit-level attention layer further considers key clinical information for each visit, such as whether it is a turning point in the patient's condition and the time interval between visits. Combining this with a feature matrix composed of the code-level aggregated features of all visits, a visit-level attention weight is generated for each visit through an attention mechanism. This quantifies the importance of each visit in the patient's overall disease course, enabling the model to identify key visits that significantly impact the patient's health. This two-tiered attention mechanism makes the subsequently generated global health representation of the patient more comprehensive and accurate, providing reliable reference data for medication recommendations and better assisting doctors in making medication decisions.

[0112] In some embodiments, such as Figure 2 As shown, based on temporal correlation, all medical code vectors in each medical visit record are weighted and aggregated to generate code-level aggregated features for each visit, which may include:

[0113] S121: Based on the temporal correlation of each medical code and the temporal diagnosis and treatment sequence, an attention mechanism is used to determine the attention weight of each medical code in its respective medical record;

[0114] S122: Based on the attention weight of each medical code, the vectors of all medical codes in each medical visit record are weighted and aggregated to obtain the code-level aggregated features for each medical visit.

[0115] For example, the attention weight of the i-th medical code in the t-th visit record can be calculated using the following code-level attention weight calculation formula. :

[0116] ;

[0117] in, , For querying the key matrix, Embedding dimensions into medical code, For the attention head dimension, Scaling factor Let be the temporal correlation degree of the i-th medical code in the t-th visit. Let be the temporal correlation degree of the j-th medical code in the t-th visit. This represents the i-th medical code vector in the t-th medical visit record. Let T represent the vector of n medical codes for the t-th visit, where T is the total number of visits.

[0118] For example, the code-level aggregation feature of the t-th visit The following formula can be used to calculate it:

[0119] ;

[0120] in, For value matrices, Embedding dimensions into medical code, For the attention head dimension, For the code-level aggregated features of the t-th visit, This represents the i-th medical code vector in the t-th medical visit record. Let be the attention weight of the i-th medical code in the t-th visit record, and n be the total number of medical codes in the t-th visit.

[0121] In this embodiment, based on the temporal correlation of each medical code and the temporal diagnosis and treatment sequence, an attention mechanism is used to calculate the attention weight of each medical code. The higher the attention weight, the greater the reference value of the medical code for the current diagnosis and treatment. This ensures that medical codes with higher temporal importance in the patient's course of illness can obtain greater weight. Then, based on the attention weight, all medical code features in a single visit are weighted and aggregated to obtain the code-level aggregated features of the visit, which can more accurately reflect the clinical role of the visit.

[0122] In some embodiments, such as Figure 3 As shown, based at least on the disease stage weight of the current visit and the feature matrix composed of code-level aggregated features of all visits, corresponding visit-level attention weights are generated, which may include:

[0123] S123: Extract the core clinical event set corresponding to the primary diagnosis of the current visit from the medical professional knowledge base, and obtain the clinical event association weight of the current visit based on the matching degree between the clinical event set of the current visit and the core clinical event set.

[0124] S124: Based on the disease stage weight, clinical event association weight, and feature matrix composed of code-level aggregated features of all visits, the attention mechanism is used to calculate the visit-level attention weight corresponding to the current visit.

[0125] Here, the primary diagnosis (represented by the primary diagnosis code) for the current medical visit is the most important disease diagnosis at that visit. For this primary diagnosis, its core clinical event set can be extracted from the knowledge graph in the medical professional knowledge base. The core clinical event set includes core clinical events related to the primary diagnosis, such as treatment behaviors, symptoms, and examination results. For example, for the primary diagnosis of "diabetes," the core clinical event set may include blood glucose monitoring, insulin treatment, etc. These events represent the treatment pathway or key characteristics of the disease.

[0126] The clinical event set for a single medical visit comprises all the actual medical events represented by the medical codes included in the visit record. For example, diagnostic codes, surgical codes, medication codes, and examination codes in this visit record can all constitute the clinical event set.

[0127] In step S123, the matching degree between the clinical event set of the current visit and the core clinical event set of the primary diagnosis of the current visit can be obtained by calculating the ratio of their intersection and union, or by using cosine similarity, etc. The higher the matching degree, the more the clinical manifestations of the current visit match the event characteristics of the primary diagnosis. After obtaining the matching degree between the clinical event set of the current visit and the core clinical event set, the association weight of the clinical events of the current visit can be calculated. The larger the association weight of the clinical events, the stronger the correlation between the clinical events of the current visit and the primary diagnosis of the current visit, and the higher its reference value.

[0128] In step S124, an attention mechanism is employed to combine the weights of the disease stage and clinical event associations of the current medical visit with code-level aggregation features to calculate the visit-level attention weight, which represents the relative importance of this visit in the entire temporal medical sequence. For example, the attention mechanism can be a self-attention mechanism.

[0129] In some examples, the clinical event association weight of the t-th visit The following formula can be used to calculate it:

[0130] ;

[0131] in, This represents the set of core clinical events that indicate the primary diagnosis of the current medical visit. For the set of clinical events during the t-th visit, This is an indicator function, where m is the number of core events and k is an index variable used to index the core events.

[0132] In some examples, the attention weight for the t-th visit corresponds to the visit-level attention weight. The following formula can be used to calculate it:

[0133] ;

[0134] in, , For patient-level queries and key matrices, The weight of the disease stage at the t-th visit is given. Let be the clinical event association weight for the t-th visit. d' represents the attention head dimension, and d' represents the patient-level attention dimension. This represents the code-level aggregated feature of the t-th visit. This represents the code aggregation feature matrix, where T is the total number of medical visits.

[0135] In some examples, the patient's global health characterization H can be calculated using the following formula:

[0136] ;

[0137] in, For value matrices, As a comprehensive indicator of the patient's health, This represents the attention weight for the t-th visit. Let T represent the code-level aggregated feature of the t-th visit, where T is the total number of visits.

[0138] like Figure 4 As shown, the patient's time-series diagnosis and treatment sequence The frequency of occurrence of each medical code determined based on the time-series diagnosis sequence can be assessed through a code-level attention layer. With time interval Calculate the temporal correlation sequence of the i-th medical code in different medical visits. Then, combining the query with the key matrix , After processing, medical code-level attention weights can be obtained. By combining medical code-level attention weights, the medical code vectors in each patient's medical record are weighted and aggregated to obtain code-level aggregated features. Then, the code-level aggregated features are combined with disease stage weights (e.g., based on disease inflection points). Determined), clinical event association weights (e.g., based on core event sets) (Confirmed), calculate the attention weights for the consultation level. Then, the code-level aggregated features are weighted and aggregated based on the patient's consultation-level attention weights to generate the patient's global health representation H.

[0139] In some examples, the current patient's various medical characteristics may include: code-level aggregated features of each visit, visit-level attention weights, temporal correlation of medical codes, disease stage weights of each visit, clinical event correlation weights and other temporal parameters, as well as the current patient's global health representation, which can provide key features for subsequent similarity retrieval and recommendation optimization.

[0140] In this embodiment, a medical expertise base is introduced to accurately determine the turning points of the illness and extract the core clinical event set of the primary diagnosis. Combined with the time interval between visits and a feature matrix composed of code-level aggregated features of all visits, the generation process of visit-level attention weights is no longer a simple combination of features, but incorporates rich medical prior knowledge and clinical logic. This effectively improves the accuracy and medical interpretability of visit-level attention weights, ensuring that the model can effectively identify and assign higher weights to visit records that have a key impact on the patient's health status, providing a reliable basis for the subsequent generation of global health representations.

[0141] In some embodiments, a method for recommending medication is provided, such as... Figure 5 As shown, the method may include:

[0142] S210: Based on the current patient's primary diagnosis code and the preset medical coding hierarchy table, select historical cases from the case information database whose primary diagnosis codes belong to the same coding level as the current patient to form the first candidate case set;

[0143] S220: For each historical case in the first candidate case set, based on the consultation-level attention weight and the knowledge graph in the medical professional knowledge base, the disease course of the current patient and the historical cases are divided into multiple disease course stages.

[0144] S230: Based on the code-level aggregation features of each visit and the visit-level attention weight corresponding to each visit, calculate the stage aggregation features of the current patient and historical cases in each disease stage, with each disease stage including at least one visit.

[0145] S240: Based on the stage aggregation characteristics of the current patient and historical cases in each stage of the disease course, select historical cases similar to the current patient from the first candidate case set as reference cases.

[0146] In some examples, steps S210 to S240 are implementations Figure 1In step S130, one optional implementation is to retrieve similar historical cases from the case information database as reference cases based on at least one of the multiple medical characteristic information of the current patient, wherein the multiple medical characteristic information includes the master diagnosis code.

[0147] The primary diagnostic code can be a diagnostic code used in medical records to identify a patient's main disease or health problem. A preset medical coding hierarchy table is used to stratify medical codes according to a coarse-to-fine, higher-level to lower-level relationship. For example, the preset medical coding hierarchy table is an ICD coding hierarchy table.

[0148] In step S210, based on the current patient's primary diagnosis code, the system can trace upwards to a specific level (e.g., disease category or subcategory) in a preset medical code hierarchy table, and then filter out historical cases in the case information database whose primary diagnosis codes also belong to that level. This hierarchical matching of the current patient's primary diagnosis code for preliminary case screening not only ensures that the initially selected historical cases have a high correlation with the current patient in terms of core disease type, but also significantly narrows the scope of subsequent refined comparisons, improving retrieval efficiency.

[0149] For example, based on the ICD coding hierarchy table, the primary diagnosis code in the case information database can be compared with the current patient's primary diagnosis code. Cases belonging to the same subcategory were used to obtain the first candidate case set. , For the global health characteristics of the k-th historical case, This represents the treatment scenario label for the k-th historical case. This represents the medication regimen for the k-th historical case. This represents the primary diagnosis code for the k-th historical case.

[0150] In step S220, the key medical visit nodes (e.g., diagnosis establishment, treatment plan change, disease deterioration or improvement) in the course of each historical case in the current patient and the first candidate case set can be identified by using the medical visit level attention weight. Combined with the disease course stage nodes defined in the knowledge graph, the medical visit records between the key medical visit nodes are divided into different disease course stages.

[0151] For example, dividing the disease course of both the current patient and the preliminary candidate cases into four stages—"initial diagnosis stage, treatment stage, stable stage, and adjustment stage"—can yield the disease course stage division results for the current patient. Disease progression stage classification results compared with historical case k in the first candidate case set It is understood that in practical applications, the number of disease stages can be set according to actual needs. For example, it can be divided into two, three, or more than four stages. This application does not specifically limit this.

[0152] In step S230, for each stage of the disease process, the code-level aggregated features of all visits by the current patient and historical cases within that stage of the disease process can be weighted and averaged according to the visit-level attention weights corresponding to each visit, so as to obtain the stage aggregated features of the current patient and historical cases within that stage of the disease process.

[0153] In step S240, the similarity between the current patient and each historical case across all corresponding disease stages (e.g., cosine similarity, Euclidean distance) can be calculated. These stage similarities are then combined to obtain a global similarity, and reference cases are sorted and selected based on this global similarity. Alternatively, a similarity matching model based on deep learning can be used, taking the disease stage aggregate features of the current patient and historical cases as input, outputting a similarity score, and selecting the most similar historical case as a reference case based on this similarity score.

[0154] In this embodiment, by introducing hierarchical screening of the master diagnostic code, dividing the disease course into stages, and calculating the stage aggregation features, and by comparing the stage aggregation features of the current patient and historical cases at each stage of the disease course, it is possible to screen out historical cases that are most similar to the current patient's disease course evolution pattern as reference cases. This similarity comparison based on disease course stages, compared with simple global feature matching, makes the final selected reference cases not only consistent with the current patient in terms of disease type, but also highly similar in terms of disease progression pattern, which can provide more accurate data basis for subsequent medication recommendations.

[0155] In some embodiments, such as Figure 6 As shown, in step S240 above, based on the stage aggregation characteristics of the current patient and historical cases at each stage of the disease course, selecting historical cases similar to the current patient as reference cases from the first candidate case set may include:

[0156] S241: Obtain the similarity of the stage aggregation features between the current patient and historical cases at each stage of the disease course, and obtain the stage similarity for each stage of the disease course.

[0157] S242: Calculate the global similarity between the current patient and historical cases based on the stage similarity of each disease stage;

[0158] S243: Based on the global similarity between the current patient and each historical case in the first candidate case set, select the N historical cases with the highest similarity from the first candidate case set to form the second candidate case set, where N is a positive integer;

[0159] S244: Based on historical cases in the second candidate case set, determine reference cases.

[0160] In step S241, the stage similarity of each disease stage can be calculated using the following method:

[0161] ;

[0162] in, The similarity between the current patient and historical case k at the p-th stage of the disease. , , respectively, are the stage aggregate features of the current patient and historical case k at the p-th stage of the disease course (weighted average of the code-level aggregate features of visits within the stage), and T is the total number of visits.

[0163] In step S242, the global similarity between the current patient and historical cases is calculated using the following method:

[0164] ;

[0165] in, The global similarity between the current patient and historical case k. The similarity between the current patient and historical case k at the p-th stage of the disease course; Let p be the weight of the p-th stage of the disease course. The weight can be set according to the importance, duration, or clinical significance of the stage of the disease course. For example... .

[0166] In step S243, the global similarity of all historical cases in the first candidate case set with the current patient can be sorted in descending order, and then the top N historical cases can be selected. Alternatively, a similarity threshold can be set to filter out all historical cases with a global similarity higher than the threshold to form a second candidate case set. If the number is less than N, it can be supplemented to N; if the number exceeds N, the N cases with the highest similarity can be selected. The value of N can be, for example, [20, 30].

[0167] In step S244, other medical feature information (such as treatment scenario tags) can be combined to perform secondary screening or weighting of cases in the second candidate case set to determine the final reference cases; or if the difference between the maximum similarity and minimum similarity in the second candidate case set is lower than a preset value, the entire second candidate case set can be directly used as the reference case set.

[0168] In this embodiment, by calculating the stage similarity of each disease stage and further aggregating it into a global similarity, compared to the limitations of relying on only a single feature or coarse matching, the similarity between the current patient and historical cases can be assessed more refined, making the retrieval of similar cases more comprehensive and accurate. This ensures that the selected reference cases not only match the primary diagnosis, but also highly match the current patient in the entire disease development trajectory, thereby providing a more reliable basis for subsequent medication recommendations and helping to improve the accuracy of medication recommendations.

[0169] In some embodiments, the multiple medical feature information further includes treatment scenario tags. Treatment scenario tags are used to identify the scenario of a patient's most recent medical visit. For example, treatment scenario tags may include preset categories such as "emergency", "outpatient", and "inpatient". Treatment scenario tags can be manually selected by medical professionals when entering medical records, or obtained by the system automatically extracting and classifying structured fields (such as visit type and department information) in electronic medical records.

[0170] like Figure 7 As shown, in step S244 above, determining reference cases based on historical cases in the second candidate case set may include:

[0171] S2441: For each historical case in the second candidate case set, determine the preset adaptation coefficient corresponding to the matching degree based on the matching degree between the current patient's treatment scenario label and the treatment scenario label of the historical case;

[0172] S2442: Calculate the similarity score between the current patient and the historical cases based on the preset adaptation coefficient and the global similarity between the current patient and the historical cases;

[0173] S2443: Select the M historical cases with the highest similar case scores from the second candidate case set as reference cases, where M is a positive integer less than N.

[0174] The matching score is used to evaluate the similarity between the treatment scenario labels of the current patient and historical cases. For example, when the treatment scenario labels of the current patient and historical cases are completely identical, the matching score can be set to 1.0; when the labels are not completely identical but belong to the same broad category (e.g., both belong to outpatient scenarios), the matching score can be set to 0.5; when the labels are completely unrelated, the matching score can be set to 0. The calculation method of the matching score can be flexibly designed according to the type and hierarchical relationship of the labels, such as using Boolean matching or ontology-based semantic similarity calculation.

[0175] Preset adaptation coefficients can be used to weight and correct the global similarity of historical cases, thereby enhancing the influence of historical cases that are highly matched with the current patient treatment scenario, while reducing the impact of cases that do not match the scenario.

[0176] In step S2441, the preset adaptation coefficient corresponding to the matching degree can be determined according to the pre-established mapping relationship between the matching degree and the preset adaptation coefficient. For example, when the matching degree is 1, the preset adaptation coefficient can be set to a value greater than or equal to 1 (e.g., set to 1); when the matching degree is greater than 0.5 and less than 1, the preset adaptation coefficient can be set to 0.6; when the matching degree is less than or equal to 0.5, the preset adaptation coefficient can be set to 0.3. It is understood that the value of the preset adaptation coefficient can be optimized based on clinical experience or through machine learning methods so that the coefficient can effectively reflect the impact of the scene matching degree on the case relevance.

[0177] In step S2442, the global similarity can be multiplied by the preset fitting coefficient to calculate the similarity case score.

[0178] For example, the formula for calculating similar case scores is as follows:

[0179] ;

[0180] in, Score the similarity between the current patient and historical case k in the second candidate case set. The global similarity between the current patient and historical case k; The scenario fit coefficient is determined based on the matching degree between the current patient and historical cases k in the second candidate case set.

[0181] In step S2443, all historical cases in the second candidate case set can be sorted in descending order according to the similarity case score, and then the top M cases can be selected. For example, the 5 to 10 cases with the highest similarity case scores can be selected as reference cases to form the final similar case set. And extract the medication regimens from these cases to form a candidate drug set. ,in, This indicates the medication regimen for historical case k.

[0182] Considering the specific treatment scenarios patients encounter, such as emergency rooms, outpatient clinics, or inpatient wards, the characteristics of patients' conditions, treatment procedures, and medication strategies may vary significantly. This means that while selected reference cases may be similar in overall medical characteristics, they may not be entirely applicable in specific treatment scenarios. Therefore, to further improve the accuracy and effectiveness of the final medication recommendation, this embodiment introduces treatment scenario tags and determines a preset fit coefficient based on the matching degree between the current patient's treatment scenario tags and the treatment scenario tags of the historical cases. This allows for a more refined assessment of the correlation between historical cases and the current patient, ensuring that the final selected reference cases are not only highly similar in medical characteristics but also highly applicable in specific treatment scenarios. This effectively improves the accuracy and targeting of medication recommendations, making the recommendations more in line with the actual treatment needs of patients.

[0183] In some embodiments, a medication recommendation method is provided, such as... Figure 8 As shown, the user recommendation method may include the following steps:

[0184] S310: Based on the patient's current global health profile, the mean of code temporal correlation, the mean of disease stage weights, and the characteristics of each drug in the drug feature library, a pre-trained medication recommendation scoring model generates recommendation scores for each candidate drug in the candidate drug set.

[0185] S320: Generate a drug recommendation list by sorting each candidate drug from highest to lowest recommendation score.

[0186] Among them, the mean code temporal correlation degree is determined based on the temporal correlation degree between each medical code of the current patient in different medical records, the mean disease stage weight is determined based on the disease stage weight of each visit of the current patient, and the candidate drug set is constructed based on the medication plan of the reference case.

[0187] In some examples, steps S310 to S320 are implementations Figure 1 Optional implementation of step S140.

[0188] The current patient's global health representation is obtained by deep learning processing of the current patient's temporal diagnosis and treatment sequence. It integrates medical code information from the current patient's multiple medical records and combines the temporal correlation and importance between medical records, which can accurately reflect the current patient's disease progression, treatment response and other key information.

[0189] In some examples, the method for obtaining the current patient's global health representation can be found in [reference needed]. Figure 1 The steps involved are S120, Figure 2 The steps involved are S121 to S122. Figure 3The optional implementation methods of steps S123 to S124 involved, and Figure 1 , Figure 2 , Figure 3 Other related parts in the embodiments involved will not be described in detail here.

[0190] The medication recommendation list may include the recommended drugs and their corresponding medication guidance information, which may include key information such as dosage, administration method, timing of administration, and safety tips.

[0191] Drug feature databases store feature information for various drugs. Drug features may include, but are not limited to, the chemical characteristics of a drug, its pharmacological mechanism of action, indications, contraindications, adverse reactions, drug interactions, dosage form, and route of administration.

[0192] The mean temporal correlation of codes is a quantification of the temporal correlation between each medical code and different medical records. The mean weight of disease stage is a quantification of the weight of the disease stage for each medical visit.

[0193] In some examples, the temporal correlation of medical codes and the weight of each disease stage at each visit can be obtained through a code-visit two-level hierarchical attention model, as detailed in [link to relevant documentation]. Figure 1 The relevant content in the embodiments involved will not be repeated here.

[0194] In some examples, reference cases are historical cases similar to the current patient in the case database. The method for determining reference cases can be found in [link to relevant documentation]. Figure 1 The steps involved are S130, Figure 5 The steps involved are S210 to S240. Figure 6 The steps involved are S241 to S244. Figure 7 The optional implementation methods of steps S2441 to S2443 involved, and Figure 1 , Figure 5 , Figure 6 , Figure 7 Other related parts in the embodiments involved will not be described in detail here.

[0195] The candidate drug set is constructed based on the medication regimens of reference cases. For example, drugs used in the actual medication regimens of the most similar reference cases can be extracted. In addition, these drugs are screened and expanded using a medical expertise base to form a subset of drugs with high relevance to the current patient, thereby narrowing the scope of recommendations and improving recommendation efficiency.

[0196] The recommendation score for a candidate drug indicates its suitability or suitability for the current patient. A higher score places the drug higher on the recommendation list, indicating a higher priority. The recommendation list provides physicians with decision-making support.

[0197] In this embodiment, a pre-trained medication recommendation scoring model is used to predict a medication recommendation score based on input features (including the current patient's global health profile, the mean of code temporal correlation, the mean of disease stage weights, and the features of each drug in the drug feature library). The medication recommendation scoring model can be a deep neural network-based recommendation model, such as one built on at least one of fully connected networks, multilayer perceptrons (MLPs), convolutional neural networks, and recurrent neural networks, used to capture complex nonlinear relationships between features and ultimately output a recommendation score between 0 and 1. This model has been trained and optimized using historical datasets before practical application, enabling it to learn and capture the interactions between complex features, thus calculating a recommendation score for each drug in the candidate drug set that reflects its suitability for the current patient.

[0198] The training process for the medication recommendation scoring model can be found here. Figure 9 The specific embodiments involved will not be described in detail here.

[0199] In this embodiment, a pre-trained medication recommendation scoring model is introduced, combined with the current patient's global health profile, the mean of code temporal correlation, the mean of disease stage weights, and the characteristics of each drug in the drug feature library. This calculates a recommendation score for each drug in the candidate drug set, reflecting its suitability for the current patient. Since the candidate drug set is constructed based on medication regimens from reference cases, this approach not only comprehensively considers the current patient's overall health status and the actual medication practices of similar cases, but also delves deeper into the temporal characteristics of disease progression and the intrinsic properties of the drugs themselves, thereby effectively improving the accuracy and clinical applicability of medication recommendations. By ranking the candidate drug recommendation scores from highest to lowest, doctors can more intuitively understand the recommendation priorities of different drugs, thus assisting them in making more scientific and reasonable medication decisions. This effectively avoids the problems of inappropriate or inefficient medication that may result from relying solely on experience or simple matching.

[0200] In some embodiments, a method for training a medication recommendation scoring model is provided, such as... Figure 9 As shown, the training method includes the following steps:

[0201] S410: Acquire training data. The training data includes the feature data, retrieval data and label data of the sample patients. The feature data includes the global health representation of the sample patients, the temporal correlation of each medical code between different medical records, and the weight of the disease stage of each visit. The retrieval data includes the stage similarity between the sample patients and historical cases at each disease stage, similar case scores and candidate drug sets. The label data includes the actual medication regimens of the sample patients.

[0202] S420: Obtain auxiliary data that includes drug characteristic data and drug interaction risk data;

[0203] S430: Input the concatenated vector constructed based on the feature data of sample patients and the feature data of drugs into the medication recommendation scoring model to generate the initial recommendation score for each candidate drug in the candidate drug set;

[0204] S440: Calculate the multi-constraint loss function of the medication recommendation scoring model based on the characteristic data, retrieval data, tag data, initial recommendation scores, and auxiliary data of the sample patients;

[0205] S450: Update the parameters of the medication recommendation scoring model by minimizing the value of the multi-constraint loss function.

[0206] In this embodiment, the medication recommendation scoring model trained by this method can be applied to... Figure 8 Examples of recommended medication methods involved.

[0207] The characteristic data of the sample patients can be used to describe key information about their health status and medical history.

[0208] In some examples, the sample patients may include the current patient.

[0209] In some examples, the global health representation of sample patients, the temporal correlation of each medical code across different medical records, and the weights of the disease stage for each visit can be obtained through a code-visit two-level hierarchical attention model. See [link to relevant documentation] for details. Figure 1 The relevant content in the embodiments involved will not be repeated here.

[0210] In some examples, the global health representation of sample patients, the temporal correlation of each medical code across different medical records, and the weights of the disease stage for each visit can be obtained through a code-visit two-level hierarchical attention model. See [link to relevant documentation] for details. Figure 1 The relevant content in the embodiments involved will not be repeated here.

[0211] In some examples, the stage similarity between the sample patient and historical cases at each stage of the disease can be obtained based on the similarity of the stage aggregated features between the current patient and historical cases at each stage of the disease. See [link to relevant documentation] for details. Figure 6 Step S241, and Figure 5 , Figure 6 Other related parts in the embodiments involved will not be described in detail here.

[0212] In some examples, the similarity score between the sample patient and historical cases can be obtained based on a preset fit coefficient determined by the matching degree between the sample patient's treatment scenario labels and the treatment scenario labels of the historical cases, as well as the global similarity between the sample patient and the historical cases. See [link to relevant documentation] for details. Figure 6 Step S242 Figure 7 Steps S2441 to S2442, and Figure 5 , Figure 6 Other related parts in the embodiments involved will not be described in detail here.

[0213] In some examples, the candidate drug set is constructed based on medication regimens from historical cases similar to the sample patients. For details on how to retrieve historical cases similar to the sample patients, please refer to [link to relevant documentation]. Figure 1 The steps involved are S130, Figure 5 The steps involved are S210 to S240. Figure 6 The steps involved are S241 to S244. Figure 7 The optional implementation methods of steps S2441 to S2443 involved, and Figure 1 , Figure 5 , Figure 6 , Figure 7 Other related parts in the embodiments involved will not be described in detail here.

[0214] Supporting data includes drug characteristic data and drug interaction risk data. Drug characteristic data can be obtained from drug knowledge bases and drug package inserts. Drug interaction risk data can include descriptions of potential interactions between different drug combinations and their risk levels.

[0215] In some examples, the medication recommendation scoring model can be constructed using a fully connected network. The input features of the model are the global health representation of the sample patients, the mean of the code temporal correlation, the mean of the disease stage weight, and the concatenated vector of drug feature data. The network calculates the initial recommendation score for each candidate drug. The mean of the code temporal correlation is the average of the temporal correlation of different medical codes, and the mean of the disease stage weight is the average of the weights of different disease stages at different visits.

[0216] For example, the initial recommendation score is calculated using the following formula. :

[0217] ;

[0218] in, This is a concatenated vector representing the patient's global health profile, mean code correlation, mean disease course weight, and drug characteristics. , This is the weight matrix. , As a bias term, the model here uses the ReLU (Rectified Linear Unit) function as a nonlinear activation function.

[0219] Multi-constraint loss functions can be used to guide model training, enabling models to not only predict accurately but also meet other business or security requirements. For example, a multi-constraint loss function can be a weighted sum of multiple loss functions, with each loss function corresponding to a constraint.

[0220] In some examples, the multi-constraint loss function can be obtained by a weighted combination of two or more of the following losses: temporal constraint loss (such as KL divergence based on cross-entropy loss and the actual medication used by sample patients), retrieval constraint loss (e.g., based on contrastive learning loss to make the model recommend medications that are closer to the medications used in similar cases), and safety margin loss (e.g., by using a penalty function to reduce the score of recommended risky drug combinations). KL (Kullback-Leibler) divergence is also known as relative entropy.

[0221] During model training, model parameters can be adjusted through optimization algorithms to minimize the value of the multi-constraint loss function. Optimization algorithms, such as the Adam (Adaptive Moment Estimation) optimizer, can iteratively update model parameters to improve the model's predictive performance.

[0222] In this embodiment, a concatenated vector constructed from the characteristic data of sample patients and the characteristic data of drugs is input into the medication recommendation scoring model to generate initial recommendation scores for each candidate drug in the candidate drug set. Based on this, a multi-constraint loss function is calculated and its value is minimized to update the model parameters. This allows the medication recommendation scoring model to comprehensively learn about the patient's individual health status, historical treatment sequence, association with similar cases, and the risk of drug interactions. This training method enables the medication recommendation scoring model to more accurately assess the effectiveness and safety of drugs, thereby improving the clinical applicability and patient safety of the recommendation results.

[0223] In some embodiments, such as Figure 10As shown, in step S440 above, the multi-constraint loss function of the medication recommendation scoring model is calculated based on the characteristic data, retrieval data, tag data, initial recommendation score, and auxiliary data of the sample patients. This may include:

[0224] S441: Based on the first loss function, according to the temporal correlation degree of each medical code, the weight of the disease stage of each visit, the global health representation of the sample patients, and the actual medication plan, the temporal constraint loss between the predicted medication plan and the actual medication plan is calculated by maximizing mutual information.

[0225] S442: Based on the second loss function, calculate the retrieval constraint loss between the initial recommendation score of the candidate drug and the historical scores of similar cases with similar scores greater than the threshold for the candidate drug at the same disease stage, according to the stage similarity, similar case scores, candidate drug set and the initial recommendation score of each candidate drug;

[0226] S443: Based on the third loss function and drug interaction risk data, the recommended score of drug combinations in the candidate drug set that exceed the preset level range is constrained to be lower than the safety threshold, thus obtaining the safety boundary loss.

[0227] S444: The temporal constraint loss, retrieval constraint loss, and safety boundary loss are fused to obtain the value of the multi-constraint loss function.

[0228] The first loss function is used to calculate the temporal constraint loss between the predicted medication regimen and the actual medication regimen, which enables the model to prioritize the optimization of features with high temporal value.

[0229] For example, time-constrained loss The following formula can be used to calculate it:

[0230] ;

[0231] in, The weight of the disease stage at the t-th visit is given. Let be the temporal correlation degree of the i-th medical code in the t-th visit, and n be the total number of medical codes in the t-th visit. Let KL divergence be the KL divergence. This means that, given the patient's global health representation H, the model predicts the actual medication regimen. The log-likelihood value, where β is the information bottleneck coefficient, for example... T represents the total number of visits to the sample patients.

[0232] The second loss function is used to calculate the retrieval constraint loss between the initial recommended score of the candidate drug and the historical scores of similar cases for the candidate drug at the same disease stage. This can be achieved by calculating the mean squared error (MSE) or cosine similarity loss between the predicted score and the historical scores of similar cases, with a focus on cases with similar scores exceeding a preset threshold to emphasize the reference value of highly similar cases. Alternatively, a contrastive learning approach can be used, treating historical drug scores of similar cases as positive samples and drug scores of dissimilar or irrelevant cases as negative samples. The loss is constructed by maximizing the similarity of positive sample pairs and minimizing the similarity of negative sample pairs, enabling the model to better retrieve and learn from historical data.

[0233] For example, retrieval constraint loss The following formula can be used to calculate it:

[0234] ;

[0235] in, The sample patients are scored against similar cases to historical cases k, where historical cases k is the set of similar cases to the sample patients. The kth historical case in the series, The weight of the p-th stage of the disease. The similarity between the sample patients and historical cases k at the p-th stage of the disease. This is the initial recommendation score for drug y output by the model. For historical case k, the historical score of drug y. This is the medication regimen for case k at the p-th stage of the disease.

[0236] The third loss function is used to constrain drug combinations in the candidate drug set whose risk level exceeds a preset range, causing their recommendation scores to fall below a safety threshold, thus yielding a safety boundary loss. By constraining the scores of high-risk drug combinations based on drug interaction risk levels, the probability of recommending risky drugs can be reduced. For example, a penalty term could be introduced, forcing the recommendation score of a drug combination to fall below a preset safety threshold when its risk level exceeds the preset threshold, thereby suppressing the recommendation of high-risk drug combinations.

[0237] For example, safety boundary loss The following formula can be used to calculate it:

[0238] ;

[0239] in, y1 and y2 represent the number of drugs in the candidate drug set. Two different drugs in the formula, The risk level of the interaction between drug y1 and drug y2, for example , This is the initial recommendation score for drug y1 output by the model. The initial recommendation score for drug y2 output by the model, where τ is the safety threshold, for example... .

[0240] It should be noted that this embodiment does not specifically limit the execution order of each step in steps S441 to S443. For example, steps S441 to S443 can be executed simultaneously to improve model training efficiency.

[0241] In step S444, the timing constraint loss can be calculated using the following formula. Search constraint loss and safety boundary loss By fusing the results, a multi-constraint loss function is obtained. The value of .

[0242] ;

[0243] in, , These are the balance coefficients, for example , .

[0244] In this embodiment, a multi-constraint loss function is used. With minimization as the objective, the scoring model can be trained and its parameters updated using the Adam optimizer (Adaptive Moment Estimation). After training, the trained model is used to calculate and rank the final recommendation scores of candidate drugs for the current patient for whom medication is to be recommended.

[0245] Furthermore, based on the ranking results of the recommendation scores of candidate drugs, drugs with absolute contraindications can be eliminated using a clinical knowledge graph. The final output is a drug recommendation list consisting of the top 5 ranked drugs, including the drug name, the corresponding recommendation confidence level, and the basis for application. This can provide a direct reference for clinical drug use decisions.

[0246] In this embodiment, a multi-constraint loss function is constructed by introducing and fusing a first loss function, a second loss function, and a third loss function. During the training of the medication recommendation scoring model, this multi-constraint loss function comprehensively considers the temporal evolution of patient visits, medication regimens of similar historical cases, and the safety of drug interactions, making recommendations more clinically reasonable, improving the accuracy of recommendations and the safety of medication regimens. Furthermore, by minimizing this loss function that integrates multiple constraints such as temporal, retrieval, and safety, the medication recommendation scoring model can be trained to be more robust and intelligent, thus resulting in more accurate medication recommendation results when applied to medication recommendations.

[0247] Next, with specific examples, the medication recommendation method provided in the embodiments of this application will be further explained.

[0248] The medication recommendation method provided in this application is applied to a medication recommendation system. By integrating a medication recommendation algorithm that combines time-aware dynamic weight adjustment, hierarchical progressive similar patient retrieval, and multi-constraint optimization, it can be applied to intelligent medication auxiliary decision-making scenarios in clinical diagnosis and treatment.

[0249] Specifically, the medication recommendation system deploys a multi-constraint medication recommendation algorithm based on time-series awareness and precise retrieval. This system includes the following modules: a patient data preprocessing module (referred to as the "preprocessing module"), a time-series awareness attention representation module (referred to as the "representation module"), a hierarchical progressive similarity retrieval module (referred to as the "retrieval module"), and a multi-constraint recommendation generation module (referred to as the "recommendation module"). These modules work collaboratively. The representation module can extract dynamic weights and patient representations through a code-visit hierarchical attention model; the retrieval module can locate similar cases through a three-level mechanism of "coarse screening-fine screening-fitting"; and the recommendation module can embed time-series weights and retrieval features into a multi-constraint loss function to optimize the scoring model and output medication recommendations.

[0250] Specifically, the patient data preprocessing module can be used to transform raw medical data into a standardized time-series data format that can be directly used for model calculations. Its input is the raw medical data, covering key information such as basic patient information, diagnostic codes, surgical codes, medication codes, examination indicators, and timestamps of each visit. Through structured data standardization, time-series data organization, and handling of outliers and missing values, an ordered sequence of diagnosis and treatment data is formed. The final output is a standardized and time-series-organized patient diagnosis and treatment sequence, providing high-quality data input for subsequent feature extraction. See details... Figure 1 Step S110, and Figure 1 The related parts in the embodiments involved will not be described again here.

[0251] The temporal-aware attention representation module captures temporal value information from medical data through a code-visit hierarchical attention model, generating patient representations that combine clinical relevance and temporal features. Its input includes preprocessed standardized temporal medical sequences and a clinical knowledge graph or other medical professional knowledge base containing information such as disease-symptom-drug relationships and rules for determining disease turning points. This module performs code-level and visit-level temporal attention processing through the code-visit hierarchical attention model, ultimately outputting three core temporal parameters: code temporal relevance, disease stage weight, and clinical event relevance weight, as well as a global patient health representation. This provides key features for subsequent similarity retrieval and recommendation optimization. For details, please refer to [link to relevant documentation]. Figure 1 Step S120, and Figure 1 , Figure 2 , Figure 3 The related parts in the embodiments involved will not be described again here.

[0252] The hierarchical and progressive similarity search module can accurately match historical similar cases through a three-level search mechanism, providing a reference for medication recommendations.

[0253] like Figure 11 As shown, the inputs are the patient's global health representation output by the time-series awareness module, the current patient's treatment scenario labels (such as "outpatient initial visit," "inpatient treatment," etc.), the patient representation memory (containing the health representation, scenario labels, and medication regimens of historical cases), and a standard coding hierarchy table (such as the ICD coding table). Here, the patient representation memory can also be called the "case information database."

[0254] This module first performs a coarse screening stage (hard matching of disease types), then a fine screening stage (time-series alignment similarity calculation), and finally an adaptation stage (treatment scenario weight adjustment). It outputs staged similarity scores, similar case scores, and a candidate drug set, providing similar case reference information for subsequent recommendation optimization. See details in [link to documentation]. Figure 5 Steps S210 to S240, and Figure 5 , Figure 6 , Figure 7 The related parts in the embodiments involved will not be described again here.

[0255] The multi-constraint recommendation generation module can optimize the medication recommendation scoring model by integrating the multi-constraint fusion loss function of three types of constraints: time series, retrieval, and safety, to generate accurate and safe medication recommendations. The input of the multi-constraint recommendation generation module includes the patient's global health representation, code time series correlation, and disease stage weights output by the time series awareness module, the staged similarity, similar case scores, candidate drug sets output by the similarity retrieval module, as well as the drug feature library (including embedded features such as drug indications and contraindications) and drug interaction graphs.

[0256] The medication recommendation scoring model can be constructed using a fully connected network. The input features are a concatenated vector of the patient's global health characteristics, drug characteristics, the mean of the code temporal correlation, and the mean of the weights of the disease stage. The network calculates the initial recommendation score for each candidate drug.

[0257] In the multi-constraint fusion loss function, the first part is the temporal constraint loss, which combines the temporal correlation of codes and the weight of disease stages, and uses mutual information correlation calculation to make the model prioritize the optimization of features with high temporal value; the second part is the retrieval constraint loss, which combines similar case scores and staged similarity to force the current patient's medication score to align with the medication features of the same stage of highly similar cases; the third part is the safety boundary loss, which constrains the scores of high-risk drug combinations based on the drug interaction risk level, reducing the probability of risky recommendations.

[0258] Model training aims to minimize the total loss function. The scoring model is trained using the Adam optimizer, and the model parameters are updated. After training, the final scores of candidate drugs are calculated and ranked. Drugs with absolute contraindications are removed based on the clinical knowledge graph. Finally, a list of the top 5 recommended drugs is output, including the drug name, recommendation confidence level, and applicable basis.

[0259] The output recommendation results are an optimized and filtered list of medication recommendations, providing direct reference for clinical medication decisions.

[0260] For details regarding the multi-constraint recommendation generation module, please refer to [link / reference]. Figure 8 Steps S310 to S320 Figure 9 Steps S410 to S450, and Figures 8 to 10 Other related parts in the embodiments involved will not be described in detail here.

[0261] In summary, the technical solution provided in this application has at least the following beneficial effects:

[0262] 1. Improved Representation Quality: Temporal-aware attention, through dynamic weight allocation, further enhances the feature contribution of key codes and core medical records, resulting in better clinical relevance of patient representations compared to traditional dual-attention algorithms;

[0263] 2. Improved search accuracy: Hierarchical progressive search solves the problem of asynchronous disease progression, and the accuracy of matching similar cases is higher compared with traditional global search;

[0264] 3. Excellent recommendation performance: The multi-constraint loss function achieves multi-objective balance, integrates disease progression time sequence patterns and diagnosis and treatment scenario information, improves the interpretability of recommendation results, is more in line with the diagnosis and treatment thinking of clinicians, and is easy to implement in clinical practice.

[0265] Compared with existing technologies, this application adopts time-aware dynamic weight adjustment, hierarchical progressive similarity retrieval, and deep coupling of multiple constraint loss functions. It can adjust parameters such as stage weights and safety thresholds according to different clinical scenarios (such as chronic disease management and tumor diagnosis and treatment), and has good scalability.

[0266] 1. Existing technologies use static weight allocation. This application designs a two-level temporal attention system of "code-visit", introduces code temporal correlation and disease stage weight, so that the weight allocation conforms to the disease development pattern and solves the defect of static weight ignoring temporal value.

[0267] 2. Existing technologies use global similarity calculation. This application proposes a three-level retrieval system of "coarse screening-fine screening-fitting", and introduces disease stage alignment and scenario adaptation coefficients to solve the problems of asynchronous disease progression and scenario mismatch.

[0268] 3. Existing technologies use single or simple combination loss functions. This application constructs a three-dimensional constraint loss function of "time series-retrieval-security", which directly embeds time series weights and retrieval features into the optimization objective, realizes multi-objective collaborative optimization, and overcomes the limitations of traditional loss functions.

[0269] The various embodiments or implementation methods described in this specification are presented in a progressive manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other.

[0270] In the various embodiments of the specification, some or all of the steps and their optional implementations can be arbitrarily combined with some or all of the steps in other embodiments, or arbitrarily combined with the optional implementations in other embodiments.

[0271] Figure 12 This application provides a schematic diagram of the structure of a medication recommendation system, as shown in the embodiment. Figure 12 As shown, the medication recommendation system 100 includes:

[0272] The preprocessing module 101 is used to preprocess the current patient's raw medical data into a standardized time-series diagnosis and treatment sequence, wherein the time-series diagnosis and treatment sequence contains multiple medical records arranged in chronological order, and each medical record is represented by multiple medical code vectors;

[0273] The representation module 102 is used to input the time-series diagnosis and treatment sequence and the medical professional knowledge base into the code-visit two-level hierarchical attention model for processing, to obtain the code-level aggregated features and corresponding visit-level attention weights for each visit, and to perform weighted aggregation of the code-level aggregated features based on the visit-level attention weights to generate the global health representation of the current patient.

[0274] The retrieval module 103 is used to retrieve similar historical cases as reference cases from the case information database based on at least one of the multiple medical feature information of the current patient. The case information database stores the medical feature information and medication plan of historical cases. The multiple medical feature information includes global health representation, code-level aggregation features of each visit and corresponding visit-level attention weights.

[0275] The recommendation module 104 is used to generate and output a medication recommendation list for the current patient based at least on the current patient's global health profile and the medication regimen of the reference case.

[0276] In some embodiments, the code-visit two-tiered hierarchical attention model includes:

[0277] The code-level attention layer is used to calculate the temporal correlation degree of each medical code between different medical records based on the occurrence frequency and time interval of each medical code determined based on the temporal diagnosis and treatment sequence, and to perform weighted aggregation of all medical code vectors in each medical record based on the temporal correlation degree to generate the code-level aggregation feature of each medical record.

[0278] The consultation-level attention layer is used to generate corresponding consultation-level attention weights for each consultation, based at least on whether the consultation is a turning point in the condition, the consultation time interval, and the feature matrix composed of the code-level aggregated features of all consultations.

[0279] In some embodiments, the code-level attention layer is specifically used for:

[0280] Based on the temporal correlation of each medical code and the temporal diagnosis and treatment sequence, an attention mechanism is used to determine the attention weight of each medical code in its respective medical record;

[0281] Based on the attention weight of each medical code, all medical code vectors in each medical visit record are weighted and aggregated to obtain the code-level aggregated features of each medical visit.

[0282] In some embodiments, the patient-level attention layer is specifically used for:

[0283] For each medical visit, perform the following operations:

[0284] Based on the medical professional knowledge base, it is determined whether the current visit is a turning point in the condition, and the weight of the disease stage of the current visit is obtained by combining the time interval between the current visit and the previous visit.

[0285] Extract the core clinical event set corresponding to the primary diagnosis of the current visit from the medical professional knowledge base, and obtain the clinical event association weight of the current visit based on the matching degree between the clinical event set of the current visit and the core clinical event set.

[0286] Based on the disease stage weight, clinical event association weight, and feature matrix composed of code-level aggregated features of all visits, the attention mechanism is used to calculate the visit-level attention weight corresponding to the current visit.

[0287] In some embodiments, the retrieval module 103 includes:

[0288] The first retrieval unit is used to filter historical cases whose main diagnostic codes belong to the same coding level as the current patient from the case information database based on the current patient's main diagnostic code and a preset medical coding hierarchy table, so as to form a first candidate case set;

[0289] The second retrieval unit is used for:

[0290] For each historical case in the first candidate case set, based on the consultation-level attention weight and the knowledge graph in the medical professional knowledge base, the disease course of the current patient and the historical case are divided into multiple disease course stages;

[0291] Based on the code-level aggregation features of each visit and the visit-level attention weight corresponding to each visit, the stage aggregation features of the current patient and the historical cases in each disease stage are calculated respectively, and each disease stage includes at least one visit.

[0292] Based on the stage aggregation characteristics of the current patient and the historical cases in each stage of the disease course, historical cases similar to the current patient are selected from the first candidate case set as reference cases.

[0293] In some embodiments, the second retrieval unit is specifically used for:

[0294] Obtain the similarity of the stage aggregation features between the current patient and the historical cases at each stage of the disease course, and obtain the stage similarity for each stage of the disease course;

[0295] Based on the stage similarity of each disease stage, calculate the global similarity between the current patient and the historical cases;

[0296] Based on the global similarity between the current patient and each historical case in the first candidate case set, the N historical cases with the highest similarity are selected from the first candidate case set to form a second candidate case set, where N is a positive integer;

[0297] The reference case is determined based on historical cases in the second candidate case set.

[0298] In some embodiments, the second retrieval unit is specifically used for:

[0299] For each historical case in the second candidate case set, a preset adaptation coefficient corresponding to the matching degree is determined based on the matching degree between the current patient's treatment scenario label and the treatment scenario label of the historical case;

[0300] Based on the preset adaptation coefficient and the global similarity between the current patient and the historical cases, a similarity score between the current patient and the historical cases is calculated.

[0301] Select the M historical cases with the highest similarity scores from the second candidate case set as reference cases, where M is a positive integer less than N.

[0302] In some embodiments, the recommendation module 104 is specifically used for:

[0303] The process of generating and outputting a medication recommendation list for the current patient, based at least on the current patient's global health profile and the medication regimen of the reference case, includes:

[0304] The pre-trained medication recommendation scoring model generates recommendation scores for each candidate drug in the candidate drug set based on the current patient's global health characteristics, the mean value of code temporal correlation, the mean value of disease stage weights, and the characteristics of each drug in the drug feature library. The medication recommendation list is then generated by sorting the candidate drugs from high to low according to their recommendation scores.

[0305] The mean temporal correlation degree of the code is determined based on the temporal correlation degree of each medical code of the current patient among different medical records, the mean weight of the disease stage is determined based on the weight of the disease stage of each visit of the current patient, and the candidate drug set is constructed based on the medication plan of the reference case.

[0306] In some embodiments, the medication recommendation system 100 further includes a training module, the training module comprising:

[0307] The first acquisition unit is used to acquire training data, which includes feature data, retrieval data and label data of the sample patients. The feature data includes the global health representation of the sample patients, the code temporal correlation degree of each medical code between different medical records, and the weight of the disease stage of each medical visit. The retrieval data includes the stage similarity between the sample patients and historical cases at each disease stage, similar case scores and candidate drug sets. The label data includes the actual medication regimen of the sample patients.

[0308] The second acquisition unit is used to acquire auxiliary data including drug characteristic data and drug interaction risk data;

[0309] Training units are used for:

[0310] The concatenated vector constructed based on the feature data of the sample patients and the feature data of the drugs is input into the medication recommendation scoring model to generate the initial recommendation score for each candidate drug in the candidate drug set;

[0311] Based on the characteristic data, retrieval data, tag data, initial recommendation score, and auxiliary data of the sample patients, the multi-constraint loss function of the medication recommendation scoring model is calculated;

[0312] The parameters of the medication recommendation scoring model are updated by minimizing the value of the multi-constraint loss function.

[0313] In some embodiments, the training unit is specifically used for:

[0314] Based on the first loss function, the temporal constraint loss between the predicted medication plan and the actual medication plan is calculated by maximizing mutual information, according to the temporal correlation degree of each medical code, the weight of the disease stage of each visit, the global health representation of the sample patients, and the actual medication plan.

[0315] Based on the second loss function, according to the stage similarity, the similar case score, and the initial recommendation score of each candidate drug, the retrieval constraint loss between the initial recommendation score of the candidate drug and the historical scores of similar cases with similar case scores greater than the threshold for the candidate drug at the same disease stage is calculated.

[0316] Based on the third loss function, and according to the drug interaction risk data, the recommended score of the drug combination in the candidate drug set that exceeds the preset level range is constrained to be lower than the safety threshold, thus obtaining the safety boundary loss.

[0317] The time-series constraint loss, retrieval constraint loss, and safety boundary loss are fused to obtain the value of the multi-constraint loss function.

[0318] For optional implementation methods of the medication recommendation system, please refer to the optional implementation methods and other related parts in the previous method embodiments, which will not be repeated here.

[0319] This application also provides an electronic device, including a processor and instructions for calling instructions to cause the electronic device to execute steps of the medication recommendation method provided in any of the foregoing embodiments, or steps of the training method of the medication recommendation scoring model provided in any of the foregoing embodiments.

[0320] This application also provides a storage medium, including an executable program stored thereon. When the executable program is executed by a processor, it implements the steps of the medication recommendation method provided in any of the foregoing embodiments, or the steps of the training method of the medication recommendation scoring model provided in any of the foregoing embodiments.

[0321] For ease of understanding, the following focuses on explaining the terminology used in this embodiment:

[0322] In this application embodiment, the processor is a circuit with signal processing capabilities. In one implementation, the processor can be a circuit with instruction read and execute capabilities, such as a Central Processing Unit (CPU), a microprocessor, a Graphics Processing Unit (GPU) (which can be understood as a type of microprocessor), or a Digital Signal Processor (DSP). In another implementation, the processor can implement certain functions through the logical relationships of hardware circuits. The logical relationships of the aforementioned hardware circuits are fixed or reconstructable. For example, the processor is a hardware circuit implemented using an Application-Specific Integrated Circuit (ASIC) or a Programmable Logic Device (PLD), such as an FPGA. In a reconstructable hardware circuit, the processor loads a configuration document, implementing a cyclical process of hardware circuit configuration. This can be understood as the processor loading instructions to implement the functions of some or all of the above units or modules in a cyclical process. In addition, it can also be a hardware circuit designed for artificial intelligence, which can be understood as an ASIC, such as a Neural Network Processing Unit (NPU), a Tensor Processing Unit (TPU), a Deep Learning Processing Unit (DPU), etc.

[0323] The computer-readable storage medium provided in this embodiment can execute the medication recommendation method of the above embodiment. Its implementation principle and technical effect are similar to those of the above embodiment, and will not be repeated here.

[0324] The aforementioned computer-readable storage medium 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. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0325] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in an electronic device or a host device.

[0326] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0327] The various embodiments or implementation methods described in this specification are presented in a progressive manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other.

[0328] In the description of this specification, references to "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0329] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A method for recommending medication, characterized in that, The method includes: The patient's original medical data is preprocessed into a standardized time-series diagnosis and treatment sequence, which contains multiple medical records arranged in chronological order, with each medical record represented by multiple medical code vectors; The time-series diagnosis and treatment sequence and medical professional knowledge base are input into the code-visit two-level hierarchical attention model for processing to obtain the code-level aggregated features and corresponding visit-level attention weights for each visit. The code-level aggregated features are then weighted and aggregated based on the visit-level attention weights to generate the global health representation of the current patient. Based on at least one of the multiple medical characteristic information of the current patient, similar historical cases are retrieved from the case information database as reference cases. The case information database stores the medical characteristic information and medication plan of historical cases. The multiple medical characteristic information includes global health representation, code-level aggregated features of each visit and corresponding visit-level attention weights. Based at least on the current patient's global health profile and the medication regimen of the reference case, generate and output a medication recommendation list for the current patient; The code-visit two-tiered hierarchical attention model includes: The code-level attention layer is used to calculate the temporal correlation degree of each medical code between different medical records based on the occurrence frequency and time interval of each medical code determined based on the temporal diagnosis and treatment sequence, and to perform weighted aggregation of all medical code vectors in each medical record based on the temporal correlation degree to generate the code-level aggregation feature of each medical record. The consultation-level attention layer is used to obtain the disease stage weight for each consultation based on whether the consultation is a turning point in the condition and the consultation time interval. It also generates the corresponding consultation-level attention weight based on at least the disease stage weight of the consultation and the feature matrix composed of the code-level aggregated features of all consultations. The process of generating and outputting a medication recommendation list for the current patient, based at least on the current patient's global health profile and the medication regimen of the reference case, includes: A pre-trained medication recommendation scoring model generates recommendation scores for each candidate drug in the candidate medication set based on the current patient's global health characteristics, the mean temporal correlation of codes, the mean weight of disease stages, and the characteristics of each drug in the drug feature library. The medication recommendation list is then generated by sorting the candidate drugs from highest to lowest recommendation scores. The mean temporal correlation of codes is determined based on the temporal correlation of each medical code of the current patient across different medical records. The mean weight of disease stages is determined based on the weight of the disease stage for each visit of the current patient. The candidate medication set is constructed based on the medication plan of the reference case.

2. The medication recommendation method according to claim 1, characterized in that, Based on the aforementioned temporal correlation, all medical code vectors in each medical visit record are weighted and aggregated to generate code-level aggregated features for each medical visit, including: Based on the temporal correlation of each medical code and the temporal diagnosis and treatment sequence, an attention mechanism is used to determine the attention weight of each medical code in its respective medical record; Based on the attention weight of each medical code, all medical code vectors in each medical visit record are weighted and aggregated to obtain the code-level aggregated features of each medical visit.

3. The method for recommending medication according to claim 1, characterized in that, Based at least on the disease stage weight of the current visit and the feature matrix composed of code-level aggregated features of all visits, corresponding visit-level attention weights are generated, including: Extract the core clinical event set corresponding to the primary diagnosis of the current visit from the medical professional knowledge base, and obtain the clinical event association weight of the current visit based on the matching degree between the clinical event set of the current visit and the core clinical event set. Based on the disease stage weight, clinical event association weight, and feature matrix composed of code-level aggregated features of all visits, the attention mechanism is used to calculate the visit-level attention weight corresponding to the current visit.

4. The medication recommendation method according to claim 1, characterized in that, The multiple medical characteristic information also includes a master diagnosis code; the step of retrieving similar historical cases from the case information database as reference cases based on at least one of the multiple medical characteristic information of the current patient includes: Based on the current patient's primary diagnosis code and the preset medical code hierarchy table, historical cases whose primary diagnosis codes belong to the same coding level as the current patient are selected from the case information database to form a first candidate case set; For each historical case in the first candidate case set, based on the consultation-level attention weight and the knowledge graph in the medical professional knowledge base, the disease course of the current patient and the historical case are divided into multiple disease course stages; Based on the code-level aggregation features of each visit and the visit-level attention weight corresponding to each visit, the stage aggregation features of the current patient and the historical cases in each disease stage are calculated respectively, and each disease stage includes at least one visit. Based on the stage aggregation characteristics of the current patient and the historical cases in each stage of the disease course, historical cases similar to the current patient are selected from the first candidate case set as reference cases.

5. The medication recommendation method according to claim 4, characterized in that, Based on the stage aggregation characteristics of the current patient and the historical cases at each stage of the disease course, historical cases similar to the current patient are selected from the first candidate case set as reference cases, including: Obtain the similarity of the stage aggregation features between the current patient and the historical cases at each stage of the disease course, and obtain the stage similarity for each stage of the disease course; Based on the stage similarity of each disease stage, calculate the global similarity between the current patient and the historical cases; Based on the global similarity between the current patient and each historical case in the first candidate case set, the N historical cases with the highest similarity are selected from the first candidate case set to form a second candidate case set, where N is a positive integer; The reference case is determined based on historical cases in the second candidate case set.

6. The method for recommending medication according to claim 5, characterized in that, The multiple medical feature information also includes treatment scenario tags; determining the reference case based on historical cases in the second candidate case set includes: For each historical case in the second candidate case set, a preset adaptation coefficient corresponding to the matching degree is determined based on the matching degree between the current patient's treatment scenario label and the treatment scenario label of the historical case; Based on the preset adaptation coefficient and the global similarity between the current patient and the historical cases, a similarity score between the current patient and the historical cases is calculated. Select the M historical cases with the highest similarity scores from the second candidate case set as reference cases, where M is a positive integer less than N.

7. The method for recommending medication according to claim 1, characterized in that, The training process of the medication recommendation scoring model includes: Acquire training data, which includes feature data, retrieval data and label data of sample patients. The feature data includes the global health representation of sample patients, the temporal correlation of each medical code between different medical records, and the weight of the disease stage of each medical visit. The retrieval data includes the stage similarity of sample patients and historical cases at each disease stage, similar case scores and candidate drug sets. The label data includes the actual medication regimen of sample patients. Obtain auxiliary data that includes drug characteristic data and drug interaction risk data; The concatenated vector constructed based on the feature data of the sample patients and the feature data of the drugs is input into the medication recommendation scoring model to generate the initial recommendation score for each candidate drug in the candidate drug set; Based on the characteristic data, retrieval data, tag data, initial recommendation score, and auxiliary data of the sample patients, the multi-constraint loss function of the medication recommendation scoring model is calculated; The parameters of the medication recommendation scoring model are updated by minimizing the value of the multi-constraint loss function.

8. The method for recommending medication according to claim 7, characterized in that, The calculation of the multi-constraint loss function of the medication recommendation scoring model based on the feature data, retrieval data, tag data, initial recommendation score, and auxiliary data of the sample patients includes: Based on the first loss function, the temporal constraint loss between the predicted medication plan and the actual medication plan is calculated by maximizing mutual information, according to the temporal correlation degree of each medical code, the weight of the disease stage of each visit, the global health representation of the sample patients, and the actual medication plan. Based on the second loss function, according to the stage similarity, the similar case score, and the initial recommendation score of each candidate drug, the retrieval constraint loss between the initial recommendation score of the candidate drug and the historical scores of similar cases with similar case scores greater than the threshold for the candidate drug at the same disease stage is calculated. Based on the third loss function, and according to the drug interaction risk data, the recommended score of the drug combination in the candidate drug set that exceeds the preset level range is constrained to be lower than the safety threshold, thus obtaining the safety boundary loss. The time-series constraint loss, retrieval constraint loss, and safety boundary loss are fused to obtain the value of the multi-constraint loss function.

9. A medication recommendation system, characterized in that, The system includes: The preprocessing module is used to preprocess the current patient's raw medical data into a standardized time-series diagnosis and treatment sequence, which contains multiple medical records arranged in chronological order, with each medical record represented by multiple medical code vectors; The representation module is used to input the time-series diagnosis and treatment sequence and the medical professional knowledge base into the code-visit two-level hierarchical attention model for processing, to obtain the code-level aggregated features and corresponding visit-level attention weights for each visit, and to perform weighted aggregation of the code-level aggregated features based on the visit-level attention weights to generate the global health representation of the current patient. The retrieval module is used to retrieve similar historical cases as reference cases from the case information database based on at least one of the multiple medical feature information of the current patient. The case information database stores the medical feature information and medication plans of historical cases. The multiple medical feature information includes global health representation, code-level aggregation features of each visit and corresponding visit-level attention weights. The recommendation module is used to generate and output a medication recommendation list for the current patient, based at least on the current patient's global health profile and the medication regimen of the reference case. The code-visit two-tiered hierarchical attention model includes: The code-level attention layer is used to calculate the temporal correlation degree of each medical code between different medical records based on the occurrence frequency and time interval of each medical code determined based on the temporal diagnosis and treatment sequence, and to perform weighted aggregation of all medical code vectors in each medical record based on the temporal correlation degree to generate the code-level aggregation feature of each medical record. The consultation-level attention layer is used to generate corresponding consultation-level attention weights for each consultation, based at least on whether the consultation is a turning point in the condition, the consultation time interval, and the feature matrix composed of the code-level aggregated features of all consultations. The recommendation module is used for: The pre-trained medication recommendation scoring model generates recommendation scores for each candidate drug in the candidate drug set based on the current patient's global health characteristics, the mean value of code temporal correlation, the mean value of disease stage weights, and the characteristics of each drug in the drug feature library. The medication recommendation list is then generated by sorting the candidate drugs from high to low according to their recommendation scores. The mean temporal correlation degree of the code is determined based on the temporal correlation degree of each medical code of the current patient among different medical records, the mean weight of the disease stage is determined based on the weight of the disease stage of each visit of the current patient, and the candidate drug set is constructed based on the medication plan of the reference case.

Citation Information

Patent Citations

  • Electronic health record representation learning method and system based on BiLSTM

    CN111370084A

  • Drug recommendation method and system based on comparative learning and hierarchical aggregation

    CN120853994A