Commit abb7f5bb authored by Ashley Stewart's avatar Ashley Stewart 💃
Browse files

Merge branch 'getendpoints' into 'master'

Updated GetEndpoints function to correct errors in lines 101-105 and 112 causing wrong AdjOutcomeSubClass to populate

See merge request aspree/aspree-r-package!43
parents 2727d1fe 1838ada6
......@@ -59,7 +59,7 @@ GetEndpoints <- function(con, sectionPaths = SDrivePaths()) {
Endpoint$AdjOutcome[which(Endpoint$AdjOutcomeDesc == "Stroke Death ")] <- 38
Endpoint$AdjOutcome[which(Endpoint$AdjOutcomeDesc == "Stroke type uncertain")] <- 39
Endpoint$AdjOutcome[which(Endpoint$AdjOutcomeDesc == "Sub-arachnoid hemorrhage Stroke")] <- 40
# Generate EventType variable to match longitudinal data set
Endpoint$EventType <- NA
Endpoint$EventType[which(Endpoint$DMCEndpointType == 5)] <- 1
......@@ -75,7 +75,7 @@ GetEndpoints <- function(con, sectionPaths = SDrivePaths()) {
Endpoint$EventType[which(Endpoint$DMCEndpointType == 9)] <- 11
Endpoint$EventType[which(Endpoint$DMCEndpointType == 2009)] <- 12
Endpoint$EventType[which(Endpoint$DMCEndpointType == 3)] <- 13
# Generate Adjudication subclassification variable to match longitudinal data set based on CANCER TYPE
Endpoint$AdjOutcomeSubClass <- NA
Endpoint$AdjOutcomeSubClass[which(Endpoint$CancerType == 1)] <- 1
......@@ -96,20 +96,20 @@ GetEndpoints <- function(con, sectionPaths = SDrivePaths()) {
Endpoint$AdjOutcomeSubClass[which(Endpoint$CancerType == 15)] <- 28
Endpoint$AdjOutcomeSubClass[which(Endpoint$CancerType == 16)] <- 34
Endpoint$AdjOutcomeSubClass[which(Endpoint$CancerType == 98)] <- 35
# Replace AdjOutcomeSubclass column with value to match longitudinal data set for CORONARY HEART DISEASE DEATH
Endpoint[which((Endpoint$AdjSubClass == 1) & (Endpoint$AdjOutcome <- 6)), c("AdjOutcomeSubClass")] <- 5
Endpoint[which((Endpoint$AdjSubClass == 2) & (Endpoint$AdjOutcome <- 6)), c("AdjOutcomeSubClass")] <- 19
Endpoint[which((Endpoint$AdjSubClass == 5) & (Endpoint$AdjOutcome <- 6)), c("AdjOutcomeSubClass")] <- 21
Endpoint[which((Endpoint$AdjSubClass == 3) & (Endpoint$AdjOutcome <- 6)), c("AdjOutcomeSubClass")] <- 27
Endpoint[which((Endpoint$AdjSubClass == 4) & (Endpoint$AdjOutcome <- 6)), c("AdjOutcomeSubClass")] <- 33
Endpoint[which((Endpoint$AdjSubClass == 1) & (Endpoint$AdjOutcome == 6)), c("AdjOutcomeSubClass")] <- 5
Endpoint[which((Endpoint$AdjSubClass == 2) & (Endpoint$AdjOutcome == 6)), c("AdjOutcomeSubClass")] <- 19
Endpoint[which((Endpoint$AdjSubClass == 5) & (Endpoint$AdjOutcome == 6)), c("AdjOutcomeSubClass")] <- 21
Endpoint[which((Endpoint$AdjSubClass == 3) & (Endpoint$AdjOutcome == 6)), c("AdjOutcomeSubClass")] <- 27
Endpoint[which((Endpoint$AdjSubClass == 4) & (Endpoint$AdjOutcome == 6)), c("AdjOutcomeSubClass")] <- 33
# Replace AdjOutcomeSubclass column with value to match longitudinal data set for CLINICALLY SIGNIFICANT BLEEDING
Endpoint$AdjOutcomeSubClass[which((Endpoint$AdjSubClass == 1) & (Endpoint$AdjOutcome == 5))] <- 11
Endpoint$AdjOutcomeSubClass[which((Endpoint$AdjSubClass == 2) & (Endpoint$AdjOutcome == 5))] <- 10
Endpoint$AdjOutcomeSubClass[which((Endpoint$AdjSubClass == 4) & (Endpoint$AdjOutcome == 5))] <- 8
Endpoint$AdjOutcomeSubClass[which((Endpoint$AdjSubClass == 5) & (Endpoint$AdjOutcome == 5))] <- 20
Endpoint$AdjOutcomeSubClass[which(Endpoint$AdjSubClassDesc == "Intraventricular hemorrhage (Non- traumatic)")] <- 8
Endpoint$AdjOutcomeSubClass[which(Endpoint$AdjSubClassDesc == "Intraventricular hemorrhage (Non- traumatic)")] <- 14
Endpoint$AdjOutcomeSubClass[which(Endpoint$AdjSubClassDesc == "Parenchymal hematoma (Non- traumatic)")] <- 24
Endpoint$AdjOutcomeSubClass[which(Endpoint$AdjSubClassDesc == "Parenchymal hematoma (Traumatic)")] <- 25
Endpoint$AdjOutcomeSubClass[which(Endpoint$AdjSubClassDesc == "Subarachnoid hemorrhage (Non- traumatic)")] <- 29
......@@ -117,14 +117,14 @@ GetEndpoints <- function(con, sectionPaths = SDrivePaths()) {
Endpoint$AdjOutcomeSubClass[which(Endpoint$AdjSubClassDesc == "Subdural hemorrhage (Non- traumatic)")] <- 31
Endpoint$AdjOutcomeSubClass[which(Endpoint$AdjSubClassDesc == "Subdural hemorrhage (Traumatic)")] <- 32
Endpoint$AdjOutcomeSubClass[which(Endpoint$AdjSubClassDesc == "Extradural hemorrhage (Traumatic)")] <- 9
# Rename columns to match the longitudinal data
Endpoint$EndpointDt <- Endpoint$EndpointDate
Cutoff <- as.Date("2018-01-31")
Endpoint$XTEvent <- NA
Endpoint$XTEvent[which(Endpoint$DetectedDt > Cutoff)] <- 1
Endpoint <- Endpoint[which(!is.na(Endpoint$Event)), ]
# Generate slimline endpoint data set to match F2
Endpoint <- Endpoint[, c("SubjectID", "CodeID", "EndpointDt", "DetectedDt", "AdjOutcome", "XTEvent", "AdjOutcomeSubClass", "EventType", "AdjStatus", "AdjStatusDesc")]
Endpoint$Status_Sum <- NA
......@@ -133,12 +133,12 @@ GetEndpoints <- function(con, sectionPaths = SDrivePaths()) {
Endpoint$Status_Sum[which(Endpoint$AdjStatus %in% c(21, 1002, 29, 33, 20))] <- 3
Endpoint$Status_Sum[which(Endpoint$AdjStatus %in% c(5, 4, 2, 1, 1001, 10, 83))] <- 4
# Status_Sum 1= Endpoint Yes; Status_Sum 2= Endpoint No; Status_Sum 3=Adjudication in Progress; Status_Sum 4 = Dtaa collection not yet complete
# Get Dementia data
Dementia <- DBI::dbReadTable(con, "vwDementiaAssessment_AE")
Dementia <- Dementia[, c("SubjectID", "CodeID", "Status", "Cause", "VisitDate")]
Dementia <- Dementia[which(Dementia$Status != 1), ]
Endpoint <- merge(Endpoint, Dementia, by = c("SubjectID", "CodeID"), all = TRUE)
Endpoint$DA <- NA
Endpoint$DA[which(!is.na(Endpoint$VisitDate))] <- 1
......@@ -151,17 +151,17 @@ GetEndpoints <- function(con, sectionPaths = SDrivePaths()) {
Endpoint$DA[which((is.na(Endpoint$VisitDate)) & (Endpoint$Status == 17))] <- 6
Endpoint$DA[which((is.na(Endpoint$VisitDate)) & (Endpoint$Status == 18))] <- 7
# Note DA 1= Complete; DA 2 =Not contacted; DA 3= Willing;DA 4=Not reviewed; DA 5= Provisionally approved;DA 6 = Pt unwilling; DA 7= Status inappropriate
# Add Country
Endpoint <- MergeCountryBySubjectId(Endpoint, sectionPaths)
Endpoint <- Endpoint[which(!is.na(Endpoint$EventType)), ]
# Add column to indicate if event was in F2
F2 <- read.csv(sectionPaths$SectionF2_DMC)
F2 <- F2[, c("SubjectID", "CodeID")]
F2$ASP_Endpoint <- 1
Endpoint <- merge(F2, Endpoint, by = c("CodeID", "SubjectID"), all = TRUE)
return(Endpoint)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment