Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added CCG level rollup

  • Loading branch information...
commit 91241b88135f032044838e014e37e49464a08023 1 parent fba7188
Francine Bennett fhr authored

Showing 1 changed file with 16 additions and 13 deletions. Show diff stats Hide diff stats

  1. +16 13 GP_drugs_analysis.R
29 GP_drugs_analysis.R
@@ -91,19 +91,6 @@ ggplot(practice.indicator, aes(items.alldrugs,pct.statin.atorva))+
91 91 ggplot(practice.indicator, aes(items.alldrugs,pct.statin.rosuva))+
92 92 geom_point()+opts(title="Rosuva funnel")
93 93
94   -# Roll up to CCG level
95   -ccg.rollup<-read.xls("list-of-proposed-practices-ccg.xls",sheet="Practice list")
96   -spend.ccg.totals<-merge(spend.practice.totals,ccg.rollup,by.x="Practice.code",by.y="Practice.code",all.x=TRUE)
97   -ccg.totals.headings<- list("Drug"=spend.ccg.totals$Drug,
98   - "Proposed.CCG.name"=spend.ccg.totals$Proposed.CCG.name,
99   - "Interim.CCG.code"=spend.ccg.totals$Interim.CCG.code,
100   - "category"=spend.ccg.totals$category)
101   -spend.ccg.totals<-
102   - aggregate(spend.ccg.totals[,c("cost.thisdrug","items.thisdrug",
103   - "amount.wasted")],
104   - by=ccg.totals.headings,
105   - FUN=sum)
106   -
107 94 ## Timeseries plots
108 95 t<-subset(spend.practice,Drug %in% c("Atorvastatin","Rosuvastatin Calcium","Simvastatin"))
109 96 statin.timeseries<-aggregate(t$cost.thisdrug,by=list(t$Month,t$Drug),FUN=sum)
@@ -139,6 +126,22 @@ pct.totals$pct.problem<-round(pct.totals$pct.problem,3)
139 126 pct.totals$total.items.month<-round(pct.totals$total.items.month,0)
140 127 write.csv(pct.totals,"pct_statin_totals.csv",row.names=FALSE)
141 128
  129 +# Roll up to CCG level for mapping
  130 +ccg.rollup<-read.xls("list-of-proposed-practices-ccg.xls",sheet="Practice list")
  131 +ccg.totals<-merge(spend.practice.totals,ccg.rollup,by.x="Practice.code",by.y="Practice.code",all.x=TRUE)
  132 +ccg.totals<-subset(ccg.totals,category=="statin")
  133 +ccg.totals$item.bad<-FALSE
  134 +ccg.totals[ccg.totals$Drug %in% c("Atorvastatin","Rosuvastatin Calcium"),]$item.bad<-TRUE
  135 +ccg.totals<-aggregate(ccg.totals$items.thisdrug,by=list(ccg.totals$item.bad,ccg.totals$Interim.CCG.code),FUN=sum)
  136 +ccg.totals<-cast(ccg.totals,Group.2~Group.1)
  137 +names(ccg.totals)<-c("CCG.code","ok.drugs","problem.drugs")
  138 +ccg.totals$ccg.problem<-ccg.totals$problem.drugs/(ccg.totals$problem.drugs+ccg.totals$ok.drugs)
  139 +ccg.totals$total.items.month<-(ccg.totals$ok.drugs+ccg.totals$problem.drugs)/length(file.list)
  140 +ccg.totals<-ccg.totals[,c("CCG.code","total.items.month","ccg.problem")]
  141 +ccg.totals$ccg.problem<-round(ccg.totals$ccg.problem,3)
  142 +ccg.totals$total.items.month<-round(ccg.totals$total.items.month,0)
  143 +write.csv(ccg.totals,"ccg_statin_totals.csv",row.names=FALSE)
  144 +
142 145 ## Savings figures
143 146 median(subset(statin.timeseries,Drug=="Atorvastatin")$Spend)*problem.drugs[problem.drugs$Drug=="Atorvastatin",]$saving
144 147 median(subset(statin.timeseries,Drug=="Rosuvastatin Calcium")$Spend)*problem.drugs[problem.drugs$Drug=="Rosuvastatin Calcium",]$saving

0 comments on commit 91241b8

Please sign in to comment.
Something went wrong with that request. Please try again.