medAdherence/0000755000175100001440000000000011742207530012635 5ustar hornikusersmedAdherence/MD50000644000175100001440000000331011742207530013142 0ustar hornikusersa0f41f0de43a9799ded6bdc143e51169 *COPYING c07cf22d7d6a16229f0fe57c804eae86 *ChangeLog fe67c133a80ae0f911de8e136464b3f5 *DESCRIPTION aa2e47ab0e1db894e20fee652cf6f352 *NAMESPACE 8d766617afc3eee77d2a9750e1396c6c *R/medCMA.R 263a13265b46f94079730425ecc2c7d6 *R/medCMG.R b78857937e37ef724d1e1e50735653ef *R/medCMOS.R a3dd5a0a60761e4580a56e5f2b25a6a2 *R/medCR.R bbd27bfe77330c085a76f73863994f02 *R/medCSA.R 2b33c792549d95db58baa686b1654211 *R/medDBR.R 36b5a03aae4dad9ea07967469833d928 *R/medDTMPR.R 40a04d7459bc39cb89686485036f1dab *R/medMPR.R f9a66df2abd778619a830dd17dbf8c3e *R/medMPRm.R a1a2a6bf13a0594a025fd0ba528dfad8 *R/medPDC.R c5f431ae0ec32442eceac2e395b99156 *R/postData.R db30840834b2cb0d0dad67dbc83c2796 *R/preData.R 0edb09f6ab9a9c4e57d8f85cc42e4e20 *R/rxExampledt.R 26fac598acb0457fde6df6cc2886a740 *R/rxGaps.R dbd17fb67642cfd3a29ee73a01890df0 *man/Adherence-package.Rd d3b00d144df46941bf1819f51034a248 *man/medCMA.Rd d72609e20c5f1a515bde1a9d700fb7bc *man/medCMG.Rd c917a64b58bea94e5b721cf302187e66 *man/medCMOS.Rd 7fc14ee7878f443ca17f3528ba0dcf67 *man/medCR.Rd 75c56b0396293de9267d7423c015a207 *man/medCSA.Rd aad3a914b883f80dd92322188c36a350 *man/medDBR.Rd 2cc292ddde10c5b9d9a0a9f3fcfe437f *man/medDTMPR.Rd e9460197921e7c5d534592a3addd5596 *man/medMPR.Rd 78c557846b64a0c8111c3722d8339525 *man/medMPRm.Rd 06ae6254946ce65ae501b627106aa797 *man/medPDC.Rd 27c1681cdaf29b8b2c7fc9f7d49dba3c *man/postData.Rd 1649dd864e46d2aef1ce82d101f0bd0b *man/preData.Rd cda2811fcb22a7633da7db20c9901687 *man/rxExampledt.Rd 185c03843f3ed1aea065e64175eec027 *man/rxGaps.Rd b9b0ee9ceb661f5c04f409c944bfa250 *src/cma.c ac4874240fca6e654f80fb29097af4cb *src/cmos.c ffbfde679f9dbd6addd008ad01e00e99 *src/csa.c 1f96413dee75627c90133372606e0276 *src/pdc.c medAdherence/ChangeLog0000644000175100001440000000043211742031322014400 0ustar hornikusers 2012-04-12 Xiangyang Ye * CSA over-run was fixed. Thanks to Prof Brian Ripley's array over-runs check. * To fulfill the promise to Andreas Tille , file "COPYING" was added to declare the GPLv2 http://www.gnu.org/licenses/gpl-2.0.txt medAdherence/COPYING0000644000175100001440000000075311742031546013677 0ustar hornikusersThis is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. These can also be viewed at http://www.r-project.org/Licenses/GPL-2 medAdherence/NAMESPACE0000644000175100001440000000034511742055265014064 0ustar hornikusers useDynLib(medAdherence, .registration=TRUE) export("medCMA", "medCMG", "medCMOS", "medCR", "medCSA", "medDBR", "medDTMPR", "medMPR", "medMPRm", "medPDC", "postRxData", "preRxData", "rxExampledt", "rxGaps") medAdherence/DESCRIPTION0000644000175100001440000000070011742207530014340 0ustar hornikusersPackage: medAdherence Type: Package Title: Medication Adherence: Commonly Used Definitions Version: 1.03 Date: 2012-04-12 Author: Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah Maintainer: Xiangyang Ye Description: Medication Adherence: Commonly Used Definitions License: GPL-2 LazyLoad: yes Packaged: 2012-04-13 20:38:25 UTC; u0585652 Repository: CRAN Date/Publication: 2012-04-14 05:47:04 medAdherence/R/0000755000175100001440000000000011742107256013042 5ustar hornikusersmedAdherence/R/postData.R0000644000175100001440000000142411311753102014732 0ustar hornikusers postRxData <- function(df=data){ #create equal refill counts for all patients uniqid <- unique(df$id) #unique patient id's, put in a data set #finaldt <- data.frame(uniqid) #names(finaldt) <- "id" xf <- max(table(df$id))+1 #max refill number +1, counter for loop #each patien has same refill count, some refills are '0', meaning no refill for that record xn <- length(uniqid) reps <- rep(xf,xn) ids <- data.frame(rep(uniqid,reps)) names(ids) <- "id" newsq <- data.frame(unlist(lapply(rle(ids$id)$lengths,seq))) names(newsq) <- "SEQ" ids <- cbind(ids,newsq) nx <- merge(ids,df,by.x=c("id","SEQ"),all.x=TRUE) nx$rxDay <- ifelse(is.na(nx$rxDay),0,nx$rxDay) nx$Supp <- ifelse(is.na(nx$Supp),0,nx$Supp) return(nx) } medAdherence/R/medCSA.R0000644000175100001440000000132611311753100014246 0ustar hornikusers medCSA <- function(df=data, digits=2) { n <- length(unique(df$id)) rxmax <- dim(df)[[1]]/n ncsa <- rep(0,n*rxmax) xx <- .C("csa",n=as.integer(n), rxmax=as.integer(rxmax), rxDay = as.integer(df$rxDay), refills = as.integer(df$Supp), ncsa=as.integer(ncsa), ngap=as.integer(ncsa),PACKAGE="medAdherence") Ncsa <- data.frame(cbind(xx$ncsa,xx$ngap)) names(Ncsa) <- c("CsaSupplies","CsaInterval") ndt <- cbind(df,Ncsa) ndt$CSA <- round(ndt$CsaSupplies/ndt$CsaInterval*100,digits) ndt <- ndt[,c("id","rxDay","Supp","CsaSupplies", "CsaInterval", "CSA")] ndt <- ndt[ndt$rxDay!=0,] rownames(ndt) <- NULL return(ndt) } medAdherence/R/rxGaps.R0000644000175100001440000000075011311753102014420 0ustar hornikusers rxGaps <- function(df=data,gap=NA){ xy <- data.frame(diff(df$rxDay + df$Supp,1)) names(xy) <- "lag1" x0 <- data.frame(matrix(0,nrow=1)) names(x0) <-names(xy) xy <-rbind(x0,xy) dt2 <- cbind(df,xy) dt2$lag1 <- ifelse(dt2$first.id==1,NA,dt2$lag1) dt2$gap <- dt2$lag1-dt2$Supp dt2$lag1 <- NULL if(is.na(gap)) dt2$gap <- ifelse(dt2$gap<0,0,dt2$gap) #dt2 <- dt2[!is.na(dt2$first.id),] rownames(dt2) <- NULL return(dt2) } medAdherence/R/medCMA.R0000644000175100001440000000106611311753100014241 0ustar hornikusers medCMA <- function(df=data,followUpDays=365, digits=2) { n <- length(unique(df$id)) aseq <- numeric(n) rxmax <- dim(df)[[1]]/n xx <- .C("cma",n=as.integer(n), rxmax=as.integer(rxmax), refills = as.integer(df$Supp), nCMA=as.integer(aseq),PACKAGE="medAdherence") ndt <- data.frame(unique(df$id),xx$nCMA) #rownames(ndt) <- NULL names(ndt) <- c("id","daySupplies") ndt$followUpDays <- followUpDays ndt$CMA <- round(ndt$daySupplies / ndt$followUpDays*100,digits) return(ndt) } medAdherence/R/medDTMPR.R0000644000175100001440000000123211311753100014522 0ustar hornikusers medDTMPR <- function(df=data,followUpDays=NA,truncated="yes", digits=2){ ndt <- do.call(rbind,lapply(split(df,list(df$id)),function(y) cbind(y,cumsum(y$Supp)))) ndt2 <- ndt[ndt$last.id==1,] ndt2 <- ndt2[,c(-6:-4)] names(ndt2) <- c("id","rxDay","lastSupp","totalSupp") rownames(ndt2) <-NULL ndt2$followUpDays <- ndt2$rxDay + ndt2$lastSupp-1 if(!is.na(followUpDays)) ndt2$followUpDays <- followUpDays ndt2$DTMPR <- round((ndt2$totalSupp/2)/ndt2$followUpDays*100,digits) ndt2$rxDay<- NULL ndt2$lastSupp<-NULL if(truncated=="yes") ndt2$DTMPR<- ifelse(ndt2$DTMPR>100,100,ndt2$DTMPR) return(ndt2) } medAdherence/R/medMPRm.R0000644000175100001440000000122111311753100014445 0ustar hornikusers medMPRm <- function(df=data,followUpDays=NA,truncated="yes", digits=2){ ndt <- do.call(rbind,lapply(split(df,list(df$id)),function(y) cbind(y,cumsum(y$Supp)))) ndt2 <- ndt[ndt$last.id==1,] ndt2 <- ndt2[,c(-6:-4)] names(ndt2) <- c("id","rxDay","lastSupp","totalSupp") rownames(ndt2) <-NULL ndt2$followUpDays <- ndt2$rxDay + ndt2$lastSupp-1 if(!is.na(followUpDays)) ndt2$followUpDays <- followUpDays ndt2$MPRm <- round(ndt2$totalSupp/ndt2$followUpDays*100,digits) ndt2$rxDay<- NULL ndt2$lastSupp<-NULL if(truncated=="yes") ndt2$MPRm<- ifelse(ndt2$MPRm>100,100,ndt2$MPRm) return(ndt2) } medAdherence/R/medPDC.R0000644000175100001440000000143611311753100014250 0ustar hornikusers medPDC <- function(df=data,followUpDays=365, digits=2) { n <- length(unique(df$id)) rxDay <- df$rxDay Supp <- df$Supp x <- c(1:n) rxmax <- dim(df)[[1]]/n xx <- .C("pdc",n=as.integer(n), m=as.integer(followUpDays), rxmax=as.integer(rxmax), rxDay = as.integer(rxDay), refills = as.integer(Supp), rxs=as.integer(x), supplies=as.integer(x),PACKAGE="medAdherence") npdc <- data.frame(cbind(xx$supplies,xx$rxs)) names(npdc) <- c("Supplies","nPDC") uniqid <- unique(df$id) #unique patient id's, put in a data set finaldt <- data.frame(uniqid) names(finaldt) <- "id" finaldt <- cbind(finaldt,npdc) finaldt$PDC <- round(finaldt$nPDC/followUpDays * 100,digits) return(finaldt) } medAdherence/R/preData.R0000644000175100001440000000301111311753102014525 0ustar hornikusers preRxData <- function(df=data,id=NULL, rxDate=NULL,daySupply=NULL,followUpDays=365){ id <- deparse(substitute(id)) rxref <- deparse(substitute(rxDate)) rxsup <- deparse(substitute(daySupply)) newdt <- df; newdt$id <- eval(substitute(newdt$id,list(id=as.name(id)))) newdt$rxDay <- eval(substitute(newdt$rxref,list(rxref=as.name(rxref)))) newdt$Supp <- eval(substitute(newdt$rxsup,list(rxsup=as.name(rxsup)))) if(!is.numeric(newdt$rxDay)) stop("Please transform the rxDate as numeric first.") newdt <- newdt[,c("id","rxDay","Supp")] #order by id, rxDate and days supplies newdt <- newdt[order(newdt$id,newdt$rxDay,newdt$Supp),] #the first refill and last refill for each individual breaks <- diff(newdt$id) newdt$first.id <- c(1, breaks != 0) newdt$last.id <- c(breaks != 0, 1) #first rxDate indexdt <- newdt[newdt$first.id==1,] indexdt <- indexdt[,c("id","rxDay")] names(indexdt)[[2]] <- "firstrxDay" newdt <- merge(newdt,indexdt,by.x="id") newdt$rxDay <- newdt$rxDay - newdt$firstrxDay+1 #refill sequence number for each individual seq <- data.frame(unlist(lapply(rle(newdt$id)$lengths,seq))) names(seq) <- "SEQ" newdt <- cbind(newdt,seq) newdt <- newdt[,c("id","rxDay","Supp","first.id","last.id","SEQ")] #update last supplies if beyond the study period newdt$Supp <- ifelse(newdt$Supp + newdt$rxDay>followUpDays, followUpDays - newdt$rxDay, newdt$Supp) return(newdt) } medAdherence/R/medCR.R0000644000175100001440000000127511311753100014147 0ustar hornikusers medCR <- function(df=data, digits=2){ df$Supp <- ifelse(df$last.id==1,0,df$Supp) ndt <- do.call(rbind,lapply(split(df,list(df$id)),function(y) cbind(y,cumsum(y$Supp)))) ndt2 <- ndt[ndt$last.id==1,] ndt2 <- ndt2[,c(-6:-2)] names(ndt2) <- c("id","totalSupp") ndt4 <- ndt[ndt$first.id==1 | ndt$last.id==1,] ndt4 <- ndt4[,c("id","rxDay")] xs <- diff(ndt4$rxDay) mxs <- matrix(xs,ncol=1) mxs <- cbind(c(1:dim(mxs)[[1]]),mxs) mxs <- mxs[-which(mxs[,1]%%2==0),] intervals <- mxs[,2] newdt <- cbind(ndt2,intervals) rownames(newdt) <-NULL newdt$CR <- round(newdt$totalSupp/newdt$intervals*100,digits) return(newdt) } medAdherence/R/medCMG.R0000644000175100001440000000075011311753100014246 0ustar hornikusers medCMG <- function(df=data,followUpDays=365, digits=2){ #df$Supp <- ifelse(df$last.id==1,0,df$Supp) ndt <- do.call(rbind,lapply(split(df,list(df$id)),function(y) cbind(y,cumsum(y$Supp)))) ndt2 <- ndt[ndt$last.id==1,] ndt2 <- ndt2[,c(-6:-2)] names(ndt2) <- c("id","totalSupp") rownames(ndt2) <-NULL ndt2$CMG <- round((followUpDays - ndt2$totalSupp)/followUpDays*100,digits) ndt2$CMG <- ifelse(ndt2$CMG<0,0,ndt2$CMG) return(ndt2) } medAdherence/R/rxExampledt.R0000644000175100001440000000105711311753102015452 0ustar hornikusersrxExampledt <-function(){ cat("1 1/1/2007 30", "1 8/1/2007 30", "2 1/1/2007 30", "2 2/20/2007 30", "2 3/2/2007 30", "2 5/10/2007 30", "2 6/2/2007 30", "2 8/15/2007 30", "2 9/10/2007 30", "2 11/2/2007 30", "2 12/10/2007 30","3 1/1/2007 30", "3 1/25/2007 30", "3 3/1/2007 30",file="Examp.dat", sep="\n") exdt <- read.table("Examp.dat") unlink("Examp.dat") names(exdt) <- c("ptid","rxdate", "supplies") exdt$rxDay <- as.numeric(as.Date(exdt$rxdate, format="%m/%d/%Y")) return(exdt) } medAdherence/R/medDBR.R0000644000175100001440000000144111311753100014245 0ustar hornikusers medDBR <- function(df=data,followUpDays=NA, digits=2){ #df$Supp <- ifelse(df$last.id==1,0,df$Supp) ndt <- do.call(rbind,lapply(split(df,list(df$id)),function(y) cbind(y,cumsum(y$Supp)))) ndt2 <- ndt[ndt$last.id==1,] ndt2 <- ndt2[,c(-6:-2)] names(ndt2) <- c("id","totalSupp") ndt4 <- ndt[ndt$first.id==1 | ndt$last.id==1,] ndt4 <- ndt4[,c("id","rxDay")] xs <- diff(ndt4$rxDay) mxs <- matrix(xs,ncol=1) mxs <- cbind(c(1:dim(mxs)[[1]]),mxs) mxs <- mxs[-which(mxs[,1]%%2==0),] intervals <- mxs[,2] newdt <- cbind(ndt2,intervals) rownames(newdt) <-NULL if(is.na(followUpDays)) followUpDays <- newdt$intervals newdt$DBR <- 100 - round((followUpDays-newdt$totalSupp)/followUpDays*100,digits) return(newdt) } medAdherence/R/medCMOS.R0000644000175100001440000000173211742075413014416 0ustar hornikusers medCMOS <- function(df=data, followUpDays=365, digits=2){ x <- rxGaps(df,gap=-1) n <- length(unique(x$id)) rxmax <- nrow(x)/n x$surplus <- ifelse(x$gap<0,-x$gap,0) x$deficit <- ifelse(x$gap>0,-x$gap,0) x <- x[,c("id","surplus","deficit")] x$surplus <- ifelse(is.na(x$surplus),0,x$surplus) x$deficit <- ifelse(is.na(x$deficit),0,x$deficit) ss <- .C("cmos", surplus = as.integer(x$surplus), deficit = as.integer(x$deficit), n = as.integer(n), rxmax = as.integer(rxmax), surp=as.integer(rep(0,n)), defic=as.integer(rep(0,n)), PACKAGE="medAdherence") surplus <- data.frame(cbind(unique(x$id),ss$surp,ss$defic)) names(surplus) <- c("id","surplus", "deficit") surplus$surplusPCT = round(surplus$surplus/followUpDays *100,digits) surplus$deficitPCT = -round(surplus$deficit/followUpDays *100,digits) return(surplus) } medAdherence/R/medMPR.R0000644000175100001440000000171511742075530014314 0ustar hornikusers".First.lib" <- function(lib, pkg) { library.dynam("medAdherence", pkg, lib) #if(interactive() || getOption("verbose")) # not in test scripts # cat(sprintf("Package %s (%s) loaded.\n",pkg,packageDescription(pkg)$Version)) # To cite, see citation(\"%s\")\n", pkg, packageDescription(pkg)$Version, pkg)) } medMPR <- function(df=data,followUpDays=NA,truncated="yes", digits=2){ ndt <- do.call(rbind,lapply(split(df,list(df$id)),function(y) cbind(y,cumsum(y$Supp)))) ndt2 <- ndt[ndt$last.id==1,] ndt2 <- ndt2[,c(-6:-4)] names(ndt2) <- c("id","rxDay","lastSupp","totalSupp") rownames(ndt2) <-NULL ndt2$followUpDays <- ndt2$rxDay + ndt2$lastSupp if(!is.na(followUpDays)) ndt2$followUpDays <- followUpDays ndt2$MPR <- round(ndt2$totalSupp/ndt2$followUpDays*100,digits) ndt2$rxDay<- NULL ndt2$lastSupp<-NULL if(truncated=="yes") ndt2$MPR<- ifelse(ndt2$MPR>100,100,ndt2$MPR) return(ndt2) } medAdherence/man/0000755000175100001440000000000011742107253013411 5ustar hornikusersmedAdherence/man/medCMG.Rd0000644000175100001440000000300511311753076014774 0ustar hornikusers\name{medCMG} \alias{medCMG} \title{Continuous measure of Medication Gaps} \description{\code{medCMG} function calculates the Continuous measure of Medication Gaps. This is \bold{non-adherence rate}. The higher CMG, the lower adherence rate.\cr \bold{C}ontinuous measure of \bold{M}edication \bold{G}aps (\bold{CMG}) was estimated by total number of days in treatment gaps (days for which a drug was unavailable) divided by the duration of the time period of interest.\cr The formula is: (Total Days in Study - Total Days' Supply)/(Total Days in Study) x 100. If numerator is negative, it will be set to '0'. } \usage{medCMG(df=data,followUpDays=365, digits=2)} \arguments{ \item{df}{a dataframe created by \code{preData} funtion} \item{followUpDays}{days of total study period. 365 is the default, 12 month follow up.} \item{digits}{round to decimals. Default is 2} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah} \references{ Steiner, JF and Prochazka, AV The Assessment of Refill Compliance Using Pharmacy Records: Methods, Validity, and Application \emph{Journal of Clinical Epidemiology} 1997;50:105-116\cr Hess, LM, Raebel, MA, et al. Measurement of Adherence in Pharmacy Administrative Databases: A Proposal for Statndard Definitions and Preferred Measures \emph{The Annals of Pharmacotherapy} 2006;40:1280-1288 } \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) medCMG(predt) } medAdherence/man/medDBR.Rd0000644000175100001440000000326211311753076015002 0ustar hornikusers\name{medDBR} \alias{medDBR} \title{Days Between Refills adherence rate} \description{\code{medDBR} function calculates the Days Between Reills adherence rate.\cr \bold{D}ays \bold{B}etween \bold{R}efills (\bold{DBR}) adherence rate was estimated by comparing patients' monthly pharmacy refill records to the prescribed regimen documented in their medical records. An assumption was made that any extra doses accumulated during the study period were used as needed by the patients in order to adhere to the prescribed therapy if medication refills were not obtained on time.\cr The formula is: Adherence Rate = (1-(Days Between Refills - Total Days' Supply)/(Days Between Refills)) x 100. } \usage{medDBR(df=data,followUpDays=NA, digits=2)} \arguments{ \item{df}{a dataframe created by \code{preData} funtion} \item{followUpDays}{days of follow up. If no follow up days provided, the elapsed interval from the first dispensation date to last dispensation date will be used.} \item{digits}{round to decimals. Default is 2} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah} \references{ Chisholm MA, Molly LL, et al. Comparing Renal Transplant Patients' Adherence to Free Cyclosporine and Free Tacrolimus Immunosuppressant Therapy. \emph{Clinical Transplant} 2005;19:77-82\cr Hess, LM, Raebel, MA, et al. Measurement of Adherence in Pharmacy Administrative Databases: A Proposal for Statndard Definitions and Preferred Measures \emph{The Annals of Pharmacotherapy} 2006;40:1280-1288 } \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) medDBR(predt) } medAdherence/man/medCSA.Rd0000644000175100001440000000247411311753076015005 0ustar hornikusers\name{medCSA} \alias{medCSA} \title{Continuous Single-interval measure of medication Availability} \description{\code{medCSA} function calculates the Single-interval medication availability.\cr \bold{C}ontinuous \bold{S}ingle-interval measure of medication \bold{A}vailability (\bold{CSA}) was calculated by the days' supply of a medication divided by the number of days in the interval from the dispensation date up to, but not include, the next dispensation date (or the study end). } \usage{medCSA(df=data,digits=2)} \arguments{ \item{df}{a dataframe created by \code{postData} funtion} \item{digits}{round to decimals. Default is 2} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah} \references{ Steiner, JG and Prochazka, AV. The Assessment of Refill Compliance Using Pharmacy Records: Methods, Validity, and Applications. \emph{Journal of Clinical Epidemiology} 1997;50:105-116 \cr Hess, LM, Raebel, MA, et al. Measurement of Adherence in Pharmacy Administrative Databases: A Proposal for Statndard Definitions and Preferred Measures \emph{The Annals of Pharmacotherapy} 2006;40:1280-1288 } \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) postdt <-postRxData(predt) medCSA(postdt) } medAdherence/man/preData.Rd0000644000175100001440000000152711311753076015267 0ustar hornikusers\name{preRxData} \alias{preRxData} \title{First Data Preparation} \description{\code{preRxData} function prepares the data for medical adherence calculation. } \usage{preRxData(df=data,id=NULL,rxDate=NULL,daySupply=NULL,followUpDays=365)} \arguments{ \item{df}{a dataframe. Patient id (id), prescription refill date (rxDate), days supply (DaySupply) are required variables} \item{id}{a variable to identify patients} \item{rxDate}{numeric variable name. Medication dispensation date} \item{daySupply}{numeric varable name. Prescription days' supply} \item{followUpDays}{a scalar. 365 days is the default, 12 month follow up} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah} \examples{ cmos <- rxExampledt() preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) } medAdherence/man/medCR.Rd0000644000175100001440000000243711311753076014702 0ustar hornikusers\name{medCR} \alias{medCR} \title{Compliance Rate} \description{\code{medCR} function calculates the compiance rate.\cr \bold{C}ompliance \bold{R}ate (\bold{CR}) were computed taking the ratio of the sum of days' supplies (excluding the last days' supply) to the elapsed intervals between the last dispensation date and the first dispensation date. \cr The formula is: (Total Days' Supply - Last Days' Supply)/(Last Dispensation Date - First Dispensation Date) x 100. } \usage{medCR(df=data,digits=2)} \arguments{ \item{df}{a dataframe created by \code{preData} funtion} \item{digits}{round to decimals. Default is 2} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah } \references{ Ren XS, Kazis LE, et al. Identifying Patient and Physician Characteristics That Affect Compliance with Antihypertensive Medications. \emph{Journal of Clinical Pharmacy and Therapeutics} 2002;27:47-56\cr Hess, LM, Raebel, MA, et al. Measurement of Adherence in Pharmacy Administrative Databases: A Proposal for Statndard Definitions and Preferred Measures \emph{The Annals of Pharmacotherapy} 2006;40:1280-1288 } \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) medCR(predt) } medAdherence/man/Adherence-package.Rd0000644000175100001440000000276511742033254017160 0ustar hornikusers\name{adherence-package} \alias{adherence-package} \docType{package} \title{Medication Adherence: Commonly Used Definitions } \description{ Adherence is defined as "the extent to which a person's behavior coincides with medical or health advice", which is very important, for both clinical researchers and physicians, to identify the treatment effect of a specific medication(s).\cr A variety of measures have been developed to calculate the medication adherence. Definitions and methods to address adherence differ greatly in public literature. Choosing which definition should be determined by overall study goals. This package provides the functions to calculate medication adherence based on commonly used definitions. } \details{ \tabular{ll}{ Package: \tab medAdherence\cr Type: \tab Package\cr Version: \tab 1.03\cr Date: \tab 2012-04-12\cr License: \tab GPL-2\cr LazyLoad: \tab yes\cr } } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah<\email{xyexye08@gmail.com}> } \references{ Haynes RB, Taylor DW, Sachett DL, eds. \emph{Compliance in health care}. Baltimore: John Hopkins University Press, 1979\cr Hess, LM, Raebel, MA, et al. Measurement of Adherence in Pharmacy Administrative Databases: A Proposal for Statndard Definitions and Preferred Measures \emph{The Annals of Pharmacotherapy} 2006;40:1280-1288 } \keyword{package } \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos, id=ptid, rxDate=rxDay, daySupply=supplies) } medAdherence/man/rxGaps.Rd0000644000175100001440000000134211311753076015146 0ustar hornikusers\name{rxGaps} \alias{rxGaps} \title{rxGaps} \description{\code{rxGaps} function calculate the gaps between the date of dispensation plus days supplies and the next dispensation date. } \usage{rxGaps(df=data,gap=NA)} \arguments{ \item{df}{a dataframe. a object that \code{rxGaps} funtion created} \item{gap}{how to deal with negative gap. Negative gap is kept if any scalar is previded. Otherwise, negative gap is considered as '0', which is the default.} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah} \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) postdt <-postRxData(predt) rxGaps(postdt) } medAdherence/man/rxExampledt.Rd0000644000175100001440000000112111311753076016172 0ustar hornikusers\name{rxEampledt} \alias{rxExampledt} \title{Sample Dataset Creation} \description{A sample dataset with 3 patients, 4 variables,14 records will be created by this function.} \usage{rxExampledt()} \format{ A data frame with 14 observations on the following 4 variables will be created. \describe{ \item{\code{ptid}}{a numeric vector} \item{\code{rxdate}}{a character vector, prescription refill date} \item{\code{supplies}}{a numeric vector} \item{\code{rxDay}}{a numeric vector, prescription refill date} } } \examples{ cmos <- rxExampledt() cmos } medAdherence/man/medDTMPR.Rd0000644000175100001440000000301711311753076015257 0ustar hornikusers\name{medDTMPR} \alias{medDTMPR} \title{Dual Therapy Medication Possession Ratio} \description{\code{medDTMPR} function calculates the Dual Therapy Medication Possession Ratio.\cr \bold{D}ual \bold{T}herapy \bold{M}edication \bold{P}ossession \bold{R}atio (\bold{DTMPR}) were computed taking the ratio of the sum of days' supplies (devided by 2) to the intervals elapsed between date of first prescription refill and last prescription refill plus the days' supply of last refill. \cr Same as MPR, the ratio alone can't be combined across patients due to different observation days (denomitor). DTMPR may exceed 100\% due to early refills and/or polypharmacy. Very commonly, if DTMPR>100\%, it will be truncated to 100\%. } \usage{medDTMPR(df=data,followUpDays=NA,truncated="yes", digits=2)} \arguments{ \item{df}{a dataframe created by \code{preData} funtion} \item{followUpDays}{days of follow up} \item{truncated}{limit MPR to 100\% or not. "yes" is the default} \item{digits}{round to decimals. Default is 2} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah } \references{ Vanderpoel, DR. , Hussein, MA, et al. Adherence to a Fixed-Dose Combination of Rosiglitazone Maleate/Metformin Hydrochloride in Subjects with Type 2 Diabetes Mellitus: A Retorspective Database Analysis \emph{Clinical Therapeutics} 2004;26:2066-2075 } \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) medDTMPR(predt) } medAdherence/man/medCMOS.Rd0000644000175100001440000000510011311753076015125 0ustar hornikusers\name{medCMOS} \alias{medCMOS} \title{Continuous Multiple interval measure of Over-Supply} \description{\code{medCMOS} function calculates the Continuous Multiple interval measure of Over-Supply} \details{ \bold{C}ontinuous \bold{M}ultiple interval measure of \bold{O}ver-\bold{S}upply (\bold{CMOS}) was calculated concurrently with CMG. The description of both calculations are as follows: \cr From the first prescription refill to the next prescription refill, a patient can accumulate a surplus or a deficit by either coming to pick up their medicaiton too early (which would show up as a surplus) or too late (which is considered to be a deficit). Future deficits and surpluses are accumulated based on existing deficits and surpluses. \cr If a person continuously has deficits or surpluses for each prescription refill period, the deficits or surpluses are always accumulated into accumulated deficits or surplus categories, respectively. An old surplus can cancel out a new deficit. If the accumulated surplus is more than the new deficit, the remaining surplus remains an accumulated surplus. If there is an accumulated surplus that precedes a new deficit , but less than the new deficit, the remaining deficit goes to the accumulated gap category. \cr At the end of the observation period, the accumulated gap is divided by the total days between the first and last prescription to get the CMG value for each patient. Similarly, the accumulated surplus is divided by the total days between the first and last presciption to get the measure of surplus for each patient. } \usage{medCMOS(df=data,followUpDays=365, digits=2)} \arguments{ \item{df}{a dataframe created by \code{preData} funtion} \item{followUpDays}{days of follow up. 365 is the default, 12 month follow up} \item{digits}{round to decimals. Default is 2} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah} \references{ Morningstar, BA, Sketris IS, et al. Variation in Pharmacy Prescription Refill Adherence Measures by Type of Oral Antihyperglycaemic Drug Therapy in Seniors in Nova Scotia, Canada \emph{Journal of Clinical Pharmacy and Therapeutics} 2002;27:213-220 Hess, LM, Raebel, MA, et al. Measurement of Adherence in Pharmacy Administrative Databases: A Proposal for Statndard Definitions and Preferred Measures \emph{The Annals of Pharmacotherapy} 2006;40:1280-1288 } \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) postdt <- postRxData(predt) medCMOS(postdt) } medAdherence/man/medMPR.Rd0000644000175100001440000000303011311753076015022 0ustar hornikusers\name{medMPR} \alias{medMPR} \title{Medication Possession Ratio} \description{\code{medMPR} function calculates the medication possession ratio.\cr \bold{M}edication \bold{P}ossession \bold{R}atio (\bold{MPR}) were computed taking the ratio of the sum of days' supplies to number of days in study (\bold{important}: the first day in study is not necessary a prescription refill date). \cr The ratio alone can't be combined across patients due to different observation days (denomitor). MPR may exceed 100\% due to early refills and/or polypharmacy. Very commonly, if MPR>100\%, it will be truncated to 100\%. } \usage{medMPR(df=data,followUpDays=NA,truncated="yes", digits=2)} \arguments{ \item{df}{a dataframe created by \code{preData} funtion} \item{followUpDays}{days of follow up} \item{truncated}{limit MPR to 100\% or not. "yes" is the default} \item{digits}{round to decimals. Default is 2} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah } \references{ Skaer TL, Sclar DA, et al. Effect of Pharmaceutical Formulation for Diltiazem on Health Care Expenditures fo Hypertension \emph{Clinical Therapeutics} 1993;15:905-911 Hess, LM, Raebel, MA, et al. Measurement of Adherence in Pharmacy Administrative Databases: A Proposal for Statndard Definitions and Preferred Measures \emph{The Annals of Pharmacotherapy} 2006;40:1280-1288 } \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) medMPR(predt) } medAdherence/man/postData.Rd0000644000175100001440000000077711311753076015474 0ustar hornikusers\name{postRxData} \alias{postRxData} \title{Second Data Preparation} \description{\code{postRxData} function further prepares the data for medical adherence calculation. } \usage{postRxData(df=data)} \arguments{ \item{df}{a dataframe created by \code{preData} funtion} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah} \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) postRxData(predt) } medAdherence/man/medMPRm.Rd0000644000175100001440000000326511311753076015211 0ustar hornikusers\name{medMPRm} \alias{medMPRm} \title{Medication Possession Ratio(modified)} \description{\code{medMPRm} function calculates the medication possession ratio,modified.\cr \bold{M}edication \bold{P}ossession \bold{R}atio, \bold{m}odified (\bold{MPRm}) were computed taking the ratio of the sum of days' supplies to the intervals elapsed between date of first prescription refill and last prescription refill plus the days' supply of last refill. \cr Same as MPR, the ratio alone can't be combined across patients due to different observation days (denomitor). MPRm may exceed 100\% due to early refills and/or polypharmacy. Very commonly, if MPRm>100\%, it will be truncated to 100\%. } \usage{medMPRm(df=data,followUpDays=NA,truncated="yes", digits=2)} \arguments{ \item{df}{a dataframe created by \code{preData} funtion} \item{followUpDays}{days of follow up} \item{truncated}{limit MPR to 100\% or not. "yes" is the default} \item{digits}{round to decimals. Default is 2} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah } \references{ Vanderpoel, DR. , Hussein, MA, et al. Adherence to a Fixed-Dose Combination of Rosiglitazone Maleate/Metformin Hydrochloride in Subjects with Type 2 Diabetes Mellitus: A Retorspective Database Analysis \emph{Clinical Therapeutics} 2004;26:2066-2075 Hess, LM, Raebel, MA, et al. Measurement of Adherence in Pharmacy Administrative Databases: A Proposal for Statndard Definitions and Preferred Measures \emph{The Annals of Pharmacotherapy} 2006;40:1280-1288 } \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) medMPRm(predt) } medAdherence/man/medPDC.Rd0000644000175100001440000000245711311753076015006 0ustar hornikusers\name{medPDC} \alias{medPDC} \title{Proportion of Days Covered} \description{\code{medPDC} function calculates the proportion of days covered.\cr \bold{P}roportion of \bold{D}ays \bold{C}overed (\bold{PDC}) was calculated by the nubmer of days with supply in study (no matter how many medications were taken on the day) divided by total number of days in study. The maximum of PDC is 100\%. } \usage{medPDC(df=data,followUpDays=365, digits=2)} \arguments{ \item{df}{a dataframe created by \code{postData} funtion} \item{followUpDays}{days of follow up. 365 is the default, 12 month follow up} \item{digits}{round to decimals. Default is 2} } \references{ Benner JS, Glynn RJ, et al. Long-term Persisitence in Use of Statin Therapy in Elderly Patients \emph{the Journal of the American Medical Association} 2002;288:455-461 Hess, LM, Raebel, MA, et al. Measurement of Adherence in Pharmacy Administrative Databases: A Proposal for Statndard Definitions and Preferred Measures \emph{The Annals of Pharmacotherapy} 2006;40:1280-1288 } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah} \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) postdt <-postRxData(predt) medPDC(postdt) } medAdherence/man/medCMA.Rd0000644000175100001440000000260711311753076014775 0ustar hornikusers\name{medCMA} \alias{medCMA} \title{Continuous measure of Medication Availability} \description{\code{medCMA} function calculates the Continuous measure of Medication Acquisition.\cr \bold{C}ontinuous measure of \bold{M}edication \bold{A}cquisition (\bold{CMA}) was calculated by the days' supplies of medication throughout the study period divided by the number of days from the first dispensation date up to the patient's participation completion (study end). } \usage{medCMA(df=data,followUpDays=365, digits=2)} \arguments{ \item{df}{a dataframe created by \code{postData} funtion} \item{followUpDays}{days of follow up. 365 is the default, 12 month follow up} \item{digits}{round to decimals. Default is 2} } \author{ Xiangyang Ye, Pharmacotherapy Outcomes Research Center, University of Utah} \references{ Steiner, JG and Prochazka, AV. The Assessment of Refill Compliance Using Pharmacy Records: Methods, Validity, and Applications. \emph{Journal of Clinical Epidemiology} 1997;50:105-116 \cr Hess, LM, Raebel, MA, et al. Measurement of Adherence in Pharmacy Administrative Databases: A Proposal for Statndard Definitions and Preferred Measures \emph{The Annals of Pharmacotherapy} 2006;40:1280-1288 } \examples{ cmos <- rxExampledt() predt <- preRxData(df=cmos,id=ptid,rxDate=rxDay,daySupply=supplies) postdt <-postRxData(predt) medCMA(postdt) } medAdherence/src/0000755000175100001440000000000011742107257013431 5ustar hornikusersmedAdherence/src/pdc.c0000644000175100001440000000163511742107301014336 0ustar hornikusers /*void R_CheckUserInterrupt(void);*/ void pdc(int *n, int *m, int *rxmax,int *rxdate, int *refills,int *rxs, int *supplies) { int i,j,k, total; int cap[*n][*m]; int rx[*n* *rxmax][2]; for (i=0;i<*n;i++) for (j=0;j<*m;j++) cap[i][j]=0; for (i=0;i<*n* *rxmax;i++) { rx[i][0]=*(rxdate+i); rx[i][1]=*(refills+i); } for (i=0;i<*n;i=i+1) for (j=*rxmax *i;j<(i+1) * *rxmax-1;j++) if (rx[j][0] > 0) for (k = rx[j][0]; k < rx[j][0] + rx[j][1]; k++) if (k<*m) { cap[i][k]=1; /*R_CheckUserInterrupt();*/ } for (j=0;j<*n;j++) { total=0; for (i=0;i<*m;i++) { total= total+cap[j][i]; rxs[j]=total; } } for (i=0;i<*n;i=i+1){ supplies[i]=0; for (j=*rxmax *i;j<(i+1) * *rxmax-1;j++) supplies[i] = supplies[i] + rx[j][1]; } } medAdherence/src/cma.c0000644000175100001440000000050311742107301014321 0ustar hornikusers void cma(int *n, int *rxmax,int *refills,int *supp) { int i,j; int rx[*n* *rxmax]; ; for (i=0;i<*n* *rxmax;i++) rx[i]=*(refills+i); for (i=0;i<*n;i=i+1) { supp[i]=0; for (j=*rxmax *i;j<(i+1) * *rxmax-1;j++) if (rx[j]>0) supp[i] = supp[i] + rx[j]; } } medAdherence/src/cmos.c0000644000175100001440000000170111742107301014523 0ustar hornikusers void cmos(int *x,int *y, int *n, int *rxmax, int *surp, int *defic){ int i,j; for (i=0;i<*n;i=i+1) for (j=0;j<*rxmax;j++){ if ((x[i* *rxmax+j]>0) & (y[i* *rxmax+j]<0) & (j<*rxmax-1)) { y[i* *rxmax+j] = y[i* *rxmax+j] + x[i* *rxmax+j]; if (y[i* *rxmax+j]>0) { x[i* *rxmax+j] = y[i* *rxmax+j]; y[i* *rxmax+j] = 0; } else x[i* *rxmax+j] = 0; } if ((x[i* *rxmax+j]>0) & (y[i* *rxmax+j]==0) & (j<*rxmax-1)) { x[i* *rxmax+j+1] = x[i* *rxmax+j+1] + x[i* *rxmax+j]; x[i* *rxmax+j]=0; } else if ((x[i* *rxmax+j]>0) & (y[i* *rxmax+j]<0) & (j==*rxmax-1)) { y[i* *rxmax+j] = y[i* *rxmax+j] + x[i* *rxmax+j]; if (y[i* *rxmax+j]>0) { x[i* *rxmax+j] = y[i* *rxmax+j]; y[i* *rxmax+j] = 0; } } } for (i=0;i<*n;i=i+1) { surp[i]=0; defic[i]=0; for (j=0;j<*rxmax;j++){ surp[i]=surp[i]+ x[i* *rxmax + j]; defic[i]=defic[i]+ y[i* *rxmax + j]; } } } medAdherence/src/csa.c0000644000175100001440000000143411742107301014333 0ustar hornikusers /* void R_CheckUserInterrupt(void);*/ void csa(int *n, int *rxmax,int *rxdate, int *refills,int *ncsa, int*ngap) { int i; int cap[*n* *rxmax][2]; int rx[*n* *rxmax][2]; for (i=0;i<*n* *rxmax;i++) { rx[i][0]=*(rxdate+i); rx[i][1]=*(refills+i); } for (i=0;i<*n* *rxmax;i=i+1) { cap[i+1][0]=rx[i][1]; cap[i+1][1]=rx[i+1][0] - rx[i][0]; } for (i=0;i<*n* *rxmax;i=i+1) if (rx[i][0] == 0) { cap[i][0]=0; cap[i][1]=0; } for(i=0;i<*n;i=i+ 1) { cap[i * *rxmax][0]=0; cap[i * *rxmax][1]=0; } for (i=0;i<*n* *rxmax-1;i=i+1) { *(ncsa+i+1) = cap[i+1][0]; *(ngap+i+1) = cap[i+1][1]; } }