Modelling Reliability and Efficiency of English Community Pharmacy Processes

The research reported in this paper describes a Coloured Petri Net (CPN) method for modelling and analysing reliability and efficiency of the dispensing process in English community pharmacies. The results of CPN simulations are used within an optimisation framework, based on an Ant Colony optimisation (ACO) algorithm, in order to find optimal solutions for a range of process parameters, such as the number of dispensers and pharmacists to employ, prescription checking strategy or staff work pattern. Set-ups are evaluated using a multi-objective utility function with three parameters: the number of prescriptions completed, the number of errors, and the average waiting time. In-field data from 4 English pharmacies are used to control the firing of key transitions of the CPN. The results indicate that if a pharmacy has a large budget the optimal setup is likely to contain many staff, of which a majority will be dispensers. Alternatively, if the budget is small, it is likely the optimal team will be small and contain a majority of pharmacists.


INTRODUCTION
In the face of a growing and aging population, the healthcare industry continues to be of great importance to our societies. Ways to deliver reliable care and ensure patient safety need to be efficient, especially when healthcare funding resources become limited due to increased service demand. Patient safety within healthcare systems has been of growing concern within the last two decades [5]. Secondary care settings such as hospitals, were found to be the setting where many iatrogenic errors were occurring and it was understood that potentially similar volumes of errors could be occurring in primary care. In England there are 11,619 pharmacy stores which compete to provide primary care to patients in the form of over 1 billion dispensed prescriptions each year [1]. European community pharmacy error rates have been reported to be between 0.014% [2] and 3.3% [3] per item dispensed. Applying these error rates to English pharmacies suggests that up to 36 million items may contain errors each year. As well as safety concerns, patient satisfaction with pharmacy services is also linked to waiting times [4]. To encourage customers to use the same pharmacy repeatedly, pharmacies must meet customer expectations in terms of time taken to provide medication.
This paper aims to contribute to the field of reliability and efficiency simulation modelling of healthcare, and more specifically to the modelling of community pharmacies. The paper offers two novel contributions: a modern heuristic is used to extend previous CPN modelling of the dispensing process, and the state space of the problem is constructed to consider typical pharmacy set ups which contain only a single pharmacist. Such set ups are typical of English community pharmacies, and the problem therefore matches closely the situation found in many stores.

Key stages of the dispensing process
Previous work of the authors has developed a Coloured Petri Net (CPN) simulation model of the dispensing process. This was built by considering how a team of practitioners work together to move prescriptions through pharmacies [6]. This section of the paper details the key features of the CPN model, which is later optimised to produce a set of optimal pharmacy configurations. The main stages of the dispensing process are shown in Figure 1 [7].  Figure 1 describes the typical journey of a prescription through a community pharmacy. One person carries out each stage of the process. Only pharmacists or Accredited Checking Technicians (ACTs) are qualified to perform the final accuracy check (also known as a secondary task), whereas dispensers can carry out other stages (primary tasks).

Resources
Pharmacies make use of a number of human (dispensers, pharmacists and ACTs), and technological resources (a computer linked to a label printer) to dispense prescriptions. Larger stores may have a number of people of each staff type, while a single pharmacist may run a small store.
Prescriptions are made up of a number of medicinal items, which have been prescribed to patients. These items must be collected, appropriately labelled and accuracy checked before being handed out to patients. In the model, a number of items in a prescription is assumed to follow a Geometric(0.35) probability distribution. The number of items influences the duration of the stages.

Non-dispensing tasks
As well as providing patients with prescriptions, there are a number of non-dispensing tasks, which must be completed. Non-dispensing tasks included in the model are: advanced services (a number of additional health related services offered in English pharmacies, such as vaccinations or medicine use reviews), restocking the medicine shelves, and counselling patients about how best to take their medication. These tasks were seen as an important part of pharmacies operations. The model includes them by taking staff resources away for a period to model the action being completed.

Failures
In the model, errors can occur during 4 stages: generating labels, picking medicines, applying labels and checking accuracy. Note that intermediate accuracy checks are also possible; dispensers complete them after the application of labels. Error rates are shown below in Table 1, they have been inferred using a table of human error rate probabilities found in [8].

Model assumptions
x Only dispensers and pharmacists (no ACTs) are modelled.
x The pharmacy is open between 9am and 5pm.
x Staff prioritise walk-in prescriptions over deliveries.
x A batch of 150 delivery prescriptions enter the pharmacy at 10am. x The duration of each task and the error rate does not depend on the type of staff.
x Once a member of staff begins to print labels, they continue working on the same prescription until they have applied labels.
x Customers arriving in the pharmacy are attended to as soon as a member of staff becomes available.
x Staff work most of the day; each dispenser takes their lunch break sequentially, whereas pharmacists fit their lunch in when they are free. For further information about the CPN model see [6].

DATA COLLECTION
To enhance the model outlined in Section 2, duration data for 6 stages of the dispensing process was collected from 4 UK community pharmacies, and then incorporated into the CPN model. There have been previous attempts to time the dispensing process, but the data has been unsuitable for use in this model because samples sizes were small [4], or the stages of dispensing were not timed individually [7]. Table 2 displays the key characteristics of the pharmacies included in the study. The two pharmacies A and B were both members of the same large business, and pharmacies C and D were independent pharmacies. A was co-located with a doctor's practice.
For the 4 stages, from generating labels to applying labels, two variable observations were collected: the number of items in the prescription and the time taken to complete the stage. The duration data was grouped into 6 segments: 1 item, 2 items, 3 items, 4 items, 5-8 items (medium), and 9+ items (large). For the stages of prescription reception and handing over to patients, only the duration was recorded. All data was collected using researcher observation between 3 to 5 days in each site, using a stopwatch to time each stage. The results of the data analysis have been previously published in [9].

Background
Experiments have demonstrated that ant colonies have the ability to locate the shortest path to nearby food sources [12]. They do this by secreting pheromones which other ants can detect, where this collective path following and path marking behavior is the basis of Ant Colony Optimisation (ACO). ACO is considered one of the stronger algorithms for tackling discrete optimisation problems [13]. This paper uses Max Min Ant System (MMAS), a variant of ACO, which encourages exploration of the problem space by enforcing variable limits on the concentration of pheromone which can be placed on paths.
Ants have two modes of operation in the algorithm: solution construction (forward mode), or pheromone update (backward mode). A state space is constructed to represent the problem space by drawing a graph of nodes connected by edges representing all possible choices that could be made. Initially ants construct solutions by moving over the state space, using pheromone concentration levels to guide their choices. Once all the ants have constructed a solution, the best performing ant lays pheromone onto the path it walked across the search space to encourage future ants to use those values. An iteration of the algorithm involves each ant constructing and evaluating a solution, then updating all the pheromones by evaporating some off of each path, and placing new pheromone onto the best performing path. The equations which govern these key behaviors are outlined next.

Solution construction
The MMAS algorithm uses a decision policy to govern how ants move across a graph to build potential solutions. The policy is dependent on the amount of pheromone on edges and the inherent desirability of each edge. Hence, an ant on node i, will use the concentration of pheromone on surrounding edges and prior heuristic information about surrounding nodes to make a choice about where to move next. Under the assumption that the pheromone concentration on all arcs from node i to j is denoted by ɒ , and the heuristic value for the desirability of node j is given by ɋ , then the decision policy is shown in equation (1).
In equation (1) p is the probability of an ant choosing to move to node j after visiting node i. Ni is the neighbouring set of nodes adjacent to node i, i.e. the set of nodes which can be reached from node i by travelling along 1 arc. The values of Į DQG ȕ give weighted preference to either heuristic or pheromone information during the construction of solutions.

Pheromone update
The update of pheromones is performed in two stages. First, an amount of pheromone is removed from every path using equation (2): where ȡ LV a constant representing the rate of evaporation of pheromone. Then additional pheromone is placed onto the paths used by the best performing ant using equation (3): where οɒ is the amount of additional pheromone deposited on the edge (i, j), and k indicates which ant provided the best solution. The pheromone deposit is proportional to the quality of solution generated, and is calculated using equation (4): where Pk is the set of paths that make up the kth ants path, and O k is the objective value returned by the kth ant.

Encouraging exploration
Where MMAS differs from standard implementations of ACO algorithms is the incorporation of flexible upper and lower on pheromone concentrations. This bounding of the pheromone concentrations is designed to improve the algorithm's performance by stopping premature convergence to sub-optimal solutions. The flexible bounds are implemented using equation (5): where the upper bound, ɒ ௫ ‫,)ݐ(‬ is set using equation (6): and O best is the best solution returned by the ants up to time t. The lower bound for pheromone concentrations is set using equation (7): where pbest is the probability that any ant will choose to use a path which is marked with the maximum allowed concentration of pheromone and all others paths have the minimum allowed concentration, and avg is the average number of options available to the ant at each step during path construction.

APPLYING MMAS TO THE COMMUNITY PHARMACY OPTIMISATION PROBLEM
The problem tackled in this paper assumes that a pharmacy is looking to use a conventional staff set-up commonly found in UK pharmacies, where a single pharmacist works in a store with the assistance of a number of dispensers. This section describes how the MMAS optimisation algorithm has been applied to the community pharmacy model to solve this problem.

Decision variables
The four decision variables chosen to represent the problem outlined above were: x The number of dispensers to employ.
x The number of labelling stations.
x The checking strategy to use while dispensing.
x The work pattern to use Using this framework a community pharmacy set-up can be defined using a 4 tuple of integers, P = (d, l, cstrat,wpattern), where d corresponds to the number of dispensers employed, l indicates the number of labelling stations used, cstrat is the checking strategy followed, and wpattern is the work pattern employed in the pharmacy.

State space
By setting out ranges of acceptable values for each of the four decision variables, the state space of the optimisation problem can be constructed and converted into an ACO framework. Figure 2 shows how the state space of the problem can be represented. Four layers of nodes are used to represent the state space, where arcs exist between adjacent layers, but not between nodes within the same layer. To create a valid solution, ants must choose a single node from each of the four layers constructing a route from their nest to a food source. As an example, the path shown in Figure 2 indicates a community pharmacy set-up which uses 3 dispensers, 2 labelling stations, the second of three checking strategies, and the second of two work patterns.

Figure 2. Example community pharmacy set-up in an ACO framework
There is a legal requirement for the presence of a responsible pharmacist to be on site at all times for pharmacies to dispense prescriptions. However, no comparable legislation exists for dispensers, and thus the option of a set-up including zero dispensers is possible. The three checking strategies available to pharmacies in this optimisation, are as follows: 1. A single final accuracy check performed by a pharmacist. 2. Two checks, the first carried out as the labels are applied to the items in a prescription, the second is a final accuracy check from the pharmacist. Errors discovered during the first check are sent to be dispensed again. 3. As in 2, there are two checks, the first carried out as the labels are applied to the items in a prescription, the second is a final accuracy check from the pharmacist. Errors discovered during the first check are attempted to be fixed immediately after they are found. The above strategies can be used to check prescriptions in community pharmacies, however, it is unknown which strategy is most common in practice. There are two work patterns available to pharmacies in the optimisation framework; they are as follows: 1. Pharmacists are allowed to complete primary dispensing tasks. These include dispensing prescriptions, or receiving prescriptions from patients. 2. Pharmacists focus on tasks only they are qualified to carry out, and do not contribute to any primary tasks. There are 165 possible unique community pharmacy setups in the optimisation, (6 × 5 × 3 × 2) -15 = 165. Note that 15 set-ups are invalid when no dispensers are available and the pharmacist does not complete primary tasks.

Cost of wages
Each community pharmacy set-up is assigned a cost based on the median wages of dispensers and pharmacists, which were found to be £21,314 and £41,500 respectively [14]. The cost of including each label printer for each set-up was assumed to be £200. Hence, the cost of wages for each set-up was calculated using equation (8): Cost = 41,500 + 200 × l + 21,134 × d (8) where l is the number of label printers used by the pharmacy, and d is the number of dispensers.

Local search
To improve the algorithm's search strategy, a local search step was included to improve upon strong solutions returned by the ants, by testing adjacent solutions in the search space. The local search was implemented by randomly choosing one of the four layers of nodes, and then choosing nodes adjacent to the one, which produced a strong solution within the selected layer.

Utility function
To evaluate the performance of each set-up, three performance variables were used. These were: the average waiting time for walk-in patients visiting the pharmacy, the number of prescriptions completed, and the number of dispensing errors made. These three performance indicators were combined to evaluate different community pharmacy setups using equation (9): where the constants, Ȝ1, Ȝ2, Ȝ3 > 0, weight the importance given to each of the performance indicators. The aim is to minimise the value of U. $ FRQVWDQW RI Ȗ ZDV LQFOXGHG WR JXDUDQWHH SRVLWLYH values of U. The three performance indicators were assumed to be of relatively equal value, and therefore, the three weighting constants were chosen so that each indicator was of the same order when multiplied by the weighting constant. To achieve this the three constants were chosen as follows: Ȝ1 = 0.1, Ȝ2 = 60, Ȝ3 = 0.1. This choice implies that reducing the number of errors by 0.5 each day on average, is equivalent to reducing the average waiting time by 5 minutes.

Pheromone updates and stopping conditions
Pheromones were updated using a cycle of 3. The first 2 pheromone updates were placed using the iteration best ant, and the 3 rd was updated using the global best ant path. After the first completion of this cycle, it was repeated for further iterations until the algorithm terminated. The stopping condition was either when the maximum number of iterations had been completed (N = 50), or if the same iteration best solution was returned 3 times consecutively.

Model implementation
The ACO algorithm was run using 2 phases for each iteration. Four 'search' ants were sent out to test solutions during the first phase, and the path which returned the strongest solution was locally searched. The initial 'search' ants simulated the pharmacy set-up indicated by their path choice 500 times, and the local search tested the original best path a further 500 times, and then simulated each of the neighbouring local solutions 1000 times each. An estimate for the minimum objective value, ɒ , was obtained by running the algorithm for a single iteration. The MMAS algorithm was run for 50 iterations where the ants were purely guided by their own pheromone trails. All the solutions were assigned a cost as in equation (8), and a set of non-dominated solutions was compiled.
The set of parameters used to control the optimisation are shown in Table 3. The values of Į DQG ȕ ZHUH FKRVHQ VR WKDW heuristic values were not taken into account during the ant's path construction. The rate of pheromone evaporation was chosen to be 0.98, a previously used value which allows for a slow rate of evaporation, and hence a long exploratory phase [15]. The number of ants was chosen using ad-hoc selection, an analytical approach to parameter selection can be found in [16].
Note that the number of ants in the colony was chosen to be only 4, since the problem space is small. Other studies have used a wide range of colony sizes, ranging from a single ant, up to 1000 ants or more. Table 3. ACO parameter settings

Model results
The optimisation algorithm tested a total of 54 unique solutions to the problem. The results of all solutions tested at the local search stage of the optimisation are plotted in Figure  4. Strat 1, 2 and 3 stand for the three strategies described in 5.2.
Of all of the solutions tested by the algorithm, only 9 were considered to be non-dominated (i.e. no other solution was both cheaper and more effective). These solutions make up a Pareto front for the problem, and are shown in Table 4.

Table 4. Pareto Optimal Solutions
The optimal solution returned by the algorithm was a setup using 5 dispensers and 3 labelling stations, checking strategy 2, and a non-flexible work pattern. Every solution in the Pareto front made use of checking strategy 2, a strategy where an independent check is performed and errors are sent to be dispensed again. Figure 4 shows that set-ups using more dispensers performed better. It also clearly illustrates that checking strategy 1 performs worse than the alternative checking strategies, 2 and 3. The number of labelling stations appears to have a smaller effect, and can be less clearly seen, especially if the number of dispensers is high. Overall, the results indicate that the best way to set up a pharmacy using a single pharmacist, is to hire as many dispensers as the budget will allow, and use checking strategy 2. The additional benefits of hiring more dispensers diminish as more are added.

CONCLUSION
This paper has addressed the problem of how best to set up a community pharmacy using a typical staff set-up, where only a single pharmacist is employed. The MMAS optimisation was introduced and applied to a community pharmacy set-up problem generated by considering varying the initial conditions of a Coloured Petri Net simulation model. Future work could include considering how a wider range of decision variables can impact upon the dispensing process, optimising the ACO setup parameters, or expanding the model to include the potential for evaluating pharmacy chains consisting of more than 1 store. Further avenues suggested by pharmacy experts include modelling non-dispensing tasks, such as purchase of non-