Reliability and efficiency evaluation of a community pharmacy dispensing process using a coloured Petri-net approach

It has been estimated that European customers visit community pharmacies to access essential primary healthcare around 46 million times every day. Studies of dispensing error rates in community pharmacies have reported error rates of between 0.08% and 3.3% per item dispensed. While severe cases of dispensing in-accuracies often garner a high level of media coverage, less significant errors are also causing inefficiencies in primary healthcare delivery. If a variety of dispensing protocols and their consequences could be analysed using a modelling tool, the results would form the evidence for decisions on best practice guidelines in order to improve patient safety and pharmacy efficiency. This paper presents a Coloured Petri Net (CPN) modelling technique for analysing the reliability and efficiency of a community pharmacy dispensing process. The proposed approach is a novel method for considering reliability and efficiency in a single simulation based model. The CPN model represents how a team of practitioners work together to complete a set of tasks carried out in community pharmacies. It describes a close-to-reality dispensing process, which evaluates pharmacy performance over a number of key performance indicators of process reliability and efficiency, and records how staff distribute their time between tasks. Where possible, results are validated against published studies of community pharmacies.


Background
The last two decades have seen a growing awareness of iatrogenic patient safety issues within healthcare systems. Reports by the US Institute of Medicine [37] and the UK Department of Health [17] provided evidence of clear patient safety issues. These seminal reports were focused on patient safety issues occurring in secondary care settings, such as hospitals. However, the issue of patient safety in primary care has become of high priority for the World Health Organization (WHO), which identified pharmacies as a priority primary care area for improving patient safety [56]. There is a growing school of thought within the healthcare community that their attitude to risk should mirror the practices seen in other high risk industries [47]. In the UK, demand from the public on community pharmacy services is continuing to grow, for example, the Office for National Statistics recently reported that 1.106 billion prescriptions were dispensed in 2017, a 0.2% increase on the previous year [44]. Previous studies of dispensing error rates in community pharmacies have reported error rates of between 0.08% [10] and 3.3% [24] per item dispensed, which suggests nationwide errors could total up to 36,432,000 per year. The variability between these findings can be attributed to a number of factors, although a key one to consider is the methodology of data collection. Studies using external examination to detect errors returned higher error rates than those using self-report based methodologies [6]. Furthermore, since evaluations of error detection methodologies have shown that all error detection techniques underestimate the true number of errors [22], 36 million errors per year may be an underestimate.
As well as ensuring patient safety, community pharmacies operate in a competitive marketplace. There are over 11,000 pharmacies in England, with 40% of stores being located in clusters, where three or more pharmacies are within a 10 min walk of each other [18]. To encourage customers to return to use the same pharmacy repeatedly, pharmacies must offer a high quality service and meet customer requirements [14]. Patient satisfaction with pharmacy services has been shown to be closely related to waiting times [1], and long waiting times have been given as a reason for why patients will not return to a particular pharmacy [52].

Reliability engineering
Reliability engineering techniques have been used to manage risk in a wide range of fields, such as the aviation, space, nuclear and chemical industries [3] [40] [29] [26]. There is an established collection of reliability engineering techniques capable of performing system failure analyses [2]. For example, fault and event trees are commonly used reliability engineering techniques, dating back to 1961, when they were first used to study the Minuteman missile launch system [8]; NASA further promoted the technique with the publication of their fault tree handbook in 2002 [54]. Fault trees are a combinatorial method which relies on an assumption that the occurrence of basic events is independent. Markov models are an effective technique for modelling systems containing repairable components, dynamic operation, and general behaviour which cannot be modelled using simpler methods [9]. However, a limitation in their use comes from the fact that Markov systems grow exponentially with the number of system states, making them unsuitable for the analysis of large and complex systems. Petri nets, first seen in 1962 and named after their inventor Carl Adam Petri [43], have proved to be a highly effective way of modelling systems containing concurrent processes [51]. Since their inception, a number of extensions of the basic technique have been introduced to expand upon the modelling power of basic place transition nets. For example, timed nets control the firing of transitions using deterministic or stochastic periods of time, allowing Petri nets to represent temporal processes. Another extension (the technique used in this paper), Coloured Petri nets, introduces colour sets to tokens, enabling the transmission of token specific information around the net [30]. Coloured Petri nets have been used to model complex concurrent processes in a number of fields [33,34].
Healthcare is a relatively new field of application for reliability engineering. Where work has been done, secondary health care settings, such as hospitals, have been the common setting [12,20]. In primary care, Cohen et al. [11] made use of fault and event trees, to perform a socio-technical probabilistic risk assessment of the dangers involved in dispensing high-alert medications in community pharmacies. This paper presented a table of human error probabilities for basic tasks, derived from a variety of techniques such as the SPAR-H human reliability analysis method [27], and the THERP technique for human reliability analysis [53]. Petri nets have also been used to model secondary healthcare services to analyse system performance in terms of resource efficiency, and ability to deal with increased patient demands [15,19,58]. Similarly, secondary healthcare settings have been the focus of Coloured Petri net modelling approaches [5,13,48]. Previous Coloured Petri Net modelling work based in healthcare settings has focused on either the detailed variations in a process which can affect outcomes, or a macro scale analysis of how best to manage a whole healthcare unit. These approaches have led to different forms of results, such as the rate of failure of a process [48], or the efficiency of a delivery strategy [5]. This paper aims to address both issues by modelling the individual dispensing process being completed by practitioners, and evaluating the overall performance of the pharmacy. Reliability engineering techniques can be well suited to the requirements of modelling healthcare processes [35], however, there are some key challenges facing a reliability engineer, specifically when modelling healthcare processes. These include the unavailability of failure data, complexities in representing human actors, and reliance on the testimony of experts, which may be biased [57].
This paper proposes a timed Coloured Petri net modelling technique, as a tool for modelling the community pharmacy dispensing process. The novelty of this approach is the ability to perform the evaluation of process reliability and efficiency in a single simulationbased model. This paper presents the proposed modelling approach, the rules for the CPN model development, and illustrates the diversity of performance indicators that can be obtained from the model. This approach advances the current techniques due to its ability to evaluate the dispensing process in two dimensions: the system's ability to process prescriptions under various resource constraints and patient demands, and the reliability of the process. It extends the previous publications by the authors [38,39] through the usage of the CPN features to model a number of staff members performing the same type of activities by a single subnet with concurrent transitions. The remainder of the paper has the following structure: Section 2 outlines the standard community pharmacy dispensing process, Section 3 presents the modelling approach, Section 4 shows results and analysis of the model, and Section 5 provides a conclusion to the paper.

The main stages of dispensing
A typical community pharmacy dispensing process is presented in this section. Fig. 1 shows the six keys stages of the dispensing process [32,41,55]. In this process, a prescription can begin moving through the pharmacy after the prescription is handed in (either in person or electronically), where it is received by a member of staff. While receiving prescriptions, a legal check is performed, to make sure the prescription is legal to dispense. Then the labels, containing important information on how medicines are to be used, are generated. Labels used to be hand written, although in modern pharmacies label production is semi-automated with some data checking and entry where necessary. For example, some details, including the instructions for use and dose regimen, must be selected from drop-down menus on a computer screen. The Royal Pharmaceutical Society [49] provide a summary of the information which must be included on a label: Once the labels have been made, the items contained in the prescriptions are collected together, after which the labels are attached onto the corresponding medicine boxes. Once the assembly is complete, the finished prescription is passed onto a pharmacist or an appropriately qualified Accredited Checking Technician (ACT), who performs a final accuracy check. This check is designed to be the final failsafe of the dispensing process, and its purpose is to ensure a match between the prescription form and the prescription being prepared. If no discrepancies between the form and the assembled prescription are found, the assembled prescription is handed over to the patient (or placed into a box to be delivered later).
A further clinical check must be performed on the prescription to make sure the medicine being dispensed is clinically appropriate for the patient. This check may technically happen at any point in the process, although it is common for pharmacists to perform a clinical check in Errors are to be identified and rectified at the final check, and any errors that are found should be recorded as a near miss for use in future analysis of the failure [55]. Meanwhile, any failures that go unspotted at the final accuracy check are likely to reach the patient.
Each stage of the dispensing process may be completed by a single member of the pharmacy staff team. The only restriction is that only pharmacists or ACTs, are qualified to complete the final accuracy check. The order of task completion follows Fig. 1 in the model, however, in practice the order of generating labels and picking medicines may be switched, and the clinical check may be completed independently of the final accuracy check at any point in the process by a qualified pharmacist.

Resources
A pharmacy staff team may contain a number of pharmacists, dispensers, and ACTs. Large pharmacies may have many of each, while a small pharmacy may have only a single pharmacist. There must always be a responsible pharmacist present on site for a pharmacy to dispense prescriptions.
The resources involved in the dispensing process are: prescriptions, dispensers, pharmacists, medicines, labels, and labelling stations. Prescriptions can contain a number of medicinal items which must be gathered together during the assembly stage of dispensing. Note that in this paper, all analysis is conducted at a prescription level, where a prescription contains a number of items. The number of items affects how long a prescription takes to dispense at certain points in the process. However, it does not affect error rates.

Non-dispensing tasks
In addition to completing dispensing tasks, there are also a number of non-dispensing tasks that pharmacies must complete [16]. The nondispensing tasks included in this study are: stock management, patient counselling and advanced pharmacy services. Patient counselling and advanced services may only be provided by a pharmacist, whereas all staff is capable of carrying out stock management tasks.
Stock management involves maintaining the supply of medicines on the shelves. Patient counselling is done while handing out prescriptions to patients. Pharmacists must offer verbal advice to the patient or their representative on how to take medicine in a safe and effective manner [32]. There are six advanced services offered by pharmacies: the morning after pill, influenza vaccinations, medicine use reviews, smoking cessation, appliance use reviews, stoma appliance customization and NHS (National Health Service) urgent medicine supply. Advanced services take a pharmacist away from the dispensing process for a period of time [45], while they use a privacy room to see to the patient.

Failure modes
To provide correct prescriptions for customers in an acceptable amount of time and do it reliably, are the two main goals of community pharmacies. Hence, the pharmacy dispensing process can be considered to fail when: 1. A prescription given/delivered to a patient is incorrect. 2. A prescription takes such a long time to dispense, that distress or inconvenience is caused to the patient, and the pharmacy becomes an undesirable choice for return visits.
There are number of ways which prescriptions can be incorrect. For example, the contents of the prescription may be of the wrong strength, wrong volume, wrong type of medication, or the wrong pharmaceutical form (tablets/capsules/inhalers/patches etc.). An error of this kind would be classified as a content error. Another type of error is a labelling error, which occurs when the medicine labels contain an error. One example is that the label may indicate to take the medicine more frequently than was prescribed. Finally, the labels may have been generated correctly so that they match the items, which also match the prescriber's intended medication. However, an error can occur if the labels are applied to mismatching medicine boxes.

Definitions of process reliability and process efficiency
The reliability of the dispensing process, R, is defined as the proportion of prescriptions dispensed where the outcome is completely correct, as shown in Eq. (1): where p total is the total number of completed prescriptions, and p correct is the number of correct prescriptions.
The efficiency of a process is usually calculated through a comparison between useful outputs and the required resources to sustain the production. As the cost of resources is not taken into account in this study, a set of efficiency indicators are used to measure the pharmacies performance. The indicators use the number of prescriptions completed, and the time taken to complete them, as the two main measures of efficiency. The best outcome in terms of efficiency is one which outputs a large number of prescriptions with each prescription being completed quickly.

Definitions of near misses and dispensing errors
Near misses and dispensing errors are two commonly seen categories in literature, related to capturing the error rate of dispensing in community pharmacies [4,10,31]. Below there are two typical definitions of near misses and dispensing errors used by Chua et al. [10]: 1. A near miss is defined as an error in the dispensing process that is identified by the pharmacy staff before the medication is given to a patient. 2. A dispensing error is an error that is discovered after the prescription has been given to a patient.
These definitions are used in the paper to classify the outcome of prescriptions, with some minor adjustments. In the model, if a prescription is handed over to a patient, or stored for delivery with an error present, this is counted as a dispensing error. Another implicit difference between the 2nd definition above and the one used in the model, is that in the model each error is recorded, whereas in practice, some dispensing errors might not be discovered. This would happen if a pharmacy gave a patient the wrong medication, but the patient fails to notice the error. Finally, note it is possible for a single prescription to undergo multiple near misses.

Overview
This section of the paper presents an introduction to Petri Nets, and demonstrates the development of a Coloured Petri Net (CPN) model for simulating processes carried out in a community pharmacy, where tokens mimic the behaviour of pharmacy staff as they dispense prescriptions, and complete non-dispensing tasks.

Introduction to Petri nets
Petri nets are executable directed bi-partite graphs. They consist of two sets of nodes, places and transitions, with arcs running between these two sets of nodes. Places may contain a number of tokens, which are used to govern the firing of transitions, following a firing rule. This paper uses a Timed Petri Net extension, where delay times can be random (sampled from any distribution), or deterministic (also equal to 0) [51]. It is similar to the Stochastic Petri Net (SPN) formalism presented in [7], without the restrictions that only the exponential distribution may be used, and non-zero deterministic delays can occur, as in [46]. Fig. 2 shows an example Petri net. The firing rule states that, if all input places of a transition are marked with at least w i tokens (w i is the weight of the edge connecting input place to transition), then the transition is enabled. The transition will fire after time D, equal to the timing of the transition. If the transition is stochastically timed, D will be equal to a single sample of time from the probability distribution attached to the transition. Alternatively, if D is deterministic, it will fire after the deterministic amount of time specified. Upon firing, a new marking is generated by reducing the number of tokens on input places of the transition by w i , and increasing the number of tokens on output places by w o (the weight of the edges connecting a transition to its output places).
Once constructed, results can be derived from Petri net models through Monte Carlo simulation, or in the case where only exponential random variables are used to control transition timings, Markov methods can be used to analyse the system [42]. In this paper, since not only the exponential distribution is used to control the timing of transitions, all results are derived from Monte Carlo simulations.

Coloured Petri nets
Colours can be added to a Petri net framework. In this paper, combinations of colour sets are used to define a set of distinct token types. This paper uses three token types: prescription (p), worker (w), and basic tokens (e), to represent the resources. The worker (w) token type has one colour field used to indicate the role of the worker token (as either dispenser or pharmacist), and a further set of colours which correspond to the tasks they are allowed to complete. The prescription token type, (p) uses a larger set of colours, which are described in Section 3.3.5. Basic tokens (e) have no colour sets attached to them, and they are used in the PN to permanently enable transitions, model the availability of labelling stations, and count the number of times a pharmacist has completed an advanced service.
The firing rule for Coloured Petri nets is similar to that of non-coloured nets, although there are additional control mechanisms to take into account, such as transition guard expressions and arc inscriptions. Guard expressions can be used to constrain the enabling conditions of transitions based on the colours of tokens on their input places. Arc expressions can be used to alter the properties of tokens being placed onto output places, or the types of tokens needed to enable a transition on input places. The use of colours in this paper has been inspired by [30], however, the way time is introduced follows that seen in [51]. Fig. 3 shows an example CPN transition. The expression beside each place marker indicates the types of tokens contained in each place, and arc expressions take the form of a multi-set of colours. In the example, there are two coloured token types, p and w. p tokens include waiting time as one of their colours, and w tokens have colours that correspond to time spent completing various tasks. After the transition has fired, the waiting time and the colour corresponding to the task being completed, are both incremented by the delay time D. Note that the waiting time of the p token on place 2, is also incremented.
Introducing token colours into a Petri net framework enables much more detailed analysis of token behaviour. The colours enable each token to represent distinct entities, unlike a Petri net without colours, where two tokens on a single place are always indistinguishable. The ability to distinguish between tokens allows for a higher level of modelling resolution, desirable for this community pharmacy application.

Building the model
The model presented in this paper has been designed to simulate a community pharmacy which uses a manual dispensing method (instead of the automated method [25]), with the ability to accommodate variable numbers of pharmacists and dispensers. The staff are capable of working in parallel to complete prescriptions. Fig. 4 shows the full graph of the CPN used to model the process. The model was built by considering how a single prescription moves around a pharmacy, and then incorporating the way resources are used in dispensing a prescription. Table 1 lists each place, along with a description of the place, and the token types that are allowed to occupy each place. Places are used for different purposes in the net. Some places are used to hold staff resources, others show at which stage prescriptions are in the dispensing journey. Alternatively, some places are used to generate new tasks, by keeping a transition constantly enabled (1, 19, 20, and 23). Note that increments of a constantly enabled exponentially distributed transition represent a Poisson random variable, used for modelling the arrival of walk-in patients or advanced services. Table 2 shows a list of transitions, their distribution used for transition timings, a small description of what a transition controls, and a letter Y in the 4th column designates some transitions as processor transitions (events which are affected by the number of items in a prescription). For example, generating labels is a processor transition, since it will take longer to generate a set of labels for a prescription containing a large number of items.
Some transitions are representative of community pharmacy dispensing tasks (eg. 2, 7, 8, 11 and 12), for example, labelling, filling or new prescriptions entering the system, while other transitions (3, 5, 9, 13, 17, and 20), are for controlling the way tokens are allocated around the net, and are not representative of any real task. The latter are used  to determine which tasks pharmacy staff prioritise. The CPN models a pharmacy in which people may assemble prescriptions and accuracy check prescriptions simultaneously. This is a reflection on the relative size of the pharmacy being modelled. If a specific pharmacy is capable of having more or less people work simultaneously on similar tasks, the model is able to accommodate this by limiting the number of self concurrencies allowed for specific transitions. Transition timings have been generated through in depth discussions with two experienced community pharmacists. All interviewees had previous experience working in community pharmacy dispensaries. The interviews generated the estimates of the mean duration of each stage, while distribution types have been assumed, for example, use the Poisson distribution, a common distribution to count arrivals, to describe patient arrivals.

Model assumptions
A key feature of the model is the distinction between primary and secondary tasks, as shown in Fig. 4, and between the two types of staff, dispensers and pharmacists. The model designates each task as either primary or secondary, where any member of staff may complete primary tasks, but only pharmacists may complete secondary tasks. As well as this distinction, the model uses further assumptions about staff behaviour, and pharmacy resources. The assumptions about staff behaviour are as follows: • Staff complete tasks in an identical way, i.e. the same probability distributions are used to determine how long tasks take to complete, and error probabilities are the same.
• Primary dispensing tasks include: receiving prescriptions, generating labels, assembling prescriptions, applying labels and stock management. Secondary tasks include: final accuracy checking prescriptions, completing advanced pharmacy services, handing prescriptions over to patients (along with patient counselling) and storing medicines for delivery.
• Pharmacists prioritise completing secondary dispensing tasks, but they may also contribute to completing primary tasks. If a pharmacist is on place 16 with no secondary tasks to complete, and no dispensers are in place 6, the pharmacist will instantaneously move to complete a primary task.
Assumptions about labelling stations, pharmacy opening hours, and prescriptions, are given below: • There are 2 labelling stations (A labelling station is a computer linked to a small printer, capable of producing labels).
• When a customer arrives in the pharmacy, the first member of staff available to complete primary tasks moves over to the counter to receive the prescription. If multiple staff are available, the member of staff that has been idle for the longest time receives the prescription.
• Once a member of staff begins generating labels for a prescription, they continue working on the same prescription until the labels have been applied, i.e. the same person will generate labels, collect the contents, and apply the labels consecutively. • Walk-in prescriptions and advanced services arrive with increments of exponential distributions.

Resources
Simulations begin with no prescriptions in the pharmacy. Dispensers and pharmacists are initially placed in places 6 and 16 respectively. The only resource modelled by basic tokens, are the labelling stations used to create and print labels. These are represented in Fig. 4 by the basic tokens on places 7.

Primary task allocation
Staff tokens wait in an 'available' place, until a task needs to be completed. Once a task becomes available, the member of staff who has been waiting the longest is allocated to complete that task. Fig. 5 is an enlarged section of Fig. 4, showing workers waiting to be allocated to various primary tasks.
As tasks arrive, workers are allocated using instantaneous transitions which each has a parameter to determine their order of priority. The priority parameter controls which task workers are allocated to if there are multiple tasks needing completion. Fig. 5 shows the allocation transitions for four primary dispensing tasks which require worker resources (transitions 3, 5, 17 and 20).
The hierarchy of primary tasks from the top priority to the lowest Advanced service waiting to be completed. e 19 Advanced services task generator. e 20 Stocking task generator. e 21 Stocking task waiting to be completed. e 22 Stocking task being completed. w 23 Dispenser lunch break generator. e 24 Lunch break is ready to be taken. e 25 A dispenser is on their lunch break. w 26 Arrivals counter. w 27 Advanced services counter. priority is as follows: receiving prescriptions, lunch break, stock management and starting to dispense a prescription. Thus transition 3 is given priority over transition 20, which is given priority over transition 17, which is given priority over transition 5. Receiving prescriptions is the top priority, since patients waiting at the counter need to be seen quickly. Lunch breaks and stock management are next, above starting to dispense prescriptions, since these are infrequent compared to dispensing, and these tasks may never be completed if dispensing were prioritised, since the constant stream of dispensing would deny staff a break. Fig. 6 shows the net section used to allocate pharmacists to secondary tasks. Similarly to the transitions used to allocate staff to primary dispensing tasks, the transitions for secondary tasks use a hierarchy determined by their frequency. The hierarchy from highest to lowest is as follows: advanced services, followed by completing secondary dispensing tasks.

Prescription modelling
Prescription tokens have 8 colours representing: 1. Delivery or a walk-in. 2. The time taken to dispense the prescription 3. Number of iterations to complete the prescription, if faults occur 4. The overall outcome of the prescription (near miss, dispensing error, or completely correct) 5. The number of items in the prescription 6. Labels 7. Contents 8. Label application The number of iterations is an integer, counting how many times a prescription has needed to be corrected, whenever a pharmacist returns a prescription after a near miss. Overall outcome is also an integer, which represents the three possible outcomes of dispensing a prescription. The colours for labels, contents and label application are Boolean, and they indicate whether an error of the corresponding type is present in the prescription.
There is no difference between a rectified near miss prescription and a completely correct prescription being handed over to a patient, but in this analysis, the number of near misses is an indicator of how well the final accuracy check is performing, and how frequently errors occur during the dispensing process.

Failures
The occurrence of failures is modelled in the CPN using Bernoulli random variables. The processes of label generation, prescription assembly and label application introduce a probability of a labelling error, contents error, or label application error respectively. The failure probabilities used for each stage can be found in Table 3. These probabilities were taken from Cohen et al. [11]. It was then assumed that label generation may be twice as likely to fail as applying completed labels to prescription boxes.
The probability of errors is introduced to the CPN using arc inscriptions. The final accuracy check outcome is conditional on the state of the prescription being checked. If a prescription is error free, it is assumed that the prescription passes through the final accuracy check to the next stage of the process.
If the prescription being checked contains an error, the pharmacist attempts to spot the error at the final accuracy check. If an error is spotted, the prescription is sent back to place 5 to be dispensed again. If a prescription containing an error is checked, and the error is not found, the erroneous prescription will continue through the dispensing process.

Item modelling
Each prescription is assigned a random number of items, by sampling from a Geometric(0.35) distribution. This distribution has a mean of 1/0.35, and has been assumed, based on the following reasoning. Assume a patient goes to a doctor and is given a prescription. The first assumption is that there will be at least 1 item in the prescription. The second assumption is that prescriptions containing more items are less likely to occur than those containing fewer.
The number of items in a prescription affects the duration of some stages of the dispensing process. To simulate this, transitions representing processor stages sample from their distribution a number of times equal to the number of items in the prescription being processed, and the sum of those samples is used as the delay.

Reviewing studies of dispensing errors
A review of the literature identified six studies which collected data on dispensing errors and near misses in community pharmacies, with one study in the US [23], three UK studies [4,10,24], one from Denmark [31] and one from Spain [50]. A UK study that only collected data on the occurrence of dispensing errors, but no near-misses, has also been included [24] in Table 4. Table 4 gives the key information taken from each study. The columns titled near misses and dispensing errors represent the percentage of the total number of items (or prescriptions, depending on the study) that were found to contain either type of error. The column entitled "contents/labelling/administration" represents the percentage of each type. Note that any errors that were neither content nor labelling errors have been included in administration errors. The column of "self-report/external" indicates the type of data collection method used.
There was a large variation in the error rates found in the studies of community pharmacies. Discrepancies include: the rate of near miss or dispensing error occurrence per item or prescription dispensed, the proportion of dispensing errors to near misses, and the relative prevalence of contents and labelling errors. Along with the differences  found between studies, there were also reportedly variations of error rates between pharmacies taking part in the same study, even when the same data collection technique was being used. As these studies do not state the exact specifics of the observed pharmacies (size, number of staff, number of prescriptions, etc.) their outputs cannot be used for the PN model validation. However, these studies, taken as a group, give an indication of the range of values for the near miss and dispensing error rates and can be used to comment on the outputs of the PN model, as discussed in Section 4.1.1. The proposed PN model has been verified by expert community pharmacists as a reasonable representation of the core dispensing process in a community pharmacy.

Pharmacy scenarios and their analysis
To demonstrate the ability to simulate the effects on performance of different community pharmacy variations, five scenarios were chosen for analysis. Scenarios 1 and 2 investigate the effects of implementing an infallible final accuracy check. Scenarios 3, 4 and 5 have been chosen to demonstrate the effects of changing the make up of the pharmacy team and the effects of non-dispensing activity. The number of staff in these scenarios is chosen as a representation of small pharmacies in the UK. Same as scenario 3, but with 1 pharmacist and 3 dispensers.

Scenario 5
Same as scenario 3, but with 2 pharmacists and 2 dispensers.
Different initial conditions of the CPN are used to model each scenario. Fig. 4 shows the CPN used in Scenario 3. The initial conditions of other scenarios are created by adding or removing tokens, or altering error rates. Adding additional dispenser tokens to place 6, or pharmacist tokens to place 16 alter the number of staff for Scenarios 4 and 5. The tokens in places 19, 20 and 23 control whether any advanced services, stocking, or lunch breaks are included in the simulation. Additionally, to model an infallible accuracy check in Scenario 1, the probability of 0 is used instead of 0.05 to describe the probability of failure during an accuracy check.

Results and their analysis
An object oriented Coloured Petri Net simulation environment was coded in C++, in which the CPN in Fig. 4 was constructed. A single day of community pharmacy operation was simulated 150,000 times for each scenario. The key results of the performance under the five scenarios are shown in Table 5 (note that the sixth scenario, 3a, is discussed in section 4.1.5). Further results on how members of staff distributed their time between tasks are shown in Tables 6 and 7. A convergence test was done on Scenario 3 to test whether 150,000 simulations was sufficient. This was done by running 900,000 simulations of Scenario 3 for comparison with the original results. All results are presented to the level of precision at which the two runs agreed. Scenario 3 was chosen for the convergence test since it has many similarities with all the other scenarios.
The values in Table 5 are generated by querying place 15, and averaging over the set of simulations. The number of prescriptions completed is counted, and the colours attached to each prescription token are inspected to determine the number of prescriptions that were Table 4 Summary of studies of dispensing errors and near misses in community pharmacies.    Tables 6 and 7 are generated by inspecting the colours attached to each worker token in the PN, which keep track of how much time each worker has spent completing each task. When a simulation ends, the average time spent completing each activity is calculated for each staff type (dispensers and pharmacists).

Scenario variations
Introducing additional non-dispensing demands on the pharmacy increased the waiting time of prescriptions, as can be seen by comparing scenarios 2 and 3. Due to the priority given to walk-in prescriptions over deliveries, there is a corresponding decrease in the number of delivery prescriptions completed as additional non-dispensing demands are considered.
A decrease in the average waiting time was seen when increasing the number of staff. Having three dispensers instead of 2 (scenario 4) reduced the average waiting time for walk-in prescriptions by 103 s. A higher still decrease in the average waiting time was gained by adding a second pharmacist to the team (scenario 5). This reduced the average waiting time for walk-in prescriptions by 178 s. Notably, in both scenarios where 4 staff were used (scenarios 4 and 5), the pharmacy was finishing a very high percentage of deliveries, over 99% in both scenarios. This suggests that 4 staff working in the pharmacy may have been able to complete a higher number of delivery prescriptions in the allotted time, increasing pharmacy productivity. This hypothesis is backed up by Tables 6 and 7, where it can be seen that the staff were idle considerably longer in scenarios 4 and 5.
The difference in the average dispense time between scenarios 1 and 2 is of note. The results show that including the potential for the final accuracy check to fail, reduced the mean waiting time by 5 s. This is expected, since a prescription containing an error will always be identified if the final check is infallible (scenario 1), and thus it will be sent to be dispensed again and therefore take longer. In scenario 2 a small number of erroneous prescriptions which are not dispensed again (due to them not being spotted at the final accuracy check) make the process faster, but at the cost of dispensing errors reaching patients. This result makes a strong case that, if it was possible to have an infallible final accuracy check, the cost in terms of increased average dispensing times would be low.
The results of the model indicate that the pharmacy dispensing process had a reliability of 0.992, i.e. 99.2% of prescriptions were dispensed correctly. Hence, the simulations produced a dispensing error rate within the reported range seen in Table 4. On the other hand, the frequency of near misses generated during simulations is considerably higher than those reported in previous studies. The discrepancy may relate to the fact that error probabilities in Table 4 for dispensing stages may have been set too high, studies may be underestimating the true rate of near misses, or the lack of specifics in the literature makes it unsuitable for the validation of the proposed method. Studies on the rate of near misses occurring in community pharmacies are often based on self-report methodologies, which are known to under-report error rates [22]. Tables 6 and 7 show the percentage of time that was spent on each task for dispensers and for pharmacists. Work sampling studies have been conducted in community pharmacies, with the objective of describing how pharmacists spend their time [16,21,28,36]. These studies are used to collect observations about a subject working in practice, recording their activity at either fixed or randomly timed intervals. If the set of observations is large enough, then the proportion of each recorded activity can be approximated to the overall time spent on that activity. It should be noted that different studies have returned a range of results for how pharmacists spend their time. For example, considering the time pharmacists spend resting, the four studies cited above returned results between 5.8%-18.1%. Such difference may be attributable to the different work patterns, or variable levels of staff present. Work patterns here, refer to the way tasks are divided up within the pharmacy. In some pharmacies, the pharmacist may not need to contribute to primary tasks, such as stock management or receiving prescriptions, whereas in others, they may have to.

Work sampling comparison
For comparison Davies et al. [16] work sample is used as a benchmark for the model, as one of the more recent community pharmacy work sampling studies. The results of the model compared well with the work sample study on a number of fields, the time pharmacists spent on patient counselling and advanced services were within 1% in multiple scenarios. The largest discrepancy was the time spent accuracy checking. In the model pharmacists spend almost 3 times the amount of time checking than reported in the work sample study. This may be because the model omits some activities. Davies et al.'s work sample study has a number of activities which are not included in the model, such as, housekeeping, staff training, sales transactions, which are all not included in the model. Tables 6 and 7 both show that increasing the number of staff gives staff much more idle time. Fig. 7 shows the distributions of the waiting times for walk-in prescriptions in scenarios 3, 4 and 5. Only these scenarios were considered since they were sufficiently different from scenarios 1 and 2, where no non-dispensing tasks are being completed. The waiting times for each prescription were recorded during a separate run of 6000 simulations, with each scenario totalling just over 600,000 prescriptions dispensed. A prescription was considered to have been delayed if it took more than 15 min to be dispensed to a customer, denoted by the dashed line in Fig. 7.

Causes of delays
There are a number of potential causes for delays. These include: a prescription containing a large number of items being likely to take longer due to the way multiple item prescriptions are handled in the pharmacy, a prescription having to be repeated a number of times due to near misses, or pharmacists being busy with non-dispensing tasks. Table 8 shows the average properties of prescriptions completed in different time periods, for scenarios 3, 4 and 5. It can be seen across scenarios, that prescriptions being completed in increasingly delayed time periods have, on average, a larger number of items and require more iterations of dispensing to complete. As larger teams dispense faster, the average number of items in the same band of duration increases.

Intermediate check
A sixth pharmacy scenario (3a) was included in the analysis to test the effect of implementing an intermediate accuracy check [41,55] in the dispensing process, in addition to the final check. This check operated in a similar manner to the final accuracy check, but by checking prescriptions for errors while the labels were being applied, i.e. before the prescription is passed to the pharmacist for the final check, and returning them to be dispensed again if an error was found. The error probability of the check was assumed to be 0.1. The results for this scenario are shown in Table 5, the row 3a.
Introducing an intermediate check at this stage of the process had relatively small effects on the pharmacies efficiency. It reduced the waiting time by 21 s, increased the percentage of prescriptions dispensed by 0.8%, and reduced the percentage of delayed prescriptions by 1.7%. This could be due to the fact that when using an additional intermediate check the errors are identified earlier and therefore the prescription can be rectified and completed faster. However, it had comparatively larger effects on process reliability. The additional check increased reliability by 0.069, which in day to day terms meant 29 fewer near misses, and 1.7 fewer dispensing errors per day. Overall, introduction of an intermediate check is a good option for increasing process reliability and efficiency.

Conclusions
This paper demonstrated that Coloured Petri Nets is a viable method for evaluating the reliability and efficiency of the community pharmacy dispensing process. Pharmacy processes were simulated in order to compare the performance under different team compositions. A set of efficiency and reliability performance indicators were generated for each scenario. The results indicate that adding an additional pharmacist had a larger benefit for the process, in terms of process efficiency, versus adding an additional dispenser, and that if an infallible method of accuracy checking was achieved, the cost in terms of additional dispensing times would be low. Introduction of an intermediate check would increase process reliability without any loss in pharmacy efficiency. Such a method could be used to inform pharmacy decisions on the size of the team and areas of improvement for staff training.
Future work could include collection of in-field data to obtain task durations and error probabilities, and carry out an investigation of how these parameters are affected by factors, such as staff job role, age, level of training, experience and motivation. Different dispensing paradigms or conventions could be tested and compared within the modelling framework, examples of which could be the inclusion of electronic prescriptions, or the use of robotic dispensing technology. Finally, an optimisation algorithm could be applied in order to find an optimal make-up of the pharmacy team for improved process reliability and efficiency.

Acknowledgements
This work was supported by the Engineering and Physical Sciences