Intelligent auxiliary diagnosis and treatment system for common diseases in primary medical care based on knowledge graph

By using a knowledge graph-based intelligent assisted diagnosis and treatment system, combined with a neural theorem prover and fuzzy Petri nets, the problems of incomplete diagnostic evidence and unclear logical reasoning in primary healthcare have been solved. This has enabled standardized and interpretable diagnostic and treatment recommendations, thereby improving the diagnostic and treatment outcomes in primary healthcare.

CN121964116BActive Publication Date: 2026-07-03SHANDONG UNIVALSOFT JOINT- CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHANDONG UNIVALSOFT JOINT- CO LTD
Filing Date
2026-04-02
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

When faced with multiple common diseases with similar symptoms, primary healthcare institutions lack interpretable logical reasoning and standardized diagnostic evidence in their existing technologies. Furthermore, the process of making treatment recommendations suffers from insufficient path constraints due to unclear knowledge function positioning and incomplete evidence.

Method used

An intelligent auxiliary diagnosis and treatment system based on knowledge graphs is adopted. By extracting medical record elements and anchoring them to knowledge graphs, a neural theorem prover is used for diagnostic reasoning. Fuzzy Petri nets are combined to constrain clinical pathways, thereby achieving interpretability of logical reasoning and fuzzy matching ability. It can distinguish between diagnostic knowledge and suggested knowledge and adapt to the condition of incomplete evidence in primary healthcare scenarios.

Benefits of technology

It provides standardized and interpretable intelligent assisted diagnosis results, improving the diagnostic accuracy and rationality of treatment recommendations for common diseases in primary healthcare, and ensuring the logical purity of diagnostic reasoning and the adaptability of the pathway.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121964116B_ABST
    Figure CN121964116B_ABST
Patent Text Reader

Abstract

This invention discloses an intelligent auxiliary diagnosis and treatment system for common diseases in primary healthcare based on knowledge graphs, belonging to the field of healthcare informatics technology. The system includes the following steps: Step 1: Obtain the patient's medical record text, and extract candidate diagnosis and treatment subgraphs by performing subgraph traversal starting from the patient element anchor node set; Step 2: Extract patient observation facts and diagnostic knowledge facts from the candidate diagnosis and treatment subgraphs to form a set of diagnostic logical facts, and arrange them in descending order of comprehensive evidence strength to form candidate disease reasoning results; Step 3: Standardize and encode the clinical diagnosis and treatment path into a fuzzy Petri net, and summarize to generate intelligent auxiliary diagnosis and treatment results. This invention organically integrates the interpretability of logical reasoning, the fuzzy matching capability of semantic embedding, and the differentiated path constraints of fuzzy Petri nets, enabling it to provide standardized and interpretable intelligent auxiliary diagnosis and treatment results even when diagnostic evidence in primary healthcare is not entirely sufficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of healthcare informatics technology, and in particular to an intelligent auxiliary diagnosis and treatment system based on knowledge graphs for common diseases in primary healthcare. Background Technology

[0002] Primary healthcare institutions bear the responsibility of initial diagnosis and treatment of common and frequently occurring diseases. However, due to uneven distribution of medical resources and a shortage of professional personnel, primary care physicians often rely on personal experience when faced with multiple common diseases presenting with similar symptoms, making it difficult to guarantee the standardization and consistency of diagnoses. In recent years, artificial intelligence-assisted diagnosis and treatment technologies have been gradually applied to the medical field. Existing research has used deep learning models to perform named entity recognition and relation extraction on electronic medical record texts, transforming unstructured medical record information into structured data, providing a foundation for subsequent automated diagnosis. In terms of knowledge representation, the construction of medical knowledge graphs provides a structured knowledge carrier for the relationships between diseases, symptoms, examinations, and drugs. Some systems use graph database queries or graph neural networks to retrieve and reason about knowledge graphs, achieving a preliminary mapping from patient symptoms to candidate diseases. Regarding the constraints of treatment guidelines, some studies have attempted to encode clinical pathway guidelines into conditional judgment logic in rule engines to verify the compliance of the system's output treatment suggestions. However, existing technologies still have the following shortcomings. At the diagnostic reasoning level, while methods based on graph neural networks or embedding similarity matching can utilize the structural information of knowledge graphs, they lack explicit logical reasoning mechanisms. The reasoning process lacks interpretability, and clinicians cannot understand the specific reasoning path and evidence source for a given diagnostic conclusion. This severely restricts the clinical adoption of the system in primary healthcare settings. At the knowledge utilization level, existing methods often mix the knowledge required for diagnostic reasoning with that required for treatment recommendations, failing to distinguish the different functional roles of diagnostic and advisory knowledge facts. This leads to medication recommendations or contraindications potentially participating in the judgment process of whether a disease is established, affecting the logical purity of diagnostic reasoning. At the clinical pathway constraint level, existing rule engines employ strict Boolean decision-making, requiring all diagnostic conditions to be fully met before allowing pathway progression. This fails to handle common situations in primary healthcare settings where diagnostic evidence is incomplete or insufficient, and it does not assign differentiated impact levels to evidence deficiencies at different stages of diagnosis and treatment. Summary of the Invention

[0003] The purpose of this invention is to provide an intelligent auxiliary diagnosis and treatment system for common diseases in primary healthcare based on knowledge graphs. It organically integrates the interpretability of logical reasoning, the fuzzy matching capability of semantic embedding, and the differentiated path constraints of fuzzy Petri nets, and can provide standardized and interpretable intelligent auxiliary diagnosis and treatment results under the condition that the diagnostic evidence in primary healthcare is not completely sufficient.

[0004] To address the aforementioned technical problems, this invention provides an intelligent auxiliary diagnosis and treatment system based on knowledge graphs for common diseases in primary healthcare, comprising the following steps:

[0005] Step 1, Medical Record Element Extraction and Knowledge Graph Anchoring: Obtain the patient's medical record text, use a pre-trained language model and sequence labeling model to extract entity units from the medical record text to form a structured medical record element set, link each entity unit to a standardized entity node in a pre-built primary healthcare knowledge graph to obtain a patient element anchoring node set, create patient instance nodes in the primary healthcare knowledge graph and establish relationship edges with each node in the patient element anchoring node set to generate a patient observation fact set, and perform subgraph traversal to extract candidate diagnosis and treatment subgraphs starting from the patient element anchoring node set;

[0006] Step 2, Diagnostic reasoning based on the neural theorem prover: Extract patient observation facts and diagnostic knowledge facts from the candidate diagnosis and treatment subgraph to form a set of diagnostic logical facts. Construct a target triplet for each disease node. Perform recursive rule expansion and unified operation on the target triplet based on the set of diagnostic rules through the neural theorem prover to obtain the comprehensive evidence strength and optimal evidence link for each disease node. Arrange the candidate disease reasoning results in descending order of comprehensive evidence strength.

[0007] Step 3, generating clinical pathway constraints and treatment suggestions based on fuzzy Petri nets: The clinical treatment pathway is coded into a fuzzy Petri net. For each disease node, the associated entity set is queried along the suggested knowledge relationship edge. The token is driven to flow along the fuzzy Petri net by using the comprehensive evidence strength as the initial fuzzy assignment of the token. Based on the fuzzy assignment of each library and the associated entity set, recommended examination items, recommended medication plans, medication risk warnings, follow-up suggestions, and referral suggestions are output. The results are then summarized to generate intelligent assisted treatment results.

[0008] Furthermore, in step 1, the medical record text includes the chief complaint text, past medical history text, and basic examination results text. Each medical record text is segmented at the character level, and a classification tag is inserted at the beginning and a separator tag is inserted at the end to obtain the input tag sequence. The pre-trained language model is the BERT full-word mask pre-trained model. The multi-layer Transformer encoder in the BERT full-word mask pre-trained model performs multi-head self-attention calculation and feedforward network transformation on each tag in the input tag sequence layer by layer. The sequence labeling model is the Conditional Random Field labeling layer. The Conditional Random Field labeling layer takes the hidden state vector of all tags in the final layer as input and searches for the tag sequence with the highest joint probability through the Viterbi decoding algorithm. The tag categories include 9 types: symptom onset, symptom internal, sign onset, sign internal, examination indicator onset, examination indicator internal, drug allergy onset, drug allergy internal, and non-entity. Continuous tags with adjacent tags of the same type are merged into entity units.

[0009] Furthermore, in step 1, the entity linking process includes: retrieving all candidate standardized entity nodes in the entity name index of the knowledge graph of common diseases at the grassroots level, which have a character-level edit distance of no more than a preset distance threshold, to form a candidate node set; verifying whether the entity type label in the knowledge graph of common diseases at the grassroots level and the label category output by the entity unit in the sequence labeling model belong to the same preset type mapping group for each candidate standardized entity node in the candidate node set; retaining candidate standardized entity nodes with the same type; and selecting the one with the smallest edit distance among the retained candidate standardized entity nodes as the anchor node of the entity unit.

[0010] Furthermore, in step 1, the process of generating the patient observation fact set includes: establishing symptom-related edges from patient instance nodes to each symptom-related node in the patient element anchoring node set, establishing signs-related edges to each sign-related node, establishing examination-related edges to each examination indicator-related node, and establishing allergy-related edges to each drug allergy-related node.

[0011] Furthermore, the knowledge graph of common primary care diseases contains two types of relationship edges: the first type is diagnostic knowledge relationship edges, including symptom-related disease relationship edges, sign-related disease relationship edges, and examination-supported disease relationship edges; the second type is suggested knowledge relationship edges, including disease-recommended examination relationship edges, disease-recommended medication relationship edges, drug contraindication relationship edges, disease-corresponding follow-up requirements relationship edges, disease-corresponding critical illness marker relationship edges, and disease-corresponding specialist treatment relationship edges. The candidate diagnosis and treatment subgraph is extracted by performing a breadth-first traversal along the diagnostic knowledge relationship edges and suggested knowledge relationship edges with a preset number of hops, starting from all nodes in the patient element anchor node set.

[0012] Furthermore, in step 2, the set of diagnostic logical facts is composed of triples corresponding to all patient observation facts and all diagnostic knowledge relation edges in the candidate diagnosis and treatment subgraph; the head entity of the target triple is the patient instance node, the relation is the candidate diagnosis relation, and the tail entity is the disease node; each diagnostic rule in the set of diagnostic rules is represented in the form of a Horn clause, the rule body contains one or more conditional logical facts, the rule head is one conclusion logical fact, and the function of each diagnostic rule is to bridge the patient observation facts and diagnostic knowledge facts to the candidate diagnostic conclusion.

[0013] Furthermore, the recursive rule expansion and unified operation process includes: performing a unified operation on each rule head and target triple in the diagnostic rule set; calculating the cosine similarity between the head entity embedding vector of the rule head and the head entity embedding vector of the target triple, the cosine similarity between the relation embedding vector of the rule head and the relation embedding vector of the target triple, and the cosine similarity between the tail entity embedding vector of the rule head and the tail entity embedding vector of the target triple, and taking the minimum value among the three cosine similarities as the rule head matching degree; when the rule head matching degree exceeds a preset matching threshold, each conditional logic event in the rule body is... As a sub-proof target, a unified operation is performed on each sub-proof target in the set of diagnostic logical facts to calculate the unified matching degree. When the unified matching degree exceeds the preset matching threshold, the sub-proof target is successfully proved. When the unified matching degree does not exceed the preset matching threshold, the sub-proof target is used as a new target triple and the rules are recursively executed. The recursion depth does not exceed the preset maximum inference level. When all sub-proof targets are successfully proved, the minimum value between the rule header matching degree and the unified matching degree of all sub-proof targets is taken as the path evidence strength. All logical facts and diagnostic rules passed through the proof path in sequence are recorded as an ordered evidence chain according to the execution order.

[0014] Furthermore, in step 3, the types of fuzzy Petri nets include preliminary diagnosis sites, examination recommendation sites, medication advice sites, treatment advice sites, follow-up arrangement sites, and referral determination sites. The flow conditions between adjacent sites are encoded as transitions. Each transition is configured with a fuzzy activation threshold, and each site is pre-configured with an evidence loss attenuation value corresponding to the clinical importance level of the site.

[0015] Furthermore, the token flow process along the fuzzy Petri net includes: injecting the token's initial fuzzy assignment, using the comprehensive evidence strength of the disease node as the token's initial value, into the preliminary diagnostic repository of the clinical pathway corresponding to the disease node; when the token reaches each transition, comparing its current fuzzy assignment with the transition's fuzzy activation threshold; when the fuzzy assignment is not lower than the fuzzy activation threshold, the transition is activated, and the token enters the subsequent repository; when the token enters each repository, checking whether the entity set corresponding to the repository is empty; when the entity set is not empty, the token maintains its current fuzzy assignment and continues to flow; when the entity set is empty, subtracting the evidence loss attenuation value configured for the repository from the token's fuzzy assignment, the token continues to flow; wherein the entity set corresponding to each repository is obtained by querying along the suggested knowledge relationship edge in the candidate diagnosis and treatment subgraph using the disease node as the index.

[0016] Furthermore, when the token flows to the medication recommendation database, the set of recommended medication entities is used as the recommended medication plan. Simultaneously, the database queries all contraindicated entities associated with each recommended medication entity through drug contraindication relationships in the primary healthcare knowledge graph and compares them with drug allergy nodes in the patient element anchor node set. When a match is found, a medication risk warning is generated. When the token flows to the referral judgment database, a dual-condition referral judgment is executed. The first condition is that the fuzzy value currently carried by the token is lower than the preset referral trigger threshold. The second condition is that the set of critical and severe illness marker entities or the set of specialist treatment entities of the disease node are not empty. When either the first or the second condition is met, a referral recommendation is output. When neither the first nor the second condition is met, a routine treatment recommendation is output.

[0017] The intelligent auxiliary diagnosis and treatment system for common diseases in primary healthcare based on knowledge graphs of the present invention has the following beneficial effects:

[0018] It can accurately extract multiple entities such as symptoms, signs, examination indicators, and drug allergies from primary healthcare medical records. It completes entity linking through dual constraints of edit distance filtering and entity type consistency verification, effectively reducing the impact of colloquial complaints and non-standard medical expressions on the accuracy of structured extraction.

[0019] This invention employs a neural theorem prover to perform recursive rule expansion and unified operations based on embedding vector similarity on a knowledge graph. This extends the symbol-level precise matching of traditional logical reasoning to fuzzy matching in a continuous semantic space. This enables the diagnostic reasoning process to possess both the hierarchical evidence organization capabilities of logical reasoning and the semantic capacity to accommodate the diversity and hierarchical relationships of medical terminology. Furthermore, each diagnostic conclusion is accompanied by an ordered evidence chain composed of logical facts and diagnostic rules, providing clinicians with traceable and interpretable reasoning basis.

[0020] This invention explicitly separates diagnostic knowledge relation edges from suggestion knowledge relation edges. In the diagnostic reasoning stage, only diagnostic knowledge facts are used to prove whether a disease is established. In the suggestion generation stage, information on examinations, medications, follow-ups, and referrals is retrieved from suggestion knowledge facts using a defined disease node as an index. This avoids logical interference caused by non-diagnostic knowledge participating in disease judgment.

[0021] This invention further encodes clinical treatment pathways into a constraint structure with fuzzy trigger thresholds and differential evidence deficiency attenuation values ​​through fuzzy Petri nets. This enables the generation of treatment recommendations to adapt to the actual situation of incomplete and insufficient diagnostic evidence in primary healthcare scenarios. Furthermore, it achieves referral determination through a dual-condition mechanism of fuzzy assignment below the referral trigger threshold or the presence of critical illness indicators, thereby improving the level of intelligent assistance in common disease screening, standardized medication, and referral triage for primary healthcare institutions. Attached Figure Description

[0022] Figure 1 This is a schematic diagram illustrating the principle of cosine similarity unification operation in the embedding space provided in an embodiment of the present invention.

[0023] Figure 2 This is a schematic diagram of the multi-head self-attention weight matrix of the BERT full-word masking model provided in an embodiment of the present invention;

[0024] Figure 3 This is a schematic diagram of the label transition score matrix of a conditional random field provided in an embodiment of the present invention;

[0025] Figure 4 A schematic diagram of the change curve of fuzzy Petri net token fuzzy assignment along the flow of the storage area, provided for an embodiment of the present invention. Detailed Implementation

[0026] A knowledge graph-based intelligent auxiliary diagnosis and treatment system for common diseases in primary healthcare includes the following steps:

[0027] Step 1: Obtain the patient's medical record text, extract entity units from the medical record text using a pre-trained language model and sequence labeling model to form a structured medical record element set, link each entity unit to a standardized entity node in a pre-built knowledge graph of common primary diseases to obtain a patient element anchor node set, create patient instance nodes in the knowledge graph of common primary diseases and establish relationship edges with each node in the patient element anchor node set to generate a patient observation fact set, and perform subgraph traversal starting from the patient element anchor node set to extract candidate diagnosis and treatment subgraphs;

[0028] Step 2: Extract patient observation facts and diagnostic knowledge facts from the candidate diagnosis and treatment subgraph to form a set of diagnostic logical facts. Construct a target triple for each disease node. Perform recursive rule expansion and unified operation on the target triple based on the set of diagnostic rules using a neural theorem prover to obtain the comprehensive evidence strength and optimal evidence link for each disease node. Arrange the candidate disease reasoning results in descending order of comprehensive evidence strength.

[0029] Step 3: The clinical diagnosis and treatment pathway is standardized and encoded as a fuzzy Petri net. For each disease node, the associated entity set is queried along the suggested knowledge relationship edge. The token is driven to flow along the fuzzy Petri net with the comprehensive evidence strength as the initial fuzzy assignment. Based on the fuzzy assignment of each library and the associated entity set, recommended examination items, recommended medication plans, medication risk warnings, follow-up suggestions and referral suggestions are output. The results are then summarized to generate intelligent assisted diagnosis and treatment results.

[0030] In the context of auxiliary diagnosis and treatment of common diseases in primary healthcare settings, patients' clinical information is typically recorded in medical record texts in natural language, including chief complaint texts, past medical history texts, and basic examination results texts. The chief complaint text records the main symptoms and their duration as stated by the patient at the time of consultation, such as "recurrent cough with sputum for 2 weeks, fever for 3 days." The past medical history text records the patient's previous illnesses, surgical history, long-term medication use, and drug allergy information, such as "hypertension for 5 years, long-term oral amlodipine, penicillin allergy." The basic examination results text records routine examination data completed in primary healthcare institutions, such as "white blood cell count 12.5 x 10^9 per liter, C-reactive protein 28 mg / L, chest X-ray showing patchy shadows in the right lower lung." These three types of medical record texts constitute the original input of this system. After acquiring these texts, the system first needs to accurately identify and extract various medical entities, and then establish correspondences between these entities and standardized nodes in a knowledge graph, providing structured input evidence for subsequent diagnostic reasoning.

[0031] For the preprocessing of medical record text, the system performs character-level segmentation on each acquired medical record text. Unlike English text, Chinese medical record text lacks natural spaces separating words; therefore, using individual Chinese characters as the smallest segmentation unit avoids word segmentation ambiguity interfering with subsequent entity recognition. Specifically, each medical record text is split into a character sequence composed of individual Chinese characters, numbers, punctuation marks, and English letters. A classification tag is inserted at the beginning of the character sequence, and a separator tag is inserted at the end. The classification tag provides a global semantic convergence point for the entire input sequence; in the subsequent multi-layer processing of the Transformer encoder, the hidden state vector corresponding to the classification tag can aggregate the global contextual information of the entire sequence. The separator tag explicitly indicates the boundary termination position of the current input sequence to the model. After the above processing, the input tag sequence is obtained. Taking the chief complaint "recurrent cough with phlegm for 2 weeks" as an example, its input tag sequence is: [classification tag, recurrent, cough, cough, accompanied, cough, phlegm, 2, weeks, separator tag], which contains a total of 11 tags.

[0032] The input labeled sequence is fed into the BERT full-word masking pre-training model for semantic encoding. The reason for choosing the BERT full-word masking pre-training model instead of the standard BERT model is that the standard BERT performs masking operations on Chinese text at the individual character level during pre-training. This leads to the model potentially masking only a portion of the characters in a multi-character word while retaining the rest. This allows the model to easily predict the masked characters from surrounding unmasked characters of the same word, thus failing to fully learn word-level semantic representations. In contrast, the BERT full-word masking pre-training model masks all characters belonging to the same word simultaneously during pre-training, forcing the model to rely on information from other words in the context to predict the complete masked word, thereby learning more accurate word-level semantic features. In medical record texts, many key medical terms consist of multiple characters, such as "bronchitis," "amlodipine," and "C-reactive protein." The full-word masking mechanism enables the model to form a more complete and accurate semantic representation of these multi-character medical terms, thereby improving the accuracy of subsequent entity extraction.

[0033] The internal structure of the BERT full-word mask pre-trained model consists of multiple stacked Transformer encoders. In one implementation, the model contains 12 Transformer encoders, each with a hidden state dimension of 768 and 12 attention heads. In another optional implementation, when the computing resources of primary healthcare institutions are limited, a lightweight configuration with 6 Transformer encoders, a hidden state dimension of 384, and 6 attention heads can be used. After the input token sequence enters the model, it first passes through an embedding layer to convert each token into an initial embedding vector. The output of the embedding layer is obtained by element-wise addition of three parts: token embedding, position embedding, and fragment embedding. Token embedding maps each token to a vector representation of a fixed dimension. Position embedding assigns different positional information to tokens at different positions in the sequence so that the model can distinguish the order of tokens in the sequence. Fragment embedding is used to distinguish different input fragments.

[0034] The vector sequence output from the embedding layer is then processed layer by layer by the Transformer encoders. Each Transformer encoder performs multi-head self-attention computation on each tag, the core purpose of which is to enable each tag in the sequence to dynamically aggregate the contextual information of the entire sequence based on its relevance to other tags. Specifically, the hidden state vector of the current tag is transformed into a query vector, a key vector, and a value vector through three different linear transformations. The query vector represents "what information the current tag needs to obtain," the key vector represents "what information the current tag can provide," and the value vector represents "the actual information content carried by the current tag." For a given tag in the sequence, its query vector is multiplied by the key vectors of all tags in the sequence, and the resulting inner product reflects the semantic relevance between the current tag and all other tags. To keep the range of the inner product values ​​stable, each inner product value is divided by the square root of the query vector dimension as a scaling factor to obtain a scaled attention score. In an example configuration with 12 attention heads and a 768-dimensional hidden state dimension, each attention head processes a dimension of... ,in The dimensions of the query vector and key vector for each attention head, where the scaling factor is... The scaled attention scores are normalized using the softmax function. The softmax function converts all attention scores into attention coefficients, each ranging from 0 to 1 and summing to 1. A larger attention coefficient indicates a greater semantic contribution of the corresponding tag to the current tag. The normalized attention coefficients are then weighted and summed with the corresponding tag value vectors to obtain the output vector of a single attention head. The output vectors of all 12 attention heads are concatenated along their vector dimensions into a single 768-dimensional concatenated vector. This concatenated vector is then mapped back to 768-dimensional space using a linear transformation layer, yielding the output of the multi-head self-attention computation.

[0035] refer to Figure 2 , Figure 2 Taking the input token sequence of the chief complaint "recurrent cough with phlegm for 2 weeks" as an example, the attention coefficient matrix obtained after multi-head self-attention computation is shown. The rows of the matrix correspond to the token positions of the query vector, and the columns correspond to the token positions of the key vector. Each element in the matrix represents the attention coefficient value of the row token to the column token. The attention coefficients are normalized using the softmax function, and the sum of all elements in each row is 1. The larger the coefficient value, the higher the degree of information dependence of the row token on the column token during semantic encoding. Figure 2The following characteristics can be observed: the attention coefficients at diagonal positions are generally high, indicating that each label maintains strong attention to its own position; the attention coefficient between the labels "cough" (column 4) and "spit" (column 5) is significantly higher than that of other off-diagonal positions, indicating that the multi-head self-attention mechanism captures the internal correlation of "cough" as a complete symptom entity during the encoding process. This correlation is precisely the advantage brought by BERT's full-word masking pre-training strategy. Full-word masking masks all characters belonging to the same word simultaneously during the pre-training stage, forcing the model to learn the strong dependencies between characters within the word. Similarly, the labels "cough" (column 7) and "phlegm" (column 8) also show a high attention coefficient, reflecting the intra-word correlation of the symptom entity "cough and phlegm". The classification label [CLS] maintains a certain degree of attention coefficient for all label positions, indicating that the classification label aggregates the global contextual information of the entire sequence. The high attention coefficient between the label "2" and the label "week" reflects the semantic correlation between time values ​​and time units. Figure 2 The gray level of the matrix is ​​directly proportional to the magnitude of the attention coefficient.

[0036] The output of the multi-head self-attention computation is residually concatenated with the hidden state vector preceding the input layer, followed by layer normalization. The residual concatenation adds the output of the multi-head self-attention computation element-wise to the input of the current layer, mitigating the vanishing gradient problem in deep networks and preserving low-level feature information. Layer normalization normalizes the mean and variance of the vector after residual concatenation along the feature dimensions, stabilizing the numerical distribution of each dimension and accelerating model training convergence. The vector after residual concatenation and layer normalization enters the feedforward network, which consists of two linear transformations and one GELU activation function. The first linear transformation maps the 768-dimensional vector to a 3072-dimensional intermediate space; the GELU activation function introduces non-linear transformation capability; and the second linear transformation maps the 3072-dimensional vector back to the 768-dimensional space. The output of the feedforward network is again residually concatenated with its input and layer normalized to obtain the final hidden state vector of the current Transformer encoder layer. The above process is repeated sequentially in all 12 layers of the Transformer encoder, and the hidden state vector of all the tags output by the final layer is the context semantic encoding result of the input tag sequence.

[0037] The hidden state vectors of all labels from the final layer are input into the Conditional Random Field (CRF) labeling layer. Compared to classifying each label independently, the CRF labeling layer has the ability to model the global dependencies of the label sequence. In medical entity recognition tasks, there are explicit transition constraints between labels. For example, the label "internal symptoms" can only appear after the label "symptom onset," but not directly after the label "sign onset." The CRF labeling layer maintains a label transition matrix, where the row and column dimensions are equal to the total number of label categories. Each element in the matrix represents the transition score from one label to another. In this system, there are nine label categories: symptom onset, internal symptoms, sign onset, internal sign, examination indicator onset, examination indicator internal, drug allergy onset, drug allergy internal, and non-entity. Therefore, the label transition matrix has a dimension of 9 rows and 9 columns. This two-level tagging system, consisting of a start tag and an inner tag, is used to accurately locate the boundaries of multi-character entities. The start tag marks the first character of the entity, and the inner tag marks all subsequent characters starting from the second character. When a non-entity tag or another type of start tag is encountered, the boundary of the current entity ends.

[0038] The scoring process of the Conditional Random Field (CRF) labeling layer for the label sequence is as follows: For a candidate label sequence corresponding to the input label sequence, its total score is obtained by adding two parts. The first part is the emission score of each label obtained by linearly mapping the hidden state vector output by the final layer of the BERT full-word mask pre-trained model at each position. The emission score reflects the model's tendency to independently identify each position as a label. The second part is the sum of the transition scores of adjacent labels in the label transition matrix. The transition score reflects the reasonableness of the global combination between adjacent labels. In the decoding stage of the CRF labeling layer, the Viterbi decoding algorithm is used to search for the label sequence with the highest joint probability among all possible candidate label sequences. The Viterbi decoding algorithm is an exact search algorithm based on dynamic programming. It starts from the first position of the sequence and advances position by position. At each position, it records the optimal path to each label and the corresponding cumulative highest score. When it advances to the end of the sequence, it backtracks from the label corresponding to the cumulative highest score to recover the globally optimal complete label sequence. The tag sequence output by the Viterbi decoding algorithm is the tag sequence with the highest joint probability, and each tag in the sequence is assigned a specific tag.

[0039] refer to Figure 3 , Figure 3This demonstrates the label transition matrix maintained within the labeling layer of a Conditional Random Field (CRF). The rows of the matrix represent the source label, and the columns represent the target label. The matrix has a 9x9 dimension, corresponding to 9 label categories: symptom onset, symptom internal, sign onset, sign internal, examination indicator onset, examination indicator internal, drug allergy onset, drug allergy internal, and non-entity. Each element in the matrix represents the transition score from the source label to the target label. A higher transition score indicates that the CRF model considers the transition path more reasonable in the labeling sequence; a negative transition score indicates that the transition path should almost never occur. Figure 3 The following patterns can be observed: The transfer score from each starting label to its corresponding internal label is a high positive value. For example, the transfer score from symptom starting label to symptom internal label is 2.8, from sign starting label to sign internal label is 2.7, from examination indicator starting label to examination indicator internal label is 2.9, and from drug allergy starting label to drug allergy internal label is 2.6. These high positive values ​​ensure that the Viterbi decoding algorithm can correctly label consecutive characters after the starting label as internal labels of the same type when labeling multi-character entities. The transfer score between internal labels of different types is a negative 3.0, such as from symptom internal label to sign internal label, or from examination indicator internal label to drug allergy internal label. These strong negative values ​​constitute a hard constraint, making it almost impossible for internal labels of different types of entities to transfer directly, thus preventing confusion between the boundaries of different types of entities. The transfer scores from non-entity labels to all types of starting labels are positive values, indicating that any type of new entity can be reasonably started after a non-entity label. The transfer score from non-entity labels to all types of internal labels is a negative 3.0, indicating that internal labels cannot appear directly without a starting label. The aforementioned distribution pattern of the transition scores ensures that the label sequence output by the conditional random field labeling layer satisfies the structural constraints of medical entity labeling at the global level.

[0040] The output label sequence is merged into entity units: starting from the beginning of the sequence, when a certain type of starting label is encountered, the corresponding label is used as the first character of the new entity. The scanning continues, appending all subsequent labels with the same type of internal label to the current entity until a non-entity label or a different type of starting label is encountered, at which point the current entity terminates, thus merging into a complete entity unit. After performing the above process on all three medical record texts, all obtained entity units are summarized to form a structured medical record element set. Taking the aforementioned chief complaint text as an example, after label sequence output and entity unit merging, the entity units "cough" (label category: symptom), "sputum" (label category: symptom), and "fever" (label category: symptom) are obtained. Taking the aforementioned past medical history text as an example, the entity units "hypertension" (label category: symptom), "amlodipine" (label category: drug allergy subcategory, which will be classified into a relevant category based on contextual semantics in subsequent processing), and "penicillin allergy" (label category: drug allergy) are obtained. Taking the aforementioned basic examination results text as an example, we can obtain the entity units "white blood cell count 12.5 x 10^9 per liter" (label category: examination indicator), "C-reactive protein 28 mg per liter" (label category: examination indicator), and "patchy shadow in the right lower lung" (label category: examination indicator).

[0041] After obtaining the structured medical record element set, each entity unit needs to be linked to the corresponding standardized entity node in the primary healthcare common disease knowledge graph. The primary healthcare common disease knowledge graph is a pre-constructed medical domain knowledge graph containing standardized disease nodes, symptom nodes, sign nodes, examination indicator nodes, drug nodes, treatment nodes, and other related entity nodes. Each node has one standardized entity name and one entity type tag. The entity name index in the primary healthcare common disease knowledge graph is a retrieval index structure built with all standardized entity names as terms, used to support fast text matching queries.

[0042] The specific process of entity linking is as follows. For each entity unit in the structured medical record element set, the character-level edit distance between the string of the entity unit and each standardized entity name is calculated in the entity name index of the primary healthcare common disease knowledge graph. The character-level edit distance refers to the minimum number of single-character edit operations required to convert one string into another. Allowed edit operations include inserting one character, deleting one character, and replacing one character. The smaller the edit distance value, the closer the two strings are in literal form. All candidate standardized entity nodes whose character-level edit distance with the entity unit does not exceed a preset distance threshold are retrieved to form a candidate node set. In one implementation, the preset distance threshold is set to 2, that is, a difference of up to 2 single-character edit operations is allowed. In another optional implementation, when the average character length of the standardized entity names in the primary healthcare common disease knowledge graph is short, the preset distance threshold can be set to 1 to reduce the risk of mismatch.

[0043] Filtering candidate nodes solely based on edit distance may introduce cross-type mislinks. For example, the entity unit "enlarged liver" (a vital sign) might match "hepatitis" (a disease) due to a small edit distance. To eliminate such cross-type mislinks, for each candidate standardized entity node in the candidate node set, it is further verified whether its entity type label in the primary healthcare knowledge graph and the label category output by the entity unit in the conditional random field annotation layer belong to the same preset type mapping group. The preset type mapping group is a pre-established correspondence table between label categories and entity type labels. For example, the symptom start and symptom internal label correspond to the symptom category entity type label, the vital sign start and vital sign internal label correspond to the vital sign category entity type label, the examination indicator start and examination indicator internal label correspond to the examination indicator category entity type label, and the drug allergy start and drug allergy internal label correspond to the drug category entity type label. When the entity type label of a candidate standardized entity node and the label category of the entity unit are not in the same mapping group, the candidate standardized entity node is removed from the candidate node set. After retaining the candidate standardized entity nodes with consistent types, the one with the smallest edit distance is selected as the anchor node for that entity unit. When multiple candidate standardized entity nodes have the same and minimum edit distance, the node with the most relational edges in the primary care medical knowledge graph is selected as the anchor node. If an entity unit fails to find any candidate standardized entity nodes that meet the edit distance threshold and type consistency requirements, that entity unit will not participate in the subsequent anchoring process. All successfully anchored standardized entity nodes constitute the patient element anchor node set.

[0044] After completing the entity linking, a patient instance node is created in the primary healthcare knowledge graph for common diseases. The patient instance node is a virtual node temporarily created for the currently visiting patient. Its function is to unify scattered patient observation information onto a single node, allowing subsequent diagnostic reasoning to access all patient evidence information through this node as a unified entry point. Relationship edges are established from the patient instance node to each node in the patient element anchor node set: a symptom-related edge is established to each symptom-related node, a sign-related edge is established to each physical sign-related node, an examination-related edge is established to each examination-related node, and an allergy-related edge is established to each drug allergy-related node. All the relationship edges established from the patient instance node and their connected anchor nodes together constitute the patient observation fact set. Each fact in the patient observation fact set is represented in the form of a triple, such as (patient instance node, symptom, cough), (patient instance node, examination results, elevated C-reactive protein), (patient instance node, allergy, penicillin).

[0045] The pre-stored relationship edges in the knowledge graph of common diseases at the grassroots level are divided into two categories. Category 1 consists of diagnostic knowledge relationship edges, including those indicating disease based on symptoms, those indicating disease based on physical signs, and those supporting disease based on examination findings. These three types of edges record diagnostic knowledge pointing from clinical manifestations to the disease. For example, (cough, symptom indicating disease, acute bronchitis), (elevated white blood cell count, examination supporting disease, bacterial pneumonia). Category 2 consists of suggestive knowledge relationship edges, including those recommending examinations, recommending medications, contraindications, follow-up requirements, critical illness markers, and specialist treatment. These six types of edges record suggestive knowledge pointing from the disease to treatment actions. For example, (bacterial pneumonia, recommended medication, amoxicillin), (amoxicillin, contraindications, penicillin allergy), (severe pneumonia, critical illness marker, blood oxygen saturation below 90%). The purpose of clearly distinguishing between diagnostic knowledge relation edges and advisory knowledge relation edges is that: in the diagnostic reasoning stage, only diagnostic knowledge relation edges are needed to prove whether a certain disease exists, and medication recommendations or contraindications should not be used as evidence of whether a disease exists. This separation ensures the logical purity of the diagnostic reasoning process; while advisory knowledge relation edges play a role in the path constraint stage, providing suggestions on examination, medication, follow-up and referral for identified candidate diseases.

[0046] Starting with all nodes in the patient element anchor node set, a breadth-first traversal with a preset number of hops is performed along the diagnostic knowledge relationship edges and suggested knowledge relationship edges in the primary healthcare knowledge graph for common diseases, extracting candidate treatment subgraphs. In one implementation, the preset number of hops is set to 3. The first hop is from the symptom or examination indicator node to the disease node, the second hop is from the disease node to the recommended drug or recommended examination node, and the third hop is from the drug node to the contraindicated entity node, covering the complete path from patient presentation to disease diagnosis, treatment suggestions, and safety verification. In another optional implementation, when the primary healthcare knowledge graph for common diseases is large and the relationship edge density is high, the preset number of hops can be set to 2 to control the size of the candidate treatment subgraph. All nodes reached by the breadth-first traversal and all relationship edges traversed, along with patient instance nodes and the patient observation fact set, are extracted to form the candidate treatment subgraph. The candidate treatment subgraph is a local subgraph in the original primary healthcare knowledge graph for common diseases that is related to the current patient's condition, providing a precisely focused reasoning space for the subsequent neural theorem prover.

[0047] After completing the extraction of medical record elements and anchoring of the knowledge graph, the system enters the diagnostic reasoning stage based on the neural theorem prover. The core task of this stage is to screen out the most likely candidate diseases for the current patient from the candidate diagnosis and treatment subgraph, and provide a traceable reasoning evidence path for each candidate disease.

[0048] The candidate treatment subgraph extracts all patient observation facts and all triples corresponding to diagnostic knowledge relation edges, which together constitute the diagnostic logical fact set. Patient observation facts are the triples corresponding to all relation edges established from the patient instance node in the previous step, such as (patient instance node, symptoms, cough) and (patient instance node, examination results, elevated C-reactive protein). Triples corresponding to diagnostic knowledge relation edges are all triples belonging to the diagnostic knowledge relation edge category in the candidate treatment subgraph, including triples corresponding to symptom-indicating-disease relation edges, sign-indicating-disease relation edges, and examination-supporting-disease relation edges, such as (cough, symptoms indicating disease, acute bronchitis) and (elevated C-reactive protein, examination supporting disease, bacterial pneumonia). Merging these two types of triples yields the diagnostic logical fact set. The reason for including only these two types of facts in the set of diagnostic logical facts and not in the triplet corresponding to the suggested knowledge relation edge is that the goal of the diagnostic reasoning stage is to determine which disease the patient may have. This judgment should and should only be based on the clinical evidence shown by the patient and the diagnostic knowledge between the clinical manifestations and the disease. Suggestive knowledge such as medication recommendations, follow-up requirements, and contraindications is irrelevant to the judgment of whether the disease is established. Mixing them into diagnostic reasoning will introduce logically irrelevant interference signals.

[0049] A pre-defined set of diagnostic rules for common diseases at the primary care level is provided. Each diagnostic rule in the set is represented using a Horn clause. A Horn clause is a restricted clause form in first-order logic. Each Horn clause consists of a rule header and a rule body containing several conditional logical facts. Its semantic meaning is "when all the conditional logical facts in the rule body are true simultaneously, the conclusion logical fact expressed in the rule header is true." In this system, each diagnostic rule serves to bridge the patient's observed facts with diagnostic knowledge facts to the candidate diagnostic conclusion. Taking a specific diagnostic rule as an example: the rule header is (patient instance node, candidate diagnosis, bacterial pneumonia), and the rule body contains three conditional logical facts: (patient instance node, symptoms, cough), (patient instance node, examination shows, elevated C-reactive protein), and (elevated C-reactive protein, examination supports the disease, bacterial pneumonia). This rule means: when a patient exhibits cough symptoms, and examination shows elevated C-reactive protein, and the elevated C-reactive protein supports the diagnosis of bacterial pneumonia in medical knowledge, a candidate diagnostic conclusion of suspected bacterial pneumonia can be drawn. The rules in the diagnostic rule set are compiled by medical experts based on their clinical diagnostic experience and treatment guidelines for common diseases at the grassroots level. In one implementation, the diagnostic rule set contains 200 to 500 diagnostic rules covering common diseases at the grassroots level. In another optional implementation, for more detailed diagnostic scenarios of specific specialty diseases, the diagnostic rule set can be further expanded to more than 800 rules.

[0050] Each entity in the candidate diagnosis and treatment subgraph is assigned a fixed-dimensional embedding vector, and each relation is assigned a vector of the same dimension. The embedding vector is a numerical representation that maps discrete entities or relations to a continuous vector space, ensuring that semantically similar entities are grouped close together and semantically dissimilar entities are grouped far apart. In one implementation, the dimension of the embedding vector is set to 128. In another optional implementation, when the number of entities in the candidate diagnosis and treatment subgraph is large and the semantic distribution is complex, the dimension of the embedding vector can be set to 256 to provide a richer representation space. The initial values ​​of the embedding vectors can be obtained by pre-performing knowledge graph embedding training on a basic-level common disease medical knowledge graph. During training, existing triples in the knowledge graph are used as positive samples, and triples generated by randomly replacing the head or tail entity are used as negative samples. Optimization is performed to make the vector operation results between the head entity, relation, and tail entity in the positive sample triples as consistent as possible, while making the vector operation results of the negative sample triples as inconsistent as possible, thereby obtaining the embedding vector for each entity and each relation. The patient instance node, as a newly created temporary node during the current consultation, has its embedding vector obtained by taking the element-wise arithmetic mean of the embedding vectors of all anchor nodes in the patient element anchor node set. This method allows the vector representation of the patient instance node to aggregate the semantic information of all clinical evidence for the current patient. The candidate diagnostic relation is a relation type specifically defined for this system, and its embedding vector is also obtained in advance during the knowledge graph embedding training phase.

[0051] For each disease node in the candidate diagnosis and treatment subgraph, a target triple is constructed. The head entity of the target triple is the patient instance node, the relation is the candidate diagnosis relation, and the tail entity is the disease node currently being evaluated. The semantic meaning of the target triple is "the current patient is suspected of having a certain disease," and whether it is true needs to be determined by the neural theorem prover searching for supporting evidence in the set of diagnostic logical facts and the set of diagnostic rules. Assuming that the candidate diagnosis and treatment subgraph contains 5 disease nodes, namely acute bronchitis, bacterial pneumonia, upper respiratory tract infection, pulmonary tuberculosis, and bronchial asthma, the system will construct 5 target triples for each disease and prove them one by one.

[0052] The neural theorem prover performs a recursive proof process for each target triple. Traditional logic theorem provers require strict symbolic matching between triples when performing the unification operation; that is, the head entity, relation, and tail entity must be completely identical for unification to succeed. This strict matching method has significant limitations when dealing with medical knowledge graphs, because in primary healthcare scenarios, the same clinical concept may have different expressions, hierarchical differences, or synonymous relationships, resulting in semantically matching triples that are not completely identical at the symbolic level. The neural theorem prover replaces the traditional symbolic-level exact matching with continuous similarity calculation based on embedding vectors, thereby introducing fuzzy matching capabilities at the semantic level while preserving the logical reasoning structure, enabling the reasoning process to accommodate the diversity and hierarchical relationships of medical terminology.

[0053] The specific execution method of the recursive proof process is as follows. Taking a target triple as the target to be proved, each diagnostic rule in the diagnostic rule set is expanded one by one. During rule expansion, the rule header of the diagnostic rule and the target triple are first subjected to a unified operation. The unified operation process is as follows: calculate the cosine similarity between the head entity embedding vector of the rule header and the head entity embedding vector of the target triple, the cosine similarity between the relation embedding vector of the rule header and the relation embedding vector of the target triple, and the cosine similarity between the tail entity embedding vector of the rule header and the tail entity embedding vector of the target triple. and cosine similarity equal to vector with vector The inner product divided by the vector Magnitude and vector The product of the moduli, where The first embedding vector to be compared. The second embedding vector to be compared. The value of takes the range from -1 to +1. The closer the value is to +1, the more consistent the directions of the two vectors are, meaning they are semantically similar. The minimum value among the head entity cosine similarity, relation cosine similarity, and tail entity cosine similarity is taken as the rule head matching degree. The reason for taking the minimum value instead of the average value is that, in the context of logical reasoning, the unified operation requires that all three positions of the triple satisfy the matching condition. Insufficient matching degree at any one position means that there is a weak link in the overall matching between the rule head and the target triple. The strategy of taking the minimum value follows the barrel principle, that is, the overall matching strength is determined by the weakest position. This strict strategy can avoid mismatches caused by high similarity at some positions masking low similarity at other positions.

[0054] refer to Figure 1 , Figure 1Six vector rays are drawn with the origin of the embedding space as the common starting point. Three solid rays represent the head entity embedding vector, relation embedding vector, and tail entity embedding vector of the target triple, respectively. Three dashed rays represent the head entity embedding vector, relation embedding vector, and tail entity embedding vector of the rule head of the diagnostic rule, respectively. The head entity of the target triple is the patient instance node, the relation is the candidate diagnostic relation, and the tail entity is the disease node to be evaluated. The head entity, relation, and tail entity of the rule head correspond to the various components in the diagnostic rule conclusion. An arc is drawn between each pair of solid and dashed rays at the same position, with the cosine similarity value between the vectors labeled next to the arc. The cosine similarity between the head entity positions is 0.93, between the relational positions is 0.89, and between the tail entity positions is 0.86. Cosine similarity is calculated as a vector... with vector The inner product of the two vectors divided by the product of their magnitudes, ranging from -1 to positive 1, indicates that the two vectors are more consistent in direction within the embedding space, meaning they are semantically closer. The final result of the unification operation is the minimum cosine similarity among the three positions, which is taken as the unification matching degree. In other words, the unification matching degree equals the minimum of the head entity similarity, relation similarity, and tail entity similarity. Figure 1 In the example shown, the uniform matching score is 0.86, corresponding to the cosine similarity of the tail entity position. The strategy of taking the minimum value ensures that the uniform matching score is determined by the position with the weakest matching degree, avoiding the high similarity of some positions from masking the low similarity of other positions. When the uniform matching score exceeds the preset matching threshold, the unification operation between the rule head and the target triple is successful, and the diagnostic rule can proceed to the subsequent rule expansion process. Figure 1 The diagram also uses a light gray area to indicate the distribution range of all vector rays, and the legend in the diagram distinguishes the line type difference between the target triplet embedding vector and the regular head embedding vector.

[0055] When the rule head match exceeds a preset matching threshold, it indicates that the conclusion of the diagnostic rule is semantically close enough to the current target triple, and an attempt can be made to indirectly prove the target by proving all the conditions in the rule body. In one implementation, the preset matching threshold is set to 0.65. In another optional implementation, for scenarios requiring higher diagnostic strictness, the preset matching threshold can be increased to 0.75. In this case, rule expansion is only allowed when the semantic match is even closer, thereby reducing the possibility of misinference. When the rule head match does not exceed the preset matching threshold, the diagnostic rule is skipped, and the next rule in the diagnostic rule set is evaluated.

[0056] When the matching degree of the rule head exceeds the preset matching threshold, each conditional logical fact in the rule body of the diagnostic rule is taken as a sub-proof target. For each sub-proof target, a unified operation is performed on each item in the set of diagnostic logical facts to calculate the unified matching degree. The unified operation process between the sub-proof target and the diagnostic logical facts is the same as the unified operation process between the rule head and the target triple, calculating the cosine similarity of the head entity, relation, and tail entity and taking the minimum value. When the unified matching degree exceeds the preset matching threshold, it indicates that there is a fact in the set of diagnostic logical facts that is semantically sufficiently close to the sub-proof target, and the sub-proof target is successfully proved. Taking the aforementioned diagnostic rule as an example, the first conditional logical fact in its rule body is (patient instance node, symptoms, cough). There is exactly a triple (patient instance node, symptoms, cough) in the set of diagnostic logical facts. The head entity, relation, and tail entity of the two are completely consistent or highly similar in the embedding vector space. Therefore, the unified matching degree is close to positive 1, exceeding the preset matching threshold, and the sub-proof target is successfully proved.

[0057] When the uniform matching degree does not exceed the preset matching threshold, it indicates that there is no fact in the diagnostic logic fact set that can directly match the sub-proof target. At this time, the sub-proof target is taken as a new target triple, and the above rule expansion process is recursively executed. That is, the rule head that can match the new target triple is searched one by one from the diagnostic rule set, and then further decomposed into lower-level sub-proof targets. This recursive mechanism enables the neural theorem prover to have multi-hop reasoning ability, and can delve deeper along the relation chain in the knowledge graph, decomposing complex diagnostic reasoning tasks into multiple simple fact matches that can be directly verified in the diagnostic logic fact set. The recursion depth does not exceed the preset maximum reasoning level. In one implementation, the preset maximum reasoning level is set to 3. In another optional implementation, when the diagnostic rule set contains a long reasoning chain, the preset maximum reasoning level can be set to 5. The purpose of setting the upper limit of recursion depth is to prevent the reasoning process from recursively recursing in the loop rules, while controlling the computational overhead, because the number of rule expansion branches that need to be evaluated increases exponentially with each increase in recursion depth.

[0058] When all sub-proof objectives of a diagnostic rule are successfully proved, the rule expansion path constitutes a complete proof path from the set of diagnostic logical facts to the target triple. The path evidence strength is calculated by combining the rule head matching degree with the unified matching degree of all sub-proof objectives, and taking the minimum value as the path evidence strength. Path evidence strength reflects the degree of matching of the weakest link in the entire proof path; it means that each step in the reasoning process leading to the diagnostic conclusion needs to be sufficiently reliable, and the overall reliability depends on the least reliable step. Simultaneously, all logical facts and diagnostic rules traversed by the proof path are recorded in the order of execution as an ordered evidence chain. An ordered evidence chain is an ordered sequence, where each element is a logical fact or a diagnostic rule. These elements are arranged according to the actual execution order in the proof process, allowing subsequent steps to trace back the reasoning basis of each diagnostic conclusion, providing clinicians with an interpretable diagnostic reasoning process.

[0059] For a single disease node, there may be multiple different diagnostic rule development paths that can successfully prove its corresponding target triple. For each disease node, all proof paths with evidence strength exceeding a preset matching threshold are collected. The path with the highest evidence strength is taken as the overall evidence strength of that disease node, and the corresponding ordered evidence link is taken as the optimal evidence link. The proof path with the highest evidence strength is chosen instead of the average or sum of all paths because, in the context of diagnostic reasoning, a single strong proof path is sufficient to support the rationality of the diagnostic conclusion, while multiple weaker paths cannot compensate for logical weaknesses. The overall evidence strength ranges from the preset matching threshold to +1; a higher value indicates more sufficient evidence for the diagnostic reasoning of that disease node. If no proof path has evidence strength exceeding the preset matching threshold for a disease node, that disease node is not included in the subsequent ranking.

[0060] All disease nodes with successfully proven paths are sorted in descending order according to the strength of their comprehensive evidence, with disease nodes having higher comprehensive evidence strength appearing first. The top-ranked disease nodes, along with their comprehensive evidence strength and optimal evidence link, constitute the candidate disease reasoning result. In one implementation, the preset number is set to 5, retaining the top 5 disease nodes in terms of comprehensive evidence strength. In another optional implementation, when clinicians in primary healthcare institutions request more differential diagnostic references, the preset number can be set to 8 or 10. The candidate disease reasoning result is an ordered list, with each entry containing three pieces of information: disease node, comprehensive evidence strength, and optimal evidence link.

[0061] After completing the diagnostic reasoning, the system enters the stage of generating clinical pathway constraints and treatment suggestions based on fuzzy Petri nets. The core purpose of this stage is that although the candidate disease reasoning results provide a possible disease ranking, the diagnosis and treatment behavior of primary healthcare institutions must follow established clinical pathway norms. Different diseases have corresponding normative constraints in terms of examination recommendations, medication selection, treatment plans, follow-up arrangements, and referral decisions. Therefore, the system does not directly convert the diagnostic reasoning results into treatment suggestions, but rather allows the diagnostic confidence level of each candidate disease to be verified and adjusted step by step within the constraint framework of clinical pathway norms, ultimately outputting only standardized treatment suggestions that have passed pathway verification.

[0062] The pre-defined clinical diagnosis and treatment pathways for common primary care diseases are standardized and encoded as fuzzy Petri nets. Petri nets are a formal modeling tool used to describe concurrent systems and process control, consisting of three types of elements: places, transitions, and directed arcs. Places represent states or links in the system, transitions represent the conditions for transitions between states, and directed arcs connect places and transitions to describe the direction of flow. In classic Petri nets, transition activation uses strict Boolean criteria: activation occurs if the condition is met, and interruption occurs if the condition is not met. Fuzzy Petri nets introduce the concept of fuzzy values, allowing tokens to carry a fuzzy assignment between 0 and 1 representing the degree of confidence in the current state. The activation condition for transitions is also extended from strict Boolean criteria to fuzzy threshold criteria: a transition can only be activated if the fuzzy assignment of the token is not lower than the fuzzy activation threshold configured for the transition. This fuzzification extension enables the model to handle situations where diagnostic evidence is not entirely sufficient: in primary healthcare settings, patients often have incomplete examinations and varying degrees of diagnostic evidence. Fuzzy Petri nets allow the flow of clinical pathways to be driven by different levels of confidence, rather than simply inputting diagnostic results into the pathway in an either-or manner.

[0063] During the coding process, each diagnostic and treatment step is coded as a repository. Repository types include preliminary diagnosis repository, examination recommendation repository, medication recommendation repository, treatment recommendation repository, follow-up arrangement repository, and referral determination repository. Taking bacterial pneumonia as an example, its corresponding clinical diagnostic and treatment pathway includes the following steps in sequence: preliminary diagnosis (confirming suspected bacterial pneumonia), examination recommendation (recommending sputum culture and blood routine re-examination), medication recommendation (recommending the use of antibacterial drugs), treatment recommendation (antipyretic treatment and airway management), follow-up arrangement (re-examining blood routine and chest X-ray 3 days after medication), and referral determination (assessing whether referral to a higher-level hospital is necessary). These six steps are coded as six repositories. The transfer conditions between adjacent repositories are coded as one transition. For example, one transition is configured between the preliminary diagnosis repository and the examination recommendation repository, and one transition is configured between the examination recommendation repository and the medication recommendation repository, and so on. Each transition is configured with a fuzzy activation threshold, the value of which reflects the required sufficiency of evidence for the corresponding transfer step. In one implementation, the fuzzy trigger threshold for the transition from the initial diagnosis database to the recommended testing database is set to 0.30, because even if the diagnostic evidence is insufficient, further testing should be recommended to gather more evidence; the fuzzy trigger threshold for the transition from the recommended testing database to the medication recommendation database is set to 0.50, because medication use requires relatively clear diagnostic support; the fuzzy trigger threshold for the transition from the medication recommendation database to the treatment recommendation database is set to 0.45; the fuzzy trigger threshold for the transition from the treatment recommendation database to the follow-up arrangement database is set to 0.40; and the fuzzy trigger threshold for the transition from the follow-up arrangement database to the referral decision database is set to 0.30. The different fuzzy trigger thresholds for different transitions reflect the differentiated requirements for the sufficiency of evidence at each stage of the clinical pathway.

[0064] Each repository is pre-configured with an evidence deficiency attenuation value corresponding to its clinical importance level. The evidence deficiency attenuation value is a value between 0 and 1. When a token flows to a repository, if the entity set corresponding to that repository is empty (i.e., there is no relevant suggestion information for that step in the knowledge graph), the token's fuzzy assignment will be reduced by the evidence deficiency attenuation value for that repository. A larger evidence deficiency attenuation value indicates a more severe impact of the lack of evidence at that step on the overall diagnostic confidence. In one implementation, the evidence deficiency attenuation value for the recommended examination repository is set to 0.15, because the lack of recommended examination information means that further confirmation of the diagnosis is impossible, significantly impacting subsequent treatment decisions; the evidence deficiency attenuation value for the medication suggestion repository is set to 0.12; the evidence deficiency attenuation value for the treatment suggestion repository is set to 0.08; and the evidence deficiency attenuation value for the follow-up arrangement repository is set to 0.05, because the lack of follow-up information has a relatively small impact on the urgency of the current treatment. In another alternative implementation, different evidence loss attenuation values ​​can be configured for the same library type for different diseases. For example, the evidence loss attenuation value for recommended libraries for cardiovascular diseases can be set to 0.20, which is higher than 0.15 for respiratory diseases, because cardiovascular diseases have a greater risk of being missed when key tests are lacking.

[0065] For each disease node in the candidate disease reasoning results, all associated entities are queried along the suggested knowledge relationship edges in the candidate treatment subgraph, using that disease node as an index. Specifically, the query along the disease-recommended examination relationship yields the recommended examination entity set, the query along the disease-recommended medication relationship yields the recommended medication entity set, the query along the disease-corresponding follow-up requirement relationship yields the follow-up requirement entity set, the query along the disease-corresponding critical illness marker relationship yields the critical illness marker entity set, and the query along the disease-corresponding specialist treatment relationship yields the specialist treatment entity set. These entity sets originate from the suggested knowledge pre-stored in the knowledge graph, rather than the optimal evidence link. The function of the optimal evidence link is to explain the diagnostic reasoning process, which records the reasoning steps to prove the existence of the disease, and does not necessarily include all the examination and medication information required for the disease. Therefore, the entity source of the treatment suggestions and the evidence source of the diagnostic reasoning are independent of each other; the former is obtained based on the suggested knowledge relationship edges, while the latter is obtained based on the diagnostic knowledge relationship edges and diagnostic rule reasoning, each performing its own function.

[0066] Taking the recommended examination entity set as an example, assuming the entities associated with the bacterial pneumonia node along the disease-related recommended examination relationship edge include "sputum culture," "blood routine re-examination," and "chest CT," then the recommended examination entity set is a set containing these three entities. Assuming the entities associated with this node along the disease-related recommended medication relationship edge include "amoxicillin" and "cefaclor," then the recommended medication entity set is a set containing these two entities. Assuming the entities associated with this node along the disease-related follow-up requirement relationship edge include "blood routine re-examination 3 days after medication," then the follow-up requirement entity set is a set containing this entity. Assuming the entities associated with this node along the disease-related critical illness marker relationship edge include "blood oxygen saturation below 90%" and "respiratory rate exceeding 30 breaths per minute," then the critical illness marker entity set is a set containing these two entities. Assuming the node has no associated entities along the disease-related specialist treatment relationship edge, then the specialist treatment entity set is an empty set.

[0067] After completing the entity set query, a token is generated for each disease node. The token serves as the flow carrier in the fuzzy Petri net, carrying a fuzzy assignment representing the current level of diagnostic confidence. The overall evidence strength of the disease node is used as the initial fuzzy assignment for the token. For example, if the overall evidence strength of the bacterial pneumonia node is 0.82, the generated token carries an initial fuzzy assignment of 0.82. The token is then injected into the preliminary diagnosis repository of the corresponding clinical pathway, initiating the token flow process.

[0068] The token flows sequentially through the locations and transitions of the fuzzy Petri net, starting from the initial diagnostic location. Upon reaching each transition, the token's current fuzzy assignment is compared to the transition's fuzzy activation threshold. If the fuzzy assignment is not lower than the threshold, the transition is activated, the token enters the subsequent location, and the clinical pathway advances to the next treatment stage. If the fuzzy assignment is lower than the threshold, the transition is not activated, the token stops flowing at the current location, and the treatment stage corresponding to the subsequent location no longer generates recommendations. The failure to activate a transition signifies that the current level of diagnostic confidence is insufficient to support the pathway's advancement to deeper treatment stages. This is a key constraint mechanism imposed by the fuzzy Petri net on clinical pathways—treatment recommendations for subsequent stages should not be given when evidence is insufficient, to avoid inappropriate medication or treatment guidance under low confidence levels.

[0069] refer to Figure 4 , Figure 4 The horizontal axis represents the location of the six locations in the fuzzy Petri net, which are, in order, the preliminary diagnosis location, the examination recommendation location, the medication suggestion location, the treatment suggestion location, the follow-up arrangement location, and the referral determination location. The vertical axis represents the fuzzy assignment carried by the token. Figure 4Four curves were plotted, corresponding to four disease nodes in the candidate disease inference results: bacterial pneumonia, acute bronchitis, upper respiratory tract infection, and pulmonary tuberculosis. The four curves are distinguished by different line shapes. The starting point of each curve represents the overall evidence strength of the corresponding disease node, i.e., the initial fuzzy assignment of the token. The initial fuzzy assignment for bacterial pneumonia is 0.82. Since the entity sets corresponding to this token in all six databases are not empty, the fuzzy assignment remains at 0.82 without decay. Ultimately, the fuzzy assignment in the referral judgment database exceeds the referral trigger threshold, resulting in the output of a standard treatment recommendation. The initial fuzzy assignment for acute bronchitis is 0.71. Since the entity set corresponding to this token in the treatment recommendation database is empty, the evidence deficiency attenuation value of 0.08 configured for that database is triggered, reducing the fuzzy assignment to 0.63 and maintaining it until the referral judgment database, where it exceeds the referral trigger threshold, resulting in the output of a standard treatment recommendation. The initial fuzzy assignment for upper respiratory tract infection was 0.58. The entity set corresponding to this token in the medication recommendation database was empty, triggering a deduction of 0.12 for the missing evidence attenuation value, reducing the fuzzy assignment to 0.46. Similarly, the entity set corresponding to this token in the follow-up arrangement database was also empty, triggering a deduction of 0.05 for the missing evidence attenuation value, further reducing the fuzzy assignment to 0.41. Finally, the fuzzy assignment in the referral judgment database exceeded the referral trigger threshold of 0.35, resulting in the output of standard treatment recommendations. The initial fuzzy assignment for pulmonary tuberculosis was 0.48. At the transition between the examination recommendation database and the medication recommendation database, the fuzzy assignment of 0.48 was lower than the fuzzy trigger threshold of 0.50 configured for that transition, preventing the transition from being triggered and causing the token to stop flowing. Figure 4 The location of the blockage is marked with a cross. Figure 4 The system also includes a referral trigger threshold line with a value of 0.35, which is used to determine whether a referral recommendation should be triggered based on the referral decision database.

[0070] Each time a token enters a repository, it checks whether the corresponding entity set is empty. The correspondence between each repository and entity set is as follows: the recommended check repository corresponds to the recommended check entity set, the medication suggestion repository corresponds to the recommended medication entity set, the treatment suggestion repository corresponds to the specialist treatment entity set, and the follow-up arrangement repository corresponds to the follow-up requirement entity set. When the entity set is not empty, it indicates that there is relevant suggestion information for the disease in this diagnosis and treatment stage in the knowledge graph, and the token continues to flow to the next transition with its current fuzzy assignment. When the entity set is empty, it indicates that there is a lack of relevant information for the disease in this diagnosis and treatment stage in the knowledge graph. This lack of evidence will reduce the overall confidence level of diagnosis and treatment. Therefore, the token's fuzzy assignment is subtracted from the evidence deficiency attenuation value configured for that repository before continuing to flow. Taking the aforementioned bacterial pneumonia token as an example, after the token enters the preliminary diagnosis repository with a fuzzy assignment of 0.82, it reaches the first transition. The fuzzy activation threshold for the transition is 0.30. Since 0.82 is not lower than 0.30, the transition is activated, and the token enters the check recommendation repository. The set of entities corresponding to the recommendation library is checked and contains 3 entities. It is not empty. The token is kept fuzzy and assigned a value of 0.82 and continues to flow.

[0071] When the token flows to the recommended check library, the set of recommended check entities is output as the recommended check items. In the example above, the output recommended check items are "sputum culture", "complete blood count re-examination" and "chest CT".

[0072] When the token flows to the medication recommendation database, the set of recommended medication entities is output as the recommended medication plan. Simultaneously, a medication safety check is performed: the knowledge graph of common primary healthcare diseases queries all contraindicated entities associated with each recommended medication entity through drug contraindication edges, and compares each of these contraindicated entities with the drug allergy-related nodes in the patient element anchor node set. When a contraindicated entity matches a drug allergy-related node, it indicates that the current patient has a risk of allergy to the recommended medication, and a medication risk warning is generated. For example, the recommended medication entity "Amoxicillin" is associated with "Penicillin Allergy" through drug contraindication edges in the knowledge graph of common primary healthcare diseases, and the patient element anchor node set contains the drug allergy-related node "Penicillin." Since the two match successfully, the system generates a medication risk warning: "Amoxicillin and the patient's penicillin allergy are contraindicated; it is recommended to switch to a non-penicillin antibiotic." In one optional implementation, when a recommended medication entity triggers a medication risk warning, the system can further mark the entity as a contraindicated medication in the set of recommended medication entities, and output the remaining recommended medication entities that have not triggered risk warnings as alternative medication plans.

[0073] When a token flows to the disposal suggestion repository, it checks if the set of specialized disposal entities is empty. If the set of specialized disposal entities is not empty, the entities within it are output as disposal suggestions. If the set of specialized disposal entities is empty, the token's fuzzy assignment is subtracted from the evidence deficiency attenuation value configured in the disposal suggestion repository, and the token continues to flow without generating any disposal suggestion output.

[0074] When the token flows to the follow-up arrangement repository, the set of follow-up request entities is output as a follow-up suggestion. In the example above, the output follow-up suggestion is "re-examine blood routine test 3 days after medication". When the set of follow-up request entities is empty, the token continues to flow after the fuzzy assignment is subtracted from the evidence loss attenuation value configured in the follow-up arrangement repository, and no follow-up suggestion output is generated.

[0075] When a token flows to the referral decision database, a two-condition referral decision is executed. The first condition is that the fuzzy value currently carried by the token is lower than a preset referral trigger threshold. In one implementation, the preset referral trigger threshold is set to 0.35. The first condition being met means that after all the diagnostic and treatment processes and the attenuation of evidence loss, the diagnostic confidence level of the disease has dropped to a low level, and primary healthcare institutions may not have sufficient resources to complete the subsequent diagnosis and treatment of the disease. The second condition is that the set of critical and severe illness marker entities or the set of specialist treatment entities for the disease node are not empty. The second condition being met means that the disease is marked with critical and severe illness indicators or requires specialist treatment in the knowledge graph, and even if the current diagnostic confidence level is still acceptable, the severity of the disease itself or the complexity of the treatment has exceeded the capabilities of the primary healthcare institution. When either the first or second condition is met, a referral recommendation is output. When neither the first nor the second condition is met, a standard treatment recommendation is output. In another optional implementation, the preset referral trigger threshold can be adjusted according to the actual capacity of primary healthcare institutions in different regions. Institutions with relatively weak medical resources can appropriately increase the referral trigger threshold to 0.45, so that more cases with insufficient evidence can trigger referrals, thereby reducing the risk of misdiagnosis and missed diagnosis. Institutions with relatively abundant medical resources can reduce the referral trigger threshold to 0.25, so that more cases can complete diagnosis and treatment at the primary level.

[0076] After executing the token flow process for each disease node in the candidate disease reasoning results, the recommended examination items, recommended medication regimens, medication risk warnings, follow-up suggestions, referral suggestions, and routine treatment suggestions corresponding to all disease nodes that have completed token flow are summarized. These, along with the optimal evidence link for each disease node, serve as the basis for diagnostic interpretation, generating intelligent assisted diagnosis and treatment results for common diseases in primary healthcare. The intelligent assisted diagnosis and treatment result is a structured output report containing a list of candidate diseases sorted by comprehensive evidence strength, the reasoning evidence path for each candidate disease, recommended examination items, medication regimens and risk warnings, follow-up arrangements, and referral decisions. Clinicians in primary healthcare institutions can determine the diagnostic direction based on the candidate disease ranking in the intelligent assisted diagnosis and treatment result, arrange further examinations based on the recommended examination items, develop a safe medication plan based on the medication regimen and risk warnings, schedule follow-up visits according to the follow-up suggestions, and promptly transfer patients to higher-level medical institutions upon receiving referral suggestions. The optimal evidence link enables clinicians to understand the reasoning behind each diagnostic conclusion, enhancing their trust in the intelligent assisted diagnosis and treatment results and their willingness to adopt them clinically.

[0077] The present invention has been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of the invention. The descriptions of the embodiments above are merely for the purpose of helping to understand the system and core ideas of the present invention. It should be noted that those skilled in the art can make various improvements and modifications to the present invention without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of the present invention.

Claims

1. A knowledge graph-based intelligent auxiliary diagnosis and treatment system for common diseases in primary healthcare, characterized in that: Includes the following steps: Step 1: Obtain the patient's medical record text. Using a pre-trained language model and sequence labeling model, extract entity units from the medical record text to form a structured medical record element set. Link each entity unit to a standardized entity node in a pre-constructed primary healthcare knowledge graph to obtain a patient element anchor node set. Create patient instance nodes in the primary healthcare knowledge graph and establish relationship edges with each node in the patient element anchor node set to generate a patient observation fact set. The primary healthcare knowledge graph contains two types of relationship edges: the first type is diagnostic knowledge relationship edges, including symptom-indicating disease relationship edges, sign-indicating disease relationship edges, and examination-supporting disease relationship edges; the second type is suggested knowledge relationship edges, including disease-recommended examination relationship edges, disease-recommended medication relationship edges, drug contraindication relationship edges, disease-corresponding follow-up requirement relationship edges, disease-corresponding critical illness marker relationship edges, and disease-corresponding specialist treatment relationship edges. Starting from all nodes in the patient element anchor node set, perform a breadth-first traversal along the diagnostic knowledge relationship edges and suggested knowledge relationship edges with a preset number of hops to extract candidate treatment subgraphs. Step 2: The triples corresponding to all patient observation facts and all diagnostic knowledge relation edges extracted from the candidate diagnosis and treatment subgraph constitute the diagnostic logical fact set. For each disease node, a target triple is constructed. The head entity of the target triple is the patient instance node, the relation is the candidate diagnosis relation, and the tail entity is the disease node. The neural theorem prover performs recursive rule expansion and unified operation on the target triple based on the diagnostic rule set. Each diagnostic rule in the diagnostic rule set is represented in the form of a Horn clause, the rule body contains one or more conditional logical facts, and the rule head is one conclusion logical fact. The process of recursive rule expansion and unified operation includes: performing unified operation on each rule head and target triple in the diagnostic rule set; calculating the cosine similarity between the head entity embedding vector of the rule head and the head entity embedding vector of the target triple, the cosine similarity between the relation embedding vector of the rule head and the relation embedding vector of the target triple, and the cosine similarity between the tail entity embedding vector of the rule head and the tail entity embedding vector of the target triple; taking the minimum value among the three cosine similarities as the rule head matching degree; when the rule head matching degree exceeds a preset matching threshold, each conditional logical fact in the rule body is taken as a sub-proof target; and for each sub-proof target, the diagnostic logical fact set is... The unified operation is performed one by one to calculate the unified matching degree. When the unified matching degree exceeds the preset matching threshold, the sub-proof target is successfully proved. When the unified matching degree does not exceed the preset matching threshold, the sub-proof target is treated as a new target triple and the rule is recursively executed and the recursion depth does not exceed the preset maximum reasoning level. When all sub-proof targets are successfully proved, the minimum value of the rule head matching degree and the unified matching degree of all sub-proof targets is taken as the path evidence strength. All logical facts and diagnostic rules passed through the proof path in sequence are recorded as an ordered evidence link in the execution order. The comprehensive evidence strength and optimal evidence link of each disease node are obtained and arranged in descending order of comprehensive evidence strength to form the candidate disease reasoning results. Step 3: The clinical treatment pathway is standardized and encoded as a fuzzy Petri net. The types of repositories in the fuzzy Petri net include preliminary diagnosis repositories, examination recommendation repositories, medication suggestion repositories, treatment suggestion repositories, follow-up arrangement repositories, and referral determination repositories. The flow conditions between adjacent repositories are encoded as transitions. Each transition is configured with a fuzzy activation threshold, and each repository is pre-configured with an evidence loss attenuation value corresponding to the clinical importance level of the repositories. For each disease node, the associated entity set is queried along the suggested knowledge relationship edge in the candidate treatment subgraph using the disease node as the index. The overall evidence strength of the disease node is used as the initial fuzzy assignment of the token, which is injected into the preliminary diagnosis repositories of the clinical pathway corresponding to the disease node to drive the token to flow along the fuzzy Petri net. When the token reaches each transition, the current fuzzy assignment is compared with the fuzzy activation threshold of the transition. When the fuzzy assignment is not lower than the fuzzy activation threshold, the transition is activated, and the token enters the subsequent repositories. Each time the token enters a repositories, it checks whether the entity set corresponding to the repositories is empty. When the entity set is not empty, the token retains its current fuzzy assignment. The process continues. When the entity set is empty, the token's fuzzy assignment is subtracted from the evidence loss attenuation value configured in the repository before continuing. When the token flows to the medication suggestion repository, the recommended medication entity set is used as the recommended medication plan. Simultaneously, all contraindicated entities associated with each recommended medication entity through drug contraindication relationships are queried in the primary healthcare knowledge graph and compared with drug allergy nodes in the patient element anchor node set. If a match is found, a medication risk warning is generated. When the token flows to the referral judgment repository, a dual-condition referral judgment is executed. The first condition is that the fuzzy assignment currently carried by the token is lower than the preset referral trigger threshold. The second condition is that the critical illness marker entity set or the specialist treatment entity set of the disease node is not empty. If either the first or second condition is met, a referral suggestion is output. If neither the first nor the second condition is met, a routine treatment suggestion is output. Based on the fuzzy assignment and associated entity set of each repository, recommended examination items, recommended medication plans, medication risk warnings, follow-up suggestions, and referral suggestions are output, and the intelligent assisted diagnosis and treatment results are generated.

2. The intelligent auxiliary diagnosis and treatment system for common diseases in primary healthcare based on knowledge graphs according to claim 1, characterized in that, In step 1, the medical record text includes the chief complaint text, past medical history text, and basic examination results text. Each medical record text is segmented at the character level, and a classification tag is inserted at the beginning and a separator tag is inserted at the end to obtain the input tag sequence. The pre-trained language model is the BERT full-word mask pre-trained model. The multi-layer Transformer encoder in the BERT full-word mask pre-trained model performs multi-head self-attention calculation and feedforward network transformation on each tag in the input tag sequence layer by layer. The sequence labeling model is the Conditional Random Field labeling layer. The Conditional Random Field labeling layer takes the hidden state vector of all tags in the final layer as input and searches for the tag sequence with the highest joint probability through the Viterbi decoding algorithm. The tag categories include 9 types: symptom onset, symptom internal, sign onset, sign internal, examination indicator onset, examination indicator internal, drug allergy onset, drug allergy internal, and non-entity. Continuous tags with adjacent tags of the same type are merged into entity units.

3. The intelligent auxiliary diagnosis and treatment system for common diseases in primary healthcare based on knowledge graphs according to claim 1, characterized in that, In step 1, the entity linking process includes: retrieving all candidate standardized entity nodes in the entity name index of the knowledge graph of common diseases in primary care, whose character-level edit distance from the entity unit does not exceed a preset distance threshold, to form a candidate node set; verifying whether the entity type label in the knowledge graph of common diseases in primary care and the label category output by the entity unit in the sequence labeling model belong to the same preset type mapping group for each candidate standardized entity node in the candidate node set; retaining candidate standardized entity nodes with the same type; and selecting the one with the smallest edit distance from the retained candidate standardized entity nodes as the anchor node of the entity unit.

4. The intelligent auxiliary diagnosis and treatment system for common diseases in primary healthcare based on knowledge graphs according to claim 1, characterized in that, In step 1, the process of generating the patient observation fact set includes: establishing symptom relationship edges from patient instance nodes to each symptom-type node in the patient element anchor node set, establishing sign relationship edges to each sign-type node, establishing examination display relationship edges to each examination indicator-type node, and establishing allergy relationship edges to each drug allergy-type node.