A method and apparatus for dispensing pharmaceuticals based on a document drive

CN123014882APending Publication Date: 2026-10-30GENERAL HOSPITAL OF PLA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611126638.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-28
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

1)拆零时无法强制执行效期优先原则:当需要补充散药时,工作人员常基于个人经验判断选择哪个整包进行拆解,而非按“先失效先出”(First Expired First Out,FEFO)原则主动选择近效期药品,这容易使得近效期药品因积压而导致过期报废

Benefits of technology

[0015]本发明实施例提供了一种基于单据驱动的药品拆零分发方法、装置、电子设备及计算机可读存储介质。由上述内容可知,本发明实施例每收到一个发药单据,都会根据当前单据和散药缓存池对当前散药余量是否满足当前单据需求进行识别;若发现存在散药余量不足的情况,就根据单据识别结果、发药单据、散药缓存池、库存数据库和药品拆零处理接口进行一轮库存药品散装拆解、库存数据更新和散药缓存更新处理,并在库存药品散装拆解的处理过程中按FEFO原则进行处理,并在本轮处理结束后对当前散药余量是否满足当前单据需求进行再次识别,直到识别结果表明不存在任何散药余量不足的情况为止;并在确认不存在任何散药余量不足的情况后,根据发药单据、散药缓存池、药品分发处理接口和药品分发数据表进行散装药品分发和药品分发信息记录处理。基于本发明实施例,一方面减少了近效期药品积压量、减少了近效期药品的过期报废量、降低了药品浪费率;另一方面通过药品分发数据表对每次发药的跨批次信息进行全面补齐,细化了溯源信息的颗粒度;再一方面通过库存数据自动更新、散药缓存数据自动更新、药品分发信息自动记录等一系列操作,简化了人工处理流程、提高了作业效率、降低了账实不符概率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123014882A_ABST
    Figure CN123014882A_ABST
Patent Text Reader

Abstract

Embodiments of the present application relate to a kind of based on bill-driven medicine unpacking distribution method and device, the method includes:1, receive dispensing bill;2, whether the current amount of loose medicine satisfies the current bill demand according to dispensing bill and loose medicine buffer pool is identified to obtain bill identification result;3, whether all identification states of bill identification result are all for amount satisfaction, if not then turn 4, if yes then turn 5;4, according to bill identification result, dispensing bill, loose medicine buffer pool and inventory database and medicine unpacking processing interface carry out inventory medicine unpacking, inventory data update and loose medicine buffer update processing, and return 2 after this processing ends;5, according to dispensing bill, loose medicine buffer pool and medicine distribution processing interface and medicine distribution data table carry out bulk medicine distribution and medicine distribution information record processing.Based on the present application, near expiration drug overstock, traceability information granularity, operation efficiency can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method and apparatus for distributing medicines in smaller quantities based on a document-driven process. Background Technology

[0002] In pharmacy management at medical institutions, dispensing medications in smaller, individual units is a common and crucial step. Dispensing medications in smaller units refers to breaking down fully packaged medications (also known as individually packaged items, such as boxes or bottles) into their smallest usable units (also known as individual loose medications, such as tablets, granules, or vials) and dispensing them according to prescriptions or doctor's orders. Traditional methods of dispensing medications in smaller units typically employ a "pre-bulk dispensing" model: pharmacy staff periodically open some fully packaged medications in advance, storing the loose medications in a storage box or loose medication cabinet, and then directly retrieving them from the loose medications when needed.

[0003] This pre-dispensing model has several inherent drawbacks. 1) It cannot enforce the expiration date priority principle when dispensing: When replenishing loose medicine, staff often rely on personal experience to decide which whole package to dispense, rather than actively selecting near-expiration medicines according to the "First Expired First Out" (FEFO) principle. This easily leads to near-expiration medicines accumulating and becoming unusable. 2) Incomplete traceability information when dispensing across batches: When a single dispensing demand requires the simultaneous consumption of multiple batches of loose medicine, the traditional model usually only records the total number of dispensings, not the consumption quantity of each batch. 3) Separate management of whole package inventory and loose medicine inventory: In existing information systems, whole package inventory and loose medicine inventory are usually stored in separate tables or rely on manual accounting. Dispensing documents can only deduct loose medicine inventory and cannot directly drive the automatic conversion of whole packages to loose medicine inventory. When loose medicine is insufficient, a series of operations such as whole package issuance, dispensing, and loose medicine warehousing need to be initiated manually, which is cumbersome and prone to discrepancies between accounts and actual inventory. Summary of the Invention

[0004] The purpose of this invention is to address the shortcomings of existing technologies by providing a document-driven method, apparatus, electronic device, and computer-readable storage medium for distributing medicines in smaller quantities. Upon receiving each dispensing document, this invention identifies whether the current remaining quantity of loose medicine meets the document's requirements based on the document and the loose medicine buffer. If insufficient loose medicine is detected, a round of inventory dispensing, inventory data updating, and loose medicine buffer updating is performed based on the document identification result, the dispensing document, the loose medicine buffer, the inventory database, and the medicine dispensing processing interface. During the inventory dispensing process, the FEFO (Frequency-First-Out) principle is followed. After this round of processing, the current remaining quantity of loose medicine is re-identified to ensure it meets the document's requirements until the identification result indicates that there is no shortage of loose medicine. Once it is confirmed that there is no shortage of loose medicine, the loose medicine is distributed and the distribution information is recorded based on the dispensing document, the loose medicine buffer, the medicine distribution processing interface, and the medicine distribution data table. Based on this invention, on the one hand, it can reduce the backlog of drugs nearing their expiration date, reduce the amount of expired and discarded drugs nearing their expiration date, and reduce the drug waste rate; on the other hand, it can comprehensively supplement cross-batch information for each drug dispensing through the drug distribution data table, and refine the granularity of traceability information; furthermore, it can simplify manual processing procedures, improve operational efficiency, and reduce the probability of discrepancies between accounts and actual stock through a series of operations such as automatic updating of inventory data, automatic updating of bulk drug cache data, and automatic recording of drug distribution information.

[0005] To achieve the above objectives, a first aspect of the present invention provides a method for distributing medicines in smaller quantities based on a document-driven approach, the method comprising: Step 1: Receive the medication dispensing order; The medication dispensing document includes a medication dispensing number, a source prescription number, and a medication dispensing details set; the medication dispensing details set includes one or more medication dispensing details; the medication dispensing details include a drug code, drug name, quantity dispensed, unit of medicine, and drug specification. Step 2: Based on the dispensing order and the preset powdered medicine buffer pool, identify whether the current remaining powdered medicine meets the requirements of the current order to obtain the corresponding order identification result; The bulk medicine buffer pool, when not empty, includes one or more bulk medicine records. Each bulk medicine record includes a bulk medicine code, bulk medicine name, source batch number, source packaging identifier, medicine expiration date, source packaging unpacking time, remaining bulk quantity, bulk unit, and bulk specification, with the remaining bulk quantity ≥ 0. The document identification result includes one or more medicine identification results. Each medicine identification result corresponds one-to-one with the dispensing details. Each medicine identification result includes identification status and replenishment quantity, with the replenishment quantity ≥ 0. The identification status includes two states: insufficient remaining quantity and sufficient remaining quantity. When the identification status is insufficient remaining quantity, the replenishment quantity is greater than zero and less than or equal to the corresponding dispensing quantity. When the identification status is sufficient remaining quantity, the replenishment quantity is zero. Step 3: Check whether all the recognition states of the document recognition result are satisfied with the margin; if not, proceed to step 4; if yes, proceed to step 5. Step 4: Based on the document recognition result, the dispensing document, the bulk medicine cache pool, and the preset inventory database and drug splitting processing interface, perform bulk medicine disassembly, inventory data update, and bulk medicine cache update processing; and return to Step 2 after this processing is completed; In the process of dismantling and processing bulk medicines in stock, the principle of first-to-last-out is followed. The inventory database includes multiple inventory data tables; each inventory data table corresponds to a unique table identifier; each inventory data table includes multiple inventory drug records; each inventory drug record includes the following information: inbound packaging identifier, inbound drug code, inbound drug name, inbound batch number, inbound packaging unit, inbound packaging specification, bulk quantity, the bulk unit, the bulk specification, the drug's expiration date, inventory status, inbound registration time, and outbound registration time; the inventory status includes three states: in stock, locked, and outbound. The interface input data for the drug dismantling and processing interface is a first record set, and the interface output data is a second record set; the first record set includes one or more first records; the second record set includes one or more second records; the first record includes a first table identifier and a first packaging identifier; the second record includes a second table identifier, a second packaging identifier, and a first dismantling time; each first or second table identifier is a table identifier; each first or second packaging identifier is an inbound packaging identifier; Step 5: Perform bulk drug distribution and drug distribution information recording processing based on the drug dispensing document, the bulk drug cache pool, and the preset drug distribution processing interface and drug distribution data table; In the process of distributing bulk medicines, the principle of distributing the smallest remaining quantity first shall be followed. The input data of the drug distribution processing interface is a third record set, and the output data is a fourth record set. The third record set includes one or more third records; the fourth record set includes one or more fourth records; each third record corresponds one-to-one with the drug dispensing details, and each fourth record corresponds one-to-one with the third record; each third record includes the drug dispensing details and an inventory traceability set; each fourth record includes the distributor's identifier and the drug dispensing time; the inventory traceability set includes one or more inventory traceability groups; each inventory traceability group includes the receiving batch number, the receiving packaging identifier, and the quantity of bulk drugs dispensed; the total quantity of all bulk drugs dispensed in the inventory traceability set matches the quantity of drugs dispensed in its corresponding drug dispensing details. The drug distribution data table includes multiple drug distribution records; each drug distribution record corresponds one-to-one with a dispensing order; each drug distribution record includes a dispensing order number, a source prescription number, and a distribution detail set; each distribution detail set includes one or more distribution details; each distribution detail corresponds one-to-one with a dispensing list; each distribution detail includes the dispensing list, the inventory traceability set, the distributor identifier, and the drug distribution time.

[0006] Preferably, the quantity of medicine dispensed, the unit of medicine, and the specification of medicine in the dispensing details are the total number of individual bulk medicines of a designated class of medicines, the physical unit of each individual, and the quantity of medicine per individual. The inventory database is used to store inventory information for all batches of all medicines; Each inventory data table is used to store inventory information for a single batch of a single type of drug; each batch of drugs includes one or more types of packaging units, each type of packaging unit corresponds to one or more individual packages, each individual package contains one or more bulk drug individuals of the same type, and some or all of the three individual parameters of the bulk drug individuals corresponding to two types of packaging unit are different, the three individual parameters include the total number of individuals, the physical unit of the individual, and the quantity specification of the individual; during the warehousing registration, a corresponding inventory drug record is generated for each individual package; the warehousing drug code, warehousing drug name, and warehousing batch number are the same for all inventory drug records in each inventory data table; The warehousing packaging identifier is the unique individual identifier of the independent packaging unit corresponding to the current record; the warehousing drug code, the warehousing drug name, and the warehousing batch number are the code, name, and batch number of the current batch of drugs corresponding to the current record; the warehousing packaging unit and the warehousing packaging specification are respectively the packaging unit type and packaging unit drug quantity specification of the independent packaging unit corresponding to the current record; the bulk quantity, the bulk unit, and the bulk specification are respectively the total number of bulk drug units, the individual physical units, and the individual drug quantity specification of the independent packaging unit corresponding to the current record, and the bulk quantity is ≥1; in the inventory drug record, the warehousing packaging specification The relationship between the quantity and specifications of the bulk packaging is as follows: Inbound packaging specifications = Bulk quantity × Bulk specifications; the expiration date of the medicine is the validity period of the individual packaged item corresponding to the current record; the inventory status reflects the in-stock, locked, or outbound status of the individual packaged item corresponding to the current record. Only the inventory medicine records with the inventory status of "in-stock" participate in the identification process of whether the remaining quantity of bulk medicine meets the document requirements, and only the individual packaged items corresponding to the inventory medicine records with the inventory status of "locked" can be disassembled into bulk medicine; the inbound registration time and the outbound registration time are the inbound and outbound times of the individual packaged item corresponding to the current record, respectively. Each bulk medicine record in the bulk medicine buffer pool corresponds to an inventory medicine record with an outbound status; the bulk medicine code, bulk medicine name, source batch number, source packaging identifier, medicine expiration date, bulk unit, and bulk specification in the bulk medicine record correspond one-to-one with the inbound medicine code, inbound medicine name, inbound batch number, inbound packaging identifier, medicine expiration date, bulk unit, and bulk specification in the corresponding inventory medicine record; the remaining quantity of bulk medicine in the bulk medicine record is greater than or equal to zero and less than or equal to the quantity of bulk medicine in the corresponding inventory medicine record; the time of unpacking the source packaging of the bulk medicine record is the unpacking time of the corresponding individual package.

[0007] Preferably, the step of identifying whether the current remaining quantity of loose medicine meets the requirements of the current document based on the dispensing document and a preset loose medicine buffer pool to obtain the corresponding document identification result specifically includes: Each dispensing detail in the dispensing detail set of the dispensing document is taken as the current detail; and the bulk drug records in the bulk drug cache pool that match the corresponding drug code, drug name, drug unit, and drug specification in the current detail, and whose drug expiration date has not expired, are taken as the corresponding search matching records; and the total number of the search matching records is checked to see if it is zero; if so, the corresponding identification status is set to insufficient reserve, and the corresponding replenishment quantity is set to the dispensing quantity of the current detail; if... No, then the quantity difference obtained by subtracting the sum of the remaining quantities of bulk drugs from the quantity of drugs dispensed in the current details and matching records is taken as the first quantity difference. The system identifies whether the first quantity difference is greater than zero. If it is, the corresponding identification status is set to insufficient reserve and the first quantity difference is taken as the corresponding supplementary quantity. Otherwise, the corresponding identification status is set to sufficient reserve and the corresponding supplementary quantity is set to zero. The identification status and supplementary quantity corresponding to the current details constitute the corresponding drug identification result. All the obtained drug identification results constitute the corresponding document identification result.

[0008] Preferably, the step of performing bulk drug dispensing, inventory data updating, and bulk drug cache updating based on the document recognition result, the dispensing document, the bulk drug cache pool, and the preset inventory database and drug dispensing processing interface specifically includes: Step 41: Based on the document identification result, the dispensing document, the inventory database, and the drug dispensing processing interface, the bulk inventory of drugs is processed according to the first-in, first-out principle. Specifically: Each drug identification result in the document identification result where the identification status is insufficient is recorded as the corresponding identification result to be supplemented; and the dispensing details in the dispensing document corresponding to each identification result to be supplemented are recorded as the corresponding details to be supplemented. Each item to be replenished and its corresponding replenishment quantity are taken as the current item and current replenishment quantity. Following a first-in, first-out (FIFO) principle, a set of replenishment records that meet the requirements for drug item details and quantity is selected from the inventory database based on the current item and current replenishment quantity. The set of replenishment records includes one or more of the inventory drug records. All inventory drug records in the set of replenishment records are in a locked state. The first record set is set based on all the obtained supplementary record sets. Specifically, all the obtained supplementary record sets are merged to obtain a complete set of supplementary records. The table identifier and the warehousing packaging identifier corresponding to each of the inventory drug records in the complete set of supplementary records are taken as a set of corresponding first table identifier and first packaging identifier. Each set of first table identifier and first packaging identifier is composed of a corresponding first record. All the obtained first records are composed of the corresponding first record set. The first record set is then input into the drug dismantling processing interface to process the bulk dismantling of the stocked drugs and obtain the corresponding second record set. Step 42: Update the inventory data in the inventory database based on the first record set and the second record set, specifically as follows: The sets of inventory drug records corresponding to the first record set and the second record set in the inventory database are denoted as sets G1 and G2, respectively; and a set G3 is determined based on sets G1 and G2, where G3 = G1 - G1 ∩ G2; and the inventory status of all inventory drug records corresponding to set G2 in the inventory database is reset to out of stock, and the inventory status of all inventory drug records corresponding to set G3 is reset to in stock. Step 43: Update the powder medicine cache in the powder medicine cache pool according to the second record set and the inventory database, specifically as follows: Each of the second records in the second record set is taken as the current record; the inventory data table in the inventory database whose table identifier matches the second table identifier of the current record is taken as the current table; the inventory drug record in the current table whose receiving packaging identifier matches the second packaging identifier of the current record is taken as the current inventory record; a corresponding bulk drug record is generated in the bulk drug cache pool for the current inventory record as the current bulk record; and the corresponding bulk drug code, bulk drug name, source batch number, source packaging identifier, drug expiration date, bulk unit, and bulk specification in the current bulk record are set based on the receiving drug code, receiving drug name, receiving batch number, receiving packaging identifier, drug expiration date, bulk unit, and bulk specification in the current bulk record; the remaining quantity of bulk in the current bulk record is set based on the bulk quantity in the current inventory record; and the source packaging unpacking time of the current bulk record is set based on the first unpacking time of the current record.

[0009] Furthermore, the step of selecting a set of supplementary records that meet the drug details and quantity requirements from the inventory database according to the current details and the current replenishment quantity, based on the first-in, first-out (FIFO) principle, specifically includes: The inventory data tables in the inventory database that match the drug codes and drug names in the current details are formed into a corresponding current table set. Then, in each inventory data table of the current table set, the inventory drug records whose bulk unit and bulk specification match the drug unit and drug specification in the current details, whose inventory status is in stock, and whose expiration date has not expired are recorded as corresponding inventory matching records. Finally, all inventory matching records are sorted according to the chronological order of the drug expiration dates to obtain the corresponding current record sequence. The system iterates through all the inventory matching records in the current record sequence. During this iteration, the currently traversed inventory matching record is taken as the current record. The subsequence from the first record to the current record in the current record sequence is taken as the current subsequence. The sum of the bulk quantities of all the inventory matching records in the current subsequence is taken as the corresponding current total quantity. The system checks whether the current total quantity is less than the current replenishment quantity. If so, it moves to the next inventory matching record and continues traversing until the last inventory matching record is traversed. If not, it stops this iteration, and all the inventory matching records in the current subsequence form the corresponding replenishment record set. The system also locks the inventory status of all the inventory medicine records in the inventory database that correspond to the replenishment record set.

[0010] Preferably, the step of distributing bulk medicines and recording medicine distribution information based on the dispensing order, the bulk medicine buffer pool, and the preset medicine distribution processing interface and medicine distribution data table specifically includes: Step 61: Distribute bulk medicines according to the principle of "small quantity first," based on the dispensing order, the bulk medicine buffer pool, and the medicine distribution processing interface. Specifically: Based on the principle of issuing small quantities first, the corresponding third record is set according to each dispensing detail of the dispensing order and the powdered medicine buffer pool; and all the obtained third records form the corresponding third record set; and the third record set is input into the drug distribution processing interface for drug distribution processing to obtain the corresponding fourth record set; Step 62: Delete the records of bulk medicines in the bulk medicine cache pool where the remaining quantity of the bulk medicine is zero or the expiration date of the medicine has expired; Step 63: Based on the dispensing slip, the third record set, and the fourth record set, process the drug dispensing information in the drug dispensing data table, specifically as follows: A corresponding distribution detail is formed by the dispensing details, inventory traceability set, distributor identifier, and drug dispensing time of each third record in the third record set and its corresponding fourth record; and a corresponding distribution detail set is formed by all the obtained distribution details; and a corresponding drug distribution record is added to the drug distribution data table by the dispensing order number, the source prescription number, and the distribution detail set of the dispensing order.

[0011] Furthermore, the step of setting the corresponding third record based on the dispensing details of each dispensing order and the powdered medicine buffer pool according to the principle of issuing small quantities first specifically includes: Each dispensing detail in the dispensing order is taken as the current detail; and the bulk drug records in the bulk drug cache pool that match the bulk drug code, bulk drug name, bulk unit, and bulk specification with the drug code, drug name, drug unit, and drug specification of the current detail, and whose drug expiration date has not expired, are recorded as corresponding bulk matching records; and all bulk matching records are sorted in ascending order of remaining bulk quantity to obtain the corresponding current record sequence; and the current dispensing balance is initialized based on the dispensing quantity of the current detail; The system performs a sequential traversal of all bulk matching records in the current record sequence. During this traversal, the currently traversed bulk matching record is taken as the current record. The system then checks whether the remaining quantity of bulk items in the current record is greater than or equal to the current dispensing quantity. If not, the source batch number, source packaging identifier, and remaining quantity of bulk items corresponding to the current record are grouped into a corresponding inventory traceability group. The difference between the current dispensing quantity and the remaining quantity of bulk items in the current record is then used as the new current dispensing quantity. Finally, the remaining quantity of bulk items in the current record in the bulk medicine buffer pool is reset to 0, and the process continues to the next record. The bulk matching records are traversed until the last bulk matching record is traversed; if so, the current round of traversal is stopped, and the source batch number, source packaging identifier, and current dispensing quantity corresponding to the current record are used as a group to form a corresponding inventory traceability group. The difference between the current remaining quantity of bulk and the current dispensing quantity is taken as the current remaining quantity of bulk. The remaining quantity of bulk in the current record is reset based on the current remaining quantity of bulk. All the inventory traceability groups obtained in this round of traversal are combined to form a corresponding inventory traceability set, and the current details and the inventory traceability set are combined to form a corresponding third record.

[0012] A second aspect of the present invention provides an apparatus for implementing the document-driven drug dispensing method described in the first aspect above. The apparatus includes: a document receiving module, a loose drug remaining quantity identification module, an identification result judgment module, a drug dispensing processing module, and a drug dispensing processing module. The document receiving module is used to receive medication dispensing documents; wherein, the medication dispensing document includes a medication dispensing number, a source prescription number, and a medication dispensing details set; the medication dispensing details set includes one or more medication dispensing details; the medication dispensing details include a drug code, drug name, quantity dispensed, unit of medicine, and drug specification; The bulk medicine remaining quantity identification module is used to identify whether the current bulk medicine remaining quantity meets the requirements of the current document based on the dispensing document and a preset bulk medicine buffer pool, and obtain the corresponding document identification result. When the bulk medicine buffer pool is not empty, it includes one or more bulk medicine records. Each bulk medicine record includes a bulk medicine code, bulk medicine name, source batch number, source packaging identifier, medicine expiration date, source packaging unpacking time, remaining bulk quantity, bulk unit, and bulk specification, with a remaining bulk quantity ≥ 0. The document identification result includes one or more medicine identification results. Each medicine identification result corresponds one-to-one with the dispensing details. Each medicine identification result includes an identification status and a replenishment quantity, with a replenishment quantity ≥ 0. The identification status includes two states: insufficient remaining quantity and sufficient remaining quantity. When the identification status is insufficient remaining quantity, the replenishment quantity is greater than zero and less than or equal to the corresponding dispensing quantity. When the identification status is sufficient remaining quantity, the replenishment quantity is zero. The identification result judgment module is used to identify whether all the identification states of the document identification result are in the condition that the remaining amount is satisfied; if not, it is transferred to the drug splitting processing module; if yes, it is transferred to the drug distribution processing module. The drug dispensing module is used to perform bulk drug dispensing, inventory data updating, and bulk drug cache updating based on the document recognition result, the dispensing document, the bulk drug cache pool, and the preset inventory database and drug dispensing processing interface; and returns to the bulk drug remaining quantity recognition module after the processing is completed; wherein, the bulk drug dispensing process is carried out according to the first-in, first-out principle; the inventory database includes multiple inventory data tables; each inventory data table corresponds to a unique table identifier; each inventory data table includes multiple inventory drug records; each inventory drug record includes the receiving packaging identifier, receiving drug code, receiving drug name, receiving batch number, receiving packaging unit, and receiving package The package specifications, bulk quantity, bulk unit, bulk specifications, drug expiration date, inventory status, warehousing registration time, and outbound registration time are specified. The inventory status includes three states: in stock, locked, and outbound. The interface input data for the drug repackaging processing interface is a first record set, and the interface output data is a second record set. The first record set includes one or more first records. The second record set includes one or more second records. The first record includes a first table identifier and a first packaging identifier. The second record includes a second table identifier, a second packaging identifier, and a first disassembly time. Each first or second table identifier is a table identifier. Each first or second packaging identifier is an inbound packaging identifier. The drug distribution processing module is used to process bulk drug distribution and record drug distribution information based on the drug dispensing document, the bulk drug buffer pool, and a preset drug distribution processing interface and drug distribution data table. During the bulk drug distribution process, a principle of dispensing small quantities first is applied. The drug distribution processing interface has a third record set as input data and a fourth record set as output data. The third record set includes one or more third records; the fourth record set includes one or more fourth records; each third record corresponds one-to-one with the drug dispensing details, and each fourth record corresponds one-to-one with the third record; each third record includes the drug dispensing details and an inventory traceability set; each fourth record includes the distributor's identifier and the drug's information. Distribution time; the inventory traceability set includes one or more inventory traceability groups; the inventory traceability group includes the batch number of the incoming goods, the packaging identification, and the quantity of bulk medicines dispensed; the total quantity of all bulk medicines dispensed in the inventory traceability set matches the quantity of medicines dispensed in its corresponding dispensing details; the drug distribution data table includes multiple drug distribution records; the drug distribution record corresponds one-to-one with the dispensing document; the drug distribution record includes the dispensing document number, the source prescription number, and the distribution detail set; the distribution detail set includes one or more distribution details; the distribution details correspond one-to-one with the dispensing details; the distribution details include the dispensing details, the inventory traceability set, the distributor identification, and the drug distribution time.

[0013] A third aspect of the present invention provides an electronic device, including: a memory, a processor, and a transceiver; The processor is used to couple with the memory, read and execute instructions in the memory to implement the steps of the method described in the first aspect above; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

[0014] A fourth aspect of the present invention provides a computer-readable storage medium storing computer instructions that, when executed by a computer, cause the computer to perform the instructions described in the first aspect.

[0015] This invention provides a method, apparatus, electronic device, and computer-readable storage medium for distributing medicines in smaller quantities based on a document-driven process. As described above, upon receiving each dispensing document, this invention identifies whether the current remaining quantity of loose medicine meets the document's requirements based on the document and the loose medicine buffer pool. If insufficient loose medicine is detected, a round of inventory dispensing, inventory data updating, and loose medicine buffer updating is performed based on the document identification result, the dispensing document, the loose medicine buffer pool, the inventory database, and the medicine dispensing processing interface. During the inventory dispensing process, the FEFO (Frequency-First-Out) principle is followed. After this round of processing, the current remaining quantity of loose medicine is re-identified to ensure it meets the document's requirements until the identification result indicates that there is no shortage of loose medicine. After confirming that there is no shortage of loose medicine, the bulk medicine is distributed and the distribution information is recorded based on the dispensing document, the loose medicine buffer pool, the medicine distribution processing interface, and the medicine distribution data table. Based on the embodiments of the present invention, on the one hand, the backlog of near-expiry drugs is reduced, the amount of expired and scrapped near-expiry drugs is reduced, and the drug waste rate is lowered; on the other hand, the cross-batch information of each drug distribution is fully supplemented through the drug distribution data table, refining the granularity of traceability information; furthermore, through a series of operations such as automatic updating of inventory data, automatic updating of bulk drug cache data, and automatic recording of drug distribution information, the manual processing process is simplified, the work efficiency is improved, and the probability of discrepancies between accounts and actual stock is reduced. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of a document-driven drug dispensing method provided in Embodiment 1 of the present invention. Figure 2 This is a module structure diagram of a document-driven drug dispensing device according to Embodiment 2 of the present invention; Figure 3 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. Detailed Implementation

[0017] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0018] Embodiment 1 of the present invention provides a method for distributing medicines in smaller quantities based on a document-driven approach, such as... Figure 1 The schematic diagram of a document-driven drug dispensing method provided in Embodiment 1 of the present invention is shown. The method mainly includes the following steps: Step 1: Receive the medication dispensing order.

[0019] Here, the dispensing document in this embodiment of the invention includes a dispensing order number, a source prescription number, and a dispensing details set; the dispensing details set includes one or more dispensing details; the dispensing details include drug code, drug name, quantity dispensed, drug unit, and drug specification.

[0020] The dispensing slip number is the unique slip number for the current dispensing document, and the source prescription number is the unique identifier of the original prescription or medical order that generated the current dispensing document. The drug code in the dispensing details is the unique identifier of the drug, such as the national medical insurance drug code, hospital internal code, or drug standard code, used to accurately identify drug varieties within the system and avoid confusion with drugs of the same name. The drug name in the dispensing details is the generic name or trade name of the drug in Chinese (or other languages), used for manual verification by pharmacists or nurses when displaying on the interface or printing the document. The dispensing quantity, drug unit, and drug specification in the dispensing details represent the total number of individual units, individual physical units, and individual dosage specifications of a specific type of bulk drug. For example, if the dispensing document specifies the drug name as "Amoxicillin," the specified bulk drug type is tablets (i.e., the individual physical unit is a tablet, the total number of units is 10, and the individual dosage specification is 0.25g / tablet), then the dispensing quantity = 10, the drug unit = "tablet," and the drug specification = 0.25g / tablet.

[0021] It should be noted that the embodiments of the present invention include an inventory database. The inventory database includes multiple inventory data tables; each inventory data table corresponds to a unique table identifier; each inventory data table includes multiple inventory drug records; each inventory drug record includes the receiving packaging identifier, receiving drug code, receiving drug name, receiving batch number, receiving packaging unit, receiving packaging specifications, bulk quantity, bulk unit, bulk specifications, drug expiration date, inventory status, receiving registration time, and issuing registration time; the inventory status includes three states: in stock, locked, and issued.

[0022] The inventory database is used to store inventory information for all batches of all medicines.

[0023] Each inventory data table is used to store inventory information for a single batch of a single type of drug.

[0024] Each batch of medicines includes one or more types of packaging units (e.g., boxes, bottles, etc.). Each type of packaging unit corresponds to one or more individual packages, and each individual package contains one or more bulk medicines of the same type, such as 20 injections in one box, 100 tablets in one bottle, etc. Some or all of the three individual parameters differ between any two types of packaging unit corresponding to bulk medicines. The three individual parameters include the total number of individuals, the physical unit of the individual, and the dosage specification. For example, batch 001 of "Amoxicillin" contains 50 boxes of 0.25g x 10 tablets each and 30 boxes of 0.50g x 10 tablets each. A corresponding inventory record is generated for each individual package during inventory registration. It should be noted that the inventory drug code, inventory drug name, and inventory batch number are the same for all inventory drug records in each inventory data table.

[0025] In the inventory drug record: the incoming packaging label is the unique individual identifier for the current record's corresponding independent packaging unit. This label is usually printed on the outer packaging of the independent packaging unit so that operators can scan it using any scanning device; the incoming drug code, incoming drug name, and incoming batch number are the code, name, and batch number of the current batch of drugs corresponding to the current record; the incoming packaging unit and incoming packaging specifications are the packaging unit type (e.g., box, bottle, bag, etc.) and packaging unit dosage specifications (e.g., xx grams / box, xx milliliters / box, xx grams / bag, xx tablets / bottle, etc.) of the current record's corresponding independent packaging unit, respectively. Bulk quantity, bulk unit, and bulk specification represent the total number of individual bulk medicines, individual physical units, and individual medicine quantity specifications of the individual packaged medicines corresponding to the current record, respectively, with a bulk quantity ≥ 1. In the inventory medicine record, the relationship between the warehouse packaging specification and the bulk quantity and bulk specification is: warehouse packaging specification = bulk quantity × bulk specification; the medicine expiration date is the validity period of the individual packaged medicines corresponding to the current record; the inventory status reflects the in-stock, locked, or out-of-stock status of the individual packaged medicines corresponding to the current record; the warehouse entry registration time and the out-of-stock registration time are the warehouse entry and out-of-stock times of the individual packaged medicines corresponding to the current record, respectively. It should be noted that this embodiment of the invention stipulates that only inventory medicine records with an inventory status of "in stock" participate in the identification process of whether the remaining bulk medicine quantity meets the document requirements. This embodiment of the invention also stipulates that only individual packaged medicines corresponding to inventory medicine records with an inventory status of "locked" can be disassembled into bulk medicines.

[0026] Step 2: Based on the dispensing order and the preset powdered medicine buffer pool, identify whether the current remaining powdered medicine quantity meets the requirements of the current order to obtain the corresponding order identification result.

[0027] When the bulk drug buffer pool in this embodiment of the invention is not empty, it includes one or more bulk drug records. The bulk drug record includes bulk drug code, bulk drug name, source batch number, source packaging identifier, drug expiration date, source packaging unpacking time, remaining bulk quantity, bulk unit, bulk specification, and the remaining bulk quantity is ≥0.

[0028] It should be noted that each bulk medicine record in the bulk medicine buffer pool corresponds to an inventory medicine record with an outbound status. The bulk medicine code, bulk medicine name, source batch number, source packaging label, medicine expiration date, bulk unit, and bulk specifications in the bulk medicine record correspond one-to-one with the inbound medicine code, inbound medicine name, inbound batch number, inbound packaging label, medicine expiration date, bulk unit, and bulk specifications in the corresponding inventory medicine record. The remaining quantity of bulk medicine in the bulk medicine record is greater than or equal to zero and less than or equal to the quantity of bulk medicine in the corresponding inventory medicine record. The time when the source packaging of the bulk medicine record is unpacked corresponds to the unpacking time of its individual package.

[0029] The document recognition result in this embodiment of the invention includes one or more drug recognition results. Each drug recognition result corresponds one-to-one with the dispensing details. The drug recognition result includes recognition status and replenishment quantity, with the replenishment quantity ≥ 0. The recognition status includes two states: insufficient remaining quantity and sufficient remaining quantity. It should be noted that when the recognition status is insufficient remaining quantity, the replenishment quantity is greater than zero and less than or equal to the corresponding dispensing quantity; when the recognition status is sufficient remaining quantity, the replenishment quantity is zero.

[0030] The current step 2 specifically includes: Step 21: Select each dispensing detail from the dispensing details set of the dispensing order as the current detail.

[0031] Step 22: The bulk drug records in the bulk drug cache pool that match the corresponding drug codes, names, units, and specifications in the current details and whose expiration dates have not expired are used as the corresponding search matching records.

[0032] Step 23, and identify whether the total number of records for the search and matching is zero; if yes, set the corresponding identification status to insufficient reserve and set the corresponding supplementary quantity to the current detail's dispensing quantity; if no, further subtract the sum of the remaining quantities of all search and matching records from the current detail's dispensing quantity to obtain the quantity difference as the first quantity difference, and identify whether the first quantity difference is greater than zero; if yes, set the corresponding identification status to insufficient reserve and set the first quantity difference as the corresponding supplementary quantity; otherwise, set the corresponding identification status to sufficient reserve and set the corresponding supplementary quantity to zero.

[0033] Step 24, and the corresponding drug identification result is composed of the identification status and replenishment quantity corresponding to the current details; Step 25, and the corresponding document identification result is composed of all the obtained drug identification results.

[0034] Step 3: Check if all recognition statuses of the document recognition results are in the condition that the margin is satisfied; if not, proceed to step 4; if yes, proceed to step 5.

[0035] Step 4: Based on the document recognition results, dispensing documents, bulk medicine cache pool, and the preset inventory database and drug splitting processing interface, perform bulk medicine disassembly, inventory data update, and bulk medicine cache update processing; and return to Step 2 after this processing is completed.

[0036] Here, in the embodiment of the present invention, the process of dismantling and processing bulk medicines in stock is carried out according to the first-to-last-out principle.

[0037] The interface input data of the drug dismantling processing interface in this embodiment of the invention is a first record set, and the interface output data is a second record set; the first record set includes one or more first records; the second record set includes one or more second records; the first record includes a first table identifier and a first packaging identifier; the second record includes a second table identifier, a second packaging identifier, and a first dismantling time; each first or second table identifier is a table identifier; each first or second packaging identifier is an inbound packaging identifier.

[0038] It should be noted that the drug reorder processing interface in this embodiment of the invention is essentially an automatic notification and notification response processing interface. After receiving the first record set, the drug reorder processing interface sends the current first record set to the pre-designated pharmacist notification interface A (e.g., SMS, email, voice notification interface, etc.), and returns the second record set sent back by the pharmacist feedback interface A (e.g., SMS, email, API service feedback interface, etc.) as the interface output data of the current drug reorder processing interface.

[0039] It should be noted that after receiving the first record set through the pharmacist notification interface A, the pharmacist will use the first record set as a guide for picking up the medicine, export detailed medicine inventory information from the inventory database, and pick up the medicine from the designated warehouse or pharmacy based on the medicine inventory information. After the medicine is picked up, the pharmacist will scan the warehouse packaging identifier (second packaging identifier) ​​of each individual packaged item using a scanning device (handheld scanner, mobile phone, etc.), and obtain the table identifier (second table identifier) ​​corresponding to each second packaging identifier from the inventory database. The picking time of each individual packaged item will be used as the corresponding first unpacking time. The second table identifier, the second packaging identifier, and the first unpacking time of each individual packaged item will form the corresponding second record. All the second records will then form the second record set. Finally, the second record set will be sent back to the medicine splitting processing interface through the pharmacist feedback interface A.

[0040] It should also be noted that, in principle, the first and second packaging identifiers of the first and second record sets should correspond one-to-one and match perfectly. However, in practical applications, errors or redundant operations by pharmacists may result in a mismatch between the first and second packaging identifiers of the first and second record sets. For example, if a pharmacist receives some extra spare medications in addition to the medications specified in the first record set, the relative relationship between the record set G1 of the first record set and the record set G2 of the second record set is G1∈G2, and G1= G1∩G2. Another example is that when a pharmacist receives medications according to the first record set, some medication batches are incorrect, but the bulk quantity, bulk unit, and bulk specifications are correct. In this case, the number of records in the first and second record sets is the same, and each pair of first and second record pairs corresponds to the same medication type, bulk quantity, bulk unit, and bulk specifications, but the table identifier + warehouse packaging identifier of some first and second record pairs are different. For example, when a pharmacist collects medicines according to the first record set, some of the medicine names are wrong. In this case, the number of records in the first and second record sets is the same, but some of the first and second records correspond to completely different medicines.

[0041] Because the first and second packaging identifiers in the first and second record sets may not be perfectly matched one-to-one, in order to ensure that the drug cache pool can fully meet the requirements of the dispensing documents, this embodiment of the invention automatically returns to step 2 after each round of bulk drug unpacking, inventory data update and bulk drug cache update processing is completed through step 4, to re-identify whether the current bulk drug balance meets the requirements of the current document based on the dispensing documents and the latest bulk drug cache pool.

[0042] The current step 4 specifically includes: Step 41: Based on the document recognition results, dispensing documents, bulk medicine cache pool, and the preset inventory database and drug splitting processing interface, perform bulk medicine disassembly, inventory data update and bulk medicine cache update processing.

[0043] Step 41 specifically includes: Step 411: Based on the document identification results, dispensing documents, inventory database, and drug dispensing processing interface, dispose of bulk inventory drugs according to the first-in, first-out principle.

[0044] Step 411 specifically includes: Step 4111: Record the drug identification results with insufficient quantity in the document identification results as the corresponding identification results to be supplemented; and record the drug dispensing details in the dispensing document corresponding to each identification result to be supplemented as the corresponding details to be supplemented.

[0045] Step 4112: Take each item to be replenished and its corresponding replenishment quantity as the corresponding current item and current replenishment quantity; and select the set of replenishment records that meet the requirements of the drug item and quantity from the inventory database according to the first-to-last-out principle based on the current item and current replenishment quantity.

[0046] The supplementary record set includes one or more inventory drug records; the inventory status of all inventory drug records in the supplementary record set is locked.

[0047] In the current step 4112, following the first-in, first-out (FIFO) principle, a set of supplementary records that meet the drug details and quantity requirements is selected from the inventory database based on the current details and current replenishment quantity. Specifically, this includes: Step A1: Form a current table set by matching the drug codes and drug names in the inventory database with the drug codes and drug names in the current details; and record the inventory drug records in each inventory data table of the current table set that match the bulk unit and bulk specification with the drug unit and drug specification in the current details, have an inventory status of in stock, and have not expired as the corresponding inventory matching records; and sort all inventory matching records according to the time sequence of drug expiration dates to obtain the corresponding current record sequence.

[0048] Step A2: Perform a sequential traversal of all inventory matching records in the current record sequence; during this traversal, the currently traversed inventory matching record is taken as the current record; the subsequence from the first record to the current record in the current record sequence is taken as the current subsequence; the sum of the bulk quantities of all inventory matching records in the current subsequence is taken as the corresponding current total quantity; and it is determined whether the current total quantity is less than the current replenishment quantity; if so, proceed to the next inventory matching record and continue traversing until the last inventory matching record is traversed; if not, stop this round of traversal, and form a corresponding replenishment record set from all inventory matching records in the current subsequence, and set the inventory status of all inventory drug records in the inventory database corresponding to the replenishment record set to locked.

[0049] Step 4113: Set the corresponding first record set based on all the obtained supplementary record sets.

[0050] Specifically, this includes: merging all the obtained supplementary record sets to obtain the corresponding complete set of supplementary records; and taking the table identifier and warehousing packaging identifier corresponding to each inventory drug record in the complete set of supplementary records as a set of corresponding first table identifier and first packaging identifier, and forming a corresponding first record from each set of first table identifier and first packaging identifier, and forming a corresponding first record set from all the obtained first records.

[0051] Step 4114: Input the first record set into the drug dismantling processing interface to process the bulk dismantling of the inventory drugs and obtain the corresponding second record set.

[0052] Step 412: Update the inventory data in the inventory database based on the first record set and the second record set.

[0053] Specifically, this includes: designating the sets of inventory drug records corresponding to the first and second record sets in the inventory database as sets G1 and G2, respectively; determining the corresponding set G3 based on sets G1 and G2, where G3 = G1 - G1 ∩ G2; and resetting the inventory status of all inventory drug records corresponding to set G2 to out of stock and the inventory status of all inventory drug records corresponding to set G3 to in stock.

[0054] Step 413: Update the powder medicine cache pool according to the second record set and the inventory database.

[0055] Specifically, this includes: using each second record in the second record set as the current record; using the inventory data table whose table identifier matches the second table identifier of the current record as the current table; using the inventory drug record whose inbound packaging identifier matches the second packaging identifier of the current record as the current inventory record; generating a corresponding bulk drug record in the bulk drug cache pool as the current bulk record; setting the corresponding bulk drug code, bulk drug name, source batch number, source packaging identifier, drug expiration date, bulk unit, and bulk specification in the current bulk record based on the inbound drug code, inbound drug name, inbound batch number, inbound packaging identifier, drug expiration date, bulk unit, and bulk specification in the current bulk record; setting the remaining bulk quantity in the current bulk record based on the bulk quantity in the current inventory record; and setting the source packaging unpacking time in the current bulk record based on the first unpacking time of the current record.

[0056] After step 42 and step 41 are completed, return to step 2.

[0057] Step 5: Perform bulk drug distribution and drug distribution information recording processing based on the drug dispensing order, bulk drug cache pool, and preset drug distribution processing interface and drug distribution data table.

[0058] Here, in the embodiment of the present invention, the distribution of bulk medicines is carried out according to the principle of prioritizing small quantities.

[0059] The drug distribution processing interface of this invention has a third record set as input data and a fourth record set as output data. The third record set includes one or more third records; the fourth record set includes one or more fourth records; the third record corresponds one-to-one with the drug dispensing details, and the fourth record corresponds one-to-one with the third record; the third record includes the drug dispensing details and the inventory traceability set; the fourth record includes the distributor's identifier and the drug dispensing time; the inventory traceability set includes one or more inventory traceability groups; the inventory traceability group includes the batch number of the incoming goods, the packaging identifier of the incoming goods, and the quantity of bulk drugs dispensed; the total quantity of all bulk drugs dispensed in the inventory traceability set matches the quantity of drugs dispensed in its corresponding drug dispensing details.

[0060] It should be noted that the drug distribution processing interface in this embodiment of the invention is essentially an automatic notification and notification response processing interface. After receiving the third record set, the drug distribution processing interface sends the current third record set to another pre-specified pharmacist notification interface B (e.g., SMS, email, voice notification interface, etc.), and returns the fourth record set sent back by the corresponding other pharmacist feedback interface B (e.g., SMS, email, API service feedback interface, etc.) as the interface output data of the current drug distribution processing interface.

[0061] It should be noted that after receiving the third record set through the pharmacist notification interface B, the pharmacist will use each third record in the third record set as a guide to retrieve the corresponding number of individual bulk medicines from the physical bulk medicine storage devices (such as turnover boxes, bulk medicine cabinets, etc.) corresponding to the bulk medicine buffer pool, and then individually package them. Finally, all the individual bulk medicine packages corresponding to the third record set will be consolidated and packaged, and then delivered to the medicine receiving object of the medicine document corresponding to the third record set. After delivery, a corresponding distribution personnel identifier and medicine distribution time will be set for each third record, and a corresponding fourth record will be generated for each third record, thus obtaining the corresponding fourth record set. The fourth record set will then be sent back to the medicine distribution processing interface through the pharmacist feedback interface B.

[0062] The drug distribution data table in this embodiment of the invention includes multiple drug distribution records. Each drug distribution record corresponds one-to-one with a dispensing order. A drug distribution record includes a dispensing order number, a source prescription number, and a distribution detail set; each distribution detail set includes one or more distribution details; each distribution detail corresponds one-to-one with a dispensing list; each distribution detail includes a dispensing list, an inventory traceability set, a distributor identifier, and a drug distribution time.

[0063] The current step 5 specifically includes: Step 51: Distribute bulk medicines according to the principle of dispensing small quantities first, based on the dispensing order, bulk medicine buffer pool, and medicine distribution processing interface.

[0064] Step 51 specifically includes: Step 511: Based on the principle of issuing small quantities first, set the corresponding third record according to the dispensing details of each dispensing order and the powdered medicine buffer pool.

[0065] Step 511 specifically includes: Step 5111: Take each dispensing detail of the dispensing document as the current detail; and record the bulk drug records in the bulk drug cache pool that match the drug code, drug name, drug unit, and drug specification of the current detail and whose drug expiration date has not expired as the corresponding bulk matching records; sort all bulk matching records in ascending order of remaining bulk quantity to obtain the corresponding current record sequence; and initialize the current dispensing balance based on the dispensing quantity of the current detail.

[0066] Step 5112: Perform a sequential traversal of all bulk matching records in the current record sequence; during this traversal, use the currently traversed bulk matching record as the current record; and identify whether the remaining quantity of bulk in the current record is greater than or equal to the current dispensing quantity; if not, first, use the source batch number, source packaging identifier, and remaining quantity of bulk corresponding to the current record as a corresponding inbound batch number, inbound packaging identifier, and bulk dispensing quantity to form a corresponding inventory traceability group; then, use the difference between the current dispensing quantity and the remaining quantity of bulk in the current record as the new current dispensing quantity; then, reset the remaining quantity of bulk in the current record in the bulk medicine buffer pool to 0, and then continue to the next step. A bulk matching record is traversed until the last bulk matching record is traversed; if so, the current round of traversal is stopped, and the source batch number, source packaging identifier, and current dispensing quantity corresponding to the current record are used as a corresponding inbound batch number, inbound packaging identifier, and bulk dispensing quantity to form a corresponding inventory traceability group. The difference between the current record's remaining bulk quantity and the current dispensing quantity is taken as the current bulk quantity. Based on the current bulk quantity, the remaining bulk quantity of the current record in the bulk medicine cache pool is reset. All inventory traceability groups obtained in this round of traversal are combined to form a corresponding inventory traceability set, and the current details and the inventory traceability set are combined to form a corresponding third record.

[0067] Step 512: The obtained third records form the corresponding third record set.

[0068] Step 513: Input the third record set into the drug distribution processing interface to perform drug distribution processing and obtain the corresponding fourth record set.

[0069] Step 52: Delete the records of bulk medicines in the bulk medicine cache pool that have zero remaining quantity or expired expiration date.

[0070] Step 53: Process the drug distribution information recording of the drug distribution data table based on the drug dispensing document, the third record set, and the fourth record set.

[0071] Specifically, this includes: forming a corresponding distribution detail from each third record in the third record set and its corresponding fourth record, the drug dispensing details, the inventory traceability set, the distributor identifier, and the drug dispensing time; forming a corresponding distribution detail set from all the obtained distribution details; and adding a corresponding drug distribution record to the drug distribution data table from the drug dispensing order number, the source prescription number, and the distribution detail set.

[0072] Figure 2This is a module structure diagram of a drug dispensing device based on a document-driven approach, provided in Embodiment 2 of the present invention. This device can be a terminal device or server implementing the aforementioned method embodiments, or it can be a device that enables the aforementioned terminal device or server to implement the aforementioned method embodiments. For example, the device can be a device or chip system of the aforementioned terminal device or server. Figure 2 As shown, the device includes: a document receiving module 201, a loose medicine remaining quantity identification module 202, an identification result judgment module 203, a medicine splitting processing module 204, and a medicine distribution processing module 205.

[0073] The document receiving module 201 is used to receive medication dispensing documents.

[0074] The dispensing document includes the dispensing order number, the source prescription number, and the dispensing details set; the dispensing details set includes one or more dispensing details; the dispensing details include the drug code, drug name, quantity dispensed, unit of drug, and drug specification.

[0075] The loose medicine balance identification module 202 is used to identify whether the current loose medicine balance meets the requirements of the current document based on the dispensing document and the preset loose medicine buffer pool, and obtain the corresponding document identification result.

[0076] When the bulk medicine buffer pool is not empty, it includes one or more bulk medicine records. The bulk medicine record includes the bulk medicine code, bulk medicine name, source batch number, source packaging identification, medicine expiration date, source packaging unpacking time, remaining bulk quantity, bulk unit, bulk specification, and remaining bulk quantity ≥ 0.

[0077] The document recognition result includes one or more drug recognition results; the drug recognition result corresponds one-to-one with the dispensing details; the drug recognition result includes recognition status and replenishment quantity, with the replenishment quantity ≥ 0; the recognition status includes two states: insufficient balance and sufficient balance; when the recognition status is insufficient balance, the replenishment quantity is greater than zero and less than or equal to the corresponding dispensing quantity; when the recognition status is sufficient balance, the replenishment quantity is zero.

[0078] The identification result judgment module 203 is used to identify whether all identification statuses of the document identification result are in the condition that the remaining amount is satisfied; if not, it is transferred to the drug splitting processing module 204; if yes, it is transferred to the drug distribution processing module 205.

[0079] The drug dispensing processing module 204 is used to dispense bulk drugs, update inventory data, and update the bulk drug cache based on the document recognition results, dispensing documents, bulk drug cache pool, and preset inventory database and drug dispensing processing interface; and returns to the bulk drug remaining quantity recognition module 202 after the processing is completed.

[0080] In the process of dismantling and processing bulk medicines in stock, the principle of "first-in, first-out" applies.

[0081] The inventory database includes multiple inventory data tables; each inventory data table corresponds to a unique table identifier; each inventory data table includes multiple inventory drug records; each inventory drug record includes the receiving packaging identifier, receiving drug code, receiving drug name, receiving batch number, receiving packaging unit, receiving packaging specifications, bulk quantity, bulk unit, bulk specifications, drug expiration date, inventory status, receiving registration time, and issuing registration time; the inventory status includes three states: in stock, locked, and issued.

[0082] The interface input data for the drug dismantling and processing interface is a first record set, and the interface output data is a second record set. The first record set includes one or more first records; the second record set includes one or more second records; the first record includes a first table identifier and a first packaging identifier; the second record includes a second table identifier, a second packaging identifier, and a first dismantling time; each first or second table identifier is a table identifier; each first or second packaging identifier is an inbound packaging identifier.

[0083] The drug distribution processing module 205 is used to process bulk drug distribution and drug distribution information recording based on the drug dispensing order, bulk drug cache pool, preset drug distribution processing interface and drug distribution data table.

[0084] In the process of distributing bulk medicines, the principle of distributing the smallest surplus first shall be followed.

[0085] The input data for the drug distribution processing interface is a third record set, and the output data is a fourth record set. The third record set includes one or more third records; the fourth record set includes one or more fourth records; each third record corresponds one-to-one with the drug dispensing details, and each fourth record corresponds one-to-one with the third record; each third record includes the drug dispensing details and the inventory traceability set; each fourth record includes the distributor's identifier and the drug dispensing time; each inventory traceability set includes one or more inventory traceability groups; each inventory traceability group includes the receiving batch number, receiving packaging identifier, and the quantity of bulk drugs dispensed; the total quantity of all bulk drugs dispensed in the inventory traceability set matches the quantity of drugs dispensed in its corresponding drug dispensing details.

[0086] The drug distribution data table includes multiple drug distribution records; each drug distribution record corresponds one-to-one with a dispensing order; each drug distribution record includes a dispensing order number, source prescription number, and a detailed distribution set; each detailed distribution set includes one or more detailed distribution records; each detailed distribution record corresponds one-to-one with a dispensing list; each detailed distribution record includes a dispensing list, an inventory traceability set, a distributor identifier, and the drug distribution time.

[0087] The present invention provides a drug dispensing device based on document-driven operation, which can execute the method steps in the above method embodiments. Its implementation principle and technical effect are similar, and will not be repeated here.

[0088] It should be noted that the division of the various modules in the above device is merely a logical functional division. In actual implementation, they can be fully or partially integrated into a single physical entity, or they can be physically separated. Furthermore, these modules can be implemented entirely in software via processing element calls; they can be fully implemented in hardware; or some modules can be implemented by processing element calls to software, while others are implemented in hardware. For example, the document receiving module can be a separate processing element, or it can be integrated into a chip in the above device. Alternatively, it can be stored as program code in the memory of the above device, and called and executed by a processing element of the device. The implementation of other modules is similar. Moreover, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed through integrated logic circuits in the hardware of the processor element or through software instructions.

[0089] For example, these modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more Digital Signal Processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs). As another example, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a System-on-a-Chip (SOC).

[0090] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the foregoing method embodiments are generated. The computer described above can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The aforementioned computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the aforementioned computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, Bluetooth, microwave, etc.) means. The aforementioned computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The aforementioned available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state disks (SSDs)).

[0091] Figure 3 This is a schematic diagram of an electronic device provided in Embodiment 3 of the present invention. This electronic device can be a terminal device or server implementing the methods of the aforementioned embodiments, or it can be a terminal device or server connected to the aforementioned terminal device or server implementing the methods of the aforementioned embodiments. Figure 3 As shown, the electronic device may include: a processor 301 (e.g., CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transmission and reception operations of the transceiver 303. The memory 302 may store various instructions for performing various processing functions and implementing the processing steps described in the foregoing embodiments. Preferably, the electronic device involved in the embodiments of the present invention further includes: a power supply 304, a system bus 305, and a communication port 306. The system bus 305 is used to realize communication connections between components. The communication port 306 is used for communication between the electronic device and other peripherals.

[0092] exist Figure 3The system bus 305 mentioned can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This system bus can be divided into address bus, data bus, control bus, etc. For ease of representation, it is represented by only one thick line in the figure, but this does not indicate that there is only one bus or one type of bus. The communication interface is used to enable communication between the database access device and other devices (e.g., clients, read-write libraries, and read-only libraries). Memory may include Random Access Memory (RAM) and may also include Non-Volatile Memory, such as at least one disk storage device.

[0093] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), graphics processing units (GPUs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0094] It should be noted that the embodiments of the present invention also provide a computer-readable storage medium storing instructions that, when run on a computer, cause the computer to perform the methods and processes provided in the above embodiments.

[0095] This invention provides a method, apparatus, electronic device, and computer-readable storage medium for distributing medicines in smaller quantities based on a document-driven process. As described above, upon receiving each dispensing document, this invention identifies whether the current remaining quantity of loose medicine meets the document's requirements based on the document and the loose medicine buffer pool. If insufficient loose medicine is detected, a round of inventory dispensing, inventory data updating, and loose medicine buffer updating is performed based on the document identification result, the dispensing document, the loose medicine buffer pool, the inventory database, and the medicine dispensing processing interface. During the inventory dispensing process, the FEFO (Frequency-First-Out) principle is followed. After this round of processing, the current remaining quantity of loose medicine is re-identified to ensure it meets the document's requirements until the identification result indicates that there is no shortage of loose medicine. After confirming that there is no shortage of loose medicine, the bulk medicine is distributed and the distribution information is recorded based on the dispensing document, the loose medicine buffer pool, the medicine distribution processing interface, and the medicine distribution data table. Based on the embodiments of the present invention, on the one hand, the backlog of near-expiry drugs is reduced, the amount of expired and scrapped near-expiry drugs is reduced, and the drug waste rate is lowered; on the other hand, the cross-batch information of each drug distribution is fully supplemented through the drug distribution data table, refining the granularity of traceability information; furthermore, through a series of operations such as automatic updating of inventory data, automatic updating of bulk drug cache data, and automatic recording of drug distribution information, the manual processing process is simplified, the work efficiency is improved, and the probability of discrepancies between accounts and actual stock is reduced.

[0096] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented in hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0097] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A document-driven method for distributing medicines in smaller quantities, characterized in that, The method includes: Step 1: Receive the medication dispensing order; The medication dispensing document includes a medication dispensing number, a source prescription number, and a medication dispensing details set; the medication dispensing details set includes one or more medication dispensing details; the medication dispensing details include a drug code, drug name, quantity dispensed, unit of medicine, and drug specification. Step 2: Based on the dispensing order and the preset powdered medicine buffer pool, identify whether the current remaining powdered medicine meets the requirements of the current order to obtain the corresponding order identification result; The bulk medicine buffer pool, when not empty, includes one or more bulk medicine records. Each bulk medicine record includes a bulk medicine code, bulk medicine name, source batch number, source packaging identifier, medicine expiration date, source packaging unpacking time, remaining bulk quantity, bulk unit, and bulk specification, with the remaining bulk quantity ≥ 0. The document identification result includes one or more medicine identification results. Each medicine identification result corresponds one-to-one with the dispensing details. Each medicine identification result includes identification status and replenishment quantity, with the replenishment quantity ≥ 0. The identification status includes two states: insufficient remaining quantity and sufficient remaining quantity. When the identification status is insufficient remaining quantity, the replenishment quantity is greater than zero and less than or equal to the corresponding dispensing quantity. When the identification status is sufficient remaining quantity, the replenishment quantity is zero. Step 3: Check whether all the recognition states of the document recognition result are satisfied with the margin; if not, proceed to step 4; if yes, proceed to step 5. Step 4: Based on the document recognition result, the dispensing document, the bulk medicine cache pool, and the preset inventory database and drug splitting processing interface, perform bulk medicine disassembly, inventory data update, and bulk medicine cache update processing; and return to Step 2 after this processing is completed; In the process of dismantling and processing bulk medicines in stock, the principle of first-to-last-out is followed. The inventory database includes multiple inventory data tables; each inventory data table corresponds to a unique table identifier; each inventory data table includes multiple inventory drug records; each inventory drug record includes the following information: inbound packaging identifier, inbound drug code, inbound drug name, inbound batch number, inbound packaging unit, inbound packaging specification, bulk quantity, the bulk unit, the bulk specification, the drug's expiration date, inventory status, inbound registration time, and outbound registration time; the inventory status includes three states: in stock, locked, and outbound. The interface input data for the drug dismantling and processing interface is a first record set, and the interface output data is a second record set; the first record set includes one or more first records; the second record set includes one or more second records; the first record includes a first table identifier and a first packaging identifier; the second record includes a second table identifier, a second packaging identifier, and a first dismantling time; each first or second table identifier is a table identifier; each first or second packaging identifier is an inbound packaging identifier; Step 5: Perform bulk drug distribution and drug distribution information recording processing based on the drug dispensing document, the bulk drug cache pool, and the preset drug distribution processing interface and drug distribution data table; In the process of distributing bulk medicines, the principle of distributing the smallest remaining quantity first shall be followed. The input data of the drug distribution processing interface is a third record set, and the output data is a fourth record set. The third record set includes one or more third records; the fourth record set includes one or more fourth records; each third record corresponds one-to-one with the drug dispensing details, and each fourth record corresponds one-to-one with the third record; each third record includes the drug dispensing details and an inventory traceability set; each fourth record includes the distributor's identifier and the drug dispensing time; the inventory traceability set includes one or more inventory traceability groups; each inventory traceability group includes the receiving batch number, the receiving packaging identifier, and the quantity of bulk drugs dispensed; the total quantity of all bulk drugs dispensed in the inventory traceability set matches the quantity of drugs dispensed in its corresponding drug dispensing details. The drug distribution data table includes multiple drug distribution records; each drug distribution record corresponds one-to-one with a dispensing order; each drug distribution record includes a dispensing order number, a source prescription number, and a distribution detail set; each distribution detail set includes one or more distribution details; each distribution detail corresponds one-to-one with a dispensing list; each distribution detail includes the dispensing list, the inventory traceability set, the distributor identifier, and the drug distribution time.

2. The method for distributing medicines in smaller quantities based on document-driven principles according to claim 1, characterized in that, The dispensing details include the quantity of dispensing medicine, the drug unit, the total number of individual bulk drugs of a designated drug category, the individual physical unit, and the individual drug quantity specification. The inventory database is used to store inventory information for all batches of all medicines; Each inventory data table is used to store inventory information for a single batch of a single type of drug; each batch of drugs includes one or more types of packaging units, each type of packaging unit corresponds to one or more individual packages, each individual package contains one or more bulk drug individuals of the same type, and some or all of the three individual parameters of the bulk drug individuals corresponding to two types of packaging unit are different, the three individual parameters include the total number of individuals, the physical unit of the individual, and the quantity specification of the individual; during the warehousing registration, a corresponding inventory drug record is generated for each individual package; the warehousing drug code, warehousing drug name, and warehousing batch number are the same for all inventory drug records in each inventory data table; The warehousing packaging identifier is the unique individual identifier of the independent packaging unit corresponding to the current record; the warehousing drug code, the warehousing drug name, and the warehousing batch number are the code, name, and batch number of the current batch of drugs corresponding to the current record; the warehousing packaging unit and the warehousing packaging specification are respectively the packaging unit type and packaging unit drug quantity specification of the independent packaging unit corresponding to the current record; the bulk quantity, the bulk unit, and the bulk specification are respectively the total number of bulk drug units, the individual physical units, and the individual drug quantity specification of the independent packaging unit corresponding to the current record, and the bulk quantity is ≥1; in the inventory drug record, the warehousing packaging specification The relationship between the quantity and specifications of the bulk packaging is as follows: Inbound packaging specifications = Bulk quantity × Bulk specifications; the expiration date of the medicine is the validity period of the individual packaged item corresponding to the current record; the inventory status reflects the in-stock, locked, or outbound status of the individual packaged item corresponding to the current record. Only the inventory medicine records with the inventory status of "in-stock" participate in the identification process of whether the remaining quantity of bulk medicine meets the document requirements, and only the individual packaged items corresponding to the inventory medicine records with the inventory status of "locked" can be disassembled into bulk medicine; the inbound registration time and the outbound registration time are the inbound and outbound times of the individual packaged item corresponding to the current record, respectively. Each bulk medicine record in the bulk medicine buffer pool corresponds to an inventory medicine record with an outbound status; the bulk medicine code, bulk medicine name, source batch number, source packaging identifier, medicine expiration date, bulk unit, and bulk specification in the bulk medicine record correspond one-to-one with the inbound medicine code, inbound medicine name, inbound batch number, inbound packaging identifier, medicine expiration date, bulk unit, and bulk specification in the corresponding inventory medicine record; the remaining quantity of bulk medicine in the bulk medicine record is greater than or equal to zero and less than or equal to the quantity of bulk medicine in the corresponding inventory medicine record; the time of unpacking the source packaging of the bulk medicine record is the unpacking time of the corresponding individual package.

3. The method for distributing medicines in smaller quantities based on document-driven principles according to claim 1, characterized in that, The step of identifying whether the current remaining quantity of loose medicine meets the requirements of the current document based on the dispensing document and the preset loose medicine buffer pool to obtain the corresponding document identification result specifically includes: Each dispensing detail in the dispensing detail set of the dispensing document is taken as the current detail; and the bulk drug records in the bulk drug cache pool that match the corresponding drug code, drug name, drug unit, and drug specification in the current detail, and whose drug expiration date has not expired, are taken as the corresponding search matching records; and the total number of the search matching records is checked to see if it is zero; if so, the corresponding identification status is set to insufficient reserve, and the corresponding replenishment quantity is set to the dispensing quantity of the current detail; if... No, then the quantity difference obtained by subtracting the sum of the remaining quantities of bulk drugs from the quantity of drugs dispensed in the current details and matching records is taken as the first quantity difference. The system identifies whether the first quantity difference is greater than zero. If it is, the corresponding identification status is set to insufficient reserve and the first quantity difference is taken as the corresponding supplementary quantity. Otherwise, the corresponding identification status is set to sufficient reserve and the corresponding supplementary quantity is set to zero. The identification status and supplementary quantity corresponding to the current details constitute the corresponding drug identification result. All the obtained drug identification results constitute the corresponding document identification result.

4. The method for distributing medicines in smaller quantities based on document-driven principles according to claim 1, characterized in that, The process of dismantling bulk medicines, updating inventory data, and updating the bulk medicine cache based on the document identification result, the dispensing document, the bulk medicine cache pool, and the preset inventory database and medicine splitting processing interface specifically includes: Step 41: Based on the document identification result, the dispensing document, the inventory database, and the drug dispensing processing interface, the bulk inventory of drugs is processed according to the first-in, first-out principle. Specifically: Each drug identification result in the document identification result where the identification status is insufficient is recorded as the corresponding identification result to be supplemented; and the dispensing details in the dispensing document corresponding to each identification result to be supplemented are recorded as the corresponding details to be supplemented. Each item to be replenished and its corresponding replenishment quantity are taken as the current item and current replenishment quantity. Following a first-in, first-out (FIFO) principle, a set of replenishment records that meet the requirements for drug item details and quantity is selected from the inventory database based on the current item and current replenishment quantity. The set of replenishment records includes one or more of the inventory drug records. All inventory drug records in the set of replenishment records are in a locked state. The first record set is set based on all the obtained supplementary record sets. Specifically, all the obtained supplementary record sets are merged to obtain a complete set of supplementary records. The table identifier and the warehousing packaging identifier corresponding to each of the inventory drug records in the complete set of supplementary records are taken as a set of corresponding first table identifier and first packaging identifier. Each set of first table identifier and first packaging identifier is composed of a corresponding first record. All the obtained first records are composed of the corresponding first record set. The first record set is then input into the drug dismantling processing interface to process the bulk dismantling of the stocked drugs and obtain the corresponding second record set. Step 42: Update the inventory data in the inventory database based on the first record set and the second record set, specifically as follows: The sets of inventory drug records corresponding to the first record set and the second record set in the inventory database are denoted as sets G1 and G2, respectively; and a set G3 is determined based on sets G1 and G2, where G3 = G1 - G1 ∩ G2; and the inventory status of all inventory drug records corresponding to set G2 in the inventory database is reset to out of stock, and the inventory status of all inventory drug records corresponding to set G3 is reset to in stock. Step 43: Update the powder medicine cache in the powder medicine cache pool according to the second record set and the inventory database, specifically as follows: Each of the second records in the second record set is taken as the current record; the inventory data table in the inventory database whose table identifier matches the second table identifier of the current record is taken as the current table; the inventory drug record in the current table whose receiving packaging identifier matches the second packaging identifier of the current record is taken as the current inventory record; a corresponding bulk drug record is generated in the bulk drug cache pool for the current inventory record as the current bulk record; and the corresponding bulk drug code, bulk drug name, source batch number, source packaging identifier, drug expiration date, bulk unit, and bulk specification in the current bulk record are set based on the receiving drug code, receiving drug name, receiving batch number, receiving packaging identifier, drug expiration date, bulk unit, and bulk specification in the current bulk record; the remaining quantity of bulk in the current bulk record is set based on the bulk quantity in the current inventory record; and the source packaging unpacking time of the current bulk record is set based on the first unpacking time of the current record.

5. The method for distributing medicines in smaller quantities based on document-driven principles according to claim 4, characterized in that, The principle of first-in, first-out (FIFO) is used to select a set of supplementary records from the inventory database that meet the requirements of drug details and quantity based on the current details and the current replenishment quantity. Specifically, this includes: The inventory data tables in the inventory database that match the drug codes and drug names in the current details are formed into a corresponding current table set. Then, in each inventory data table of the current table set, the inventory drug records whose bulk unit and bulk specification match the drug unit and drug specification in the current details, whose inventory status is in stock, and whose expiration date has not expired are recorded as corresponding inventory matching records. Finally, all inventory matching records are sorted according to the chronological order of the drug expiration dates to obtain the corresponding current record sequence. The system iterates through all the inventory matching records in the current record sequence. During this iteration, the currently traversed inventory matching record is taken as the current record. The subsequence from the first record to the current record in the current record sequence is taken as the current subsequence. The sum of the bulk quantities of all the inventory matching records in the current subsequence is taken as the corresponding current total quantity. The system checks whether the current total quantity is less than the current replenishment quantity. If so, it moves to the next inventory matching record and continues traversing until the last inventory matching record is traversed. If not, it stops this iteration, and all the inventory matching records in the current subsequence form the corresponding replenishment record set. The system also locks the inventory status of all the inventory medicine records in the inventory database that correspond to the replenishment record set.

6. The method for distributing medicines in smaller quantities based on document-driven principles according to claim 1, characterized in that, The process of distributing bulk medicines and recording medicine distribution information based on the dispensing order, the bulk medicine buffer pool, and the preset medicine distribution processing interface and medicine distribution data table specifically includes: Step 61: Distribute bulk medicines according to the principle of distributing small quantities first, based on the dispensing order, the bulk medicine buffer pool, and the medicine distribution processing interface. Specifically: Based on the principle of issuing small quantities first, the corresponding third record is set according to each dispensing detail of the dispensing order and the powdered medicine buffer pool; and all the obtained third records form the corresponding third record set; and the third record set is input into the drug distribution processing interface for drug distribution processing to obtain the corresponding fourth record set; Step 62: Delete the records of bulk medicines in the bulk medicine buffer pool where the remaining quantity of the bulk medicine is zero or the expiration date of the medicine has expired; Step 63: Based on the dispensing slip, the third record set, and the fourth record set, process the drug dispensing information in the drug dispensing data table, specifically as follows: A corresponding distribution detail is formed by the dispensing details, inventory traceability set, distributor identifier, and drug dispensing time of each third record in the third record set and its corresponding fourth record; and a corresponding distribution detail set is formed by all the obtained distribution details; and a corresponding drug distribution record is added to the drug distribution data table by the dispensing order number, the source prescription number, and the distribution detail set of the dispensing order.

7. The method for distributing medicines in smaller quantities based on document-driven principles according to claim 6, characterized in that, The principle of issuing medication first based on small surpluses, according to the medication details of each medication dispensing order and the powdered medicine buffer pool, sets the corresponding third record, specifically including: Each dispensing detail in the dispensing order is taken as the current detail; and the bulk drug records in the bulk drug cache pool that match the bulk drug code, bulk drug name, bulk unit, and bulk specification with the drug code, drug name, drug unit, and drug specification of the current detail, and whose drug expiration date has not expired, are recorded as corresponding bulk matching records; and all bulk matching records are sorted in ascending order of remaining bulk quantity to obtain the corresponding current record sequence; and the current dispensing balance is initialized based on the dispensing quantity of the current detail; The system performs a sequential traversal of all bulk matching records in the current record sequence. During this traversal, the currently traversed bulk matching record is taken as the current record. The system then checks whether the remaining quantity of bulk items in the current record is greater than or equal to the current dispensing quantity. If not, the source batch number, source packaging identifier, and remaining quantity of bulk items corresponding to the current record are grouped into a corresponding inventory traceability group. The difference between the current dispensing quantity and the remaining quantity of bulk items in the current record is then used as the new current dispensing quantity. Finally, the remaining quantity of bulk items in the current record in the bulk medicine buffer pool is reset to 0, and the process continues to the next record. The bulk matching records are traversed until the last bulk matching record is traversed; if so, the current round of traversal is stopped, and the source batch number, source packaging identifier, and current dispensing quantity corresponding to the current record are used as a group to form a corresponding inventory traceability group. The difference between the current remaining quantity of bulk and the current dispensing quantity is taken as the current remaining quantity of bulk. The remaining quantity of bulk in the current record is reset based on the current remaining quantity of bulk. All the inventory traceability groups obtained in this round of traversal are combined to form a corresponding inventory traceability set, and the current details and the inventory traceability set are combined to form a corresponding third record.

8. An apparatus for performing the document-driven drug dispensing method according to any one of claims 1-7, characterized in that, The device includes: a document receiving module, a loose medicine remaining quantity identification module, an identification result judgment module, a medicine splitting processing module, and a medicine dispensing processing module; The document receiving module is used to receive medication dispensing documents; wherein, the medication dispensing document includes a medication dispensing number, a source prescription number, and a medication dispensing details set; the medication dispensing details set includes one or more medication dispensing details; the medication dispensing details include a drug code, drug name, quantity dispensed, unit of medicine, and drug specification; The bulk medicine remaining quantity identification module is used to identify whether the current bulk medicine remaining quantity meets the requirements of the current document based on the dispensing document and a preset bulk medicine buffer pool, and obtain the corresponding document identification result. When the bulk medicine buffer pool is not empty, it includes one or more bulk medicine records. Each bulk medicine record includes a bulk medicine code, bulk medicine name, source batch number, source packaging identifier, medicine expiration date, source packaging unpacking time, remaining bulk quantity, bulk unit, and bulk specification, with a remaining bulk quantity ≥ 0. The document identification result includes one or more medicine identification results. Each medicine identification result corresponds one-to-one with the dispensing details. Each medicine identification result includes an identification status and a replenishment quantity, with a replenishment quantity ≥ 0. The identification status includes two states: insufficient remaining quantity and sufficient remaining quantity. When the identification status is insufficient remaining quantity, the replenishment quantity is greater than zero and less than or equal to the corresponding dispensing quantity. When the identification status is sufficient remaining quantity, the replenishment quantity is zero. The identification result judgment module is used to identify whether all the identification states of the document identification result are in the condition that the remaining amount is satisfied; if not, it is transferred to the drug splitting processing module; if yes, it is transferred to the drug distribution processing module. The drug dispensing module is used to perform bulk drug dispensing, inventory data updating, and bulk drug cache updating based on the document recognition result, the dispensing document, the bulk drug cache pool, and the preset inventory database and drug dispensing processing interface; and returns to the bulk drug remaining quantity recognition module after the processing is completed; wherein, the bulk drug dispensing process is carried out according to the first-in, first-out principle; the inventory database includes multiple inventory data tables; each inventory data table corresponds to a unique table identifier; each inventory data table includes multiple inventory drug records; each inventory drug record includes the receiving packaging identifier, receiving drug code, receiving drug name, receiving batch number, receiving packaging unit, and receiving package The package specifications, bulk quantity, bulk unit, bulk specifications, drug expiration date, inventory status, warehousing registration time, and outbound registration time are specified. The inventory status includes three states: in stock, locked, and outbound. The interface input data for the drug repackaging processing interface is a first record set, and the interface output data is a second record set. The first record set includes one or more first records. The second record set includes one or more second records. The first record includes a first table identifier and a first packaging identifier. The second record includes a second table identifier, a second packaging identifier, and a first disassembly time. Each first or second table identifier is a table identifier. Each first or second packaging identifier is an inbound packaging identifier. The drug distribution processing module is used to process bulk drug distribution and record drug distribution information based on the drug dispensing document, the bulk drug buffer pool, and a preset drug distribution processing interface and drug distribution data table. During the bulk drug distribution process, a principle of dispensing small quantities first is applied. The drug distribution processing interface has a third record set as input data and a fourth record set as output data. The third record set includes one or more third records; the fourth record set includes one or more fourth records; each third record corresponds one-to-one with the drug dispensing details, and each fourth record corresponds one-to-one with the third record; each third record includes the drug dispensing details and an inventory traceability set; each fourth record includes the distributor's identifier and the drug's information. Distribution time; the inventory traceability set includes one or more inventory traceability groups; the inventory traceability group includes the batch number of the incoming goods, the packaging identification, and the quantity of bulk medicines dispensed; the total quantity of all bulk medicines dispensed in the inventory traceability set matches the quantity of medicines dispensed in its corresponding dispensing details; the drug distribution data table includes multiple drug distribution records; the drug distribution record corresponds one-to-one with the dispensing document; the drug distribution record includes the dispensing document number, the source prescription number, and the distribution detail set; the distribution detail set includes one or more distribution details; the distribution details correspond one-to-one with the dispensing details; the distribution details include the dispensing details, the inventory traceability set, the distributor identification, and the drug distribution time.

9. An electronic device, characterized in that, include: Memory, processor, and transceiver; The processor is configured to be coupled to the memory, read and execute instructions in the memory to implement the method according to any one of claims 1-7; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a computer, cause the computer to perform the method described in any one of claims 1-7.