---
title: "Syringe accuracy (TOGC) estimates for ISO 7886-1"
author: "P Phillips, Director, Surgical Materials Testing Laboratory"
date: 2016-06-02
output: pdf_document
header-includes:
    - '\usepackage{longtable}'
    - '\usepackage{rotating}'
    - '\usepackage{pdflscape}'
    - '\usepackage{lastpage}'
    - '\usepackage{fancyhdr}'
    - '\usepackage{float}'
    - '\usepackage{rcs}'
    - '\newcommand{\noop}[1]{#1}'
    - '\noop{\RCS $Revision: 1.4 $}'
    - '\noop{\RCS $Date: 2016/08/10 14:07:12 $}'
    - '\pagestyle{fancy}'
    - '\fancyhead[R]{}'
    - '\fancyhead[L]{Syringe accuracy estimates for ISO 7886-1}'
    - '\fancyfoot[R]{Revision:\ \RCSRevision}'
    - '\fancyfoot[L]{\RCSDate}'
    - '\date{\RCSDate\ - Revision: \RCSRevision}'
#    - '\usepackage{draftwatermark}'
 
---

```{r,echo=FALSE}
library(knitr)
library(xtable)
library(plyr)
library(ggplot2)
library(pander)
library(reshape2)
options(xtable.comment = FALSE)
opts_chunk$set(tidy = TRUE,echo=FALSE)
all.data<-NULL
```
# Introduction

This paper shows the method and 
for using table 1 in ISO 7886-1 to calculate the Tolerance on graduated capacity (TOGC) for syringes, and 
displays calculated values for different combinations of syringe size and expelled volume.
[It is available online as a pdf](http://smtl.co.uk/pete-phillips/224-togc-from-iso-7886-1.html).

For example, if using a 1ml syringe to deliver a particular volume of expelled liquid, ISO 7886-1 states that the tolerance on the graduated capacity is 

  * $\pm$ (1.5\% syringe vol + 2\% of the expelled volume) for volumes < 0.5ml, and 
  * $\pm$ 5\% of the expelled volume for volumes $\geq$ 0.5ml.  
  
Similar but different tolerances are used depending on the syringe size for syringes up to 50ml of nominal capacity.

# Worked examples
As a worked example, lets look at delivering 4ml from a 10ml syringe.

  * 4ml is less than half the nominal volume of a 10ml syringe so we use the first column ('less than half nominal capacity')
  * $(1.5\% \times 10) + (1\% \times 4)$ = $`r (0.015*10)` + `r (0.01*4)`$ = $`r (0.015*10) + (0.01*4)`$ml
  * As a percentage of the expelled volume (4ml), $`r (((0.015*10) + (0.01*4))/4)*100`$%
  
If instead we look at delivering an 8ml dose from a 10ml syringe:

  * 8ml is greater than half the nominal volume of a 10ml syringe so we use the first column ('equal to or greater than half nominal capacity')
  * $4\% \times 8$ = $`r (0.04*8)`$ml
  * As a percentage of the expelled volume, $`r ((0.04*8)/8)*100`$%

# Tolerance Calculation Tables

The following tables show how the error varies as the delivery volume changes for different size syringes.

The columns are as follows:

  * **Syringe Size** - Nominal capacity of syringe in ml
  * **Expelled Vol** - the volume intended to be delivered from the syringe in ml (the volume called 'expelled volume' in ISO 7886, although this may more accurately be called the intended volume of delivery)
  * **Tolerance $\pm$ (ml)** - Tolerance on graduated capacity (TOGC) calculated in ml as per Table 1, EN ISO 7886-1:1997
  * **Tolerance $\pm$ (\%)** - Tolerance on graduated capacity calculated as a \% of the Expelled Vol as per Table 1, EN ISO 7886-1:1997

The tables have been generated with the 'R'[^1] language using 'R Markdown'[^2]. This document and the original Rmarkdown code are available from the SMTL website[^3].

[^1]: https://en.wikipedia.org/wiki/R_(programming_language)
[^2]: http://rmarkdown.rstudio.com/
[^3]: http://smtl.co.uk/pete-phillips/224-togc-from-iso-7886-1.html


```{r}
# routine to generate a table given various parameters
# takes 1 parameter - the suringe volume
togc<-function(syr.vol # syringe volume
               ) {
#syr.vol<-1
#del.vol<-seq(0.1,1.0,0.1)
  # Set up sequences of the volumes to calculate for each syringe vol
if (syr.vol <=1) { 
  del.vol<-seq(0.1,1.0,0.1) # start vol, end vol, increment
  } 
if (syr.vol >1 && syr.vol <=2) { 
  del.vol<-seq(0.1,2.0,0.1)
}
if (syr.vol >2 && syr.vol <=3) { 
  del.vol<-seq(0.1,3.0,0.1)
}
if (syr.vol >3 && syr.vol <=5) { 
  del.vol<-c(seq(0.1,3.0,0.1),
             seq(3.5,5.0,0.5)) 
  }
if (syr.vol >5 && syr.vol <=6) { 
  del.vol<-c(seq(0.1,3.0,0.1),
             seq(2.5,6.0,0.5))
  }
if (syr.vol >6 && syr.vol <=10) { 
  del.vol<-c(seq(0.1,1.0,0.1),
             seq(1.5,10.0,0.5))
}
if (syr.vol >10 && syr.vol <=20) {  
  del.vol<-c(seq(0.1,1.0,0.1),
             seq(1.5,20.0,0.5)) 
  }

# create data frame with the volumes
acc.df<-as.data.frame(cbind(syr.vol,del.vol))

#acc.df

# Calculate the tolerances
if (syr.vol <2) { 
  serr<-0.015 # syringe error
  verr<-0.02 # volume error
  half.tol=0.05 # the tolerance for syringe => half capac
  } 
if (syr.vol >=2 && syr.vol <5) { 
  serr<-0.015 # syringe error
  verr<-0.02 # volume error
  half.tol=0.05 # the tolerance for syringe => half capac
}
if (syr.vol >=5 && syr.vol <50) { 
  serr<-0.015 # syringe error
  verr<-0.01 # volume error
  half.tol=0.04 # the tolerance for syringe => half capac
}

# add columns for serr and verr
acc.df$syr.err<-syr.vol*serr
acc.df$vol.err<-del.vol*verr

# if expelled vol greater than half of nominal vol,
# then tolerance is 5% otherwise is the total of the syr.err and the vol.err
acc.df$total.err <- ifelse(acc.df$del.vol>=(acc.df$syr.vol*0.5),
                           acc.df$del.vol*half.tol,
                           acc.df$syr.err+acc.df$vol.err)
# now calc percentage error
acc.df$total.err.pct<-(acc.df$total.err/acc.df$del.vol)*100

# Now drop columns no longer needed.
acc.df$syr.err<-NULL
acc.df$vol.err<-NULL
colnames(acc.df)<-c("Syringe Size","Expelled Vol", "Tolerance $\\pm$ (ml)","Tolerance $\\pm$ (\\%)")

# check if all.data is null
if (is.null(all.data)) {
  all.data<<-acc.df
} else {
  # if not null then add the new data to the accumulator dataframe to gett all data in one place
  all.data<<-rbind(all.data,acc.df)
}

# Print the table
# Note - the call to togc must be made from a results=asis environment
#print(xtable(acc.df,caption=paste("Syringe Accuracy Vol - Syringe Size = ",syr.vol, "ml"), floating = FALSE,include.colnames = TRUE, NA.string="NA",digits=c(0,0,2,3,2,1,1)),include.rownames=F,sanitize.colnames.function=identity)
print(xtable(acc.df,caption=paste("Syringe Accuracy Vol - Syringe Size = ",syr.vol, "ml"), floating = TRUE,include.colnames = TRUE, NA.string="NA",digits=c(0,0,2,3,2)),include.rownames=F,sanitize.colnames.function=identity,table.placement="H")
}
```
\newpage
```{r,results='asis'}
togc(1)
```

```{r,results='asis'}
togc(2)
```

\newpage
```{r,results='asis'}
togc(3)
```
\newpage
```{r,results='asis'}
togc(5)
```
\newpage
```{r,results='asis'}
togc(6)
```
\newpage
```{r,results='asis'}
togc(10)
```
\newpage
```{r,results='asis'}
togc(20)
```
\newpage

# APPENDIX A

SMTL is a UK NHS Medical Device Testing Laboratory, funded centrally to provide testing and medical device technical services to the Welsh NHS.  SMTL also provides medical device testing and technical services on a commercial basis to the global medical device industry.  SMTL are accredited to ISO 17025 for testing medical devices.

        Surgical Materials Testing Laboratory,
        Princess of Wales Hospital,
        Coity Road,
        Bridgend,
        CF31 1RQ
        Tel: 01656-752820
        Web: http://www.smtl.co.uk/ & http://www.medidex.com/

