A pharmacy receipt processing method and device, electronic equipment and storage medium
By using OCR recognition and data mining on pharmacy receipts, the problem of low efficiency in manual statistics in pharmacies has been solved, enabling drug demand forecasting and personalized recommendations, optimizing inventory management and promotional strategies, and improving the operational efficiency and customer satisfaction of pharmacies.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-06
- Publication Date
- 2026-03-24
AI Technical Summary
In pharmacy transactions, current technology relies on manual statistics of sales data, which leads to inaccurate and inefficient data collection and an inability to effectively utilize the data value in receipts, resulting in problems such as insufficient or excessive inventory.
By acquiring a set of receipt images, OCR recognition technology is used to extract drug sales information, and data mining and correlation analysis are performed. A target prediction model is used to predict drug demand, and K-means clustering algorithm is combined to provide personalized recommendations.
It has enabled efficient and automated processing of pharmacy receipts, improved the accuracy of data collection and analysis, optimized inventory management and promotional activity design, and enhanced user experience and operational efficiency.
Smart Images

Figure CN120047957B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, specifically to a method, apparatus, electronic device, and storage medium for processing pharmacy receipts. Background Technology
[0002] With the development of information technology, image recognition technology and big data analytics are increasingly being applied in the field of business intelligence, especially for brick-and-mortar stores. Digital processing and analysis of sales receipts can effectively improve merchants' data processing efficiency, thereby optimizing inventory management and promotional activity design. However, for pharmacies, current technologies primarily rely on manual methods to collect sales data for goods (such as medicines) and on staff experience to plan inventory based on this data. This approach fails to uncover the potential data value from receipts, often leading to inaccurate or inefficient data collection and problems such as insufficient or excessive inventory. Therefore, pharmacy management using these technologies suffers from low efficiency. Summary of the Invention
[0003] To address the aforementioned technical problems, this application provides a method, apparatus, electronic device, and storage medium for processing pharmacy receipts.
[0004] In a first aspect, this application provides a method for processing pharmacy receipts, comprising: acquiring a set of receipt images, wherein the set of receipt images includes multiple receipt images; performing OCR recognition on each receipt image in the set of receipt images to obtain a set of receipt data, wherein each receipt data in the set of receipt data corresponds to a receipt image, and each receipt data includes drug sales information; and performing data mining based on the set of receipt data to obtain mining results, wherein the mining results are used for drug management.
[0005] By adopting the above technical solutions, efficient and automated processing of pharmacy receipts can be achieved, improving the speed and accuracy of data collection and analysis. Specifically, acquiring a set of receipt images and extracting drug sales information through OCR recognition significantly improves data processing efficiency, reduces the time and cost of manual operations, and avoids the problems of high error rates and low efficiency associated with traditional manual statistics. Furthermore, data mining based on the obtained set of receipt data can more accurately predict drug demand, optimize inventory management, and avoid problems of insufficient or excessive inventory. It can also reveal valuable information hidden in large amounts of data, such as drug demand trends and customer purchasing habits, thereby helping pharmacies better manage inventory and design promotional activities, ultimately improving pharmacy management efficiency.
[0006] Optionally, data mining can be performed on a set of receipt data to obtain mining results, including: performing association analysis on a set of receipt data to obtain target frequent itemsets in the set of receipt data, wherein the target frequent itemsets include drug combinations that appear together in a set of receipt data more than or equal to a preset frequency threshold, and the mining results include target frequent itemsets.
[0007] By employing the aforementioned technical solutions and performing correlation analysis on a set of receipt data, it is possible to accurately identify which medications are frequently purchased together, forming target frequent itemsets. Based on these frequent itemsets, pharmacies can rationally arrange the placement of related medications on shelves, promoting cross-selling and enhancing the customer shopping experience. The ability to discover frequently purchased medication combinations from a set of receipt data helps pharmacies to more scientifically plan their product layout and manage inventory.
[0008] Optionally, after obtaining the target frequent itemset in a set of receipt data, the above method further includes: adjusting the layout of the target drug combination on the shelf according to the target frequent itemset, wherein the target drug combination is any drug combination included in the target frequent itemset.
[0009] By employing the aforementioned technical solution, the layout of target drug combinations on shelves can be adjusted based on the frequent itemsets of the target products in the receipt data. Specifically, by performing correlation analysis on a set of receipt data, drug combinations that are frequently purchased together during the sales process can be identified. These drug combinations are then placed together, thereby improving the customer shopping experience, reducing the time customers spend searching for the required drugs, and increasing sales. Simultaneously, this layout adjustment also helps pharmacies better manage inventory, avoiding inventory backlogs or shortages caused by improper drug placement.
[0010] Optionally, data mining can be performed based on a set of receipt data to obtain mining results, including: using a target prediction model to make predictions based on a set of receipt data to obtain prediction results, wherein the prediction results include the demand for the target drug, and the mining results include the prediction results. The target prediction model is trained using historical sales data.
[0011] By adopting the above technical solutions, the target prediction model can be used to efficiently predict the future demand for target drugs based on a set of receipt data. This not only improves the scientificity and accuracy of drug management, but also avoids the problem of insufficient or excessive inventory caused by human experience and judgment errors to a certain extent, thereby improving the overall operational efficiency and service quality of pharmacies.
[0012] Optionally, the target prediction model is trained as follows: A training sample dataset is obtained, wherein each training sample in the training sample dataset includes first sales data of the sample drug within a preset time period and second sales data after the preset time period. The second sales data represents the actual sales data of the sample drug within a preset duration after the preset time period. The initial prediction model is trained using the training sample dataset until the loss value between the predicted sample result and the actual sample result output by the initial prediction model satisfies a preset convergence condition, and the training ends. The initial prediction model at the end of training is used as the target prediction model, wherein the second sales data includes the actual sample result. If the preset convergence condition is not met, the model parameters in the initial prediction model are adjusted.
[0013] By adopting the above technical solution, a training sample dataset is obtained. Each training sample contains the first sales data within a preset time period and the actual sales data within a subsequent preset time period. Using this training sample dataset for training ensures the quality of the basic data for model training. This training sample data is then used to train the initial prediction model. By continuously adjusting the model parameters, the error between the model's predicted results and the actual sales data is minimized, thereby improving prediction accuracy. Once the model reaches the preset convergence condition, the final prediction model can more accurately predict future drug demand, helping pharmacies better manage inventory and design promotional activities, reducing the risk of inventory backlog or shortages, and improving operational efficiency.
[0014] Optionally, OCR recognition is performed on each receipt image in the receipt image set to obtain a set of receipt data. This includes: establishing an OCR recognition model, wherein the OCR recognition model is obtained by: collecting receipt samples from pharmacies and labeling them to obtain a training receipt sample set; using the receipt sample set to train the original recognition model through a reinforcement learning algorithm, enabling the original recognition model to select a preset processing strategy under different input conditions to obtain an OCR recognition model, wherein the preset processing strategy includes: a dynamic adjustment strategy for image sharpening and a rotation angle compensation strategy; and using the OCR recognition model to perform OCR recognition on each receipt image in the receipt image set according to the preset processing strategy to obtain a set of receipt data.
[0015] By employing the above technical solution, pharmacy receipt samples were collected and labeled to obtain a training sample set, ensuring the OCR recognition model's specificity and improving its generalization ability. Reinforcement learning algorithms were used to train the original recognition model, enabling it to select the optimal preset processing strategy under different input conditions, thus enhancing its adaptability and robustness. The application of dynamic image sharpening and rotation angle compensation strategies effectively solved the problem of inconsistent receipt image quality, further improving the accuracy and speed of OCR recognition. Finally, the trained OCR recognition model was used to recognize the receipt images, ensuring the high-quality generation of a set of receipt data, laying a solid foundation for subsequent data mining and analysis. This technical solution significantly improves the accuracy and efficiency of receipt image recognition.
[0016] Optionally, the above method further includes: obtaining multiple user feature vectors based on a set of receipt data, wherein each user feature vector includes basic features, behavioral features, and time features; performing cluster analysis on the multiple user feature vectors using the K-means clustering algorithm to obtain target clustering results, wherein the mining results include the target clustering results; and making personalized recommendations based on the clustering results.
[0017] By employing the above technical solution, multi-dimensional user feature information can be extracted from a set of receipt data. These feature vectors are then clustered using the K-means clustering algorithm to obtain the target clustering result. This method not only improves the accuracy of data analysis but also provides personalized recommendation services to different users based on the target clustering result, further enhancing user experience and satisfaction. Specifically: by processing the receipt data, multiple user feature vectors, including basic features, behavioral features, and time features, are obtained, making user profiles more comprehensive and accurate; the K-means clustering algorithm is used to classify the user feature vectors, and the generated target clustering result reflects the behavioral patterns and preferences of different types of users; based on the target clustering result, the system can formulate differentiated recommendation strategies for different types of user groups, improving recommendation accuracy and user stickiness.
[0018] In a second aspect of this application, a pharmacy receipt processing apparatus is also provided, comprising: an acquisition module for acquiring a set of receipt images, wherein the set of receipt images includes multiple receipt images; a recognition module for performing OCR recognition on each receipt image in the set of receipt images to obtain a set of receipt data, wherein each receipt data in the set of receipt data corresponds to a receipt image, and each receipt data includes drug sales information; and a processing module for performing data mining based on the set of receipt data to obtain mining results, wherein the mining results are used for drug management.
[0019] In a third aspect of this application, an electronic device is also provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor executes the program to implement the method steps of any of the above claims.
[0020] In a fourth aspect of this application, a computer-readable storage medium is also provided, which stores instructions that, when executed, perform the method steps of any of the above claims.
[0021] In summary, one or more technical solutions provided in this application have at least the following technical effects or advantages:
[0022] 1. It can achieve efficient and automated processing of pharmacy receipts, which can help pharmacies better manage inventory and design promotional activities, thereby improving the management efficiency of pharmacies;
[0023] 2. It can identify frequently purchased drug combinations from a set of receipt data, thereby helping pharmacies to more scientifically plan their product layout and manage inventory, and improve the user's shopping experience;
[0024] 3. It can use the target prediction model to efficiently predict the future demand for target drugs based on a set of receipt data. This not only improves the scientificity and accuracy of drug management, but also avoids the problem of insufficient or excessive inventory caused by human experience and judgment errors to a certain extent, thereby improving the overall operational efficiency and service quality of pharmacies.
[0025] 4. By using a trained OCR recognition model to recognize receipt images, a high-quality set of receipt data is generated, which can significantly improve the recognition accuracy and efficiency of receipt images.
[0026] 5. Perform cluster analysis on a set of receipt data to obtain the target clustering results. Based on the target clustering results, personalized recommendation services can be provided to different users, further improving user experience and satisfaction. Attached Figure Description
[0027] Figure 1 This is a flowchart illustrating a method for processing pharmacy receipts provided in an embodiment of this application;
[0028] Figure 2 This is a structural block diagram of a pharmacy receipt processing device provided in an embodiment of this application;
[0029] Figure 3 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application.
[0030] Explanation of reference numerals in the attached figures: 300 - Electronic device; 301 - Processor; 302 - Communication bus; 303 - User interface; 304 - Network interface; 305 - Memory. Detailed Implementation
[0031] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0032] In the description of the embodiments of this application, the words "for example" or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design that is described as "for example" or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design options. Rather, the use of the words "for example" or "for instance" is intended to present the relevant concepts in a specific manner.
[0033] In the description of the embodiments of this application, the term "multiple" means two or more. Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. The terms "comprising," "including," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0034] The following is in conjunction with the appendix Figures 1-3 The embodiments of this application will be described.
[0035] This application provides a method for processing pharmacy receipts, referring to... Figure 1 , Figure 1 This is a flowchart illustrating a method for processing pharmacy receipts according to an embodiment of this application. The method includes:
[0036] Step S101: Obtain a receipt image set, wherein the receipt image set includes multiple receipt images;
[0037] Step S102: Perform OCR recognition on each receipt image in the receipt image set to obtain a set of receipt data. Each receipt data in the set of receipt data corresponds to a receipt image, and each receipt data includes drug sales information.
[0038] Step S103: Perform data mining based on a set of receipt data to obtain mining results, which are used for drug management.
[0039] Through the above steps, efficient and automated processing of pharmacy receipts can be achieved, improving the speed and accuracy of data collection and analysis. Specifically, acquiring a set of receipt images and extracting drug sales information through OCR recognition significantly improves data processing efficiency, reduces the time and cost of manual operations, and avoids the problems of high error rates and low efficiency associated with traditional manual statistics. Furthermore, data mining based on the obtained set of receipt data can more accurately predict drug demand, optimize inventory management, avoid problems of insufficient or excessive inventory, and reveal valuable information hidden in large amounts of data, such as drug demand trends and customer purchasing habits. This helps pharmacies better manage inventory and design promotional activities, thereby improving operational efficiency and service quality.
[0040] This embodiment acquires a set of receipt images and performs OCR (Optical Character Recognition) to convert the text information in the images into processable electronic data to obtain sales information. This information is then further mined to support drug management. For example, receipt images generated during the sales process at a pharmacy can be collected through scanning, photography, or other technical means to form a receipt image set. Using Optical Character Recognition (OCR) technology, each image in the receipt image set is recognized, converting the text information in the images into editable and analyzable electronic data, thus generating a set of receipt data containing drug sales information. For example, the receipt data may include sales information such as drug name, quantity, price, transaction time, and total transaction price. Data mining is then performed on the obtained set of receipt data to extract valuable information, such as sales quantity, sales amount, and drug type, and further analysis and decision-making are based on this information. For example, association rule analysis can be performed on a set of receipt data to identify the most frequently purchased drug combinations, allowing for shelf layout adjustments to group related drug combinations together or nearby. Alternatively, a set of receipt data can be used to predict the demand or sales trend of a certain drug over a future period, facilitating the development of corresponding inventory plans. Furthermore, analysis of a set of receipt data can categorize customers with similar purchasing behaviors, enabling precise marketing strategies, such as designing promotional activities or personalized recommendation services. This embodiment significantly reduces data processing time and improves merchant efficiency through automated receipt processing. Based on the results of sales data mining, merchants can more accurately predict future demand, thereby developing more reasonable inventory plans. With real-time and accurate data support, pharmacies can more effectively make management decisions such as designing promotional activities and planning inventory, thus improving overall management levels. In some practical application scenarios, some pharmacies are newly connected to the intelligent marketing system and have not stored previous orders. The receipts are printed by simply inputting data in real time without storing the information. For example, during some promotional activities, pharmacies may use separate equipment to print receipts, but these devices are not connected to the pharmacy's computer system. Therefore, it is necessary to use OCR recognition to collect some marketing data to assist in marketing.
[0041] In an optional embodiment, data mining is performed based on a set of receipt data to obtain mining results, including: performing association analysis on a set of receipt data to obtain target frequent itemsets in the set of receipt data, wherein the target frequent itemsets include drug combinations that co-occur more or less than a preset frequency threshold in the set of receipt data, and the mining results include target frequent itemsets.
[0042] In the above embodiments, correlation analysis of a set of receipt data can accurately identify which medicines are frequently purchased together, forming target frequent itemsets. Based on these frequent itemsets, pharmacies can rationally arrange the positions of related medicines on the shelves, promoting cross-selling and improving the customer shopping experience. This data analysis method can identify frequently purchased medicine combinations from a set of receipt data, thereby helping pharmacies to more scientifically plan their product layout and inventory management. At the same time, this data analysis method can also reveal potential market trends, guiding pharmacies to better plan their inventory and avoid inventory backlogs or stockouts.
[0043] In practical applications, after OCR identifies and generates receipt data containing drug sales information, the data can be preprocessed, such as cleaned and organized, to ensure accuracy and consistency. Then, association analysis is performed on the preprocessed receipt data, an important method in data mining used to discover relationships between data items. In this scenario, association analysis aims to identify which drug combinations frequently appear together in pharmacy sales, i.e., target frequent itemsets. These are drug combinations that frequently appear together in sales records. For example, many users buy drug A and drug B simultaneously, indicating they may be complementary products or customers habitually purchase them together. Drug A and drug B can then be considered a drug combination within the target frequent itemset. To determine which drug combinations are frequent, a preset frequency threshold needs to be set. Only drug combinations whose frequency of co-occurrence is greater than or equal to this threshold are considered target frequent itemsets. The preset frequency threshold can be set according to actual application needs and can also be adjusted as needed. Based on the results of the association analysis, mining results containing target frequent itemsets are generated. These target frequent itemsets can provide valuable sales information for pharmacies. While some related technologies may only offer simple statistical analysis of receipt data without delving into the correlations and trends between data points, this embodiment utilizes association analysis to uncover potential connections between medications, providing pharmacies with deeper market insights. Through association analysis, pharmacies can gain a more comprehensive understanding of sales data, discovering correlations and trends between medications, thereby enhancing their data analysis capabilities. Based on the results of frequent itemsets, pharmacies can develop more precise promotional strategies, such as bundled sales and combined discounts, to attract customers and increase sales. Furthermore, understanding which medication combinations customers frequently purchase together helps pharmacies optimize product displays, placing related medications together for easier customer selection and a better shopping experience. The frequent itemsets obtained through association analysis can also guide pharmacy inventory management, ensuring sufficient stock of popular medication combinations and avoiding stockouts or overstocking.
[0044] The following example illustrates this. Suppose a pharmacy's sales receipt data is as follows: ① Cold medicine, Vitamin C; ② Cold medicine, Vitamin C, face mask; ③ Cold medicine, face mask; ④ Vitamin C, face mask; ⑤ Cold medicine, Vitamin C. We can first define a preset frequency threshold, such as 3 times. This means only combinations of medicines appearing simultaneously in at least 3 transactions will be considered combinations within the target frequent itemset. After defining the preset frequency threshold, we can search for frequent itemsets in a set of receipt data, such as [cold medicine, Vitamin C] above. This indicates that when a user buys cold medicine, there is a high probability that they will also buy Vitamin C. In practical applications, we can also identify frequent itemsets and association rules by setting minimum support or confidence thresholds. For example, we can first extract the names, quantities, and corresponding transaction IDs of all medicines from the receipts, remove irrelevant fields (such as cashier IDs), standardize the medicine name format, and use association rule mining algorithms such as Apriori or FP-Growth, setting minimum support and confidence thresholds to identify frequent itemsets and association rules.
[0045] In an optional embodiment, after obtaining the target frequent itemset in a set of receipt data, the method further includes: adjusting the layout of the target drug combination on the shelf according to the target frequent itemset, wherein the target drug combination is any drug combination included in the target frequent itemset.
[0046] In the above embodiments, the layout of target drug combinations on the shelves can be adjusted based on the target frequent itemsets in the receipt data. Specifically, by performing association analysis on a set of receipt data, drug combinations that are frequently purchased together during the sales process can be identified. These drug combinations are then placed together, thereby improving the customer shopping experience, reducing the time customers spend searching for the required drugs, and increasing sales. At the same time, this layout adjustment also helps pharmacies better manage inventory and avoid inventory backlogs or shortages caused by unreasonable drug placement.
[0047] Data mining techniques are used to identify frequently purchased drug combinations, such as drug combinations with a high frequency of purchase. This information is then used to adjust the layout of medicines on pharmacy shelves, placing frequently purchased drug combinations in adjacent or nearby locations. This improves shopping convenience for users, potentially boosting sales and enhancing operational efficiency. In traditional pharmacy layouts, medicines are often arranged based on product category, brand, or staff habits, without considering customer purchasing habits, leading to customers spending more time searching for relevant medicines. This embodiment reduces customer search time and improves the shopping experience by placing frequently purchased drug combinations in close proximity.
[0048] In an optional embodiment, data mining is performed based on a set of receipt data to obtain mining results, including: using a target prediction model to make predictions based on a set of receipt data to obtain prediction results, wherein the prediction results include the demand for the target drug, the mining results include the prediction results, and the target prediction model is trained using historical sales data.
[0049] In the above embodiments, the target prediction model can be used to efficiently predict the future demand for target drugs based on a set of receipt data. This not only improves the scientificity and accuracy of drug management, but also avoids the problem of insufficient or excessive inventory caused by human experience and judgment errors to a certain extent, thereby improving the overall operational efficiency and service quality of pharmacies.
[0050] A target prediction model is trained using historical sales data. This model can be a machine learning model, such as linear regression, decision trees, random forests, neural networks, or a deep learning model. The goal of the model is to predict the demand for a target drug over a future period. Optionally, a set of current receipt data can be input into the trained target prediction model for prediction, or data on a subset of drugs included in a set of receipt data can be input into the trained target prediction model for prediction, resulting in a prediction that includes the demand for the target drug over a future period. The target drug can be one or more drugs; for example, predicting the demand for the target drug over the next week or month. The prediction results are used as part of the data mining results to guide pharmacies' inventory management, procurement plans, and sales strategies. The target prediction model in this embodiment is trained based on historical sales data, meaning that the model can identify various factors affecting drug sales (such as seasonal changes, epidemic trends, etc.) and make predictions accordingly. In practical applications, the model predicts future demand changes by learning patterns and trends in historical data. For example, the model input values (feature variables) may include time series data, drug categories, price changes, promotional activities, etc., while the model output value (target variable) is the demand for the drug. Traditional pharmacy inventory management may rely on experience or intuition, leading to overstocking or shortages. This embodiment utilizes a target prediction model to more accurately predict drug demand, thereby optimizing inventory management. By employing this model, pharmacies can more accurately predict drug demand, thus optimizing inventory management, reducing overstocking and shortages. Procurement plans based on these predictions can more precisely meet the operational needs of pharmacies, reducing procurement costs and improving profitability. Through optimized inventory management and procurement planning, along with the development of precise sales strategies, pharmacies can comprehensively improve operational efficiency, reduce operating costs, and enhance market competitiveness.
[0051] In an optional embodiment, the target prediction model is trained as follows: A training sample dataset is obtained, wherein each training sample in the training sample dataset includes first sales data of the sample drug within a preset time period and second sales data after the preset time period, the second sales data representing the actual sales data of the sample drug within a preset duration after the preset time period; the initial prediction model is trained using the training sample dataset until the loss value between the predicted sample result output by the initial prediction model and the actual sample result satisfies a preset convergence condition, and the training ends, with the initial prediction model at the end of training serving as the target prediction model, wherein the second sales data includes the actual sample result; if the preset convergence condition is not met, the model parameters in the initial prediction model are adjusted.
[0052] In the above embodiment, a training sample dataset is obtained. Each training sample contains the first sales data within a preset past time period and the actual sales data within a subsequent preset time period. Training is conducted using this training sample dataset, ensuring the quality of the basic data for model training. This training sample data is used to train the initial prediction model, and by continuously adjusting the model parameters, the error between the model's predicted results and the actual sales data is minimized, thereby improving prediction accuracy. When the model reaches the preset convergence condition, the final prediction model can more accurately predict future drug demand, helping pharmacies better manage inventory and design promotional activities, reducing the risk of inventory backlog or shortages, and improving operational efficiency. This embodiment effectively trains the target prediction model, which, based on historical sales data, ensures the model's accuracy and reliability through precise sample datasets and scientific training methods.
[0053] First, a training sample dataset is obtained, containing multiple training samples. Each training sample includes the first sales data of a sample drug within a preset time period, and the second sales data within a preset time period after that preset time period. The second sales data is actually the actual sales data of the sample drug after that preset time period, used as the label or target value for model training. Next, this training sample dataset is used to train the initial prediction model. During training, the model attempts to predict the second sales data (target value) based on the first sales data (input feature) in each training sample. The difference between the model's prediction result and the actual sample result (i.e., the loss value) is calculated and used to evaluate the model's performance. If the loss value between the prediction result and the actual result does not meet the preset convergence condition, the model parameters in the initial prediction model are adjusted to improve the model's prediction performance. This process is repeated until the loss value meets the preset convergence condition, at which point training ends. At the end of training, the initial prediction model at this point is determined as the target prediction model for subsequent receipt data mining and drug demand prediction. The initial prediction model is trained using the aforementioned training samples. The goal is for the model to learn to infer the second sales data (i.e., future sales trends) from the first sales data. During training, the model continuously adjusts its parameters to minimize the difference (loss value) between the predicted and actual values. When the loss value reaches a preset convergence condition, the model is considered to have fully learned the sales pattern. At this point, training ends, and the final version of the model is designated as the target prediction model. This embodiment uses historical sales data as the training basis, enabling the model to identify various factors affecting sales and make more accurate demand forecasts accordingly. Compared to traditional experience-based judgment, this method offers higher accuracy and reliability. As new data is continuously added, the model can be retrained or fine-tuned to keep it up-to-date and quickly respond to market changes and technological advancements. It provides pharmacy management with reliable sales forecast information, helping them make more informed business decisions, such as optimal ordering time and quantity, and assessing the potential for introducing new products. Based on the prediction results of the target prediction model, pharmacies can more accurately formulate inventory management strategies, reduce inventory backlog and shortages, and improve operational efficiency.
[0054] The aforementioned target prediction model can be built based on algorithms such as ARIMA or LSTM, capable of capturing trends and seasonal variations in time series. Taking the LSTM model as an example, the training sample set consists of historical sales data from pharmacies. LSTM can handle more types of input features and excels at capturing complex nonlinear patterns. For example, input features include time series data, external factors, lagged variables, and time windows. Time series data can be the daily, weekly, or monthly sales volume of drug C. External factors can include weather conditions (such as temperature, humidity, and other meteorological data), holiday indicators (such as whether it is a holiday), and market activities (such as promotional activities and advertising). The LSTM model can automatically learn the importance of historical data through its internal mechanism. It can select sales data from the past few days as additional input to enhance model performance. In addition, to capture short-term trends, a fixed-length time window (such as 7 days or other time periods) is usually defined, and each training sample will include all feature values within that window. The output target can be the sales volume for a future period, i.e., the target value to be predicted. For the LSTM model, the output is an estimate of the sales volume of drug C for a future period (such as tomorrow, next week, or next month) based on historical data. Taking the prediction of sales volume for the next day as an example, the first sales data mentioned above is the daily sales data for a certain period in the past (such as January 1st to January 7th two years ago). The actual sales volume on the day after seven consecutive days (i.e., January 8th) is the actual result. The model's prediction result is compared with this actual result. The first sales data mentioned above consists of multiple sets of data, each set being the sales data for a certain consecutive seven days in the past. During model training, grid search or random search can be used to find the optimal hyperparameter configurations such as learning rate and batch size. Cross-validation can be used to test the model's generalization ability, and the model's performance can be evaluated on the test set. Commonly used metrics include mean squared error (MSE) and mean absolute error (MAE). If the model performs poorly, the parameters can be adjusted. Once the model training is completed and passed validation, it can be applied to new time points to predict future sales trends.
[0055] In an optional embodiment, OCR recognition is performed on each receipt image in the receipt image set to obtain a set of receipt data. This includes: establishing an OCR recognition model, wherein the OCR recognition model is obtained by: collecting receipt samples from pharmacies and labeling them to obtain a training receipt sample set; using the receipt sample set to train an original recognition model through a reinforcement learning algorithm, enabling the original recognition model to select a preset processing strategy under different input conditions to obtain an OCR recognition model, wherein the preset processing strategy includes: a dynamic adjustment strategy for image sharpening and a rotation angle compensation strategy; and using the OCR recognition model to perform OCR recognition on each receipt image in the receipt image set according to the preset processing strategy to obtain a set of receipt data.
[0056] In the above embodiments, pharmacy receipt samples are collected and labeled to obtain a trained receipt sample set, ensuring the OCR recognition model is targeted and improving its generalization ability. Reinforcement learning algorithms are used to train the original recognition model, enabling it to select the optimal preset processing strategy under different input conditions, improving its adaptability and robustness. The application of dynamic image sharpening and rotation angle compensation strategies effectively solves the problem of inconsistent receipt image quality, further improving the accuracy and speed of OCR recognition. Finally, the trained OCR recognition model is used to recognize the receipt images, ensuring the high-quality generation of a set of receipt data, laying a solid foundation for subsequent data mining and analysis. This embodiment significantly improves the accuracy and efficiency of receipt image recognition.
[0057] First, pharmacy receipt samples are collected and labeled. Labeling may include annotating text, numbers, barcodes, and other information on the receipts to facilitate subsequent training and recognition. Then, using the collected receipt sample set, an original recognition model is trained using reinforcement learning algorithms. Reinforcement learning is a method that allows a model to learn optimal strategies through interaction with its environment. Here, the model is trained to select preset processing strategies under different input conditions to optimize recognition performance. These preset processing strategies include dynamically adjusting image sharpening and rotation angle compensation strategies. These strategies aim to preprocess the images according to the actual conditions of the receipt images to improve the accuracy of OCR recognition. Using the trained OCR recognition model, OCR recognition is performed on each receipt image in the receipt image set according to the preset processing strategies. The recognition process may include image preprocessing (such as sharpening and rotation compensation), character segmentation, feature extraction, and character recognition. Finally, the OCR recognition model outputs a set of receipt data, including text, numbers, barcodes, and other information on the receipts. This information can be used for subsequent data analysis and processing. This embodiment significantly improves the recognition accuracy of the OCR model under different input conditions by introducing reinforcement learning and preset processing strategies, reducing false recognitions and missed recognitions. By dynamically adjusting image sharpening and rotation angle compensation strategies, preset processing strategies can flexibly preprocess the receipt image according to its actual situation, enhancing the model's adaptability. By collecting diverse pharmacy receipt samples and training them with reinforcement learning, the generalization ability of the OCR recognition model can be improved, enabling it to recognize more types and styles of receipt images. Using the OCR recognition model to automatically recognize receipt images can greatly accelerate data processing, reduce errors and costs associated with manual input, and improve the operational efficiency of pharmacies.
[0058] In an optional embodiment, the method further includes: obtaining multiple user feature vectors based on a set of receipt data, wherein each user feature vector includes basic features, behavioral features, and time features; performing cluster analysis on the multiple user feature vectors using the K-means clustering algorithm to obtain target clustering results, wherein the mining results include the target clustering results; and making personalized recommendations based on the clustering results.
[0059] In the above embodiments, multi-dimensional user feature information can be extracted from a set of receipt data, and these feature vectors are clustered using the K-means clustering algorithm to obtain the target clustering result. This method not only improves the accuracy of data analysis but also provides personalized recommendation services to different users based on the target clustering result, further enhancing user experience and satisfaction. Specifically: by processing the receipt data, multiple user feature vectors including basic features, behavioral features, and time features are obtained, making the user profile more comprehensive and accurate; the K-means clustering algorithm is used to classify the user feature vectors, and the generated target clustering result can reflect the behavioral patterns and preferences of different types of users; based on the target clustering result, the system can formulate differentiated recommendation strategies for different types of user groups, improving the accuracy of recommendations and user stickiness.
[0060] This study extracts basic, behavioral, and temporal characteristics of users from a set of receipt data to construct multiple user feature vectors. For example, basic characteristics may include fundamental information such as age and gender; behavioral characteristics may include purchase frequency, preferred drug types, and single purchase amount (all extracted from receipt data); and temporal characteristics may include purchase time, purchase cycle, and seasonal variations. The K-means clustering algorithm is then used to cluster these user feature vectors, grouping users with similar characteristics. Based on the clustering results, personalized product recommendations are made to different user groups. For instance, chronic disease patients are mostly over 60 years old and rely on specific medications for long-term treatment; those focused on health and beauty are mostly young women aged 20-35. The purpose of using the K-means clustering algorithm to analyze the constructed user feature vectors is to identify user groups with similar shopping patterns or preferences. In this way, customers can be divided into different categories, each representing a group of users with common characteristics. The lack of in-depth analysis of user behavior and preferences in related technologies makes it difficult for pharmacies to accurately grasp user needs, affecting the effectiveness of sales strategies. This embodiment extracts user feature vectors and performs cluster analysis to more accurately identify user purchasing behavior and needs, thereby providing personalized recommendations. By extracting user feature vectors from multiple dimensions, user data can be utilized more comprehensively, improving data utilization and recommendation accuracy.
[0061] This application provides a marketing data processing and analysis method based on OCR recognition of pharmacy receipts. It employs OCR recognition technology optimized with deep learning algorithms, significantly improving the accuracy of information recognition on pharmacy receipts, reducing the need for manual intervention, and saving substantial time and costs. Furthermore, it combines the OCR-recognized receipt data with big data analysis to uncover marketing patterns and enhance marketing effectiveness.
[0062] A large number of real pharmacy receipt samples were collected and labeled to establish a training dataset. A reinforcement learning algorithm was used to train a model, enabling it to select the optimal preprocessing and recognition strategies under different input conditions, such as dynamically adjusting image sharpening and rotation angle compensation. The model's performance was continuously evaluated through a testing system, and the model structure and parameter settings were constantly optimized to obtain a receipt recognition model. The receipt recognition model was used to identify real receipt images, obtaining receipt data (order number, detailed order number, membership card number, drug code, drug name, drug specifications, number of boxes, order time, manufacturer, chain branch, store number, store name, retail price, total transaction price, etc.). Data analysis was performed on the receipt data, combined with a time-series prediction model, to statistically analyze pharmacy transaction patterns and assist in marketing.
[0063] This application also provides a device for processing pharmacy receipts, such as... Figure 2 As shown, Figure 2 This is a structural block diagram of a pharmacy receipt processing device provided in an embodiment of this application. The device includes:
[0064] The acquisition module 201 is used to acquire a set of receipt images, wherein the set of receipt images includes multiple receipt images;
[0065] The recognition module 202 is used to perform OCR recognition on each receipt image in the receipt image set to obtain a set of receipt data, wherein each receipt data in the set of receipt data corresponds to a receipt image, and each receipt data includes drug sales information;
[0066] The processing module 203 is used to perform data mining based on a set of receipt data to obtain mining results, which are then used for drug management.
[0067] It should be noted that the above embodiments of the apparatus are only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0068] This application also provides a computer-readable storage medium storing instructions that, when executed, perform the steps of any of the methods described above.
[0069] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.
[0070] This application also discloses an electronic device. For example... Figure 3 As shown, Figure 3 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application. The electronic device 300 may include: at least one processor 301, at least one communication bus 302, a user interface 303, at least one network interface 304, and a memory 305.
[0071] The communication bus 302 is used to enable communication between these components.
[0072] The user interface 303 may include a display screen and a camera. Optionally, the user interface 303 may also include a standard wired interface and a wireless interface.
[0073] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface).
[0074] The processor 301 may include one or more processing cores. The processor 301 connects to various parts of the electronic device (such as a server) using various interfaces and lines, and performs various server functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in memory 305, and by calling data stored in memory 305. Optionally, the processor 301 may be implemented using at least one hardware form of Digital Signal Processing (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 301 may integrate one or a combination of several of the following: Central Processing Unit (CPU), Graphics Processing Unit (GPU), and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 301 and may be implemented as a separate chip.
[0075] The memory 305 may include random access memory (RAM) or read-only memory. Optionally, the memory 305 may include a non-transitory computer-readable storage medium. The memory 305 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 305 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 305 may also be at least one storage device located remotely from the aforementioned processor 301. (Refer to...) Figure 3 The memory 305, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an application program for processing pharmacy receipts.
[0076] exist Figure 3In the illustrated electronic device 300, the user interface 303 is mainly used to provide an input interface for the user and to acquire user input data; while the processor 301 can be used to call an application program for processing pharmacy receipts stored in the memory 305. When executed by one or more processors 301, the electronic device 300 performs one or more of the methods described in the above embodiments. It should be noted that, for the foregoing method embodiments, for the sake of simplicity, they are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0077] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0078] In the various embodiments provided in this application, it should be understood that the disclosed apparatus or system can be implemented in other ways. For example, the apparatus or system embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units 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 service interface; the indirect coupling or communication connection between apparatuses or units may be electrical or other forms.
[0079] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0080] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0081] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory 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 of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as USB flash drives, portable hard drives, magnetic disks, or optical disks.
[0082] The above description is merely an exemplary embodiment of this disclosure and should not be construed as limiting the scope of this disclosure. Any equivalent changes and modifications made in accordance with the teachings of this disclosure shall still fall within the scope of this disclosure. Other embodiments of this disclosure will be readily apparent to those skilled in the art upon consideration of the disclosure herein.
[0083] This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art that are not described in this disclosure.
Claims
1. A method for processing pharmacy receipts, characterized in that, include: Obtain a set of receipt images, wherein the set of receipt images includes multiple receipt images; OCR recognition is performed on each receipt image in the receipt image set to obtain a set of receipt data, wherein each receipt data in the set of receipt data corresponds to a receipt image, and each receipt data includes drug sales information; Data mining is performed on the aforementioned set of receipt data to obtain mining results, which are used for drug management. The process involves performing OCR recognition on each receipt image in the receipt image set to obtain a set of receipt data. This includes: establishing an OCR recognition model, which is obtained by: collecting receipt samples from pharmacies and labeling them to obtain a training receipt sample set; training an original recognition model using the receipt sample set through a reinforcement learning algorithm, enabling the original recognition model to select a preset processing strategy under different input conditions to obtain the OCR recognition model. The preset processing strategy includes: a dynamic image sharpening strategy and a rotation angle compensation strategy; and using the OCR recognition model to perform OCR recognition on each receipt image in the receipt image set according to the preset processing strategy to obtain the set of receipt data. The method further includes: obtaining multiple user feature vectors based on the set of receipt data, wherein each user feature vector includes basic features, behavioral features, and time features; performing cluster analysis on the multiple user feature vectors using the K-means clustering algorithm to obtain a target clustering result, wherein the mining result includes the target clustering result; and making personalized recommendations based on the clustering result.
2. The method according to claim 1, characterized in that, Data mining was performed on the aforementioned set of receipt data to obtain the following results: A correlation analysis is performed on the set of receipt data to obtain the target frequent itemsets in the set of receipt data. The target frequent itemsets include drug combinations that appear together more than or equal to a preset frequency threshold in the set of receipt data. The mining results include the target frequent itemsets.
3. The method according to claim 2, characterized in that, After obtaining the target frequent itemset from the set of receipt data, the method further includes: The layout of target drug combinations on the shelf is adjusted according to the target frequent itemset, wherein the target drug combination is any drug combination included in the target frequent itemset.
4. The method according to claim 1, characterized in that, Data mining was performed on the aforementioned set of receipt data to obtain the following results: Based on the set of receipt data, a target prediction model is used to make predictions, and the prediction results are obtained. The prediction results include the demand for the target drug, and the mining results include the prediction results. The target prediction model is trained using historical sales data.
5. The method according to claim 4, characterized in that, The target prediction model is trained in the following way: Obtain a training sample dataset, wherein each training sample in the training sample dataset includes first sales data of the sample drug within a preset time period and second sales data after the preset time period, the second sales data being used to represent the actual sales data of the sample drug within a preset duration after the preset time period; The initial prediction model is trained using the training sample dataset until the loss value between the predicted sample result and the actual sample result output by the initial prediction model meets the preset convergence condition. The training ends and the initial prediction model at the end of training is used as the target prediction model. The second sales data includes the actual sample result. If the preset convergence condition is not met, the model parameters in the initial prediction model are adjusted.
6. A device for processing pharmacy receipts, characterized in that, include: The acquisition module is used to acquire a set of receipt images, wherein the set of receipt images includes multiple receipt images; The recognition module is used to perform OCR recognition on each receipt image in the receipt image set to obtain a set of receipt data, wherein each receipt data in the set of receipt data corresponds to a receipt image, and each receipt data includes drug sales information; The processing module is used to perform data mining based on the set of receipt data to obtain mining results, wherein the mining results are used for drug management. The recognition module is used to obtain the set of receipt data in the following ways: establishing an OCR recognition model, wherein the OCR recognition model is obtained by: collecting receipt samples from pharmacies and labeling them to obtain a training receipt sample set; using the receipt sample set to train an original recognition model through a reinforcement learning algorithm, enabling the original recognition model to select a preset processing strategy under different input conditions to obtain the OCR recognition model, wherein the preset processing strategy includes: a dynamic adjustment strategy for image sharpening and a rotation angle compensation strategy; using the OCR recognition model to perform OCR recognition on each receipt image in the receipt image set according to the preset processing strategy to obtain the set of receipt data; The device is further configured to obtain multiple user feature vectors based on the set of receipt data, wherein each user feature vector includes basic features, behavioral features, and time features; perform cluster analysis on the multiple user feature vectors using the K-means clustering algorithm to obtain a target clustering result, wherein the mining result includes the target clustering result; and make personalized recommendations based on the clustering result.
7. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed, perform the method as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Medicine combination recommendation method and device, electronic equipment and storage medium
CN111914163A
Bill information identification method, device and equipment based on OCR (Optical Character Recognition) and storage medium
CN118397642A