Construction and representation method of pneumonia time sequence knowledge graph
By constructing the pneumonia timing knowledge graph and CTKGR model, the problems of missing information and irregular intervals of medical records are solved, and more comprehensive patient information representation is achieved, which improves the analysis ability of clinical record data and the performance of medical tasks.
Patent Information
- Application Number
- CN202510311798.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2025-08-01
AI Technical Summary
When processing clinical record data, existing studies failed to fully consider the missing information of the medical record and the irregularity of the time interval, resulting in incomplete patient information representation and inability to meet the clinical needs for comprehensive information analysis and precise medical decision-making.
The pneumonia timing knowledge graph is constructed, the different forms of data and timing information in the patient's medical records are fused, and the CTKGR model is designed for representation. The data loss is processed through the TRGCN polymerization encoder, GRU cyclic encoding and TLAM modules. Conv-TransE is used as the decoder to optimize the model to train with the cross entropy loss function.
It improves the ability to represent clinical records, better understand the correlation between words, handles irregular data, improves the adaptability and representation performance of the model, and is suitable for a variety of medical tasks.
Smart Images

Figure CN120409635A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of big data and knowledge graphs, and specifically, relates to a method for constructing and representing a pneumonia time-series knowledge graph. Background Art
[0002] Clinical electronic medical records have semi-structured characteristics. Semi-structured data is a data form with a relatively low degree of structuring. In clinical electronic medical records, data such as patients' basic information, medical history information, disease development process information, and examination and test information are included. These data are organized through certain logical relationships and hierarchical structures, with both fixed fields and formats and a large amount of text descriptions and free-form input content. More importantly, clinical electronic medical records may also include multiple visit records of patients and the course records of inpatients. These information are arranged in chronological order, forming a complete trajectory of the patient's disease course development.
[0003] Existing research has been carried out on the semi-structured and time-series characteristics of clinical medical record data. For example, Edward et al. extracted UMLS CUIs from the clinical texts of Stanford Hospital and then spliced them with laboratory test data to predict the death risk of patients. Koval et al. represented the semi-structured data in MIMIC as text data and structured data respectively and used a multi-modal fusion framework to obtain the overall representation of patients. Shang et al. constructed a time-series graph model of a patient with the patient's diseases and drugs as nodes, considering the time series during the patient's visit, and achieved good results in patient drug recommendation. Lee et al. used the vital sign indicators continuously detected within 24 hours of intensive care unit patients to predict the death risk of patients at discharge. However, most of these methods only use the data in a part of the clinical medical records of patients, and do not consider the missing information in the medical records and the irregularity of time intervals in the use of time-series data, and there are still some problems in the complete representation of patients.
[0004] In summary, there are some problems in existing research: Most past research only uses part of the clinical medical record data of patients. When dealing with time-series data, the missing information in the medical records and the irregularity of time intervals are not fully considered, making it difficult to represent patients completely and accurately, and unable to meet the clinical needs for comprehensive information analysis of patients and precise medical decision-making. Summary of the Invention
[0005] To address the deficiencies of existing technologies, the present invention proposes a method for constructing and representing a pneumonia temporal knowledge graph. A pneumonia temporal knowledge graph is designed, integrating different forms of data and temporal information in patient medical records, and a temporal knowledge graph representation model is designed to represent this temporal knowledge graph. By comparing with other knowledge graph representation models and text models with excellent performance in clinical text representation, the effectiveness and generalization of the method of the present invention are verified.
[0006] The present invention is achieved through the following technical solutions: A method for constructing and representing a pneumonia temporal knowledge graph:
[0007] The method specifically includes the following steps:
[0008] Step 1, data collection and preprocessing, obtaining pneumonia-related data from hospital information systems, vertical medical websites, and the Biomedical Information Ontology System (BIOS);
[0009] Step 2, constructing a pneumonia clinical temporal knowledge graph, combining the data obtained in Step 1 with time relationships and converting the serialized text data into a temporal knowledge graph;
[0010] Step 3, constructing a pneumonia temporal knowledge graph representation model (CTKGR), slicing the patient graph into a sub-graph sequence according to the course of the disease and performing probabilistic modeling; using the fused TRGCN aggregation encoder to update the vector matrix, applying the GRU recurrent encoder to capture temporal features, processing data missingness through the TLAM module based on attention and time intervals, using Conv-TransE as the decoder, and training and optimizing the model through the cross-entropy loss function to convert the knowledge graph information into vector representations;
[0011] Step 4, designing experiments for verification, evaluating the performance of the CTKGR model from two aspects: link prediction and medical tasks.
[0012] Furthermore, in Step 1,
[0013] The data obtained from the hospital information system is electronic medical records, including admission, course of disease, and discharge records. Personal information is de-identified and duplicate content is deleted;
[0014] The vertical medical websites include Xunyiwenyao.com. Crawler scripts written using the Requests and URLlib modules are used to crawl pneumonia and symptom-related data, which is stored in json format. The final representation of the obtained data is category + data name, including nine categories of information: etiology, prevention, complications, symptoms, examinations, differential diagnosis, treatment, nursing, and diet and health care;
[0015] Use the BIOS to supplement the data crawled from the website of seeking medical advice. Extract the IDs of pneumonia and related symptoms from the BIOS concept glossary, crawl data through the API interface, and delete the data of taboo drugs among them.
[0016] Furthermore, in step 2, it includes:
[0017] Step 2.1, design the ontology of the pneumonia knowledge graph. Draw on the design of the SNOMED CT and OMAHA ontology layers, refer to the clinical text semantic web, define the basic attributes, data attributes, and object attributes of the classes, add class instances, and use the Protégé tool to complete the construction of the top-level ontology framework;
[0018] Step 2.2, knowledge extraction and fusion. Use pattern matching and deep learning to identify and extract the entities corresponding to the pneumonia ontology classes from the three types of data sources in step 1, calculate the vector similarity and character similarity for entity fusion, and standardize the entities according to the clinical ontology and relevant standards;
[0019] Step 2.3, knowledge graph storage. Use the relationships to form the basic entity, relationship, entity triple structure of the knowledge graph for the isolated entity points, extract the time information to expand it into an entity, relationship, entity, timestamp quadruple, and convert it into a csv file and then use the Neo4j graph database loading command to store the knowledge graph.
[0020] Furthermore, in step 2.1,
[0021] First, define the basic attributes of the classes, determine that there are 7 major categories including treatment procedures, diet, clinical manifestations, patients, body parts, diseases, and drugs, and adopt a tree-shaped construction hierarchy;
[0022] Then, define the data attributes and object attributes of the classes. Among them, the basic attributes include the Chinese names and English names of the other major categories except the patient class, and use the Chinese name attribute as the primary key of the class; for some entity types that need to be specifically described in certain classes, five data attributes of clinical manifestation types, examination values, drug doses, patient personal conditions, and time are supplemented on the basic attributes to describe the information corresponding to a single entity; the object attributes refer to the relationships between each class and are used to improve the relationship structure of the classes;
[0023] Add class instances. Obtain class instances from the class-related entities extracted from the local medical record data and web crawler data and store them correspondingly under the corresponding concept classes to achieve the alignment of the class instance data and the constructed ontology structure.
[0024] Furthermore, in step 2.2,
[0025] First, perform semi-automatic annotation and extraction of clinical case data: Use regular matching methods to segment electronic medical records in the template form provided by doctors. Structured data is directly extracted and saved. For data still in natural language form, use CoreNLP for entity recognition and extraction. After manual correction, input it into the BERT-CRF model for iteration until all data is annotated;
[0026] Extract BIOS data using rule matching, and use the BIOS Helper tool for complex sentences; Through statistical-based methods, calculate vector similarity and character similarity for entity fusion, and then standardize entities according to clinical ontology and relevant standards.
[0027] Furthermore, in step 3, it includes:
[0028] Step 3.1, Modeling of sequence diagram representation: In the way of splitting the sequence by subgraphs, split the patient graph into a subgraph sequence according to the time points of the medical record. Adopt a probability model for modeling, fit the joint distribution function of the subgraph sequence, regard the previous subgraph as a hidden variable, and use an autoregressive model for approximate estimation;
[0029] Step 3.2, Set the aggregation encoder: CTKGR fuses R-GCN and TransE into TRGCN to perform embedded representation on entities and relationships. During model training, maintain the entity vector matrix and the relationship vector matrix, and update the vector matrix through the aggregation operation of the current node and neighbor nodes under different relationships;
[0030] Step 3.3, Set the recurrent encoder: Use two GRUs with different parameters to perform embedded encoding on entities and relationships respectively. Average pool the current relationship (entity) and the relevant entity (relationship) at the previous moment, and then concatenate it with itself as the current input of the GRU;
[0031] Step 3.4, Set the Time Length Awareness Module (TLAM): Adopt a hidden state interpolation method based on the attention mechanism and time interval; When encountering missing data, weighted sum the GRU hidden states before the missing moment according to the time interval score and the attention score to obtain the filling vector;
[0032] Step 3.5, Set the decoder and loss function: Use Conv-TransE as the decoder, and evaluate the correctness of triples by calculating the scoring function; For the link prediction task of entities and relationships, regard it as a multi-label classification task and perform joint training with the goal of minimizing the cross-entropy loss function.
[0033] Furthermore, in step 4,
[0034] Set up a link prediction task, and select the top-K hit rate (Hit@K) and the mean reciprocal ranking (MRR) as the evaluation metrics for the link prediction task to test the reasoning ability of the CTKGR model in the knowledge graph;
[0035] Set up three medical tasks: medication recommendation, symptom prediction, and length of hospital stay prediction. For the medication recommendation and symptom prediction tasks, use three metrics: ACC, AUROC, and AUPRC for evaluation; for the length of hospital stay prediction task, use AUROC and F1 as the classification accuracy evaluation metrics, and use the Kappa coefficient to measure the consistency test of classification to test the representation ability of the CTKGR model.
[0036] A system for constructing and representing a pneumonia temporal knowledge graph is as follows:
[0037] The system includes: a collection module, a temporal knowledge graph construction module, a temporal knowledge graph representation module, and a verification module;
[0038] The collection module is used for data collection and preprocessing, and obtains pneumonia-related data from hospital information systems, vertical medical websites, and the Biomedical Information Ontology System (BIOS);
[0039] The temporal knowledge graph construction is used to construct a pneumonia clinical temporal knowledge graph, combine the collected data with time relationships, and convert the serialized text data into a temporal knowledge graph;
[0040] The temporal knowledge graph representation module is used to construct a pneumonia temporal knowledge graph representation model (CTKGR), segment the patient graph into a sub-graph sequence according to the course of the disease and perform probability modeling; use the fused TRGCN aggregation encoder to update the vector matrix, use the GRU recurrent encoder to capture temporal features, process data missing through the TLAM module based on attention and time intervals, use Conv-TransE as the decoder, and train and optimize the model through the cross-entropy loss function to convert the knowledge graph information into vector representations;
[0041] The verification module designs experiments for verification and evaluates the performance of the CTKGR model from two aspects: link prediction and medical tasks.
[0042] An electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps of the above method are implemented.
[0043] A computer-readable storage medium is used to store computer instructions, and when the computer instructions are executed by a processor, the steps of the above method are implemented.
[0044] Advantages of the present invention
[0045] The present invention integrates hospital electronic medical records, medical consultation websites, and BIOS data, comprehensively covering various aspects of information such as patient diagnosis and treatment, disease knowledge, etc., enriching the data dimension of the knowledge graph. From the perspective of changing the data mode, it uses a graph structure with clearer associations to present the relationships in medical data and their changes over time, constructs a pneumonia temporal knowledge graph based on pneumonia clinical medical record data, and designs a temporal graph model CTKGR to represent it.
[0046] Compared with directly representing medical records using models such as GRU and Transformer, the present invention constructs a knowledge graph and designs a knowledge graph model to characterize clinical medical records, achieving better performance in three medical tasks.
[0047] CTKGR of the present invention is superior to GRU and some GRU variants improved for various temporal problems. The knowledge graph, with its unique edge connection method, intuitively represents the deep associations between various words in clinical medical records. CTKGR does not need to learn its structured form from the medical records, but only needs to represent this structure. The process of constructing the knowledge graph itself is a process of integrating and screening clinical medical record information, which helps to remove noise and highlight key relationships. This explicit graph data construction method is equivalent to feeding prior knowledge about text structuring into the CTKGR model, enabling CTKGR to more effectively understand the association relationships between words in clinical medical records.
[0048] The present invention introduces a Time Length Awareness Module (TLAM), which introduces the interaction of time intervals and attention scores to capture the GRU hidden state, overcomes the irregularity and missingness of clinical temporal medical records, improves the adaptability and representation ability of the model to clinical data, and has strong ability to process irregular data.
[0049] The method of representing clinical medical records by the knowledge graph of the present invention can be applied to other diseases and types of medical tasks, providing support for clinical decision-making. Brief Description of the Drawings
[0050] Figure 1 It is the pneumonia diagnosis and treatment ontology class constructed by the present invention using a tree-like structure.
[0051] Figure 2 It is an example of the visualization of the pneumonia knowledge graph.
[0052] Figure 3 It is the Clinical Temporal KnowledgeGraph Representation model (CTKGR) designed by the present invention.
[0053] Figure 4 Schematic structural diagram of the time length perception module of the present invention. Specific implementation mode
[0054] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0055] The experimental methods used in the following embodiments are all conventional methods unless otherwise specified. The materials, reagents, methods and instruments used are all conventional materials, reagents, methods and instruments in the art unless otherwise specified, and those skilled in the art can obtain them through commercial channels.
[0056] Combined with Figures 1 to 4 The present invention proposes a method for constructing and representing a pneumonia time series knowledge graph:
[0057] The method specifically includes the following steps:
[0058] Step 1, data collection and preprocessing, targeting patients with community-acquired pneumonia in the Department of Respiratory Medicine of Tongzhou Campus of Beijing Friendship Hospital from January 2019 to June 2022. The electronic medical records of these patients are used as the main data source, and data related to pneumonia in the vertical medical website Xunyiwenyao.com and the Biomedical Informatics Ontology System (BIOS) are added as supplements.
[0059] (1.1) Collection and processing of local data sets:
[0060] First, according to the guidance of clinicians, query the database of the hospital's Electronic Medical Record System (EMRS) to obtain the medical record numbers of patients diagnosed with pneumonia within the specified time range. Exporting electronic medical records from the Hospital Information System (HIS) by using the medical record numbers is carried out item by item, and both the export and the misleading correction are time-consuming. Therefore, the following selection criteria are determined for the patients from whom the electronic medical records are extracted in the embodiment:
[0061] 1. The patient must be clearly diagnosed with pneumonia by a doctor during hospitalization, and patients hospitalized due to novel coronavirus infection during the period from 2021 to 2022 are excluded;
[0062] 2. For patients with multiple hospitalization records, only the medical records of their first hospitalization are taken, but the label of readmission is retained;
[0063] 3. The basic information of the patient and the main contents in the clinical medical records should be complete, including a complete record at the time of seeing a doctor, the course record during hospitalization, and the discharge summary;
[0064] 4. Patients with major complications such as tumors, cardiovascular and cerebrovascular diseases, or severe liver and kidney diseases are excluded;
[0065] 5. Patients who are defined as dead in the discharge record are excluded.
[0066] According to the above criteria, the embodiments exported the electronic medical records of 3,214 pneumonia patients from the HIS system. The content collected includes three parts: the admission record, the course record, and the discharge record. The main contents included in each part are shown in Table 1. The data collection and use have been reviewed and approved by the clinical ethics committee.
[0067] Table 1 Main contents collected and information included
[0068]
[0069] The part with a dotted line under the main information in the table represents the content that is repeated in the three types of records, and it is deleted. The first course record is a summary of the admission record, and only the description of the main situation of the patient is retained. To retain more entities, the admission record is retained and the content of the first course record is deleted. At the same time, the personal information in the admission record is de-identified.
[0070] (1.2) Data collection and processing of the Xunyiwenyao website:
[0071] The Xunyiwenyao website is an Internet medical platform that contains knowledge related to various diseases, including disease definitions, symptoms and signs, treatment measures, and medication information. The data contained in this website belongs to semi-structured data with a regular format. Using the Requests and URLlib modules, a crawler script is written according to the architecture and content of the Xunyiwenyao website, and then the data related to pneumonia and its symptoms is crawled and stored in the form of json. The final representation of the obtained data is category + data name, which includes 9 categories of information: etiology, prevention, complications, symptoms, examinations, differential diagnosis, treatment, nursing, and diet and health care.
[0072] (1.3) BIOS data collection and processing:
[0073] BIOS is a public biomedical knowledge graph built on large-scale biomedical text data using natural language processing, text mining and other technologies. It consists of elements such as terms, relationships, biomedical concepts and their ID systems. It contains more than 50,000 medical terms, more than 60,000 triples and 13 types of medical relationships. The purpose of using BIOS is to supplement the data crawled from Xunyiwenyao.com. First, the IDs of pneumonia and pneumonia symptoms (a total of 10 categories) on Xunyiwenyao.com are extracted from the BIOS concept glossary. Then, with these IDs as the center point, the relevant data on pneumonia and its symptoms are crawled according to the triple extraction API interface officially provided by BIOS. All contraindications contained in these data are deleted.
[0074] Step 2: Construct a pneumonia time-series clinical knowledge graph. Considering the templated and semi-structured nature of clinical medical records, the serialized text data is converted into a graph for representation. Combined with the data obtained in Step 1, a pneumonia clinical knowledge graph is constructed. Also, considering the temporal nature of medical records, the timeline of the patient's hospitalization is incorporated into the graph construction process, forming a time-series knowledge graph. The knowledge graph design includes three parts: ontology design, knowledge extraction, and knowledge graph storage.
[0075] (2.1) Pneumonia knowledge graph ontology design:
[0076] An ontology is a formal description of concepts, entities, and relationships in real-world scenarios. It constructs the hierarchical structure and constraints between entities, entity attributes, and relationships within a knowledge graph. Considering the needs of subsequent clinical text representation learning and auxiliary diagnosis, the knowledge graph should include core data such as symptoms or signs, examination information, treatment methods, and medications used by pneumonia patients during hospitalization. Therefore, when designing the graph ontology, sufficient completeness must be ensured to describe the multiple categories of concepts and their related relationships in clinical text. Currently, no reusable ontology has been found for the pneumonia field. In this example, we draw on the widely used SNOMED CT ontology layer and the Chinese OMAHA ontology layer design, and refer to the semantic types of the clinical text semantic network to construct an ontology suitable for the pneumonia field. In this process, referring to pneumonia clinical guidelines and under the guidance of clinical hospital physicians, we systematically summarized the key semantic types in patients' clinical medical records and identified five important term types: disease, symptoms, examinations, signs, and treatment. Based on the scope of the ontology construction for these term types, the ontology was constructed using the Protégé tool. The specific steps are as follows:
[0077] (2.1.1) Define classes and their levels:
[0078] In ontology construction, a class is used to abstractly describe a group of objects with common characteristics. The purpose of defining a class is to provide a consistent structural framework to organize the concepts, entities, and their relationships in the knowledge graph. Specifically, each class in the pneumonia electronic medical record represents a group of entities with common characteristics. For example, the "Patient" class contains personal information entities such as the age and gender of all inpatients, and the "Clinical Manifestation" class contains all entities related to pneumonia such as fever, cough, and moist rales.
[0079] After normalizing the definitions of the above five major types of important terms in the embodiment, patients, diseases, clinical manifestations, drugs, and diets, etc. Figure 1 Seven major categories as shown are obtained. At the same time, according to the actual needs of the pneumonia electronic medical record, a tree-like structure is used to hierarchically organize these seven major categories. For example, the "Clinical Manifestation" class is subdivided into two subclasses, "Symptom" and "Sign", to accurately record the clinical conditions of patients. The finally constructed ontology classes are as Figure 1 shown.
[0080] (2.1.2) Define the data properties and object properties of the class:
[0081] For the above classes, according to the knowledge requirements of auxiliary diagnosis and representation learning, relevant properties are further set. In ontology construction, the properties of a class are elements that describe the characteristics and relationships of the class, and are used to further describe the specific details of the class. First, its internal characteristics are defined from two parts: basic properties and data properties. Among them, the basic properties include the Chinese name and English name of the class (except for the Patient class), and the Chinese name property is used as the primary key of the class. For entity types that need to be particularly described in some classes, five data properties, namely clinical manifestation type, examination value, drug dosage, patient personal situation, and time, are supplemented to their basic properties to describe the information corresponding to a single entity. In addition to the properties inside the class, the definition of object properties is also an important part of ontology construction. Object properties refer to the relationships between various classes and are used to improve the relationship structure of the class. For example, there is a "exists" relationship between the Patient and Disease classes, and there is an "occurs in" relationship between the Symptom and Body Part. The specific definitions of object properties are shown in Table 2. These seven relationships form a closed loop in terms of relationships around the above seven major categories, which helps ontology modeling and reasoning.
[0082] Table 2 Object Properties and Their Examples in the Pneumonia Diagnosis and Treatment Ontology
[0083]
[0084] (2.1.3) Add class instances:
[0085] After completing the construction of the top-level ontology framework, various corresponding instances are further set. The instance of a class is a process of materializing the abstract class concept and is also a key link in improving the data layer of the knowledge graph. Class instances need to be obtained from class-related entities extracted from local medical record data and web crawler data. The main task is to store the extracted class instances under the corresponding concept classes to align the class instance data with the constructed ontology structure. For example, in the laboratory examination class, the names of various laboratory examinations, specific examination values, etc. are added.
[0086] (2.2) Knowledge extraction and fusion:
[0087] The ontology is the upper structural framework of the medical knowledge graph. A complete knowledge graph also needs to fill various entities under this framework. The main purpose of entity extraction is to identify and extract entities corresponding to the pneumonia ontology class from three types of data sources.
[0088] The methods of entity extraction are mainly divided into rule-based pattern matching and statistics-based machine learning. The pattern matching method is relatively easy to use and the data quality obtained is relatively high, while the advantage of the machine learning method is that it can quickly extract for a large amount of data. The clinical medical record text form is a natural language form description of a patient's visit, but in fact, the electronic medical record has its own template, so the medical records of the same hospital have similar recording forms. Considering the high structural characteristics of the crawled data and the templatization of the clinical medical record text, a semi-automated entity extraction method combining pattern matching and deep learning is adopted. The specific extraction steps include the following parts:
[0089] (2.2.1) Semi-automatic annotation and extraction of clinical medical record data:
[0090] When most mainstream deep learning methods are used for entity extraction, a lot of labeled data is required as training corpus. However, large-scale labeled data is very time-consuming. Taking advantage of the ability of deep learning to process large-scale data, a semi-automated method is adopted to extract data. First, the electronic medical records are segmented according to the template form provided by the doctor using the regular matching method. The structured data is directly extracted and saved. For the data still in the natural language form, the open-source named entity recognition tool CoreNLP of Stanford University is used to identify and extract entities from it. Then, manual correction is used to annotate 100 electronic medical records. Using these 100 electronic medical records as the first-round training corpus, input it into the BERT-CRF model for training, and then use the trained model to annotate another 100 electronic medical records. After manually adjusting the annotation results and superimposing them with the previous-round training corpus, continue to send them into the model to execute the previous-round process until all data is annotated. This iterative annotation method can greatly reduce the time of annotating data, and the quality of data annotation is also guaranteed by using the manual correction method.
[0091] (2.2.2) Network data extraction:
[0092] The data of the BIOS knowledge graph itself exists in the form of entity data, so it can be seamlessly integrated into the extraction results of clinical medical record data. Different from the data of clinical medical records and the BIOS knowledge graph, the data on the Ask Doctor website does not directly appear in the form of entities, but shows highly structured characteristics. In view of this characteristic, a rule matching method is used to extract it. This process uses the RE (Regular Expression) module of Python and is completed through four processes: configuration of field information, splitting of sentence breaks, positioning of extraction sentences, and extraction by regular matching. For sentences whose structure is too complex to be matched, the BIOS Helper tool is used for entity extraction.
[0093] (2.2.3) Entity fusion:
[0094] Clinical medical record data and two types of network data come from different knowledge bases. There are entities within them and between them that describe the same concept but have different entity names. For example, for "pneumonia", there are three different expressions: "pneumonia", "lung infection", and "pulmonary inflammation". The process of entity fusion is mainly to perform entity alignment on these similar data. Manually querying whether entities express the same semantics and finding similar entities is a very time-consuming task, and it also has certain requirements for the query person's understanding of the semantics of clinical terms. In the embodiment, entity fusion is completed using two parts: statistical-based entity linking and entity standardization. For the entities within the clinical medical records, the vector of the entity in the last round of BERT in (2.2.1) is used to represent it, and then the cosine similarity is used to calculate the similarity between two entities. The calculation formula is as shown in (1).
[0095]
[0096] Among them, Sim V represents the similarity calculated for the vectors, E1 and E2 represent two entities, and e1 and e2 are their corresponding vectors. The network data does not have trained entity vectors, and its statistical similarity is calculated from the perspective of entity characters. The higher the character repetition rate between two entities, the greater the similarity between the two entities. Therefore, characters can be used as an attribute of entities, and the Dice similarity coefficient (Dice-coefficient, DICE) is used to calculate the entity similarity. The specific formula is as shown in (2).
[0097]
[0098] Among them, Sim WIt represents the similarity for characters. \(E1\cap E2\) represents the number of repeated characters within the entity, and \(E1\cup E2\) represents the total number of characters of the two entities. The similarity between different data sources is also calculated according to formula (2). Finally, the two types of similarity scores are sorted from high to low, and entity pairs with similarity scores greater than 0.8 and 0.65 are selected for alignment respectively.
[0099] (2.2.4) Entity standardization:
[0100] In the standardization process, first, each entity was distinguished according to the ontology constructed in the clinical ontology to form a pneumonia entity dictionary covering the classes defined in the ontology. Then, according to the different categories, the entities were standardized in the following way. Among them, for disease entity classes, the names in the Chinese Medical Subject Headings (CMeSH) and the Chinese version of the Tenth Revision of the International Classification of Diseases (ICD10) were used as the standards. If there are differences in the same name between the two, the name in ICD10 was used as the standard. The names of treatment procedure entity classes were based on CMeSH as the standard. The names of drug classes were based on the Chinese Pharmacopoeia published in 2015. Patient entity classes were not standardized, and for the remaining entities, there is no Chinese naming standard yet, and the standardization was mainly guided by clinical experts. According to the above standard specifications, a pneumonia noun dictionary containing 7 major categories such as diseases and symptoms was finally obtained.
[0101] (2.3) Knowledge graph storage:
[0102] Knowledge storage is the persistence of the knowledge graph, which can facilitate sharing and querying. After completing knowledge extraction, the various entities finally obtained are matched according to the class object attributes constructed, so as to form the basic triple structure (entity, relationship, entity) of the knowledge graph by using relationships for the isolated entity points.
[0103] The various symptoms and medication information of patients are highly related to time. For example, the various symptom manifestations of patients only hold in certain time periods, and the addition of drugs and treatment measures may affect the existing symptom manifestations. Therefore, the addition of time attributes is necessary. In the embodiment, the RE and pyUnit_time modules of Python are used to extract the time information in the text, and then time information is added to all triples under this timestamp, and the triples are extended to a quadruple form (entity, relationship, entity, timestamp) to form a temporal knowledge graph. Finally, the pneumonia temporal knowledge graph constructed in the embodiment contains 5231 non-patient nodes and 94730 edges, among which the number of edges with time information is 21037. As Figure 2 shown.
[0104] The current mainstream knowledge graph storage methods are divided into graph databases and RDF databases. The advantage of RDF databases is that they can enhance semantic reasoning capabilities with ontologies. However, they define multiple types of syntax and rules and are more suitable for triple storage. The Neo4j graph database has a more flexible structure, a complete Cypher query language, and graph analysis tools, with good scalability. These features make it very friendly to the incremental update of knowledge graphs. Considering the data import speed and insertability, convert each entity, relationship, and their time information into a csv file according to the rules, and use its loading command to implement the storage of the pneumonia knowledge graph.
[0105] Step 3, construct a pneumonia clinical temporal knowledge graph representation model (CTKGR), segment the patient graph into a subgraph sequence according to the disease course and perform probabilistic modeling; use the fused TRGCN aggregation encoder to update the vector matrix, use the GRU recurrent encoder to capture temporal features, process data missingness through the TLAM module based on attention and time intervals, use Conv-TransE as the decoder, and train and optimize the model through the cross-entropy loss function to convert the knowledge graph information into vector representations;
[0106] In the embodiments of the present invention, different from the temporal knowledge graphs in the general domain, the time information in the clinical temporal knowledge graph is the disease course record time during the patient's hospitalization. There are problems such as unequal lengths of multiple patient time series and variable lengths of time points, and it cannot be simply segmented into subgraphs according to time points for sequence modeling. Personalized representation for patients is required.
[0107] Based on the R-GCN model as the basic framework and combined with the characteristics of the clinical temporal knowledge graph, a clinical temporal knowledge graph representation model (Clinical Temporal Knowledge Graph Representation model, abbreviated as CTKGR) is designed. This model comprehensively considers the network structure evolution of the patient graph and the temporal modeling of disease course events. Its basic architecture is as Figure 3 shown.
[0108] The basic element of a temporal knowledge graph is a quadruple (s, r, t, τ i ), where τ iRepresents the time when there is a relationship r between the head entity s and the tail entity t. Define the pneumonia temporal knowledge graph constructed in the previous section in this form as G=(E, R, Τ), where E represents the set of all nodes in the graph, R represents the set of all relationships, and Τ is the set of all quadruples. The representation methods of temporal knowledge graphs are roughly divided into two major parts: quadruple modeling and subgraph sequence modeling. Quadruple modeling can model the entire graph, and the model is small in scale and easy to train, but its performance depends on the construction of the quadruple data model. The clinical knowledge graph faces professional and complex medical scenarios and has higher requirements for representation performance. Therefore, CTKGR models and represents the temporal knowledge graph by means of subgraph segmentation sequences, and the specific steps are as follows:
[0109] (3.1) Temporal graph representation modeling:
[0110] In the temporal graph representation, CTKGR uses a probability model for modeling. Take a patient graph G p =(E p , R p , T p ) as an example, which contains all the nodes and relationships related to the patient node in G. According to the time points in the patient's medical record, it can be segmented into a subgraph sequence where represents its subgraph at time τ, and |l| represents the number of time points in the patient's medical record during hospitalization. Similar to the representation of text sequences by language models, the purpose of the knowledge representation model is to fit the joint distribution function of the subgraph sequence Based on the conditional probability formula, it can be expressed as formula (3):
[0111]
[0112] In language models, it has been proven that can be used as a latent variable, and then autoregressive models such as RNN are used for approximate estimation. After clarifying the modeling method, it is also necessary to embed each subgraph and input the vectorized representation into the model for learning.
[0113] (3.2) Aggregation encoder:
[0114] In each subgraph, it contains a sequence of entities and a sequence of relationships For the entity set and relationship set CTKGR obtains the connections between entities through triple facts, and then mines the connections between relationships through shared entities. In the model training stage, whether it is the embedded representation of entities or relationships, they will be optimized along with the aggregation process of entities. Considering the sensitivity of the R-GCN network to the number of relationships, CTKGR fuses the R-GCN and TransE models into an aggregation encoder TRGCN, and then embeds and represents entities and relationships. Specifically, CTKGR maintains two matrices and to store entity vectors and relationship vectors respectively. The initial values of these two matrices are randomly generated. Subsequently, CTKGR updates these two vector matrices through the aggregation operation of the current node and its neighbor nodes under different relationships. This aggregation process is shown in Equation (4).
[0115]
[0116] where represents the vector representation of node e i at the l-th layer. σ represents the softmax activation function. represents all neighbor nodes related to node e i with relationship r, and its set is used to normalize the vector result. represents the feature matrix of relationship r. is the parameter of a fully connected layer without bias, used to map the translation of node e i under its relationship, is used to perform self-loop mapping on node e i . Through the iterative update of multiple layers of TRGCN, the entity and relationship embedded representations of each subgraph can be obtained.
[0117] (3.3) Recurrent Encoder:
[0118] The entity embedding at the current moment is not only affected by the current relationship embedding v r,t related to it, but also related to its own representation at the previous moment Similarly, relational embedding also follows this idea, which is consistent with the design logic of the RNN series model. Considering the influence of model complexity and training time, the GRU model is selected to encode the subgraph sequence. In CTKGR, the design logic is to embed and encode entities and relationships separately, so it is necessary to use two GRUs with different parameters to complete the sequential evolution learning of entities and relationships. But at the same time, considering the correlation between entities and relationships, CTKGR averages the current relationship (entity) and the entities (relationships) related to it at the previous moment, and then splices it with itself as the current input of the GRU. The evolution patterns of entities and relationships are shown in formulas (5) and (6) respectively.
[0119]
[0120] Where f(.) represents the average pooling function, Represents all with e i The relationship Represents all with r i relevant entities.
[0121] (3.4) Time Length Aware Module (TLAM)
[0122] Due to the particularity of clinical consultation, the patient's course of disease is often not recorded at equal intervals, which will cause data missing and data of variable length. This problem will affect the effectiveness of GRU in modeling subgraph sequences. To address this problem, CTKGR adopts a hidden state interpolation method based on attention mechanism and time interval. Its specific architecture is as follows Figure 4 This method compensates for data defects by interpolating the hidden state of the GRU unit at the missing moment. The standard GRU unit hidden state According to formula (7).
[0123]
[0124] Where W represents the training parameters, r τ Reset gate output for GRU, h t-1 is the output of the previous moment, x t is the input at the current moment. An indicator matrix I is set to indicate the missing state of a time point. If the input at time t is missing, the attention score is calculated using the hidden state at time t-1 and the hidden state at all moments between them. At the same time, considering the influence of the time interval, the time interval score is calculated using formula (8) provided in ATTAIN.
[0125]
[0126] Then, the hidden states at all times before \(t\) are weighted and summed according to the time interval fraction and the attention fraction to obtain the padding vector at time \(t\). The specific calculation formula is shown in (9).
[0127]
[0128] (3.5) Decoder:
[0129] The decoder for the knowledge graph, also known as the scoring function, aims to evaluate the probability of a triple being correct. It can rationalize the entity and relationship representations by optimizing the objective function. In CTKGR, Conv-TransE is used as the decoder of the model, which consists of a one-dimensional convolutional layer and a fully connected layer. The score function for the rationality of a certain entity and relationship is calculated by equations (10) and (11).
[0130]
[0131] (3.6) Loss function:
[0132] The link prediction tasks for entities (?, e2, r, t) and relationships (e1, e2,?, t) can both be regarded as multi-label classification tasks. Each class corresponds to an entity or a relationship. The learning objective is to minimize the cross-entropy loss function among all quadruple events:
[0133]
[0134] where \(y\) j,t+1 represents the true label of the quadruple. Finally, CTKGR is jointly trained by weighting these two loss functions.
[0135] Step 4, design experiments for verification.
[0136] (4.1) Experimental design
[0137] (4.1.1) Link prediction task
[0138] To facilitate the comparison between CTKGR and some publicly available knowledge graph representation models, the embodiment uses the link prediction task for the entire knowledge graph for experiments. The benchmark models for this task mainly include three typical static knowledge graph reasoning models, namely TransE, DisMult, and RotatE, and four temporal knowledge graph reasoning models, namely TTransE, TA-DisMult, xERTE
[107] , and RE-GCN.
[0139] In the selection of link prediction datasets, in addition to using the self-constructed pneumonia clinical time-series knowledge graph, a sub-dataset ICEWS18 extracted from the publicly available Integrated Crisis Early Warning System (ICEWS) in the general domain was also used. ICEWS18 is a commonly used dataset for evaluating time-series knowledge graph models. It contains all national political events from January to October 2018 extracted from media around the world. It contains 23,033 entities and 256 types of relationships, and the time interval for recording events is 24 hours. In the dataset division, the quadruples in both datasets were sorted according to the chronological information, and then divided into a training set, a validation set, and a test set in a ratio of 8:1:1. Table 3 shows the detailed information of the two datasets.
[0140] Table 3 Experimental Dataset Situation
[0141]
[0142]
[0143] (4.1.2) Medical Tasks
[0144] The main purpose of designing this task is to compare the representation performance of two data structures, clinical medical records and time-series knowledge graphs, and conduct experiments on three tasks: medication recommendation, symptom prediction, and length of hospital stay prediction. Among them, the medication recommendation and symptom prediction tasks can be regarded as entity link prediction tasks for a specific relationship. The length of hospital stay prediction is a multi-classification task, and its true label is a one-dimensional vector [5, 6, 7, 8, 9, 10, 11] obtained after counting the length of hospital stay of patients. Among them, the length of hospital stay less than 5 days is calculated as 5 days, classified as 10 days between 10 - 14 days, and classified as 11 days for those greater than 14 days. The baseline models for this task used two models, StageNet and FLTD, which can solve time series missing and irregularities, as well as two commonly used models on text data, GRU and Transformer. GRU and Transformer cannot solve the problem of missing time point data. The present invention uses the nearest medical record report to fill the data at the missing time points.
[0145] All deep learning algorithms of the present invention are trained on two RTX3090 GPUs using the Pytorch framework. The optimizers and their main parameters for training each task are shown in Table 4.
[0146] Table 4 Training Parameters of CTKGR for Each Task
[0147]
[0148] Note: "0.005 - 0.0005" represents the use of a learning rate decay strategy, which decreases from 0.005 to 0.0005 as the training iterates.
[0149] (4.2) Evaluation Metrics
[0150] (4.2.1) Evaluation Metrics for Link Prediction Task:
[0151] The link prediction task can be regarded as a process of masking entities or relationships in a quadruple and then predicting the masked part. For each masked entity or relationship, the model needs to calculate the quadruple score based on all entities or relationships in the knowledge graph as candidates, and then evaluate the model results according to the ranking of their scores. In the embodiment, the top-K hit rate (Hit@K) and the mean reciprocal rank (MRR) are selected as the evaluation metrics for the link prediction task, and the two evaluate the model performance in the limited candidate range and the global range respectively. MRR takes the mean of the reciprocals of the ranks of all correct relationships or entities in the prediction results as the evaluation score, and the higher this value, the better the model performance. The idea of the Hit@n score is whether the correct entity or relationship appears among the top n candidates in the prediction results. Similarly, the higher this value, the better the model performance, and the commonly used n values are 1, 3, and 10.
[0152] (4.2.2) Evaluation Metrics for Medical Tasks
[0153] For the two tasks of medication recommendation and symptom prediction, three classification metrics, namely ACC, AUROC, and AUPRC, are used. For the hospital length of stay prediction task, AUROC and F1 are used as classification accuracy evaluation metrics, and the Kappa coefficient is used to measure the consistency test of classification.
[0154] (4.3) Experimental Results
[0155] (4.3.1) Comparative Experiments
[0156] The results of node prediction using CTKGR and various baseline models on the ICEWS18 dataset are shown in Table 5. It can be seen that CTKGR shows the best results under most metrics. Compared with the optimal baseline model, the Hits@1, Hits@3, and Hits@10 metrics of CTKGR are improved by 2.24, 3.52, and 2.35 respectively, and the model can find the correct answer in the top n candidate rankings more often. The MRR score of xERTE is the highest because xERTE selects the correct result through the temporal relation attention mechanism, which will cause the correct prediction result to be more forward. However, the score of CTRKG is still better than other baseline models, indicating the stable performance of CTRKG. The data in the table also reflects that all static graph models are far weaker than the temporal graph representation models except TTransE, and this difference highlights the disadvantage of static graph models in capturing temporal dynamics, further emphasizing the importance of incorporating temporal information into the model. The TTransE model has the worst performance among all models because it only performs independent representation learning on each subgraph and lacks the ability to capture long-term dependencies, and this result also proves the effectiveness of modeling the entire subgraph sequence in CTKGR from the side.
[0157] Table 5 Node Link Prediction Results on the ICEWS18 Dataset
[0158]
[0159] Due to the uneven time points of the pneumonia temporal knowledge graph, the RE-GCN and xERTE models are restricted in this dataset. Table 6 shows the results of node link prediction of CTKGR and other baseline models on the pneumonia temporal knowledge graph. CTKGR still shows the optimal performance in all aspects, which to a certain extent indicates the generalization of CTKGR. Different from ICEWS18, in the pneumonia temporal knowledge graph, although TTransE still lags behind some static graph representation models in multiple metrics, its Hit@10 metric reaches 39.45. This is more important in real medical scenarios because when applying the model to clinical auxiliary diagnosis, the cost of preventing diseases is often lower than the cost of treating diseases, so it is very valuable to be able to accurately provide a series of candidate results.
[0160] Table 6 Node Link Prediction Results on the Pneumonia Temporal Knowledge Graph
[0161]
[0162] Tables 7 and 8 show the performance comparison between CTKGR and the text representation baseline models on three medical tasks (symptom prediction, drug recommendation, length of stay prediction). In these three tasks, CTKGR shows better performance. Especially in the task of length of stay prediction with balanced label distribution, the Kappa coefficient of CTKGR is 0.457, which indicates that CTKGR has medium classification consistency, while the Kappa coefficients of other baseline models are all below 0.4, only having general classification consistency, which further highlights the superiority of CTKGR. This fully verifies the effectiveness of the strategy of converting temporal clinical case data into a knowledge graph and performing representation learning based on this in the present invention. However, in the two imbalanced datasets of symptom prediction and drug recommendation, CTKGR performs poorly in terms of the AUPRC metric, which may be because the scoring function of CTKGR is more likely to focus on the samples with larger quantities during training.
[0163] FLTD and the StageNet model can handle the problems of irregular and missing temporal data, so they are superior to the GRU model in three medical tasks. This highlights the limitations of the method of filling with the nearest neighbor clinical text in the GRU model when solving the problem of missing temporal data. Directly filling missing values may cause the model to fail to fully learn the changes of some key features, thus affecting the prediction performance. Although both FLTD and the StageNet model improve the gating unit of the recurrent encoder by introducing time bias features, they do not consider the mutual influence between all previous units, resulting in a prediction effect inferior to CTKGR. The TLAM module is proposed in CTKGR, which uses attention scores and time interval scores to interact with all units before the missing moment, and can effectively capture the interactivity between units.
[0164] Table 7 Results of Symptom Prediction and Drug Recommendation
[0165]
[0166] Table 8 Results of Length of Stay Prediction
[0167]
[0168] (4.3.2) Ablation Experiment
[0169] In the ablation experiment session, we focus on the performance differences of the TLAM module and its different variants in CTKGR to accurately understand the contribution degree of each variant to the overall performance of CTKGR. The differences of each variant are as follows:
[0170] (1) In the GRU model, the data at the missing time points is directly filled with the nearest neighbor clinical text, and the GRU network is used to learn the clinical record data at each time point. Finally, the text representations at all time points are merged in a concatenated manner.
[0171] (2) CTKGR-TLAM-Att changes the calculation method of the TLAM module of CTKGR. It only uses the time interval coefficient to consider the mutual influence of the hidden states of all GRU units before the missing time points, and then fills the missing data without considering its attention mechanism interaction.
[0172] (3) Contrary to CTKGR-TLAM-Att, CTKGR-TLAM-TI only uses the attention mechanism interaction without considering the time interval coefficient.
[0173] (1) The biggest difference between (1) and (2), (3) is that GRU fills the missing data at the display level, while CTKGR-TLAM-Att and CTKGR-TLAM-TI fill the missing data at the implicit level. It can be observed from Table 9 that the GRU model is weaker than other models in terms of ACC and AUROC metrics, which indicates the effectiveness of considering the interaction between the hidden states of GRU units and the time interval coefficient during data filling. It also shows that compared with filling data at the display level, the model can show better performance when filling data at the implicit level. The comparison results between CTKGR-TLAM-Att and CTKGR-TLAM-TI show that using the attention mechanism to consider the mutual influence of the hidden states of all GRU units before the missing time points has a better effect than using the time interval coefficient. However, from the AURPC metric, it can be seen that CTKGR-TLAM-Att and CTKGR-TLAM-TI also inherit the defect of the poor ability of CTKGR to handle imbalanced samples.
[0174] Table 9 Results of ablation experiments on symptom prediction
[0175]
[0176] A system for constructing and representing a time series knowledge graph of pneumonia:
[0177] The system includes: a collection module, a time series knowledge graph construction module, a time series knowledge graph representation module, and a verification module;
[0178] The collection module is used for data collection and preprocessing, and obtains pneumonia-related data from hospital information systems, vertical medical websites, and biomedical information ontology systems (BIOS);
[0179] The construction of the temporal knowledge graph is used to construct a clinical temporal knowledge graph for pneumonia. By combining the collected data with time relations, the serialized text data is transformed into a temporal knowledge graph;
[0180] The temporal knowledge graph representation module is used to construct a pneumonia temporal knowledge graph representation model (CTKGR). The patient graph is sliced into a sub-graph sequence according to the disease course and probability modeled; the fused TRGCN aggregation encoder is used to update the vector matrix, the GRU recurrent encoder is used to capture temporal features, the TLAM module is used to process data missing based on attention and time intervals, the Conv-TransE is used as the decoder, and the model is trained and optimized through the cross-entropy loss function to transform the knowledge graph information into vector representations;
[0181] The verification module designs experiments for verification and evaluates the performance of the CTKGR model from two aspects: link prediction and medical tasks.
[0182] An electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps of the above method are implemented.
[0183] A computer-readable storage medium is used to store computer instructions. When the computer instructions are executed by a processor, the steps of the above method are implemented.
[0184] The memory in the embodiments of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read only memory (ROM), a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchlink DRAM (SLDRAM), and direct rambus RAM (DR RAM). It should be noted that the memory of the method described in the present invention is intended to include but not limited to these and any other suitable types of memory.
[0185] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired means such as coaxial cable, optical fiber, digital subscriber line (DSL), or wireless means such as infrared, wireless, microwave, etc. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium such as a floppy disk, hard disk, magnetic tape, an optical medium such as a high-density digital video disc (DVD), or a semiconductor medium such as a solid state disc (SSD), etc.
[0186] In the implementation process, each step of the above method can be completed by the integrated logic circuit of the hardware in the processor or the instructions in the form of software. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as being executed by the hardware processor or executed by the combination of the hardware and software modules in the processor. The software module can be located in a mature storage medium in the art such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, register, etc. This storage medium is located in the memory, and the processor reads the information in the memory and combines its hardware to complete the steps of the above method. To avoid repetition, it will not be described in detail here.
[0187] It should be noted that the processor in the embodiments of the present application can be an integrated circuit chip with signal processing capabilities. In the implementation process, the steps of the above method embodiments can be completed by the integrated logic circuit in the hardware of the processor or instructions in the form of software. The above processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as being executed and completed by the hardware decoding processor, or executed and completed by a combination of the hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory, and the processor reads the information in the memory and combines its hardware to complete the steps of the above method.
[0188] The above has introduced in detail a method for constructing and representing a pneumonia temporal knowledge graph proposed by the present invention, and has expounded on the principle and implementation manner of the present invention. The description of the above embodiments is only used to help understand the method and its core idea of the present invention; at the same time, for those of ordinary skill in the art, according to the idea of the present invention, there will be changes in the specific implementation manner and application scope. In summary, the content of this specification should not be construed as a limitation to the present invention.
Claims
1. A method for constructing and representing a pneumonia temporal knowledge graph, characterized in that: The method specifically includes the following steps: Step 1, data collection and preprocessing, obtaining pneumonia-related data from hospital information systems, vertical medical websites, and the Biomedical Information Ontology System (BIOS); Step 2, constructing a pneumonia clinical temporal knowledge graph, combining the data obtained in Step 1 with time relationships to convert serialized text data into a temporal knowledge graph; Step 3, constructing a pneumonia temporal knowledge graph representation model (CTKGR), slicing the patient graph into a sub-graph sequence according to the course of the disease and performing probabilistic modeling; using the fused TRGCN aggregation encoder to update the vector matrix, applying the GRU recurrent encoder to capture temporal features, processing data missingness through the TLAM module based on attention and time intervals, using Conv-TransE as the decoder, and training and optimizing the model through the cross-entropy loss function to convert the knowledge graph information into vector representations; Step 4, designing experiments for verification, and evaluating the performance of the CTKGR model from two aspects: link prediction and medical tasks.
2. The method according to claim 1, wherein: In Step 1, The data obtained from the hospital information system is electronic medical records, including admission, course of disease, and discharge records. Personal information is de-identified and duplicate content is deleted; The vertical medical websites include Xunyiwenyao.com. Using crawler scripts written with the Requests and URLlib modules, data related to pneumonia and symptoms is crawled and stored in json format. The final representation of the obtained data is category + data name, including 9 categories of information: etiology, prevention, complications, symptoms, examinations, differential diagnosis, treatment, nursing, and diet and health care; BIOS is used to supplement the data crawled from Xunyiwenyao.com. Pneumonia and related symptom IDs are extracted from the BIOS concept glossary, and data is crawled through the API interface, and the taboo drug data is deleted.
3. The method according to claim 2, wherein: In Step 2, it includes: Step 2.1, designing the ontology of the pneumonia knowledge graph, drawing on the SNOMED CT and OMAHA ontology layers, referring to the clinical text semantic web, defining the basic attributes, data attributes, and object attributes of the classes, adding class instances, and using the Protégé tool to complete the construction of the top-level ontology framework; Step 2.2, knowledge extraction and fusion, using pattern matching and deep learning to identify and extract the entities corresponding to the pneumonia ontology classes from the three types of data sources in Step 1, calculating the vector similarity and character similarity for entity fusion, and standardizing the entities according to the clinical ontology and relevant standards; Step 2.3, knowledge graph storage, using relationships to form the basic entity, relationship, entity triple structure of the knowledge graph for isolated entity points, extracting time information to expand it into an entity, relationship, entity, timestamp quadruple, and storing the knowledge graph using the Neo4j graph database loading command after converting it into a csv file.
4. The method according to claim 3, wherein: In Step 2.1, First, define the basic attributes of the classes, determine 7 major categories including treatment procedures, diet, clinical manifestations, patients, body parts, diseases, and drugs, and adopt a tree-shaped construction hierarchy; Then define the data attributes and object attributes of the classes. The basic attributes include the Chinese names and English names of other major categories except the patient class, and the Chinese name attribute is used as the primary key of the class. For entity types that need to be particularly described in some classes, five data attributes, namely clinical manifestation type, examination value, drug dosage, patient's personal situation, and time, are supplemented to the basic attributes to describe the information corresponding to a single entity. The object attributes refer to the relationships between classes and are used to improve the relationship structure of the classes. Add class instances. Obtain class instances from the class-related entities extracted from the local medical record data and web crawler data and store them correspondingly under the corresponding concept classes to achieve the alignment of class instance data and the constructed ontology structure.
5. The method according to claim 4, wherein: In step 2.2, First, perform semi-automatic annotation and extraction of clinical medical record data: Use the regular matching method to split the electronic medical records in the form of templates provided by doctors. The structured data is directly extracted and saved. For the data still in natural language form, use CoreNLP for entity recognition and extraction. After manual correction, input it into the BERT-CRF model for iteration until all data is annotated. Extract BIOS data using rule matching and use the BIOS Helper tool for complex sentences; Through a statistical-based method, calculate the vector similarity and character similarity for entity fusion, and then standardize the entities according to the clinical ontology and relevant standards.
6. The method according to claim 5, characterized in that: In step 3, it includes: Step 3.1, Modeling of sequence diagram representation: In the way of splitting the sequence of subgraphs, split the patient graph into a sequence of subgraphs according to the time points of the course record, use a probability model for modeling, fit the joint distribution function of the subgraph sequence, regard the previous subgraph as a hidden variable, and approximately estimate it using an autoregressive model. Step 3.2, Set the aggregation encoder: CTKGR fuses R-GCN and TransE into TRGCN to perform embedding representation on entities and relationships. During model training, maintain the entity vector matrix and relationship vector matrix, and update the vector matrix through the aggregation operation of the current node and neighbor nodes under different relationships. Step 3.3, Set the recurrent encoder: Use two GRUs with different parameters to perform embedding encoding on entities and relationships respectively. Average pool the current relationship (entity) and the related entity (relationship) at the previous moment, and then concatenate it with itself as the current input of the GRU. Step 3.4, Set the Time Length Awareness Module (TLAM): Adopt a hidden state interpolation method based on the attention mechanism and time interval; When encountering missing data, weight and sum the GRU hidden states before the missing moment according to the time interval score and attention score to obtain the filling vector. Step 3.5, Set the decoder and loss function: Use Conv-TransE as the decoder and evaluate the correctness of triples by calculating the score function; For the link prediction task of entities and relationships, regard it as a multi-label classification task and jointly train with the goal of minimizing the cross-entropy loss function.
7. The method according to claim 6, wherein: In step 4, Set up the link prediction task, and select the top-K hit rate (Hit@K) and the mean reciprocal ranking (MRR) as the evaluation metrics for the link prediction task to test the reasoning ability of the CTKGR model in the knowledge graph; Set up three medical tasks: medication recommendation, symptom prediction, and length of hospital stay prediction. For the medication recommendation and symptom prediction tasks, use three metrics, namely ACC, AUROC, and AUPRC, for evaluation; for the length of hospital stay prediction task, use AUROC and F1 as the classification accuracy evaluation metrics, and use the Kappa coefficient to measure the consistency test of classification to test the representation ability of the CTKGR model.
8. A system for implementing the method for constructing and representing a pneumonia temporal knowledge graph according to any one of claims 1 to 7, characterized in that: The system includes: a collection module, a temporal knowledge graph construction module, a temporal knowledge graph representation module, and a verification module; The collection module is used for data collection and preprocessing, and obtains pneumonia-related data from the hospital information system, vertical medical websites, and the Biomedical Information Ontology System (BIOS); The temporal knowledge graph construction is used to construct a pneumonia clinical temporal knowledge graph, combine the collected data with time relationships, and convert the serialized text data into a temporal knowledge graph; The temporal knowledge graph representation module is used to construct a pneumonia temporal knowledge graph representation model (CTKGR), split the patient graph into a sub-graph sequence according to the course of disease and perform probability modeling; update the vector matrix using the fused TRGCN aggregation encoder, capture temporal features using the GRU recurrent encoder, process data missingness based on attention and time intervals through the TLAM module, use Conv-TransE as the decoder, and train and optimize the model through the cross-entropy loss function to convert the knowledge graph information into vector representations; The verification module designs experiments for verification and evaluates the performance of the CTKGR model from two aspects: link prediction and medical tasks.
9. An electronic device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method described in claim 8.
10. A computer-readable storage medium for storing computer instructions, characterized in that, When the computer instructions are executed by the processor, it implements the steps of the method described in claim 8.
Citation Information
Cited By
Map generation method under support of customized large model
CN121053250A
Online medical intelligent medical guide system based on text graph embedding
CN121483569A
Pregnant woman gestational disease risk prediction method based on time sequence knowledge graph
CN121483625A