## Principles of Diagnostic Yields

Now that we have examined how to get examples of Endoscopic performance by analysis of documentation, we can perform the more interesting task of determining endoscopic performance by determining the pathology taken at endoscopy. This means we have to merge two datasets and then extract pathology based on the endoscopy results.

We will determine the dysplasia detection rate in our sample of Barrett’s endoscopies and we will do this per endoscopist so we can get an overview of who is the best at detecting dysplasia in Barrett’s oesopahgus. Note this is very similar to the concept of an adenoma detection rate in colonoscopy.

We start by defining our datasets. We have done this before as part of the Surveillance page so I’m not going to repeat it here. We can just start using it.

This is what the merged dataset looks like (truncated for ease of viewing):

EndoHistoMerge<-source('EndoPathMerged_ExternalCode.R')
EndoHistoMerge<-data.frame(EndoHistoMerge)
#Neaten up the names
names(EndoHistoMerge)<-gsub("value.","",names(EndoHistoMerge),fixed=T)
kable(head(EndoHistoMerge,5))
EndoHospNumId EndoReports Date.x Endoscopist Midazolam Fentanyl Indication Diagnosis BarrC BarrM Histop_dfHospNumId HistoReport Date.y Macro Diagnoses Days visible
U22415 Date of Procedure 2013-08-23 Endoscopist: Dr Jonny Begood Midazolam: 2mg Fentanyl: 150mcg Indication: Small Bowel Biopsy Diagnosis: Esophageal candidiasis .Ulcer- Oesophageal. .Possible achalasia..Extensive neoplastic looking esophageal lesion. .Food bolus obstructing the oesophagus..Gastritis 2013-08-23 Jonny Begood 2 150 Small Bowel Biopsy Diagnosis: Esophageal candidiasis .Ulcer- Oesophageal. .Possible achalasia..Extensive neoplastic looking esophageal lesion. .Food bolus obstructing the oesophagus..Gastritis NA NA U22415 Date received: 2013-08-21 Macrosopic description: 7 specimens collected the largest measuring 5 x 4 x 5 mm and the smallest 4 x 3 x 4 mm Diagnoses No Helicobacter are seen.. There is mild regenerative epithelial change, but neither dysplasia nor malignancy is seen..High grade dysplasia is present throughout this sample.Neither dysplasia nor malignancy is seen. 2013-08-21 7 specimens collected the largest measuring 5 x 4 x 5 mm and the smallest 4 x 3 x 4 mm No Helicobacter are seen.. There is mild regenerative epithelial change, but neither dysplasia nor malignancy is seen..High grade dysplasia is present throughout this sample.Neither dysplasia nor malignancy is seen. 2 FALSE
P223333 Date of Procedure 2015-03-21 Endoscopist: Dr Chubby Checker Midazolam: 6mg Fentanyl: 100mcg Indication: Previous OGD ? 8 months ago Diagnosis: Esophageal candidiasis .Barretts oesophagus. .Extensive neoplastic looking esophageal lesion. .Ulcer- Oesophageal. Barrett’s oesophagus length: C3M5 2015-03-21 Chubby Checker 6 100 Previous OGD ? 8 months ago Diagnosis: Esophageal candidiasis .Barretts oesophagus. .Extensive neoplastic looking esophageal lesion. .Ulcer- Oesophageal. Barrett’s oesophagus length: C3M5 3 5 P223333 Date received: 2015-03-19 Macrosopic description: 1 specimens collected the largest measuring 1 x 2 x 1 mm and the smallest 3 x 2 x 1 mm Diagnoses Intestinal metaplasia is present..There is no intercellular oedema in the surface epithelium..The appearances are those of Candida oesophagitis.. There is mild regenerative epithelial change, but neither dysplasia nor malignancy is seen..There is no dysplasia or malignancy..This is a dysplastic sample.High grade dysplasia is present throughout this sample.The appearances are consistent with, but not specific for Barrett’s (columnar lined) oesophagus.. There is no dysplasia and no invasive carcinoma. 2015-03-19 1 specimens collected the largest measuring 1 x 2 x 1 mm and the smallest 3 x 2 x 1 mm Intestinal metaplasia is present..There is no intercellular oedema in the surface epithelium..The appearances are those of Candida oesophagitis.. There is mild regenerative epithelial change, but neither dysplasia nor malignancy is seen..There is no dysplasia or malignancy..This is a dysplastic sample.High grade dysplasia is present throughout this sample.The appearances are consistent with, but not specific for Barrett’s (columnar lined) oesophagus.. There is no dysplasia and no invasive carcinoma. 2 FALSE
P223333 Date of Procedure 2015-03-21 Endoscopist: Dr Chubby Checker Midazolam: 6mg Fentanyl: 100mcg Indication: Previous OGD ? 8 months ago Diagnosis: Esophageal candidiasis .Barretts oesophagus. .Extensive neoplastic looking esophageal lesion. .Ulcer- Oesophageal. Barrett’s oesophagus length: C3M5 2015-03-21 Chubby Checker 6 100 Previous OGD ? 8 months ago Diagnosis: Esophageal candidiasis .Barretts oesophagus. .Extensive neoplastic looking esophageal lesion. .Ulcer- Oesophageal. Barrett’s oesophagus length: C3M5 3 5 P223333 Date received: 2015-03-23 Macrosopic description: 3 specimens collected the largest measuring 3 x 2 x 2 mm and the smallest 3 x 3 x 1 mm Diagnoses Intestinal metaplasia is present..There is no significant increase in intraepithelial eosinophils..There is no intercellular oedema in the surface epithelium.. There is no dysplasia and no invasive carcinoma..The appearances are those of Candida oesophagitis..The appearances are consistent with the endoscopic diagnosis of Barrett’s oesophagus with active chronic inflammation..Numerous Candida spores and hyphae are present admixed with ulcer slough.. PAS staining shows occasional spores, consistent with candida. 2015-03-23 3 specimens collected the largest measuring 3 x 2 x 2 mm and the smallest 3 x 3 x 1 mm Intestinal metaplasia is present..There is no significant increase in intraepithelial eosinophils..There is no intercellular oedema in the surface epithelium.. There is no dysplasia and no invasive carcinoma..The appearances are those of Candida oesophagitis..The appearances are consistent with the endoscopic diagnosis of Barrett’s oesophagus with active chronic inflammation..Numerous Candida spores and hyphae are present admixed with ulcer slough.. PAS staining shows occasional spores, consistent with candida. 2 FALSE
P223333 Date of Procedure 2015-03-21 Endoscopist: Dr Chubby Checker Midazolam: 6mg Fentanyl: 100mcg Indication: Previous OGD ? 8 months ago Diagnosis: Esophageal candidiasis .Barretts oesophagus. .Extensive neoplastic looking esophageal lesion. .Ulcer- Oesophageal. Barrett’s oesophagus length: C3M5 2015-03-21 Chubby Checker 6 100 Previous OGD ? 8 months ago Diagnosis: Esophageal candidiasis .Barretts oesophagus. .Extensive neoplastic looking esophageal lesion. .Ulcer- Oesophageal. Barrett’s oesophagus length: C3M5 3 5 P223333 Date received: 2015-03-19 Macrosopic description: 9 specimens collected the largest measuring 1 x 3 x 2 mm and the smallest 2 x 4 x 3 mm Diagnoses The appearances are consistent with, but not specific for Barrett’s (columnar lined) oesophagus..Neither dysplasia nor malignancy is seen..There is no dysplasia or malignancy..No granulomas or viral inclusions are seen..There is low grade dysplasia.This is a dysplastic sample.Intestinal metaplasia is present. 2015-03-19 9 specimens collected the largest measuring 1 x 3 x 2 mm and the smallest 2 x 4 x 3 mm The appearances are consistent with, but not specific for Barrett’s (columnar lined) oesophagus..Neither dysplasia nor malignancy is seen..There is no dysplasia or malignancy..No granulomas or viral inclusions are seen..There is low grade dysplasia.This is a dysplastic sample.Intestinal metaplasia is present. 2 FALSE
U234252 Date of Procedure 2016-06-21 Endoscopist: Dr King Richard III Midazolam: 4mg Fentanyl: 150mcg Indication: chronic abdo pain and constipaton Diagnosis: Hiatus Hernia. .Gastritis.Extensive neoplastic looking esophageal lesion. .Barretts oesophagus. .Esophageal candidiasis .Food bolus obstructing the oesophagus. 2016-06-21 King Richard III 4 150 chronic abdo pain and constipaton Diagnosis: Hiatus Hernia. .Gastritis.Extensive neoplastic looking esophageal lesion. .Barretts oesophagus. .Esophageal candidiasis .Food bolus obstructing the oesophagus. NA NA U234252 Date received: 2016-06-23 Macrosopic description: 4 specimens collected the largest measuring 3 x 5 x 1 mm and the smallest 5 x 5 x 1 mm Diagnoses There is mild regenerative epithelial change, but neither dysplasia nor malignancy is seen..No Helicobacter are seen..There is low grade dysplasia.Basal hyperplasia is prominent.This is a dysplastic sample.The appearances are consistent with the endoscopic diagnosis of Barrett’s oesophagus with active chronic inflammation..There is some ulceration. 2016-06-23 4 specimens collected the largest measuring 3 x 5 x 1 mm and the smallest 5 x 5 x 1 mm There is mild regenerative epithelial change, but neither dysplasia nor malignancy is seen..No Helicobacter are seen..There is low grade dysplasia.Basal hyperplasia is prominent.This is a dysplastic sample.The appearances are consistent with the endoscopic diagnosis of Barrett’s oesophagus with active chronic inflammation..There is some ulceration. 2 FALSE

# Breakdown of analytical method for yield

So the task now involves extracting the presence of dysplasia in those patients where Barrett’s was detected at endoscopy and then grouping them by endoscopist

So to spell out where each element of this comes from:

1. Detect rows that mention Barrett’s in the endoscopy report.

2. Also detect rows that mention dysplasia in the pathology report.

3. Group by endoscopist.

4. Then get the total number of reports that mention Barrett’s in the endoscopy report whether dyplasia is metioned or not, and group by endoscopist.

5. Calculate proportion by endoscopist then visualise it.

### 1 & 2. Detect rows that mention term of interest in the endoscopy report.

This is done using grepl. We will do a combined grepl so we can get the subset we are interested in and that mention dysplasia in the pathology report.

DysplasticBarretts<-EndoHistoMerge[grepl("[Bb]arrett",EndoHistoMerge$EndoReports)&grepl("[Dd]ysplasi",EndoHistoMerge$HistoReport),]

So you will note that there are several reports where it is mentioned that there is no dysplasia so we have to get rid of these. This is tricky but for the purposes of this site we will use the brute force technique

DysplasticBarretts<-DysplasticBarretts[!grepl("[Nn]either dysplasia",DysplasticBarretts$Diagnoses)&!grepl("[Nn]o [Dd]ysplasia",DysplasticBarretts$Diagnoses),]

### 3. Group by endoscopist

There are two ways of doing this. The first way is to use dplyr as follows:

EndoscopistDDRBarretts<-DysplasticBarretts%>%group_by(Endoscopist)%>%summarise(n=n())

kable(EndoscopistDDRBarretts)
Endoscopist n
Bilbo Baggins 132
Bugs Bunny 85
Charles Dickens 100
Chubby Checker 125
Davy Jones 118
Elmo Fudd 107
Elvis Presley 116
Florence Nightingale 115
Frank Sinatra 123
Jimminey Cricket 111
Jonny Begood 115
King Richard III 112
Rara Rasputin 105

Alternatively we can just use the table function which has a neater input but gives a messier output:

DDRtable<-table(EndoscopistDDRBarretts)
kable(DDRtable)
85 93 100 105 107 111 112 115 116 117 118 123 125 132
Bilbo Baggins 0 0 0 0 0 0 0 0 0 0 0 0 0 1
Bugs Bunny 1 0 0 0 0 0 0 0 0 0 0 0 0 0
Charles Dickens 0 0 1 0 0 0 0 0 0 0 0 0 0 0
Chubby Checker 0 0 0 0 0 0 0 0 0 0 0 0 1 0
Davy Jones 0 0 0 0 0 0 0 0 0 0 1 0 0 0
Elmo Fudd 0 0 0 0 1 0 0 0 0 0 0 0 0 0
Elvis Presley 0 0 0 0 0 0 0 0 1 0 0 0 0 0
Florence Nightingale 0 0 0 0 0 0 0 1 0 0 0 0 0 0
Frank Sinatra 0 0 0 0 0 0 0 0 0 0 0 1 0 0
Jimminey Cricket 0 0 0 0 0 1 0 0 0 0 0 0 0 0
Jonny Begood 0 0 0 0 0 0 0 1 0 0 0 0 0 0
Joseph Conrad 0 1 0 0 0 0 0 0 0 0 0 0 0 0
King Richard III 0 0 0 0 0 0 1 0 0 0 0 0 0 0
Rara Rasputin 0 0 0 1 0 0 0 0 0 0 0 0 0 0
Sal Addin 0 0 0 0 0 0 0 0 0 1 0 0 0 0

### 4. Get the total number of specific endoscopies by endoscopist:

So now we know who is picking up dysplasia we can express this as a proportion of all the Barrett’s endoscopy they have done as follows:

AllBarretts<-EndoHistoMerge[grepl("[Bb]arrett",EndoHistoMerge$EndoReports),] Endoscopist_All_Barretts<-AllBarretts%>%group_by(Endoscopist)%>%summarise(n=n()) ### 5. DDR by endoscopist: Now we just calulate the proportions to get the DDR. We have to bind Endoscopist_All_Barretts and EndoscopistDDRBarretts to calculate this. We merge by endoscopist #For a bit of variety we are going to do the merge using dplyr join functions instead of base R merge functions: DDRTable<-full_join(Endoscopist_All_Barretts, EndoscopistDDRBarretts, by = "Endoscopist") And finally the proportions: DDRTable$Prop<-(DDRTable$n.y/DDRTable$n.x)*100
DDRTable<-data.frame(DDRTable)
#Lets get rid of NA values by replacing with "0"
DDRTable$Prop[is.na(DDRTable$Prop)] <- 0

#Lets plot it out
barplot(DDRTable$Prop,names.arg=DDRTable$Endoscopist, ylab = "% dysplasia",
cex.lab = 1.5,cex.axis=1.0,cex.main = 1.0,cex.names=1.0,main = "Barrett's Endoscopic Dysplasia detection proportion",las=2)

….Looks like some people need more training…