Traditional Chinese medicine quality tracing and identifying method based on block chain two-dimensional code
By extracting the effective components, trace elements, and bioactivity indicators of Chinese medicinal materials, a latent feature fingerprint spectrum is constructed and blockchain traceability identification data is generated. This solves the problem of inaccurate traceability of Chinese medicinal materials in existing technologies, realizes accurate traceability and identification of the quality of Chinese medicinal materials, and improves the credibility of traceability and the reliability of identification results.
Patent Information
- Application Number
- CN202511107800.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-08
- Publication Date
- 2025-11-14
AI Technical Summary
Existing blockchain-based QR code-based methods for tracing the quality of Chinese medicinal materials ignore implicit quality characteristics such as the content of effective components, the proportion of trace elements, and bioactivity indicators within the medicinal materials. This leads to a discrepancy between the traceability information and the actual quality of the medicinal materials, reducing the accuracy and reliability of traceability and identification.
By extracting the content of effective components, trace elements, and bioactivity indicators of Chinese medicinal materials, a set of implicit characteristic data of medicinal materials is generated. A feature dimensionality reduction algorithm is used to construct an implicit characteristic fingerprint map, a hash mapping algorithm is used to generate blockchain traceability identification data, and on-chain and off-chain data are fused through smart contract technology to establish a verification mapping table for implicit quality data of medicinal materials, so as to realize accurate traceability and identification of the quality of Chinese medicinal materials.
It enables scientific traceability of the intrinsic quality of Chinese medicinal materials, improves the consistency and reliability of traceability data, and significantly enhances the effectiveness of traceability of Chinese medicinal materials and the reliability of identification results.
Smart Images

Figure CN120952818A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of quality traceability and identification technology, and more specifically, to a method for quality traceability and identification of traditional Chinese medicine based on blockchain QR codes. Background Technology
[0002] Existing blockchain-based QR code-based quality traceability of Chinese medicinal materials typically uses explicit indicators such as the appearance, origin, and weight of the medicinal materials as the main basis for blockchain information association and traceability.
[0003] This approach ignores the differences in implicit quality characteristics of Chinese medicinal materials, such as the content of effective components, the proportion of trace elements, and bioactivity indicators. This makes it difficult for the traceability data corresponding to the blockchain QR code to accurately express the true quality of the medicinal materials, resulting in a deviation between the traceability information and the actual quality of the medicinal materials. Consequently, the accuracy and reliability of traceability and identification of medicinal materials are reduced. Summary of the Invention
[0004] In order to overcome the above-mentioned defects of the prior art, embodiments of the present invention provide a method for tracing and identifying the quality of traditional Chinese medicine based on blockchain QR codes to solve the problems mentioned in the background art.
[0005] To achieve the above objectives, the present invention provides the following technical solution:
[0006] A method for tracing and identifying the quality of traditional Chinese medicine based on blockchain QR codes includes the following steps:
[0007] S1: Extract the content of effective components, trace elements and bioactivity indicators of Chinese medicinal materials to generate a set of latent characteristic data of medicinal materials;
[0008] S2: Based on the dataset of latent features of medicinal materials, a feature dimensionality reduction algorithm is used to construct a latent feature fingerprint map of medicinal materials and output the latent feature fingerprint identifier of medicinal materials;
[0009] S3: Based on the implicit fingerprint characteristics of medicinal materials, generate blockchain traceability identification data using a hash mapping algorithm, and output the blockchain traceability identification information of medicinal material quality;
[0010] S4: Based on the implicit fingerprint identifiers of medicinal materials, construct a corresponding off-chain implicit feature database and establish a mapping relationship between the implicit feature data of medicinal materials and the blockchain traceability identifier data;
[0011] S5: The blockchain traceability identification information of medicinal materials quality is integrated with the corresponding off-chain implicit feature database using smart contract technology to form a verification mapping table for implicit quality data of medicinal materials.
[0012] S6: Scan the blockchain QR code and perform traceability identification based on the implicit quality data verification mapping table of medicinal materials to determine the quality status of the medicinal materials.
[0013] In a preferred embodiment, S1 specifically refers to:
[0014] Collect samples of Chinese medicinal materials for quality traceability identification;
[0015] The content of active ingredients in Chinese medicinal materials was collected using a mass spectrometer.
[0016] The content of trace elements in Chinese medicinal materials was collected using an atomic absorption spectrometer.
[0017] Bioactivity indicators in Chinese medicinal materials were collected using high performance liquid chromatography.
[0018] The contents of effective components, trace elements, and bioactivity indicators are denoised, smoothed, and standardized to generate a set of latent characteristic data of medicinal materials.
[0019] In a preferred embodiment, S2 specifically refers to:
[0020] Principal component analysis algorithm is used to extract several principal component features from the latent feature data set of medicinal materials to generate principal component feature data of medicinal materials;
[0021] The content of effective components, trace elements, and bioactivity indicators in the latent feature data set of medicinal materials are classified and distinguished by linear discriminant analysis algorithm to generate medicinal material classification and discrimination feature data.
[0022] Based on the principal component feature data and classification feature data of medicinal materials, a feature fusion algorithm is used to construct a latent feature fingerprint map of medicinal materials;
[0023] Based on the latent feature fingerprint spectrum of medicinal materials, a latent feature fingerprint identifier for unique identification of medicinal materials is generated.
[0024] In a preferred embodiment, S3 specifically refers to:
[0025] The data of the latent feature fingerprint identifier of medicinal materials is hashed and encoded using a secure hashing algorithm to obtain the hash digest data of the latent feature fingerprint identifier of medicinal materials.
[0026] The hash digest data of the latent feature fingerprint of medicinal materials is encoded with blockchain traceability identifiers, and the hash digest data of the latent feature fingerprint of medicinal materials is transformed into blockchain traceability identifier data;
[0027] Based on blockchain traceability identification data, generate blockchain traceability identification information for medicinal material quality that represents a unique mapping relationship of the implicit characteristics of Chinese medicinal materials.
[0028] In a preferred embodiment, S4 specifically refers to:
[0029] Establish an off-chain latent feature database based on the latent feature fingerprints of medicinal materials;
[0030] Based on the implicit fingerprint identification of medicinal materials, establish a data association between the off-chain implicit feature database and the blockchain traceability identification information of medicinal material quality;
[0031] A mapping table is generated based on data association relationships between the off-chain implicit feature database and the blockchain traceability identification information of medicinal materials.
[0032] In a preferred embodiment, S5 specifically refers to:
[0033] Based on the blockchain traceability identification information of medicinal materials and the off-chain implicit feature database, a smart contract is constructed;
[0034] Smart contracts obtain the main component feature data of medicinal materials, the classification and identification feature data of medicinal materials, and the hash digest data of the blockchain traceability identification information of medicinal materials from the off-chain implicit feature database through the two-way call rules of on-chain and off-chain data;
[0035] The smart contract uses a hash mapping comparison algorithm for on-chain and off-chain data to establish a correspondence between the main component feature data of medicinal materials, the classification and identification feature data of medicinal materials, and the hash digest data of the blockchain traceability identification information of medicinal material quality, and to generate a two-way verification mapping relationship table for on-chain and off-chain data.
[0036] Based on the on-chain and off-chain data bidirectional verification mapping relationship table, a verification mapping table for implicit quality data of medicinal materials is constructed.
[0037] In a preferred embodiment, S6 specifically refers to:
[0038] By scanning the blockchain QR code, the blockchain traceability identification information of medicinal materials can be obtained, and data can be retrieved in the implicit quality data verification mapping table of medicinal materials;
[0039] Based on the implicit quality data verification mapping table of medicinal materials, obtain the main component feature data and classification discrimination feature data of medicinal materials corresponding to the blockchain traceability identification information of medicinal material quality;
[0040] The main component characteristic data and classification discrimination characteristic data of medicinal materials are compared with the main component characteristic data and classification discrimination characteristic data of the medicinal materials to be identified.
[0041] Based on the data consistency comparison results, the true quality status of the current Chinese medicinal material sample to be identified is determined, and the quality traceability identification result of the current Chinese medicinal material sample to be identified is generated.
[0042] The technical effects and advantages of the present invention, a method for tracing and identifying the quality of traditional Chinese medicine based on blockchain QR codes, are as follows:
[0043] By extracting the content of effective components, trace elements, and bioactivity indicators of Chinese medicinal materials, a comprehensive set of implicit characteristic data reflecting the intrinsic quality of the materials is obtained, making the traceability foundation more scientific. A feature dimensionality reduction algorithm is used to construct an implicit feature fingerprint map and generate unique fingerprint identifiers, achieving efficient compression and differentiation of complex implicit data. A hash mapping algorithm is used to convert the fingerprint identifiers into blockchain traceability identifier data, ensuring the immutability and unique mapping of traceability information. An off-chain implicit feature database is constructed and associated with on-chain identifier data, compensating for the limitations of on-chain data capacity and semantic expression. Smart contract technology is used to complete the fusion and two-way verification of on-chain and off-chain data, forming a complete implicit quality data verification mapping table, improving the consistency and credibility of traceability data. Finally, traceability identification is performed through QR code scanning combined with the verification mapping table, achieving rapid and accurate identification of the true quality status of Chinese medicinal materials, significantly improving the effectiveness of Chinese medicinal material quality traceability and the reliability of identification results. Attached Figure Description
[0044] Figure 1 This is a schematic diagram of a traditional Chinese medicine quality traceability and identification method based on blockchain QR codes according to the present invention. Detailed Implementation
[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present invention.
[0046] Example
[0047] Figure 1 This invention presents a method for tracing and identifying the quality of traditional Chinese medicine based on blockchain QR codes, which includes the following steps:
[0048] S1: Extract the content of effective components, trace elements and bioactivity indicators of Chinese medicinal materials to generate a set of latent characteristic data of medicinal materials;
[0049] S2: Based on the dataset of latent features of medicinal materials, a feature dimensionality reduction algorithm is used to construct a latent feature fingerprint map of medicinal materials and output the latent feature fingerprint identifier of medicinal materials;
[0050] S3: Based on the implicit fingerprint characteristics of medicinal materials, generate blockchain traceability identification data using a hash mapping algorithm, and output the blockchain traceability identification information of medicinal material quality;
[0051] S4: Based on the implicit fingerprint identifiers of medicinal materials, construct a corresponding off-chain implicit feature database and establish a mapping relationship between the implicit feature data of medicinal materials and the blockchain traceability identifier data;
[0052] S5: The blockchain traceability identification information of medicinal materials quality is integrated with the corresponding off-chain implicit feature database using smart contract technology to form a verification mapping table for implicit quality data of medicinal materials.
[0053] S6: Scan the blockchain QR code and perform traceability identification based on the implicit quality data verification mapping table of medicinal materials to determine the quality status of the medicinal materials.
[0054] S1: Extract the content of effective components, trace elements, and bioactivity indicators of Chinese medicinal materials to generate a set of latent characteristic data of medicinal materials, including:
[0055] Collect samples of Chinese medicinal materials for quality traceability identification;
[0056] The content of active ingredients in Chinese medicinal materials was collected using a mass spectrometer.
[0057] The content of trace elements in Chinese medicinal materials was collected using an atomic absorption spectrometer.
[0058] Bioactivity indicators in Chinese medicinal materials were collected using high performance liquid chromatography.
[0059] The contents of effective components, trace elements, and bioactivity indicators are denoised, smoothed, and standardized to generate a set of latent characteristic data of medicinal materials.
[0060] Specifically, on-site or laboratory sampling is conducted for the Chinese medicinal materials samples to be identified for quality traceability. Samples are collected according to the actual category and type of the medicinal materials, and standardized methods are used to ensure sample representativeness. For example, when collecting samples of Astragalus membranaceus for identification, several representative samples can be randomly selected from multiple packaging units within the production batch to reduce potential specific errors due to individual samples and increase the overall representativeness of the sample. If a batch of Astragalus membranaceus weighs 500 kg, samples can be taken every 50 kg, resulting in 10 sample units, which are then combined to form the sample of Astragalus membranaceus for quality traceability identification in that batch.
[0061] Mass spectrometry instruments include, but are not limited to, liquid chromatography-mass spectrometry (LC-MS). For example, after pulverizing and extracting the collected Astragalus membranaceus sample using physical or chemical methods, the extract is injected into the LC-MS instrument for analysis. LC-MS can separate effective medicinal components such as astragaloside A, verbascoside, and gentianin from the Astragalus membranaceus sample. The content of specific effective components in the Astragalus membranaceus sample is obtained by using a standard substance of known concentration as a reference curve for quantification. For example, the final content of astragaloside A is 3.5 mg / g, verbascoside is 1.2 mg / g, and gentianin is 0.8 mg / g.
[0062] The collected medicinal samples were acid-digested to release trace elements in ionic form into the solution. The digested solution was then sent to an atomic absorption spectrometer (AAS) for analysis. The AAS analyzer quantitatively calculated the specific content of trace elements in the sample by detecting the absorption of different elements at specific wavelengths of light. For example, when detecting the zinc, selenium, and magnesium content in an Astragalus membranaceus sample, the AAS analyzer emitted corresponding specific wavelengths of light. As the light passed through the sample solution, the absorption of each element varied, thus obtaining the specific content data for each element. For instance, assuming the Astragalus membranaceus sample contained 12 micrograms of zinc per gram, 0.5 micrograms of selenium per gram, and 230 micrograms of magnesium per gram, the analysis would be presented in the original text.
[0063] Medicinal samples are pretreated and extracted using appropriate solvents to obtain a sample solution suitable for chromatographic analysis. For example, when analyzing bioactive indicators (such as total flavonoids and total saponins) in Astragalus membranaceus samples, methanol or ethanol is used for extraction, and the extract is analyzed by high-performance liquid chromatography (HPLC). HPLC, under the action of a stationary phase and a mobile phase, effectively separates various bioactive substances in the medicinal sample, obtaining chromatographic peaks of specific bioactive indicators. The content of specific bioactive indicators in the medicinal sample is calculated using the standard reference method, i.e., a standard curve is prepared using standard substances of known concentrations. For example, after HPLC analysis, the total flavonoid content in the Astragalus membranaceus sample is found to be 5 mg per gram of sample, and the total saponin content is found to be 8 mg per gram of sample.
[0064] The effective component content, trace element content, and bioactivity index obtained using mass spectrometry, atomic absorption spectrometry, and high-performance liquid chromatography (HPLC) were subjected to denoising, data smoothing, and standardization. The Savitzky-Golay filtering method was used to denoise and smooth the effective component content, trace element content, and bioactivity index, eliminating noise signals generated during instrument detection and improving data accuracy. For example, the original effective component content curve was processed by a filtering algorithm to remove abnormally fluctuating data points. After data smoothing, standardization was performed using the Z-score standardization method, which involves subtracting the average value from each detection data point and dividing by the standard deviation. For example, the contents of astragaloside A, verbenafil isoflavone glucoside, and gentianin were respectively subjected to Z-score transformation, ensuring that all effective component data were compared uniformly within a unified scale. The denoising, smoothing, and standardization-transformed effective component content, trace element content, and bioactivity index data were integrated to form a set of latent characteristic data of medicinal materials within a unified scale.
[0065] S2: Based on the dataset of latent features of medicinal materials, a latent feature fingerprint map of medicinal materials is constructed using a feature dimensionality reduction algorithm, and the latent feature fingerprint identifier of the medicinal materials is output, including:
[0066] Principal component analysis algorithm is used to extract several principal component features from the latent feature data set of medicinal materials to generate principal component feature data of medicinal materials;
[0067] The content of effective components, trace elements, and bioactivity indicators in the latent feature data set of medicinal materials are classified and distinguished by linear discriminant analysis algorithm to generate medicinal material classification and discrimination feature data.
[0068] Based on the principal component feature data and classification feature data of medicinal materials, a feature fusion algorithm is used to construct a latent feature fingerprint map of medicinal materials;
[0069] Based on the latent feature fingerprint spectrum of medicinal materials, a latent feature fingerprint identifier for unique identification of medicinal materials is generated.
[0070] Specifically, principal component analysis (PCA) algorithms calculate the covariance matrix and perform eigenvalue decomposition on the latent feature dataset of medicinal materials to identify several principal component feature variables that can represent the main information of the original data in the dataset. For example, when processing the latent feature dataset of Astragalus membranaceus (Huangqi) samples using PCA, the dataset includes multidimensional data such as the content of effective components, trace elements, and bioactivity indicators. These multidimensional data have high dimensionality and are correlated to a certain extent, resulting in redundancy in direct analysis and making it difficult to intuitively express the core features of the latent feature dataset. Therefore, when implementing PCA, the covariance matrix is first calculated, i.e., the covariance between every two dimensions is calculated to describe the relationship between dimensions. Then, eigenvalue decomposition is performed on the covariance matrix, obtaining the eigenvalues and eigenvectors of the covariance matrix. Each eigenvalue represents the contribution rate of the corresponding eigenvector. Next, based on the contribution rate, the feature vectors corresponding to feature values with a cumulative contribution rate exceeding a preset threshold (e.g., a cumulative contribution rate exceeding 85%) are selected, and these selected feature vectors constitute the principal component features. The data of each dimension in the latent feature dataset of medicinal materials are projected onto the selected principal component feature vectors to obtain the dimensionality-reduced principal component feature data of the medicinal materials. For example, in the latent feature dataset of Astragalus membranaceus, assuming the total number of data dimensions for effective component content, trace element content, and bioactivity indicators reaches 20, after calculation by the principal component analysis algorithm, selecting the first four principal component features can cover more than 90% of the overall information. These four principal component features are the principal component feature data of the medicinal materials, thus reducing the dimensionality of the latent feature dataset of medicinal materials.
[0071] Linear discriminant analysis (LDA) algorithms find one or more linear combinations with classification capabilities that maximize the distinguishability between different categories of medicinal materials while minimizing the differences between materials within the same category. When performing LDA, the data in the latent feature dataset of medicinal materials needs to be labeled with categories. Taking Astragalus membranaceus (Huangqi) as an example, when classifying medicinal materials from different origins, quality grades, or batches, the category information of the samples to be analyzed must first be obtained. For example, Astragalus membranaceus from Inner Mongolia, Gansu, and Shaanxi provinces can be classified into three categories. After setting category labels, these are input into the LDA algorithm. LDA calculates the intra-class and inter-class scatter matrices on the latent feature dataset of medicinal materials. The intra-class scatter matrix measures the density of data within the same category, while the inter-class scatter matrix measures the differences between data in different categories. By solving for the extreme value of the ratio of these two scatter matrices, the optimal linear discriminant feature vector is obtained. By projecting the set of latent feature data of medicinal materials onto the linear discriminant feature vector, we can obtain the classification discriminant feature data of medicinal materials with classification attributes. For example, after performing linear discriminant analysis on three kinds of Astragalus membranaceus from different producing areas, we can obtain one or more linear discriminant features that distinguish Astragalus membranaceus from different producing areas, thereby distinguishing the latent features of different categories of Astragalus membranaceus.
[0072] Feature fusion algorithms combine principal component feature data and classification discrimination feature data of medicinal materials to obtain a comprehensive feature representation that combines principal component representativeness with category differentiation capability. Feature fusion algorithms can choose a concatenated fusion method, that is, sequentially concatenating the principal component feature data and the classification discrimination feature data of medicinal materials to form a unified feature vector. For example, concatenating and fusing the 4-dimensional principal component feature data and 2-dimensional classification discrimination feature data of Astragalus membranaceus results in a 6-dimensional comprehensive latent feature vector, which is the latent feature fingerprint of medicinal materials. The latent feature fingerprint of medicinal materials fully expresses the latent quality characteristics of medicinal materials in a numerical vector format, not only preserving the main information expression but also strengthening the classification discrimination capability, which can significantly improve the accuracy of identification and authentication.
[0073] The latent fingerprint identification of medicinal materials is a unique identifier for medicinal materials achieved through digital encoding based on the latent fingerprint spectrum. A hash function is used to encode the latent fingerprint spectrum, outputting it as a fixed-length data identifier. Taking the SHA-256 hash function as an example, the numerical vector of the latent fingerprint spectrum is used as input, and a fixed-length hash digest is calculated using a hash algorithm. This digest serves as the latent fingerprint identifier. Due to the characteristics of hash algorithms, even slight differences in the latent fingerprint spectrum will lead to significant changes in the latent fingerprint identifier. Therefore, the identifier can achieve accurate and unique mapping and identification of the latent quality characteristics of Chinese medicinal materials, meeting the requirements for traceability and precise identification of medicinal materials.
[0074] S3: Based on the implicit fingerprint characteristics of medicinal materials, generate blockchain traceability identification data using a hash mapping algorithm, and output the blockchain traceability identification information for medicinal material quality, including:
[0075] The data of the latent feature fingerprint identifier of medicinal materials is hashed and encoded using a secure hashing algorithm to obtain the hash digest data of the latent feature fingerprint identifier of medicinal materials.
[0076] The hash digest data of the latent feature fingerprint of medicinal materials is encoded with blockchain traceability identifiers, and the hash digest data of the latent feature fingerprint of medicinal materials is transformed into blockchain traceability identifier data;
[0077] Based on blockchain traceability identification data, generate blockchain traceability identification information for medicinal material quality that represents a unique mapping relationship of the implicit characteristics of Chinese medicinal materials.
[0078] Specifically, the SHA-256 secure hash algorithm is used to ensure the security and uniqueness of the latent feature fingerprint identification data of medicinal materials after encoding. For example, for the latent feature fingerprint identification of Astragalus membranaceus, the latent feature fingerprint identification is the numerical vector data corresponding to the latent feature fingerprint map of medicinal materials generated by the feature fusion algorithm. This numerical vector data is used as the input data of the SHA-256 secure hash algorithm. After the numerical vector data is input into the SHA-256 secure hash algorithm, through data transformation and iterative operation, a fixed-length hash digest data of 256 bits is finally obtained. This 256-bit fixed-length hash digest data has the characteristics of uniqueness and tamper-proof, and therefore can be used as the hash digest data of the latent feature fingerprint identification of medicinal materials. Assuming the latent fingerprint data of Astragalus membranaceus is a 6-dimensional feature vector, i.e., [0.75, 0.81, -0.35, 0.42, 1.03, -0.65], the 6-dimensional numerical data is input into the SHA-256 secure hash algorithm for processing. The result is a fixed 256-bit digest data, such as "B3AF2C1F...8F1D4E5A", a fixed-length hexadecimal hash digest that serves as the hash digest of the latent fingerprint identifier. The hash digest of the latent fingerprint identifier is unique and can be used for blockchain encoding and traceability identification.
[0079] By using blockchain encoding algorithms to perform specific blockchain encoding on the hash digest data of the implicit characteristic fingerprint identifier of medicinal materials, the hash digest data can meet the storage and verification conditions of the blockchain network and be uniquely mapped to the data nodes in the blockchain. For example, the hash digest data generated by the SHA-256 secure hash algorithm can be processed by Base58 or Base64 encoding to generate a data format that can be embedded in the blockchain network structure and is readable, serving as blockchain traceability identification data.
[0080] The blockchain traceability identification information for medicinal materials is a structured processing and expression of blockchain traceability identification data. The blockchain traceability identification data can be embedded in the blockchain's structured data framework, such as JSON data format or other specific blockchain structured data framework, to establish a unique mapping relationship of implicit features.
[0081] S4: Based on the implicit fingerprint identifiers of medicinal materials, construct a corresponding off-chain implicit feature database and establish a mapping relationship between the implicit feature data of medicinal materials and the blockchain traceability identifier data, including:
[0082] Establish an off-chain latent feature database based on the latent feature fingerprints of medicinal materials;
[0083] Based on the implicit fingerprint identification of medicinal materials, establish a data association between the off-chain implicit feature database and the blockchain traceability identification information of medicinal material quality;
[0084] A mapping table is generated based on data association relationships between the off-chain implicit feature database and the blockchain traceability identification information of medicinal materials.
[0085] Specifically, when constructing an off-chain implicit feature database for Astragalus membranaceus, either a relational or non-relational database can be used for storage. The database can be constructed and deployed using relational database management systems such as MySQL and Oracle, or non-relational database management systems such as MongoDB and Redis. A unique constraint is set for the implicit feature fingerprint identifiers of the medicinal materials in the database, meaning that each implicit feature fingerprint identifier corresponds to a unique sample of medicinal materials, thereby avoiding data confusion and identification difficulties caused by duplicate implicit feature fingerprint identifiers.
[0086] The distributed database storage structure disperses the data storage, management, and processing of off-chain implicit feature databases across multiple physical or virtual nodes. These nodes collaborate to store and manage the implicit feature fingerprints of medicinal materials and their associated data. The distributed database system is built on multiple server nodes, each storing a portion of the off-chain implicit feature database. Each node has independent data processing and retrieval capabilities, and nodes coordinate operations through network communication. For example, when building an off-chain implicit feature database for Astragalus membranaceus, the database can be distributed across different node servers in East China, South China, and North China. Each regional node stores the implicit feature data of medicinal materials in its respective region, thus avoiding the risk of data inaccessibility due to excessive load or failure of a single server, and improving the overall stability and scalability of the data. A data synchronization mechanism is established between each node to ensure data consistency. Structured storage is the standardized storage of various types of data corresponding to the latent feature fingerprints of medicinal materials using standardized data formats. For example, when storing the latent feature data of medicinal materials using a relational database, the table structure can be defined as "medicinal material name", "batch number", "principal component feature data", "classification and discrimination feature data", etc., forming a structured storage system for the latent feature fingerprints of medicinal materials.
[0087] By storing the principal component characteristic data and classification discrimination characteristic data of medicinal materials in an off-chain implicit feature database, the key quality indicators such as the intrinsic efficacy, trace elements, and biological activity of medicinal materials can be fully reflected. Taking Astragalus membranaceus as an example, the data record stored in the off-chain implicit feature database is: "Medicinal material name: Astragalus membranaceus, batch number: HQ20240101, principal component characteristic data: [0.75, 0.81, -0.35, 0.42], classification discrimination characteristic data: [1.03, -0.65]". Storing the above data in a structured form ensures accurate and rapid data retrieval and access.
[0088] Establishing data associations refers to linking data in the off-chain database with the blockchain traceability identification information of medicinal materials, using the implicit fingerprint identifiers of medicinal materials stored in the off-chain implicit feature database, to form a one-to-one accurate correspondence. First, based on the implicit fingerprint identifier of the medicinal material, the complete data record of a specific medicinal material sample is retrieved from the off-chain implicit feature database. Then, based on the same implicit fingerprint identifier, the corresponding blockchain traceability identification information of the medicinal material is retrieved. Using the implicit fingerprint identifier as a linking bridge, a unified association between detailed off-chain data and on-chain identification information is achieved. For example, taking Astragalus membranaceus as an example, when the off-chain implicit feature database contains data with the implicit fingerprint identifier "B3AF2C1F8F1D4E5A", the corresponding blockchain traceability identification data "3mJr7AoUXx2Wqd" can be accurately retrieved using the implicit fingerprint identifier, thus forming a data association.
[0089] Data associations are established using a two-way mapping mechanism. This mechanism refers to a two-way retrieval mapping between the off-chain implicit feature database and the blockchain traceability identification information for medicinal materials. This allows for rapid retrieval of on-chain blockchain information from the off-chain database, and vice versa. To implement this mechanism, a blockchain traceability identification data field needs to be set in the off-chain implicit feature database to quickly locate blockchain node data. Simultaneously, an index pointer to the off-chain database is added to the blockchain structured data to ensure rapid retrieval of detailed off-chain data from on-chain information.
[0090] The association mapping table is an index table formed by summarizing data relationships. The index table stores the data identifiers of the related parties, enabling fast indexing. For example, implementers can create an association mapping table through the database indexing mechanism, such as "Hidden Feature Fingerprint Identifier of Medicinal Materials: B3AF2C1F8F1D4E5A — Blockchain Traceability Identifier Data: 3mJr7AoUXx2Wqd", thereby enabling fast and accurate on-chain and off-chain data association retrieval.
[0091] S5: The blockchain traceability identification information for medicinal herb quality is integrated with the corresponding off-chain implicit feature database using smart contract technology to form a verification mapping table for implicit quality data of medicinal herbs, including:
[0092] Based on the blockchain traceability identification information of medicinal materials and the off-chain implicit feature database, a smart contract is constructed;
[0093] Smart contracts obtain the main component feature data of medicinal materials, the classification and identification feature data of medicinal materials, and the hash digest data of the blockchain traceability identification information of medicinal materials from the off-chain implicit feature database through the two-way call rules of on-chain and off-chain data;
[0094] The smart contract uses a hash mapping comparison algorithm for on-chain and off-chain data to establish a correspondence between the main component feature data of medicinal materials, the classification and identification feature data of medicinal materials, and the hash digest data of the blockchain traceability identification information of medicinal material quality, and to generate a two-way verification mapping relationship table for on-chain and off-chain data.
[0095] Based on the on-chain and off-chain data bidirectional verification mapping relationship table, a verification mapping table for implicit quality data of medicinal materials is constructed.
[0096] Specifically, a smart contract refers to program code stored within a blockchain network that can automatically execute predetermined rules and complete data retrieval and verification tasks. First, based on the blockchain traceability identification information for medicinal materials, and utilizing an off-chain implicit feature database, a smart contract is deployed on the blockchain platform. During deployment, a blockchain smart contract programming language (such as Solidity) is selected to write the smart contract, and the completed smart contract code is then uploaded to the blockchain network platform (such as the Ethereum network) for deployment, enabling the smart contract to run stably on the chain. For example, when deploying a smart contract for the traceability identification of Astragalus membranaceus (Huangqi) medicinal materials, the smart contract includes various data retrieval, comparison, and verification logics for medicinal material traceability functions. It can read the main component characteristic data and classification discrimination characteristic data of medicinal materials from the off-chain implicit feature database, and simultaneously call the blockchain traceability identification information for consistency verification. A smart contract successfully deployed using the above method can stably execute the implicit quality traceability and verification functions of medicinal materials over a long period.
[0097] Smart contracts include bidirectional rules for accessing on-chain and off-chain data. These rules mean that smart contracts can actively access the blockchain-based traceability identification information for medicinal materials stored on the blockchain, and simultaneously access detailed data on the latent characteristics of medicinal materials stored in the off-chain latent characteristic database; similarly, they can also retrieve the on-chain traceability identification information for medicinal materials from the off-chain latent characteristic database. In designing smart contracts, bidirectional access rules are set: the smart contract accesses data in the off-chain latent characteristic database through a pre-defined on-chain data interface API; simultaneously, the off-chain database accesses the on-chain traceability identification information for medicinal materials through a reverse data interface. Taking Astragalus membranaceus traceability as an example, if the smart contract is deployed on the Ethereum blockchain platform and the off-chain latent characteristic database uses a distributed MySQL database, then a specific interface needs to be embedded in the smart contract to enable remote access to the MySQL database. At the same time, the MySQL database management program can also access the smart contract on the blockchain through the API to query the traceability identification information for medicinal materials corresponding to the latent characteristic data. The bidirectional call mechanism ensures that data can be flexibly and efficiently exchanged and verified between on-chain and off-chain processes.
[0098] Based on the established bidirectional call rules, the smart contract can accurately retrieve the main component characteristic data and classification identification characteristic data of medicinal materials from the off-chain implicit feature database during execution. Simultaneously, the smart contract can also access the hash digest data of the blockchain traceability identification information for medicinal material quality stored on-chain. For example, for Astragalus membranaceus, during the execution of the smart contract, when a user scans the QR code, the smart contract automatically retrieves the main component characteristic data (e.g., [0.75, 0.81, -0.35, 0.42]) and classification identification characteristic data (e.g., [1.03, -0.65]) from the off-chain implicit feature database, according to the bidirectional call rules. Simultaneously, it retrieves the hash digest data corresponding to the blockchain traceability identification information for Astragalus membranaceus quality stored on-chain, such as "B3AF2C1F8F1D4E5A". Through the automatic execution logic of the smart contract, real-time access and transmission of on-chain and off-chain data can be achieved.
[0099] The hash mapping comparison algorithm performs hash calculations on the main component feature data and classification identification feature data of the medicinal materials accessed by the smart contract. This hash is then compared with the hash digest data of the blockchain traceability identification information of the medicinal materials accessed on-chain to determine if the on-chain and off-chain data are consistent. The SHA-256 hash function is selected to complete the data hash calculation process. For example, for Astragalus membranaceus, the smart contract accesses the off-chain main component feature data [0.75, 0.81, -0.35, 0.42] and classification identification feature data [1.03, -0.65]. After calculating the hash using the SHA-256 hash function, a new hash digest data string such as "B3AF2C1F8F1D4E5A" is obtained. The smart contract then automatically compares this hash digest data with the hash digest data of the blockchain traceability identification information of the medicinal materials on-chain. If the data matches, a data correspondence is established. The smart contract stores this correspondence in the blockchain in the form of a two-way verification mapping table between on-chain and off-chain data, represented in JSON format.
[0100] The implicit quality data verification mapping table for medicinal materials is a structured representation of data verification results based on the on-chain and off-chain data bidirectional verification mapping table. The verification mapping table stores the structured correspondence between the implicit quality data of the medicinal materials and the blockchain identifiers after successful verification, facilitating rapid data retrieval and verification during the traceability process of medicinal materials. For example, for Astragalus membranaceus, the verified consistency results in the bidirectional verification mapping table are structured and stored as the implicit quality data verification mapping table.
[0101] S6: Scan the blockchain QR code, verify the traceability and identification based on the implicit quality data mapping table of medicinal materials, and determine the quality status of the medicinal materials, including:
[0102] By scanning the blockchain QR code, the blockchain traceability identification information of medicinal materials can be obtained, and data can be retrieved in the implicit quality data verification mapping table of medicinal materials;
[0103] Based on the implicit quality data verification mapping table of medicinal materials, obtain the main component feature data and classification discrimination feature data of medicinal materials corresponding to the blockchain traceability identification information of medicinal material quality;
[0104] The main component characteristic data and classification discrimination characteristic data of medicinal materials are compared with the main component characteristic data and classification discrimination characteristic data of the medicinal materials to be identified.
[0105] Based on the data consistency comparison results, the true quality status of the current Chinese medicinal material sample to be identified is determined, and the quality traceability identification result of the current Chinese medicinal material sample to be identified is generated.
[0106] Specifically, using a smart mobile terminal with QR code scanning capabilities, such as a smartphone, tablet, or dedicated QR code scanning device, the blockchain QR code displayed on the outer packaging or label of Chinese medicinal materials is scanned. After scanning, the application in the smart terminal device automatically identifies the blockchain traceability identification data carried in the QR code, including hash digest data of the implicit characteristic fingerprint identifier of the medicinal material after hash encoding and blockchain encoding processing. For example, in the quality traceability identification of Astragalus membranaceus, the blockchain traceability identification data obtained by scanning is hash digest data in hexadecimal encoding form such as "B3AF2C1F8F1D4E5A". Subsequently, the scanning device connects to the blockchain platform via a wireless network and uses the hash digest data as an index key to automatically enter the implicit quality data verification mapping table of medicinal materials built on the blockchain for data retrieval. The data retrieval process is as follows: the smart contract program in the blockchain platform performs a precise search in the verification mapping table stored on the chain according to the index relationship of the hash digest data; for example, using the hash digest data "B3AF2C1F8F1D4E5A" as the index key, the corresponding entry in the implicit quality data verification mapping table of medicinal materials is found on the chain. By scanning and searching, it is possible to quickly obtain and locate structured data from the blockchain QR code on the outer packaging of medicinal materials to the implicit quality data verification mapping table of medicinal materials.
[0107] The implicit quality data verification mapping table for medicinal materials stores the implicit characteristic data of medicinal materials in a structured manner, including but not limited to the main component characteristic data and the classification and discrimination characteristic data of medicinal materials. Through an automatic retrieval operation after scanning a QR code, the smart contract will automatically retrieve and return the specific data content after accurately locating the corresponding entry in the implicit quality data verification mapping table. For example, when tracing and identifying the quality of Astragalus membranaceus, the blockchain quality traceability identification information of the medicinal material is obtained through a blockchain QR code scanning operation, and the data record is retrieved in the implicit quality data verification mapping table: "Medicinal material name: Astragalus membranaceus, Batch number: HQ20240101, Main component characteristic data: [0.75, 0.81, -0.35, 0.42], Classification and discrimination characteristic data: [1.03, -0.65]", thus obtaining the specific main component characteristic data and classification and discrimination characteristic data of the medicinal material.
[0108] Suppose a batch of Astragalus membranaceus (Huangqi) to be identified has principal component characteristic data of [0.75, 0.81, -0.34, 0.43] and classification characteristic data of [1.02, -0.64]. This data is compared with the standard medicinal material principal component characteristic data [0.75, 0.81, -0.35, 0.42] and classification characteristic data [1.03, -0.65] obtained through blockchain QR code retrieval. A smart contract or off-chain analysis program calculates the Euclidean distance or similarity coefficient between the two sets of data to derive a quantitative evaluation index of data consistency. If the similarity between the two sets of data exceeds a certain set threshold (e.g., similarity reaches 95% or higher), the medicinal material to be identified is considered to belong to the same quality state as the medicinal material sample recorded on the blockchain; if the data similarity is below the threshold, they are considered to be of different quality states.
[0109] Based on the data comparison results automatically completed by the smart contract, the quality status of the medicinal materials to be identified is automatically determined according to the set judgment rules. For example, if the consistency between the medicinal materials to be identified and the implicit characteristic data of the medicinal materials recorded on the blockchain reaches a preset threshold, then the true quality status of the medicinal materials to be identified is determined to be the same as that of the medicinal materials recorded on the blockchain, that is, it meets the standard quality status of medicinal materials; conversely, if the consistency comparison result does not reach the set threshold, then the medicinal materials are determined to not meet the standard quality status, and there may be problems such as quality abnormalities or adulteration. After automatically determining the true quality status of the medicinal materials, the smart contract automatically generates the quality traceability identification result. The identification result is stored on the blockchain in the form of structured data to facilitate traceability and supervision. For example, for a batch of Astragalus membranaceus to be identified, after data comparison, the consistency similarity is found to be 97.5%. The smart contract will automatically output the quality traceability identification result as: "Batch number of medicinal material to be identified: HQ20240102, name of medicinal material: Astragalus membranaceus, quality status: qualified, consistency similarity with standard sample is 97.5%", and store the quality traceability identification result in the blockchain, thereby realizing the transparency, verifiability and immutability of the medicinal material quality traceability identification result.
[0110] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. The semiconductor medium can be a solid-state drive.
[0111] Those skilled in the art will recognize that the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0112] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and modules described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0113] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0114] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0115] In addition, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module.
[0116] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0117] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0118] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for tracing and identifying the quality of traditional Chinese medicine based on blockchain QR codes, characterized in that, Includes the following steps: S1: Extract the content of effective components, trace elements and bioactivity indicators of Chinese medicinal materials to generate a set of latent characteristic data of medicinal materials; S2: Based on the dataset of latent features of medicinal materials, a feature dimensionality reduction algorithm is used to construct a latent feature fingerprint map of medicinal materials and output the latent feature fingerprint identifier of medicinal materials; S3: Based on the implicit fingerprint characteristics of medicinal materials, generate blockchain traceability identification data using a hash mapping algorithm, and output the blockchain traceability identification information of medicinal material quality; S4: Based on the implicit fingerprint identifiers of medicinal materials, construct a corresponding off-chain implicit feature database and establish a mapping relationship between the implicit feature data of medicinal materials and the blockchain traceability identifier data; S5: The blockchain traceability identification information of medicinal materials quality is integrated with the corresponding off-chain implicit feature database using smart contract technology to form a verification mapping table for implicit quality data of medicinal materials. S6: Scan the blockchain QR code and perform traceability identification based on the implicit quality data verification mapping table of medicinal materials to determine the quality status of the medicinal materials.
2. The method for quality traceability and identification of traditional Chinese medicine based on blockchain QR codes according to claim 1, characterized in that, S1, specifically: Collect samples of Chinese medicinal materials for quality traceability identification; The content of active ingredients in Chinese medicinal materials was collected using a mass spectrometer. The content of trace elements in Chinese medicinal materials was collected using an atomic absorption spectrometer. Bioactivity indicators in Chinese medicinal materials were collected using high performance liquid chromatography. The content of active ingredients, the content of trace elements, and the bioactivity indicators are denoised, smoothed, and standardized to generate a set of latent characteristic data of medicinal materials.
3. The method for tracing and identifying the quality of traditional Chinese medicine based on blockchain QR codes according to claim 2, characterized in that, S2, specifically: Principal component analysis algorithm is used to extract several principal component features from the latent feature data set of medicinal materials to generate principal component feature data of medicinal materials; The content of effective components, trace elements, and bioactivity indicators in the latent feature data set of medicinal materials are classified and distinguished by linear discriminant analysis algorithm to generate medicinal material classification and discrimination feature data. Based on the principal component feature data and classification feature data of medicinal materials, a feature fusion algorithm is used to construct a latent feature fingerprint map of medicinal materials; Based on the latent feature fingerprint spectrum of medicinal materials, a latent feature fingerprint identifier for unique identification of medicinal materials is generated.
4. The method for quality traceability and identification of traditional Chinese medicine based on blockchain QR codes according to claim 3, characterized in that, S3, specifically: The data of the latent feature fingerprint identifier of medicinal materials is hashed and encoded using a secure hashing algorithm to obtain the hash digest data of the latent feature fingerprint identifier of medicinal materials. The hash digest data of the latent feature fingerprint of medicinal materials is encoded with blockchain traceability identifiers, and the hash digest data of the latent feature fingerprint of medicinal materials is transformed into blockchain traceability identifier data; Based on blockchain traceability identification data, generate blockchain traceability identification information for medicinal material quality that represents a unique mapping relationship of the implicit characteristics of Chinese medicinal materials.
5. The method for tracing and identifying the quality of traditional Chinese medicine based on blockchain QR codes according to claim 4, characterized in that, S4, specifically: Establish an off-chain latent feature database based on the latent feature fingerprints of medicinal materials; Based on the latent fingerprint identification of medicinal materials, establish a data association between the off-chain latent feature database and the blockchain traceability identification information of medicinal material quality; A mapping table is generated based on data association relationships between the off-chain implicit feature database and the blockchain traceability identification information of medicinal materials.
6. The method for tracing and identifying the quality of traditional Chinese medicine based on blockchain QR codes according to claim 5, characterized in that, S5, specifically: Based on the blockchain traceability identification information of medicinal materials and the off-chain implicit feature database, a smart contract is constructed; Smart contracts obtain the main component feature data of medicinal materials, the classification and identification feature data of medicinal materials, and the hash digest data of the blockchain traceability identification information of medicinal materials from the off-chain implicit feature database through the two-way call rules of on-chain and off-chain data; The smart contract uses a hash mapping comparison algorithm for on-chain and off-chain data to establish a correspondence between the main component feature data of medicinal materials, the classification and identification feature data of medicinal materials, and the hash digest data of the blockchain traceability identification information of medicinal material quality, and to generate a two-way verification mapping relationship table for on-chain and off-chain data. Based on the on-chain and off-chain data bidirectional verification mapping relationship table, a verification mapping table for implicit quality data of medicinal materials is constructed.
7. The method for tracing and identifying the quality of traditional Chinese medicine based on blockchain QR codes according to claim 6, characterized in that, S6, specifically: By scanning the blockchain QR code, the blockchain traceability identification information of medicinal materials can be obtained, and data can be retrieved in the implicit quality data verification mapping table of medicinal materials; Based on the implicit quality data verification mapping table of medicinal materials, obtain the main component feature data and classification discrimination feature data of medicinal materials corresponding to the blockchain traceability identification information of medicinal material quality; The main component characteristic data and classification discrimination characteristic data of medicinal materials are compared with the main component characteristic data and classification discrimination characteristic data of the medicinal materials to be identified. Based on the data consistency comparison results, the true quality status of the current Chinese medicinal material sample to be identified is determined, and the quality traceability identification result of the current Chinese medicinal material sample to be identified is generated.
Citation Information
Cited By
AI digital fingerprint construction method and system for traditional Chinese medicinal material synthetic biological characteristics
CN122048393A
Construction method and system of ai digital fingerprint of synthetic biology characteristics of traditional chinese medicinal materials
CN122048393B
An under-forest traditional Chinese medicinal material rhizoma polygonati whole industry chain quality tracing system and method
CN122472617A