An opium drug management method and system based on the internet of things
By combining RFID reader arrays and gravity sensor nodes with time series prediction models, the problems of uncertain drug location, illegal operation, and abnormal medication time in the management of narcotic and psychotropic drugs have been solved. This has enabled accurate recording, legality verification, and intelligent early warning of drug management, thereby improving the safety and intelligence of drug management.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SICHUAN JINTOU FINANCIAL ECONOMIC SERVICE
- Filing Date
- 2026-06-10
- Publication Date
- 2026-07-10
AI Technical Summary
The existing narcotic and psychotropic drug management system cannot accurately locate the drug storage location, lacks real-time dual verification for retrieval and placement operations, and has difficulty in automatically issuing early warnings for abnormal patient medication times, leading to problems such as drug loss, mis-retrieval, and unreasonable medication intervals.
By combining RFID reader arrays and gravity sensor nodes, the system enables three-dimensional positioning and weight verification of medicines within the smart medicine cabinet. It also uses a time series prediction model to predict medication time windows and generates early warning information in case of abnormal situations.
It enables accurate recording of drug storage and retrieval processes, dual verification of operational legality, and intelligent early warning of medication time, thereby improving the security and intelligence level of drug management and reducing the risk of drug loss and abnormal medication use.
Smart Images

Figure CN122369849A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Internet of Things (IoT) drug management technology, specifically to a method for managing narcotic and psychotropic drugs based on the Internet of Things. Background Technology
[0002] Current management of controlled substances primarily relies on manual registration and simple electronic ledger systems. Operators manually input medication dispensing information and then verify it against paper prescriptions. While smart medicine cabinets have been used in some scenarios, they typically only use a single RFID tag to record medication entry and exit, lacking precise location accuracy. When multiple tags are read simultaneously, it's difficult to distinguish the specific compartment where the medication is located, leading to confusion. Furthermore, current technology relies mainly on manual spot checks or post-incident inventory to verify the legality of medication dispensing, lacking a real-time, automated dual verification mechanism. When the quantity of medication taken doesn't match the record, it's impossible to immediately detect and stop the operation, posing a risk of medication loss or misdelivery. On the other hand, patient medication time management relies on the experience and judgment of healthcare professionals, lacking intelligent predictive methods based on historical medication frequency and prescription data. When patients collect medication early or late, the system cannot automatically identify abnormalities and issue warnings, potentially leading to inappropriate medication intervals or drug abuse. While some drug management methods exist in existing patents, they do not yet combine location sensing, weight verification, and time series prediction, thus failing to simultaneously address the technical challenges of real-time accurate drug positioning, automatic verification of operational legality, and early warning of abnormal medication timing. Summary of the Invention
[0003] The purpose of this invention is to provide a method and system for managing narcotic and psychotropic drugs based on the Internet of Things, so as to solve the problems in the prior art that the storage location of narcotic and psychotropic drugs cannot be accurately located, the lack of real-time dual verification of retrieval and placement operations, and the difficulty in automatically warning of abnormal patient medication time.
[0004] The objective of this invention can be achieved through the following technical solutions:
[0005] This invention provides a method and system for managing narcotic and psychotropic drugs based on the Internet of Things, aiming to solve problems such as inaccurate storage and retrieval records, low reliability of operation legality verification, insufficient accuracy of medication time prediction, and delayed response to abnormal warnings in the existing management process of narcotic and psychotropic drugs.
[0006] As a technical solution of the present invention, the method includes: responding to a change in the stock of narcotic and psychotropic drugs in a smart medicine cabinet, collecting the identification information and location signal strength of drug tags through an RFID reader array, and generating a drug access record based on the identification information and the location signal strength; obtaining the weight change value of the drug placement layer through a gravity sensor node in the smart medicine cabinet, verifying the legality of drug retrieval and placement operations based on the weight change value and the drug access record, and generating a locking command and sending it to the electromagnetic lock actuator of the smart medicine cabinet when the verification result is an illegal operation; querying the corresponding patient medication association data in the cloud database based on the drug identification information in the drug access record, and performing a time series prediction model to fuse and calculate the patient medication association data and historical medication frequency to obtain a predicted medication time window; matching the predicted medication time window with the operation time in the drug access record, and generating a medication abnormality warning information when the matching deviation exceeds a preset threshold, and pushing the medication abnormality warning information to the management terminal. Through the above steps, accurate recording of the storage and retrieval process of narcotic and psychotropic drugs, dual verification of the legality of operations, intelligent prediction of medication time, and timely early warning of abnormal behavior are achieved, effectively improving the safety and intelligence level of drug management.
[0007] Preferably, the step of collecting the identification information and location signal strength of the drug label through the RFID reader array, and generating a drug access record based on the identification information and location signal strength, specifically includes: activating at least three RFID reader antennas arranged in the smart medicine cabinet to transmit query signals respectively, receiving response signals returned by the drug label, and parsing the unique identification code of the drug label from the response signals; calculating the received signal strength indication value of the response signal received by each RFID reader antenna, and using the received signal strength indication value as the location signal strength of the drug label relative to the corresponding antenna; determining the three-dimensional spatial coordinates of the drug label in the smart medicine cabinet using a triangulation algorithm based on at least three location signal strengths, comparing the three-dimensional spatial coordinates with the compartment position mapping table of the smart medicine cabinet to obtain the target compartment number where the drug label is located; and storing the unique identification code, the target compartment number, and the current timestamp in association to generate a drug access record. This process utilizes multi-antenna collaborative positioning of the RFID reader array, which can accurately identify the specific compartment location of the drug, avoid identification errors caused by signal interference from adjacent compartments, and improve the accuracy and reliability of the drug access record.
[0008] As a preferred embodiment of the present invention, when the RFID reader array fails to acquire the identification information and location signal strength of the drug label, it activates the auxiliary optical sensor in the smart medicine cabinet to acquire the image information of the drug label. The identification information of the drug label is then parsed using an image recognition algorithm as backup identification data. Specifically, this includes: extracting the label region image from the drug label image acquired by the auxiliary optical sensor; converting the label region image into a grayscale image; and obtaining a binarized image using an adaptive threshold segmentation algorithm. Contour detection is then performed on the binarized image to locate the character region in the drug label. The character region is then input into a convolutional recurrent neural network model, which includes convolutional layers, recurrent layers, and transcription layers. The convolutional layers output feature maps of the character sequence, the recurrent layers perform temporal modeling on the feature maps, and the transcription layers use a connection-time classification loss function to calculate the predicted character sequence. Finally, the unique identifier of the drug label is output according to the following decoding formula:
[0009]
[0010] in, To obtain the optimal character sequence after decoding, Given the feature sequence of the input image, Given an input feature sequence, output character sequence The conditional probability. When RFID fails due to signal obstruction or tag damage, auxiliary optical sensors and image recognition technology can reliably acquire drug identification information, ensuring the system's robustness and continuous availability in complex environments.
[0011] Preferably, the weight change value of the medicine placement layer is obtained through the gravity sensor node in the smart medicine cabinet, and the legality of the medicine retrieval operation is verified based on the weight change value and the medicine storage and retrieval record. Specifically, this includes: reading the current weight value of the medicine placement layer from the gravity sensor node; calculating the difference between the current weight value and the historical weight value stored at the previous moment to obtain the weight change value; when the weight change value is negative, it is determined to be a medicine retrieval operation; calculating the ratio of the absolute value of the weight change value to the unit weight of the medicine in the medicine storage and retrieval record to obtain the quantity of medicine retrieved; comparing the quantity of medicine retrieved with the quantity of medicine retrieved in the medicine storage and retrieval record for consistency; if the comparison is consistent, the verification result is a legal operation. Specifically, this includes: calculating the relative deviation between the quantity of medicine retrieved and the quantity of medicine retrieved, the formula for calculating the relative deviation is:
[0012]
[0013] in, The quantity of medicine taken is calculated from the weight change value. The quantity of medicines retrieved is determined by the RFID reader array in the medicine retrieval record; when the relative deviation... Less than or equal to the preset consistency tolerance threshold When the quantity of medicine taken out matches the quantity of medicine dispensed, the verification result is considered a valid operation; when If the weight change value is positive, it is considered a medication return operation. The ratio of the weight change value to the unit weight of the medication in the medication access record is calculated to obtain the returned medication quantity. The returned medication quantity is then compared with the returned medication quantity in the medication access record. If the comparison is consistent, the verification result is a legitimate operation. If the absolute value of the weight change value is inconsistent with the medication quantity in the medication access record, the verification result is an illegal operation. By comparing the weight change value with the RFID record, it is possible to effectively identify whether there are abnormalities such as quantity discrepancies, omissions, or over-receipts during the operation, solving the misjudgment problem that may exist in a single identification method and improving the accuracy of operation legitimacy verification.
[0014] As a technical solution of the present invention, the step of generating a locking command and sending it to the electromagnetic lock actuator of the smart medicine cabinet when the verification result is an illegal operation specifically includes: querying the compartment control register of the smart medicine cabinet according to the target compartment number in the medicine storage and retrieval record, reading the electromagnetic lock drive address of the corresponding compartment from the compartment control register; generating a locking command containing the electromagnetic lock drive address, and sending the locking command to the microcontroller of the electromagnetic lock actuator through the IoT communication module of the smart medicine cabinet; after parsing the locking command, the microcontroller outputs a high-level signal to the electromagnetic lock drive circuit, driving the armature of the electromagnetic lock to engage to the locked position, and simultaneously writing the status bit of the electromagnetic lock into the compartment status register; continuously monitoring the weight change value of the medicine placement layer through gravity sensor nodes, and updating the locking status in the compartment status register to "locked" when the weight change value remains stable within a preset time period, and reporting it to the cloud management platform. This solution can quickly lock the corresponding compartment when an illegal operation is detected, and uses gravity sensor nodes to assist in confirming the locking effect to prevent continuous illegal operation, while reporting the status to the cloud platform to achieve remote monitoring.
[0015] Preferably, based on the drug identification information in the drug access record, the corresponding patient medication association data in the cloud database is queried. A time series prediction model is used to fuse the patient medication association data and historical medication frequencies to obtain a predicted medication time window. Specifically, this includes: extracting drug identification information from the drug access record; retrieving the corresponding patient identifier in the cloud database using the drug identification information as an index; obtaining patient medication association data based on the patient identifier, including the prescribed medication interval, single dose, and route of administration; and retrieving the historical medication frequency sequence corresponding to the patient identifier from the cloud database. The historical medication frequency sequence includes the timestamp and dosage of each medication operation. This historical medication frequency sequence is arranged chronologically to obtain time-series input data. The patient medication association data and the time-series input data are input into a Long Short-Term Memory (LSTM) network model. The LTM network model filters irregular fluctuations in the historical medication frequency through a forgetting gate, extracts periodic features of medication intervals through an input gate, and generates a predicted value for the next medication time point through an output gate. Based on the predicted value for the next medication time point and a preset confidence interval width, the start and end times of the predicted medication time window are calculated. Utilizing the LTM network to fuse and model the patient's historical medication patterns with medical order data allows for dynamic adaptation to individual differences and changes in medication habits, generating a predicted medication time window with a confidence interval, providing a scientific basis for subsequent anomaly matching.
[0016] As a preferred embodiment of the present invention, the time series prediction model is constructed based on a long short-term memory network or a gated recurrent unit, and uses the patient's historical medication time series and medication intervals prescribed by the doctor as training samples. This model offers flexibility and can be optimized according to the data scale and computing resources, ensuring both prediction accuracy and deployment efficiency.
[0017] Preferably, the step of matching the predicted medication time window with the operation time in the drug access record, and generating a medication anomaly warning when the matching deviation exceeds a preset threshold, specifically includes: extracting the operation timestamp from the drug access record; comparing the operation timestamp with the start and end times of the predicted medication time window to determine whether the operation timestamp falls between the start and end times of the predicted medication time window; when the operation timestamp is earlier than the start time of the predicted medication time window, calculating the time difference between the start time and the operation timestamp as the early medication retrieval deviation, comparing the early medication retrieval deviation with a preset early tolerance threshold, and if the early medication retrieval deviation exceeds the early tolerance threshold, then the matching deviation exceeds the preset threshold; when the operation timestamp is later than the end time of the predicted medication time window, calculating the time difference between the operation timestamp and the end time as the delayed medication retrieval deviation, comparing the delayed medication retrieval deviation with a preset delayed tolerance threshold, and if the delayed medication retrieval deviation exceeds the delayed tolerance threshold, then the matching deviation exceeds the preset threshold; when the matching deviation exceeds the preset threshold, generating a medication anomaly warning based on drug identification information, patient identification, and the matching deviation value. By setting tolerance thresholds for early and late detection, it is possible to distinguish between random deviations and systemic medication abnormalities, thereby reducing false alarms and improving the effectiveness of early warnings.
[0018] As one technical solution of the present invention, the medication anomaly early warning information includes drug identification information, patient identification, operation time, predicted medication time window, and matching deviation value. This rich information content facilitates managers in quickly locating problems, tracing responsibility, and taking appropriate measures.
[0019] Furthermore, the method also includes acquiring facial images of the operator through the camera module of the smart medicine cabinet, performing liveness detection and facial feature extraction on the facial images, comparing the extracted facial feature vectors with a pre-stored whitelist feature library in the cloud management platform, determining the operator's identity and access level based on the comparison results, and opening the corresponding access level medicine compartments in the smart medicine cabinet according to the identity and access level. Combining liveness detection and hierarchical access control prevents unauthorized personnel from operating the system, ensuring that only personnel with the appropriate permissions can access specific levels of medicines, thus improving the level of protection capabilities for medicine safety management.
[0020] Preferably, the facial images are subjected to liveness detection and facial feature extraction. The extracted facial feature vectors are compared with a pre-stored whitelist feature library in the cloud management platform. Specifically, this includes: extracting blink frequency and lip movement parameters from multiple consecutive frames of facial images captured by the camera module; inputting the blink frequency and lip movement parameters into a liveness detection classifier; the liveness detection classifier outputs a liveness confidence score; when the liveness confidence score is lower than the liveness threshold, it is determined to be a non-liveness attack and the operation process is terminated; when the liveness confidence score reaches the liveness threshold, key feature points are extracted from the facial images. The method calculates a facial geometric feature vector based on the coordinates of the key feature points. This vector includes the ratio of the interocular distance to the bridge of the nose and the jaw angle. The facial geometric feature vector is then converted into a fixed-length feature hash code using a hash mapping algorithm. This hash code is used as an index to search and match within a whitelist feature database. When a matching hash code is found, the corresponding identity identifier and permission level are returned. If no matching hash code is found, it is sent to a cloud management platform for secondary comparison. The cloud management platform returns the comparison result and the corresponding identity identifier. This solution combines liveness detection and hash mapping retrieval, improving local matching efficiency while ensuring attack prevention capabilities. The cloud-based secondary comparison mechanism provides scalability support for large-scale whitelist databases.
[0021] As a preferred embodiment of the present invention, opening the corresponding access level of the medicine compartments in the smart medicine cabinet according to the access level specifically includes: synchronizing the access configuration table from the cloud management platform to the local storage of the smart medicine cabinet, wherein the access configuration table records the mapping relationship between each access level and medicine compartment group, and each medicine compartment group contains at least one medicine compartment number; querying the access configuration table according to the identity identifier obtained by comparison, extracting the access level corresponding to the identity identifier, and reading the corresponding medicine compartment group from the access configuration table according to the access level as the operable compartment group; writing an unlocking command into the compartment control register of the smart medicine cabinet, wherein the unlocking command contains the electromagnetic lock drive address corresponding to all medicine compartment numbers in the operable compartment group, so that the electromagnetic locks of the medicine compartments in the operable compartment group are in the unlocked state; keeping the electromagnetic locks of the medicine compartments in the inoperable compartment group in the locked state, and highlighting the location identifier of the operable compartment group on the display screen of the smart medicine cabinet. Through local synchronization of the access configuration table and compartment group management, flexible access control is achieved, and operators can only see and operate the compartments within their access scope, avoiding the risk of unauthorized operation.
[0022] Preferably, the method further includes collecting real-time operating status data of the smart medicine cabinet through an IoT gateway node. This real-time operating status data includes the on / off status of the electromagnetic lock, the measurement values of the gravity sensor node, the operating frequency of the RFID reader array, and the monitoring values of the temperature and humidity sensors. The real-time operating status data is encapsulated into data packets and uploaded to the cloud management platform via an encrypted communication protocol. The cloud management platform generates a health score for the smart medicine cabinet based on the real-time operating status data. When the health score is lower than a health threshold, a maintenance work order is generated and pushed to the maintenance terminal. This solution achieves comprehensive monitoring and health assessment of the smart medicine cabinet's hardware status, enabling timely detection of potential faults and automatic triggering of maintenance processes, ensuring long-term stable operation of the system.
[0023] This invention also provides an IoT-based management system for narcotic and psychotropic drugs, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of the aforementioned IoT-based management method for narcotic and psychotropic drugs. This system integrates multiple technologies such as radio frequency identification positioning, gravity sensing verification, time series prediction, facial recognition access control, and IoT remote monitoring, forming a closed-loop management process from drug storage and retrieval, operation verification, medication prediction to anomaly warning, access management, and equipment maintenance. This significantly improves the precision, intelligence, and security of narcotic and psychotropic drug management.
[0024] The beneficial effects of this invention are:
[0025] The system collects the identification information and location signal strength of medicine labels using an RFID reader array. Based on at least three location signal strengths, a triangulation algorithm is used to determine the three-dimensional spatial coordinates of the medicine label within the smart medicine cabinet, and the target compartment number is obtained by comparing it with a compartment location mapping table. This solution overcomes the limitation of a single RFID antenna in distinguishing labels in adjacent compartments, achieving centimeter-level spatial positioning of medicines within the cabinet. When multiple medicines are stored or retrieved simultaneously, the system can accurately identify the compartment to which each medicine belongs, avoiding identification errors caused by label collisions. Simultaneously, the RFID reader array automatically activates an auxiliary optical sensor when acquisition fails, using a convolutional recurrent neural network model to perform character recognition on the medicine label image, forming a dual backup mechanism of RFID and optical recognition. This solution ensures reliable acquisition of medicine identification information even under extreme conditions of signal interference or label damage, significantly improving the system's robustness in complex environments. Gravity sensor nodes monitor the weight change of the medicine placement layer in real time and compare it with the number of medicines identified by the RFID reader array, calculating the relative deviation and comparing it with a preset tolerance threshold. This solution provides a second verification method independent of RFID. When the weight change value is inconsistent with the identified quantity, it is immediately judged as an illegal operation, and a locking command is generated to drive the electromagnetic lock actuator. After the electromagnetic lock locks, it continuously monitors the weight stability to ensure that the locking action is effectively executed and reports to the cloud management platform. This dual verification mechanism simultaneously verifies the legality of the operation from two dimensions: physical weight and electronic identification. It eliminates the possibility of misjudgment or omission that may occur with a single sensor, and realizes real-time, automated locking control of drug retrieval and placement operations. By fusing the patient's historical medication frequency sequence and prescription medication intervals through a long short-term memory network model, the forget gate filters irregular fluctuation data, the input gate extracts the periodic features of the medication interval, and the output gate generates the predicted value of the next medication time point. Based on the confidence interval width, the predicted medication time window is obtained. This solution overcomes the shortcomings of traditional fixed time interval reminders, which cannot adapt to changes in individual patient medication habits, and can dynamically adjust the prediction window according to the actual medication frequency. This solution matches the operation timestamps in the medication retrieval records with the predicted medication time window. If the operation time is earlier than the window's start time and the deviation from early retrieval exceeds the early tolerance threshold, or later than the window's end time and the deviation from late retrieval exceeds the late tolerance threshold, a medication anomaly warning message containing the medication identifier, patient identifier, and matching deviation value is generated and pushed to the management terminal. This solution achieves intelligent identification of both early and late retrieval anomalies, automatically triggering warnings without relying on manual judgment, effectively assisting managers in identifying potential risks of medication time deviating from medical orders. Attached Figure Description
[0026] The invention will now be further described with reference to the accompanying drawings.
[0027] Figure 1This is a flowchart of a method for managing narcotic and psychotropic drugs based on the Internet of Things, as described in this invention;
[0028] Figure 2 This is a flowchart for predicting medication time windows and issuing early warnings of abnormalities.
[0029] Figure 3 This is a flowchart of the identification and hierarchical control of the operator's rights in the intelligent medicine cabinet. Detailed Implementation
[0030] 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 skilled in the art without creative effort are within the scope of protection of the present invention.
[0031] See Figure 1 This invention provides an Internet of Things (IoT)-based method for managing narcotic and psychotropic drugs. The method includes the following steps: In response to a change in the stock of narcotic and psychotropic drugs in a smart medicine cabinet, the method collects the identification information and location signal strength of drug tags using an RFID reader array, and generates a drug access record based on the identification information and location signal strength; It obtains the weight change value of the drug placement layer through a gravity sensor node in the smart medicine cabinet, verifies the legality of drug retrieval operations based on the weight change value and the drug access record, and generates a locking command and sends it to the electromagnetic lock actuator of the smart medicine cabinet when the verification result is an illegal operation; It queries corresponding patient medication association data in a cloud database based on the drug identification information in the drug access record, and performs a time series prediction model to fuse the patient medication association data and historical medication frequency to obtain a predicted medication time window; It matches the predicted medication time window with the operation time in the drug access record, and generates a medication anomaly warning message when the matching deviation exceeds a preset threshold, and pushes the medication anomaly warning message to a management terminal.
[0032] Example 1: In a specific implementation, at least three RFID reader antennas arranged inside the smart medicine cabinet are activated to transmit query signals and receive response signals returned by the medicine tags. The unique identifier of the medicine tag is then parsed from the response signals. Each antenna in the RFID reader array independently transmits an RFID query signal. When a medicine tag enters the antenna's radiation range, the chip inside the medicine tag is activated and returns a response signal containing the tag's unique identifier. The response signals received by each RFID reader antenna are transmitted to the controller module of the RFID reader array. The controller module extracts the unique identifier of the medicine tag from the data frame of the response signal.
[0033] The received signal strength indication value of the response signal received by each RFID reader antenna is calculated separately, and this received signal strength indication value is used as the position signal strength of the drug tag relative to the corresponding antenna. The controller module measures the signal strength of the response signal received by each antenna to obtain a received signal strength indication value in decibels and milliwatts, which corresponds to the distance attenuation relationship between the drug tag and the corresponding antenna. Each antenna corresponds to a position signal strength, which is recorded as a floating-point number.
[0034] The three-dimensional spatial coordinates of the medicine label within the smart medicine cabinet are determined using a triangulation algorithm based on the signal strength from at least three locations. These coordinates are then compared with the cabinet's compartment location mapping table to obtain the target compartment number where the medicine label is located. The triangulation algorithm calculates the estimated distance of the medicine label relative to each antenna based on the signal strength received from multiple antennas and a pre-calibrated signal strength-distance mapping model. Using the known spatial coordinates of at least three antennas and their corresponding distance estimates, the three-dimensional spatial coordinates of the medicine label are obtained by solving a system of nonlinear equations. The smart medicine cabinet's compartment location mapping table stores the range of three-dimensional coordinates for each compartment within the cabinet's internal coordinate system. The calculated three-dimensional spatial coordinates are compared row by row with the mapping table; when the three-dimensional spatial coordinates fall within the coordinate range of a particular compartment, that compartment is identified as the target compartment number.
[0035] The unique identifier, the target compartment number, and the current timestamp are associated and stored to generate a drug access record. The controller module combines these three data fields into a single record and stores it in the drug access record table of the smart medicine cabinet's local storage. Simultaneously, the drug access record is uploaded to the cloud management platform via the IoT communication module.
[0036] In practical implementation, when the RFID reader array fails to acquire the identification information and location signal strength of the medicine label, the auxiliary optical sensor inside the smart medicine cabinet is activated to acquire image information of the medicine label. Situations where the RFID reader array fails to acquire information include: no response signal is received after the RFID reader antenna transmits a query signal, or the signal-to-noise ratio of the received response signal is lower than a preset signal-to-noise ratio threshold, or the three-dimensional spatial coordinates calculated by the triangulation algorithm cannot match the grid position mapping table. At this time, the controller module sends a start command to the auxiliary optical sensor, which is a high-speed camera installed inside the smart medicine cabinet. This camera acquires image information of the area where the medicine label is located.
[0037] The label region image is extracted from the drug label image acquired by the auxiliary optical sensor. After converting the label region image into a grayscale image, an adaptive threshold segmentation algorithm is used to obtain a binarized image. The controller module first preprocesses the original image, using an edge detection algorithm to locate the rectangular boundary of the drug label and crop the label region image. The red, green, and blue channel values of each pixel in the label region image are converted into grayscale values according to a weighted average formula, resulting in a grayscale image. An adaptive threshold segmentation algorithm is used to calculate the local mean of the grayscale values within the neighborhood window of each pixel in the grayscale image. The local mean minus a preset offset is used as the binarization threshold. Pixels with grayscale values greater than the threshold are assigned a value of 255, and pixels with grayscale values less than the threshold are assigned a value of 0, thus generating a binarized image.
[0038] Contour detection is performed on the binarized image to locate character regions in the drug label. These character regions are then input into a convolutional recurrent neural network (RNN) model, which includes convolutional layers, recurrent layers, and transcription layers. The controller module uses a contour detection algorithm to label connected regions in the binarized image and selects contours with areas within a preset character area range as candidate character regions. These candidate character regions are arranged horizontally and normalized to a fixed size to form a character sequence image. This character sequence image is then input into the RNN model.
[0039] The convolutional layer outputs a feature map of the character sequence, the recurrent layer performs temporal modeling on the feature map, and the transcription layer uses a connection-time classification loss function to calculate the predicted character sequence and outputs the unique identifier of the drug label according to the following decoding formula:
[0040]
[0041] in, To obtain the optimal character sequence after decoding, The input image is a sequence of features, specifically the sequence of feature maps output by the convolutional and recurrent layers. Given an input feature sequence Output character sequence The conditional probability is calculated using a convolutional layer composed of multiple convolutional kernels and pooling layers. This layer extracts local features from the input image and outputs feature maps for different channels. The recurrent layer employs a bidirectional long short-term memory network structure to bidirectionally model the features in the feature maps along the temporal order, outputting the probability distribution at each time step. The transcription layer uses a connection-time classification loss function. During training, this loss function calculates the sum of probabilities of all possible alignment paths using a forward-backward algorithm. During inference, it uses a beam search algorithm or a greedy decoding algorithm to select the sequence with the highest conditional probability from all possible character sequences. . This is the unique identifier on the drug label.
[0042] Example 2: In specific implementation, the current weight value of the medicine placement layer is read from the gravity sensing node. The difference between the current weight value and the historical weight value stored at the previous moment is calculated to obtain the weight change value. The gravity sensing node is a weighing sensor installed below each medicine placement layer. The weighing sensor converts the physical weight into an analog voltage signal, which is then converted into a digital weight value by an analog-to-digital converter. The unit of the digital weight value is grams. Every preset sampling period, the controller module reads the current weight value from the register of the gravity sensing node and simultaneously retrieves the historical weight value from the local memory of the previous sampling period. The difference between the current weight value and the historical weight value is calculated. The sign of the difference indicates the direction of weight increase or decrease, and the absolute value of the difference indicates the amount of change.
[0043] When the weight change is negative, it is determined to be a medication retrieval operation. The absolute value of the weight change is calculated as the ratio of the unit weight of the medication in the medication access record to obtain the retrieval quantity. The retrieval quantity is then compared with the number of medications retrieved in the medication access record. If the comparison matches, the verification result is a valid operation. The unit weight of the medication is obtained from the basic medication information table associated with the medication identification information in the medication access record. This unit weight is the standard net weight of a single pill or vial, in grams. Quantity of medication retrieved. The calculation formula is: ,in This represents the change in weight. The unit weight of the medicine Round to the nearest whole number. Quantity of medicine dispensed. This refers to the number of drugs retrieved from the drug storage and retrieval record, as identified by the RFID reader array, i.e., the number of drug tags retrieved from the target compartment.
[0044] Calculate the relative deviation between the quantity of medicine taken and the quantity of medicine dispensed. The formula for calculating the relative deviation is:
[0045]
[0046] in, The quantity of medicine taken is calculated from the weight change value. The quantity of medicines removed is determined by the RFID reader array in the medicine access record. This is the relative deviation, expressed as a percentage. When the relative deviation... Less than or equal to the preset consistency tolerance threshold When the quantity of medicine taken out matches the quantity of medicine dispensed, the verification result is considered a valid operation; when If this occurs, it is considered inconsistent, and the verification result is an illegal operation. The preset consistency tolerance threshold... The value is set to 5%. This value is based on a combination of the measurement error per unit weight of the drug and the weighing accuracy of the gravity sensor node. Taking 5% as the judgment threshold can distinguish between minor differences caused by label recognition omissions or weight fluctuations and genuine illegal operations.
[0047] When the weight change is positive, it is determined to be a medication return operation. The ratio of the weight change to the unit weight of the medication in the medication access record is calculated to obtain the returned medication quantity. The returned medication quantity is then compared with the medication returned quantity in the medication access record. If the comparison matches, the verification result is a valid operation. The calculation method for the returned medication quantity is the same as the medication retrieved quantity, i.e. , The quantity of medicine returned. This refers to the number of returned medications identified by the RFID reader array in the medication retrieval record. The consistency comparison of medication return operations also uses the aforementioned relative deviation formula. Replace with ,Will Replace with The relative deviation is denoted as ,when If the operation is valid, it is considered a legal operation; otherwise, it is considered an illegal operation.
[0048] When the absolute value of the weight change does not match the quantity of medicine in the medicine access record, the verification result is an illegal operation. The quantity of medicine referred to here includes the quantity of medicine taken out in the retrieval operation and the quantity of medicine returned in the return operation. If the direction of the weight change does not match the operation type in the medicine access record, or if the quantity of medicine taken out or returned corresponding to the absolute value of the weight change does not match the quantity in the record, it is determined to be an illegal operation.
[0049] When the verification result indicates an illegal operation, a locking command is generated and sent to the electromagnetic lock actuator of the smart medicine cabinet. The cabinet's compartment control register is queried based on the target compartment number in the medicine access record, and the electromagnetic lock drive address for the corresponding compartment is read from the register. The compartment control register is a set of storage units within the smart medicine cabinet's main control chip; each compartment corresponds to an electromagnetic lock drive address, which is an 8-bit binary number ranging from 0x00 to 0xFF. A locking command containing the electromagnetic lock drive address is generated. The locking command is a fixed-length data frame containing a command type byte (locking command is fixed at 0x01), a drive address byte, and a verification byte. The locking command is sent to the microcontroller of the electromagnetic lock actuator via the smart medicine cabinet's IoT communication module. The IoT communication module connects to the microcontroller using a serial communication interface (such as a universal asynchronous transceiver), with a baud rate set to 115200 bits per second.
[0050] After parsing the locking command, the microcontroller outputs a high-level signal to the electromagnetic lock drive circuit, driving the armature of the electromagnetic lock to engage in the locked position. Simultaneously, it writes the status bit of the electromagnetic lock into the grid status register. Upon receiving the locking command, the microcontroller extracts the drive address from the data frame, looks up the corresponding input / output port number in the table, and switches the output level of that port from low to high. The high-level signal energizes the relay coil in the electromagnetic lock drive circuit, causing the armature inside the electromagnetic lock to engage under electromagnetic force, extending the latch to the locked position and locking the grid door. The microcontroller simultaneously writes the corresponding grid status bit in the grid status register from 0 (unlocked state) to 1 (locked state).
[0051] The weight change of the medicine placement layer is continuously monitored by gravity sensor nodes. When the weight change remains stable within a preset time period, the lock status in the grid status register is updated to "locked" and reported to the cloud management platform. The preset time period is set to 5 seconds. After issuing the lock command, the microcontroller reads the weight value of the gravity sensor node every 1 second for 5 consecutive reads. If the fluctuation range of the weight change value in the 5 reads is less than 1 gram, the weight change value is considered to be stable. At this time, the microcontroller updates the lock status bit in the grid status register to "locked" (value 2) and reports a data packet containing the grid number and lock status to the cloud management platform through the IoT communication module.
[0052] Example 3: In specific implementation, refer to Figure 2 The process involves extracting drug identification information from drug access records, retrieving the corresponding patient identifier from the cloud database using this information as an index, and obtaining patient medication association data based on the patient identifier. This data includes the prescribed dosing interval, single dose, and route of administration. The drug identification information is a unique identifier for the drug label, and the cloud database stores a mapping table between drug identification information and patient identifiers. This mapping table is queried using a structured query language to obtain the patient identifier associated with the drug identification information. Then, using the patient identifier as the query condition, the corresponding prescribed dosing interval, single dose, and route of administration fields are extracted from the patient medication information table in the cloud database. The prescribed dosing interval is the standard time interval between two doses, in hours; the single dose is the standard dose for each administration, in milligrams; and the route of administration includes preset enumerated values such as oral, intravenous, or intramuscular injection.
[0053] The historical medication frequency sequence corresponding to the patient identifier is retrieved from the cloud database. This sequence includes the timestamp and dosage of each medication administration. The historical medication frequency sequence is then arranged chronologically to obtain the time-series input data. The historical medication frequency sequence is stored in a medication record table in the cloud database, with each record containing a medication timestamp and dosage field. The historical medication frequency sequence is then sorted in ascending order by medication timestamp to generate an ordered sequence. Each element in the sequence is a two-dimensional vector containing the medication timestamp and dosage. The medication timestamp is converted to seconds from a reference time (e.g., January 1, 1970, 00:00:00), and the dosage is expressed in milligrams and rounded to one decimal place.
[0054] The patient medication association data and the time series input data are input into the Long Short-Term Memory Network model. The Long Short-Term Memory Network model filters irregular fluctuation data in historical medication frequency through the forget gate, extracts periodic features of medication intervals through the input gate, and generates the predicted value of the next medication time point through the output gate.
[0055] The structure of a Long Short-Term Memory (LSTM) network model includes an input layer, an LTM network layer, and an output layer. Each LTM network layer contains several LTM units, and each LTM unit contains a forget gate, an input gate, and an output gate. The forget gate is calculated as follows: ,in For the output of the forget gate, It is the sigmoid activation function. Here is the weight matrix for the forget gate. This is the hidden state from the previous moment. Let the input vector be the input vector at the current time. This is the bias term for the forget gate. The input gate is calculated as follows: , ,in The output of the input gate, Candidate cell state, and This is the weight matrix. and This is a bias term. The cell state is updated as follows: ,in The current cell state, This represents the cell state at the previous time step. The output gate is calculated as follows: , ,in For the output of the output gate, The current hidden state is represented by the output layer, which is a fully connected layer that maps the hidden state of the last time step of the Long Short-Term Memory (LSTM) network layer to the predicted value at the next medication time point. The activation function of the output layer is a linear function.
[0056] During the model training phase, training samples consist of patients' historical medication time series and prescribed medication intervals. Each training sample's input is a continuous sequence of historical medication timestamps, and the output is the next medication timestamp. Training data is extracted from a medication record table in a cloud database. Each patient's historical medication record is divided into multiple fixed-length sequences in chronological order, with a sequence length of 10. The input sequence contains 10 consecutive medication timestamps, and the output sequence is the 11th medication timestamp. Mean squared error is used as the loss function during training, the Adam optimizer is employed, the learning rate is set to 0.001, the batch size is set to 32, and the number of training epochs is set to 100. After training, the weight parameters of the Long Short-Term Memory (LSTM) network model are stored in a cloud model library.
[0057] In practice, the start and end times of the predicted medication time window are calculated based on the predicted value of the next medication time point and the preset confidence interval width. The predicted value of the medication time point is the timestamp value output by the Long Short-Term Memory network model, in seconds. The preset confidence interval width is set to 3600 seconds, or 1 hour. The start time of the predicted medication time window is equal to the predicted value minus 1800 seconds, and the end time of the predicted medication time window is equal to the predicted value plus 1800 seconds. Both the start and end times are stored in timestamp format.
[0058] In practice, the operation timestamp is extracted from the drug access record. This timestamp is then compared with the start and end times of the predicted medication time window to determine if it falls within that window. The operation timestamp is the current timestamp recorded in the drug access record, measured in seconds. If the operation timestamp is greater than or equal to the start time and less than or equal to the end time, it is determined that the operation timestamp falls within the predicted medication time window.
[0059] When the operation timestamp is earlier than the start time of the predicted medication time window, the time difference between the start time and the operation timestamp is calculated as the early medication retrieval deviation. This early medication retrieval deviation is compared with a preset early tolerance threshold. If the early medication retrieval deviation exceeds the early tolerance threshold, the matching deviation exceeds the preset threshold. The early medication retrieval deviation is equal to the start time minus the operation timestamp, in seconds. The preset early tolerance threshold is set to 1800 seconds, or 30 minutes. If the early medication retrieval deviation is greater than 1800 seconds, it is determined that the early medication retrieval deviation exceeds the early tolerance threshold, and the matching deviation exceeds the preset threshold.
[0060] When the operation timestamp is later than the end time of the predicted medication time window, the time difference between the operation timestamp and the end time is calculated as the delayed medication retrieval deviation. This deviation is compared with a preset delay tolerance threshold. If the delayed medication retrieval deviation exceeds the delay tolerance threshold, the matching deviation exceeds the preset threshold. The delayed medication retrieval deviation is equal to the operation timestamp minus the end time, in seconds. The preset delay tolerance threshold is set to 1800 seconds, or 30 minutes. If the delayed medication retrieval deviation is greater than 1800 seconds, it is determined that the delayed medication retrieval deviation exceeds the delay tolerance threshold, and the matching deviation exceeds the preset threshold.
[0061] When the matching deviation exceeds a preset threshold, a medication anomaly warning is generated based on the drug identification information, patient identification, and matching deviation value. The matching deviation value is the larger of the early medication retrieval deviation and the delayed medication retrieval deviation, expressed in seconds. The medication anomaly warning information includes drug identification information, patient identification, operation time, predicted medication time window, and matching deviation value. The drug identification information is the unique identifier of the drug label, the patient identification is the patient number, the operation time is the operation timestamp in the drug access record, the predicted medication time window includes the start and end times, and the matching deviation value is in seconds. The medication anomaly warning information is encapsulated as a JSON format data message and pushed to the management terminal via an IoT communication module. The management terminal is a nursing station computer or mobile terminal device.
[0062] Example 4: In specific implementation, refer to Figure 3 The system uses a camera module in the smart medicine cabinet to capture facial images of the operator, performs liveness detection and facial feature extraction on the facial images, compares the extracted facial feature vectors with a pre-stored whitelist feature library in the cloud management platform, determines the operator's identity and access level based on the comparison results, and opens the corresponding access level medicine compartments in the smart medicine cabinet according to the identity and access level.
[0063] Blink frequency and lip movement parameters are extracted from multiple consecutive frames of facial images captured by a camera module. These parameters are then input into a liveness detection classifier, which outputs a liveness confidence score. The camera module is a high-definition camera mounted on the front of the smart medicine cabinet, with a resolution of 1920×1080 pixels and a frame rate of 30 frames per second. When a human body is detected approaching, the camera module continuously captures 5 frames of facial images. The blink frequency is extracted as follows: for each frame, a cascaded classifier based on Haar features is used to detect the eye region. The rate of change of the eye region area in adjacent frames is calculated. A blink is defined as a blink when the rate of change is between 0.3 and 0.7. The number of blinks in the 5 frames is counted to obtain the blink frequency, expressed as blinks per frame. The lip movement parameters are extracted as follows: 68 key points of the lip contour are located using an active shape model. The standard deviation of the change in the vertical distance between the center points of the upper and lower lips in adjacent frames is calculated as the lip movement parameter. Blink frequency and lip movement parameters are combined into a two-dimensional vector and input into a liveness detection classifier. The liveness detection classifier is a support vector machine (SVM) model. During training, positive samples are blink frequency and lip movement parameters captured from real face videos, while negative samples are parameter features from photos, video playback, or 3D mask attacks. The SVM model uses a radial basis function (RBF) kernel with a penalty coefficient of 1.0 and a gamma value of 0.1. The liveness detection classifier outputs a liveness confidence score, a floating-point number between 0 and 1. When the liveness confidence score falls below a liveness threshold, it is considered a non-liveness attack, and the process terminates. The liveness threshold is set to 0.85, calculated based on the equal error rate on the training set; the equal error rate corresponds to a threshold of 0.85.
[0064] When the liveness confidence score reaches the liveness threshold, key feature point coordinates are extracted from the facial image. A facial geometric feature vector is calculated based on these coordinates, including the ratio of interocular distance to nasal bridge length and the mandibular angle. The key feature point coordinates are extracted using a cascaded regression model based on a convolutional neural network, outputting two-dimensional coordinates of 68 facial key points. Interocular distance is the Euclidean distance between the outer corners of the left and right eyes, in pixels. Nasal bridge length is the Euclidean distance between the root of the nose (corresponding to key point 28) and the tip of the nose (corresponding to key point 31), in pixels. The ratio of interocular distance to nasal bridge length is calculated as a dimensionless floating-point number. The mandibular angle is obtained by calculating the angle formed by the left mandibular angle (key point 5), the chin tip (key point 9), and the right mandibular angle (key point 13), in degrees. The ratio of interocular distance to nasal bridge length and the mandibular angle are combined to form a two-dimensional facial geometric feature vector.
[0065] The facial geometric feature vector is converted into a fixed-length feature hash code using a hash mapping algorithm. This feature hash code is then used as an index for retrieval and matching in a whitelist feature database. The hash mapping algorithm is a locality-sensitive hash algorithm, and the hash function family uses the random hyperplane projection method. The specific steps are as follows: a 2xk random matrix is generated, with matrix elements following a standard normal distribution. The facial geometric feature vector is multiplied by the random matrix to obtain a k-dimensional projection vector. A sign function is assigned to each component of the projection vector; a positive sign is encoded as 1, and a negative sign as 0, resulting in a k-bit binary feature hash code. k is set to 128. The whitelist feature database is stored in a hash table in the local storage of the smart medicine cabinet. The key of the hash table is the feature hash code, and the value is the corresponding operator's identity identifier and permission level. An equality search is performed using the hash table. If a hash code identical to the feature hash code is found, the corresponding identity identifier and permission level are returned; if no matching feature hash code is found, the process proceeds to a secondary comparison process on the cloud management platform.
[0066] When no matching feature hash code is found, the feature hash code is sent to the cloud management platform for secondary comparison. The cloud management platform returns the comparison result and the corresponding identity identifier. The cloud management platform's whitelist feature library stores the complete facial geometric feature vectors of all authorized personnel, along with their corresponding identity identifiers and permission levels. After receiving the feature hash code, the cloud management platform uses the same Locality Sensitive Hashing algorithm to map the feature hash code back to the candidate vector range. Within the candidate range, it calculates the Euclidean distance between each facial geometric feature vector and the vectors in the whitelist feature library. A match is determined when the Euclidean distance is less than a preset distance threshold. The preset distance threshold is set to 0.15. If a match is successful, the cloud management platform returns the corresponding identity identifier and permission level to the smart medicine cabinet via an encrypted communication protocol.
[0067] The permission configuration table is synchronized from the cloud management platform to the local storage of the smart medicine cabinet. This table records the mapping relationship between each identity permission level and the corresponding medicine compartment group. Each medicine compartment group contains at least one medicine compartment number. The permission configuration table is stored in JSON format and contains multiple entries, each including an identity permission level field and a medicine compartment group field. Identity permission levels are divided into three levels: Level 1 Administrator, Level 2 Nurse, and Level 3 Pharmacist, each corresponding to a different medicine compartment group. For example, the medicine compartment group corresponding to a Level 1 Administrator contains all compartment numbers, the medicine compartment group corresponding to a Level 2 Nurse contains compartments numbered 1 to 10, and the medicine compartment group corresponding to a Level 3 Pharmacist contains compartments numbered 11 to 20. Each time the smart medicine cabinet starts up, it sends a synchronization request to the cloud management platform via the IoT communication module, receives the latest permission configuration table, and overwrites the corresponding area in the local storage.
[0068] Based on the identity identifier obtained through comparison, the permission configuration table is queried to extract the corresponding identity permission level. Then, based on the identity permission level, the corresponding drug compartment group is read from the permission configuration table as the operable compartment group. The identity identifier is the operator's employee ID string, and the permission configuration table stores the mapping relationship between the identity identifier field and the identity permission level. By traversing the entries in the permission configuration table, entries whose identity identifier field matches the compared identity identifier are searched, and the identity permission level is extracted from them. Then, using the identity permission level as an index, the corresponding drug compartment group is read from the permission configuration table. This drug compartment group is an array containing several drug compartment numbers.
[0069] An unlock command is written to the compartment control register of the intelligent medicine cabinet. This unlock command contains the electromagnetic lock drive addresses corresponding to the numbers of all medicine compartments in the operable compartment group, thus unlocking the electromagnetic locks of the medicine compartments in that group. The compartment control register is a contiguous address space within the main control chip of the intelligent medicine cabinet, with each byte corresponding to the electromagnetic lock control bit of one compartment. The controller module converts each medicine compartment number in the operable compartment group into its corresponding electromagnetic lock drive address. The drive address is calculated as: Drive Address = Compartment Number Base Address + Compartment Number. The compartment number base address is set to 0x1000. The controller module writes 0x00 to each drive address via memory-mapped input / output, where 0x00 indicates the unlocked state. Simultaneously, the controller module writes 0x01 to the global unlock enable bit in the compartment control register, allowing the electromagnetic lock actuator to respond to the unlock command.
[0070] The electromagnetic locks of the medicine compartments in the inoperable compartment group are kept locked, and the location markers of the operable compartment group are highlighted on the display screen of the smart medicine cabinet. The inoperable compartment group consists of all compartments remaining in the smart medicine cabinet after excluding the operable compartment group. The controller module writes 0x01 to the electromagnetic lock drive address of each compartment in the inoperable compartment group, where 0x01 indicates the locked state. The display screen is an LCD touchscreen mounted on the front of the smart medicine cabinet. The controller module marks the physical location of each compartment in the operable compartment group with a green highlighted box on the display screen and displays the compartment number next to each highlighted box. At the same time, the compartment area of the inoperable compartment group is displayed in gray and cannot be clicked. The display refresh rate is set to 100 milliseconds.
[0071] Example 5: In a specific implementation, real-time operating status data of the smart medicine cabinet is collected through an IoT gateway node. This real-time operating status data includes the on / off status of the electromagnetic lock, the measured values from the gravity sensor node, the operating frequency of the RFID reader array, and the monitoring values from the temperature and humidity sensors. The IoT gateway node is an embedded communication module installed inside the smart medicine cabinet, integrating a microprocessor, a wireless communication unit, and a wired communication interface. The on / off status of the electromagnetic lock is obtained by reading the status bits in the grid status register; a status bit of 0 indicates unlocked, 1 indicates locked, and 2 indicates locked. The measured values from the gravity sensor node are read directly from its data register, in grams. The operating frequency of the RFID reader array is read from the frequency configuration field of the RFID reader array's control register; the frequency field is an integer, in kilohertz. The monitoring values from the temperature and humidity sensors are read through the integrated circuit bus interface; the temperature value is in degrees Celsius, and the humidity value is a relative humidity percentage. The microprocessor executes a data acquisition task every 10 seconds, splicing the above four data items into a data frame in a preset order. The data frame is 32 bytes long.
[0072] The real-time operating status data is encapsulated into a data packet and uploaded to the cloud management platform via an encrypted communication protocol. The data packet format is a JSON object containing four fields: device_id (unique identifier for the smart medicine cabinet), timestamp (time stamp of the collection moment, in ISO8601 format), and status_data (containing arrays of electromagnetic lock switch status, gravity sensor node measurement values, RFID reader array operating frequencies, and temperature and humidity sensor monitoring values). After encapsulation, the microprocessor establishes an encrypted connection with the cloud management platform server using a transport layer security protocol, with the cloud management platform's Uniform Resource Locator (URL) set to a pre-configured fixed address. The microprocessor sends the data packet to the cloud management platform using the POST method of the Hypertext Transfer Protocol Secure (HTTP) protocol, setting the Content-Type in the request header to application / json. Upon receiving the data packet, the cloud management platform parses the packet content and stores it in its real-time operating status database.
[0073] The cloud management platform generates a health score for the smart medicine cabinet based on the real-time operational status data. The health score is generated as follows: the cloud management platform extracts all real-time operational status data from the real-time operational status database for the 24 hours prior to the current time point, and calculates the number of anomalies for each type of operational status data. The electromagnetic lock switch status anomaly determination method is: if the status position changes more than 5 times within 3 seconds, it is counted as one anomaly. The gravity sensor node measurement value anomaly determination method is: if the difference between two consecutive measurements exceeds 100 grams and the duration exceeds 30 seconds, it is counted as one anomaly. The RFID reader array operating frequency anomaly determination method is: if the operating frequency is below 860 MHz or above 960 MHz, it is counted as one anomaly. The temperature and humidity sensor monitoring value anomaly determination method is: if the temperature value is above 40 degrees Celsius or below 0 degrees Celsius, or the humidity value is above 90% or below 10%, it is counted as one anomaly. The total number of anomalies for each type is counted and recorded as [statistic number]. Health Score The calculation formula is:
[0074]
[0075] in, A health score is given, with values ranging from 0 to 100 (integers). This represents the sum of the number of anomalies across all categories within 24 hours, with a coefficient of 5 representing the points deducted for each anomaly. When it is greater than 20, The value is set to 0. The health score is updated every 24 hours.
[0076] When the health score falls below the health threshold, a maintenance work order is generated and pushed to the maintenance terminal. The health threshold is set to 60, based on the mean time between failures (MTBF) of the smart medicine cabinet. A health score below 60 indicates a high risk of equipment failure. After each health score calculation, the cloud management platform compares the score with the health threshold. If the system detects an error, a maintenance work order will be automatically generated. The work order includes the smart medicine cabinet's device identifier, generation time, current health score, and a detailed list of various anomalies. The work order is pushed to the maintenance terminal (an application on the maintenance personnel's smartphone or tablet) in JSON format via a secure Hypertext Transfer Protocol (HTTP) protocol. Upon receiving the work order, the maintenance terminal displays a work order summary in a pop-up window on the application interface and stores the work order in its local task list, awaiting confirmation from the maintenance personnel.
[0077] A drug management system based on the Internet of Things (IoT) includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of any of the IoT-based drug management methods described above. The memory is a synchronous dynamic random access memory (DRAM) or a flash memory, and the processor is a microcontroller based on an ARM architecture or a central processing unit based on an x86 architecture. The computer program is stored in the flash memory as firmware. After the system is powered on, the processor loads the computer program from the flash memory into the DRAM and executes it. During execution, the processor interacts with peripheral devices such as RFID reader arrays, gravity sensor nodes, electromagnetic lock actuators, camera modules, displays, and IoT gateway nodes through general-purpose input / output interfaces to complete all steps of the method, including generating drug access records, verifying legality, generating predicted medication time windows, issuing medication anomaly warnings, identity verification and access control, and collecting and uploading operational status data.
[0078] The foregoing has provided a detailed description of one embodiment of the present invention, but this description is merely a preferred embodiment and should not be construed as limiting the scope of the invention. All equivalent variations and modifications made within the scope of the claims of this invention should still fall within the patent coverage of this invention.
Claims
1. A method for managing narcotic and psychotropic drugs based on the Internet of Things, characterized in that, The method includes: In response to a change in the stock of narcotic and psychotropic drugs in the smart medicine cabinet, the identification information and location signal strength of the drug tags are collected through an RFID reader array, and a drug access record is generated based on the identification information and the location signal strength. The weight change value of the medicine placement layer is obtained by the gravity sensor node in the smart medicine cabinet. The legality of the medicine retrieval operation is verified according to the weight change value and the medicine storage and retrieval record. When the verification result is illegal operation, a locking command is generated and sent to the electromagnetic lock actuator of the smart medicine cabinet. Based on the drug identification information in the drug access record, query the corresponding patient medication association data in the cloud database, and use a time series prediction model to fuse and calculate the patient medication association data and historical medication frequency to obtain the predicted medication time window; The predicted medication time window is matched with the operation time in the drug access record. When the matching deviation exceeds a preset threshold, a medication abnormality warning message is generated and pushed to the management terminal.
2. The method for managing narcotic and psychotropic drugs based on the Internet of Things according to claim 1, characterized in that, The process of acquiring the identification information and location signal strength of drug tags through a radio frequency identification (RFID) reader array, and generating drug access records based on the identification information and location signal strength, specifically includes: The system activates at least three RFID reader antennas located inside the smart medicine cabinet to transmit query signals, receives response signals returned by the medicine labels, and parses the unique identification code of the medicine labels from the response signals. Calculate the received signal strength indication value of the response signal received by each RFID reader antenna, and use the received signal strength indication value as the position signal strength of the drug label relative to the corresponding antenna; The three-dimensional spatial coordinates of the medicine label in the smart medicine cabinet are determined by a triangulation algorithm based on the signal strength of at least three locations. The three-dimensional spatial coordinates are then compared with the compartment position mapping table of the smart medicine cabinet to obtain the target compartment number where the medicine label is located. The unique identifier, the target grid number, and the current timestamp are associated and stored to generate a drug storage and retrieval record.
3. The method for managing narcotic and psychotropic drugs based on the Internet of Things according to claim 2, characterized in that, When the radio frequency identification reader array fails to collect the identification information and location signal strength of the drug label, it activates the auxiliary optical sensor in the smart medicine cabinet to collect the image information of the drug label, and uses the image recognition algorithm to parse the identification information of the drug label as backup identification data.
4. The method for managing narcotic and psychotropic drugs based on the Internet of Things according to claim 2, characterized in that, The weight change value of the medicine placement layer is obtained through the gravity sensor node in the smart medicine cabinet. The legality of the medicine retrieval and placement operation is verified based on the weight change value and the medicine storage and retrieval record. Specifically, this includes: The current weight value of the medicine placement layer is read from the gravity sensor node, and the difference between the current weight value and the historical weight value stored at the previous moment is calculated to obtain the weight change value. When the weight change value is negative, it is determined to be a drug retrieval operation. The absolute value of the weight change value is calculated as the ratio of the unit weight of the drug in the drug storage and retrieval record to obtain the drug retrieval quantity. The drug retrieval quantity is compared with the drug retrieval quantity in the drug storage and retrieval record. If the comparison is consistent, the verification result is a legal operation. When the weight change value is positive, it is determined to be a drug return operation. The ratio of the weight change value to the unit weight of the drug in the drug access record is calculated to obtain the drug return quantity. The drug return quantity is compared with the drug return quantity in the drug access record. If the comparison is consistent, the verification result is a legal operation. When the absolute value of the weight change is inconsistent with the quantity of medicine in the medicine access record, the verification result is an illegal operation.
5. The method for managing narcotic and psychotropic drugs based on the Internet of Things according to claim 4, characterized in that, The step of generating a locking command and sending it to the electromagnetic lock actuator of the smart medicine cabinet when the verification result is an illegal operation specifically includes: The intelligent medicine cabinet's compartment control register is queried based on the target compartment number in the medicine access record, and the electromagnetic lock drive address of the corresponding compartment is read from the compartment control register. A locking command containing the electromagnetic lock drive address is generated, and the locking command is sent to the microcontroller of the electromagnetic lock actuator through the IoT communication module of the smart medicine cabinet; After parsing the locking command, the microcontroller outputs a high-level signal to the electromagnetic lock drive circuit, driving the armature of the electromagnetic lock to engage in the locking position, and at the same time writes the status bit of the electromagnetic lock into the grid status register. The gravity sensor node continuously monitors the weight change value of the medicine placement layer. When the weight change value remains stable within a preset time, the lock status in the grid status register is updated to locked and reported to the cloud management platform.
6. The method for managing narcotic and psychotropic drugs based on the Internet of Things according to claim 1, characterized in that, Based on the drug identification information in the drug access record, the corresponding patient medication association data is queried from the cloud database. A time series prediction model is then used to fuse and calculate the patient medication association data and historical medication frequency to obtain a predicted medication time window, specifically including: Extract drug identification information from drug access records, retrieve the corresponding patient identifier in the cloud database using the drug identification information as an index, and obtain patient medication association data based on the patient identifier. The patient medication association data includes the prescribed medication interval, single dose, and route of administration. The historical medication frequency sequence corresponding to the patient identifier is retrieved from the cloud database. The historical medication frequency sequence includes the timestamp and dosage of each medication operation. The historical medication frequency sequence is arranged in chronological order to obtain time series input data. The patient medication association data and the time series input data are input into the long short-term memory network model. The long short-term memory network model filters irregular fluctuation data in the historical medication frequency through the forget gate, extracts the periodic features of the medication interval through the input gate, and generates the predicted value of the next medication time point through the output gate. The start and end times of the predicted medication time window are calculated based on the predicted value of the next medication time point and the preset confidence interval width.
7. The method for managing narcotic and psychotropic drugs based on the Internet of Things according to claim 1, characterized in that, The time series prediction model is constructed based on long short-term memory networks or gated recurrent units, and uses the patient's historical medication time series and medication intervals prescribed by doctors as training samples.
8. The method for managing narcotic and psychotropic drugs based on the Internet of Things according to claim 6, characterized in that, The step of matching the predicted medication time window with the operation time in the drug access record, and generating a medication anomaly warning when the matching deviation exceeds a preset threshold, specifically includes: Extract the operation timestamp from the drug access record, compare the operation timestamp with the start and end times of the predicted medication time window, and determine whether the operation timestamp falls between the start and end times of the predicted medication time window. When the operation timestamp is earlier than the start time of the predicted medication time window, the time difference between the start time and the operation timestamp is calculated as the early medication deviation. The early medication deviation is compared with a preset early tolerance threshold. If the early medication deviation exceeds the early tolerance threshold, the matching deviation exceeds the preset threshold. When the operation timestamp is later than the end time of the predicted medication time window, the time difference between the operation timestamp and the end time is calculated as the delayed medication deviation. The delayed medication deviation is compared with a preset delay tolerance threshold. If the delayed medication deviation exceeds the delay tolerance threshold, the matching deviation exceeds the preset threshold. When the matching deviation exceeds the preset threshold, medication abnormality warning information is generated based on drug identification information, patient identification, and matching deviation value.
9. The method for managing narcotic and psychotropic drugs based on the Internet of Things according to claim 1, characterized in that, The medication anomaly warning information includes drug identification information, patient identification, operation time, predicted medication time window, and matching deviation value.
10. A drug management system based on the Internet of Things, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the Internet of Things-based method for managing narcotic and psychotropic drugs as described in any one of claims 1 to 9.