--- output: html_document: default word_document: default --- title: "EPOC_Paper 2_AOA VTE compliance"" author: "Helen Badge & Ian Harris" date: '`r paste(format(Sys.Date(), "%d %b %Y"))`' output: html_document toc: yes --- ```{r setup, include=FALSE} knitr::opts_chunk$set(echo = FALSE) knitr::opts_chunk$set(tidy.opts=list(width.cutoff=80),tidy=TRUE) ``` ## R Markdown This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see . When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot. ## About ### Background This is a secondary analysis for EPOC: Evidence-based Processes and Outcomes of Care, a multi-site prospective cohort study recruiting patients from high-volume private and public arthroplasty centres in Australia. All participants were adults undergoing elective hip or knee arthroplasty for osteoarthritis. The study was designed to generate evidence on the association between adverse events and guideline compliance (for antibiotic use and venous thromboembolism [VTE] prophylaxis) in an elective arthroplasty population. This paper explores association between non-compliance with AOA VTE Guidelines (2018) and rate of symptomatic VTE events between 0 - 90 days ### Aim The primary research question is: *Is there a difference in the symptomatic VTE rate (DVT and PE) after arthroplasty between those who are compliant with AOA VTE prophylaxis guidelines and those who are not?* #### Analysis 1: VTE compliance vs VTE outcome *Predictor*: VTE AOA (2018) compliance determined by patient risk (variable: aoa_cohort_noncompliance ) *Outcome*: binary symptomatic VTE (variable: symptvte90 ) #### Load packages ```{r load packages} library(ggplot2) library(dplyr) library(tidyverse) library(caTools) library(StepReg) library(finalfit) library(tableone) library(caret) library(MASS) library(DataExplorer) library(statsr) library(tidyr) library(skimr) library(gmodels) library(ROCR) library(Amelia) library(pwr) library(epitools) library(pROC) library(broom) library(ResourceSelection) library(DescTools) ``` ### Load data ```{r load data} # Ian's PC #data <- read.csv("C:/Users/iahar/OneDrive/Documents/Research/ACORN/HCF/Paper1/epoc_with_fu_data_R_LATEST.csv na.strings = c("", "999", "NA", "N/A", "NR")) #Helen's PC data <- read.csv("epoc_with_fu_data_R_LATEST.csv", na.strings = c("", "999", "NA", "N/A", "NR")) mydata2 <- as.data.frame(data) # remove ineligible and those with no follow up, should have been done from compliance code mydata2 <- mydata2 %>% filter((optout_fu > 0) & (eligibility == 1)) table(mydata2$optout_fu) ``` #### Normalise and categorise original data prior to creating predictor variables ```{r normalise, classify & tidy dose, time & other data} mydata2$age <- as.numeric(mydata2$age) mydata2$wgt <- as.numeric(mydata2$wgt) mydata2$bmi<- as.numeric(mydata2$bmi) mydata2$los<- as.numeric(mydata2$los) mydata2$surg_duration<- as.numeric(mydata2$surg_duration) # Shorten variable names to make table columns narrower mydata2$arth_meds_antidep <- mydata2$arth_meds_antiep_antidepress # Rename arthritis meds mydata2$arth_meds_none <- mydata2$arth_meds_spec___0 mydata2$arth_meds_non_nsaids <- mydata2$arth_meds_spec___1 mydata2$arth_meds_nsaids <- mydata2$arth_meds_spec___2 mydata2$arth_meds_steroids <- mydata2$arth_meds_spec___3 mydata2$arth_meds_antidep <- mydata2$arth_meds_spec___4 mydata2$arth_meds_Opioids <- mydata2$arth_meds_spec___5 ``` ## Step 1: Create and modify variables ## Step 1.1. Create main predictor variables, AOA Arthroplasty VTE Guidelines ## Step 1.1.1.a. Calculate compliance with DURATION VTE prophylaxis, AOA General recommendations 5. ```{r AOA VTE General recs, VTE duration} # RECODE / CREATE DURATION VARIABLES ## Recode vte_chemo_yesno for id_number 74, 782 to 1 table(mydata2$vte_chemo_yesno, useNA = "always", dnn = "VTE chemical prophylaxis used") mydata2 <- mydata2 %>% mutate(vte_chemo_yesno = if_else(id_number %in% c(74, 782, 1422), 1L, vte_chemo_yesno)) table(mydata2$vte_chemo_yesno, useNA = "always", dnn = "VTE chemical prophylaxis used") # 7 people did not receive any chemical prophylaxis ## recode Duration, overall durat id74 received 42 days aspirin, id782 received 21 days fragmin, id1391 recieved aspirin Inf, convert Inf to 90 ## Recode so maximum duration 90 days to match outcome duration, instead of 365 days, and correct missing but available data from this variable mydata2 <- mydata2 %>% mutate(vte_drug_anydurat_90 = if_else(vte_drug_anydurat > 89, 90, vte_drug_anydurat)) mydata2$vte_drug_anydurat_90[mydata2$id_number == 74] <- 42 mydata2$vte_drug_anydurat_90[mydata2$id_number == 782] <- 21 mydata2$vte_drug_anydurat_90[mydata2$id_number == 1422] <- 90 # DURATION VTE PROPHYLAXIS # Compliance duration, at least 3 weeks, longer duration allowed mydata2 <- mydata2 %>% mutate(vte_drug_anydurat_cat = if_else( vte_chemo_yesno == 0 | 0 < vte_drug_anydurat_90 & vte_drug_anydurat_90 < 21, 0L, if_else( 20 < vte_drug_anydurat_90 & vte_drug_anydurat_90 < 91, 1L, 3L))) table(mydata2$vte_drug_anydurat_cat, useNA = "always", dnn = "Compliance with recommended mimimum VTE prophylaxis duration, at least 21 days") #821 non compliant duration less than 21 days # NONCOMPLIANT VTE PROPHYLAXIS DURATION mydata2 <- mydata2 %>% mutate(noncompliant_vte_prophyl_durat = if_else(!is.na(vte_drug_anydurat_cat) & vte_drug_anydurat_cat == 1, 0L, 1L)) table(mydata2$noncompliant_vte_prophyl_durat, useNA = "always", dnn = "NONCOMPLIANT VTE prophylaxis duration") ### people with NA duration had no chemoprophylaxis, included in calculation for non-recommended chemoprophylaxis duration ## CALCULATE DURATION ICP USE - recoding not working but not important at present # 636, vte_anymech_time 24\2, CEASED DAY 22, SHOULD BE 23 DAYS DURATION str(mydata2$vte_anymech_time) mydata2$vte_anymech_time[mydata2$id_number == 636] <- 23 mydata2$vte_anymech_time <- as.integer(mydata2$vte_anymech_time) mydata2 <- mydata2 %>% mutate(vte_anymech_time = if_else(vte_anymech_time %in% c("90", "91", "Inf"), 90L, vte_anymech_time)) summary(mydata2$vte_anymech_time, useNA = "always") table(foot = mydata2$vte_icp_foot, calf = mydata2$vte_icp_calf) #table(mydata2$vte_foot_durat, useNA = "always", dnn = "SCD, Foot duration") #table(mydata2$vte_calf_durat, useNA = "always", dnn = "SCD, Calf duration") #ID 927 recorded as 42 days duration calf, incorrectly recorded as calf compressor 5 days duration, GCS 42 days mydata2$vte_calf_durat[mydata2$id_number == 927] <- 5 summary(mydata2$vte_anymech_time, useNA = "always") summary(mydata2$vte_foot_durat, useNA = "always") summary(mydata2$vte_calf_durat, useNA = "always") # Calculate if indivdual VTE drug durations were recommended, convert Inf to 90 # Aspirin duration table(mydata2$vte_aspir, useNA = "always", dnn = "Aspirin") mydata2 <- mydata2 %>% mutate(vte_aspir_ceased = if_else(vte_aspir_ceased %in% c("Inf", "91", "104", "119", "180"), 90, vte_aspir_ceased)) #table(mydata2$vte_aspir_ceased) mydata2 <- mydata2 %>% mutate(vte_aspir_cess = if_else( 20 < vte_aspir_ceased & vte_aspir_ceased < 43, 1L, if_else( vte_aspir_ceased > 42, 2L, 0L))) table(mydata2$vte_aspir_cess, useNA = "always", dnn = "Aspirin ceased within 3-6 weeks") # clexane duration #max 63 days #table(mydata2$vte_clex_ceased) table(mydata2$vte_clex, useNA = "always", dnn = "Cexane") mydata2 <- mydata2 %>% mutate(vte_clex_cess = if_else( 20 < vte_clex_ceased & vte_clex_ceased < 43, 1L, if_else( vte_clex_ceased > 43, 2L, 0L))) table(mydata2$vte_clex_cess, useNA = "always", dnn = "Clexane ceased within 3-6 weeks") # Fragmin duration table(mydata2$vte_frag, useNA = "always", dnn = "Fragmin") mydata2 <- mydata2 %>% mutate(vte_frag_cess = if_else( 20 < vte_frag_ceased & vte_frag_ceased < 43, 1L, if_else( vte_frag_ceased == "Inf", 2L, if_else( vte_frag_ceased > 43, 2L, 0L)))) table(mydata2$vte_frag_cess, useNA = "always", dnn = "fragmin ceased within 3-6 weeks") # Rivaroxaban duration table(mydata2$vte_riva, useNA = "always", dnn = "Rivaroxaban") mydata2 <- mydata2 %>% mutate(vte_riva_ceased = if_else(vte_riva_ceased == "Inf", 90, vte_riva_ceased)) #table(mydata2$vte_riva_ceased) mydata2 <- mydata2 %>% mutate(vte_riva_cess = if_else( 20 < vte_riva_ceased & vte_riva_ceased < 43, 1L, if_else( vte_riva_ceased > 43, 2L, 0L))) table(mydata2$vte_riva_cess, useNA = "always", dnn = "rivaroxaban ceased within 3-6 weeks") # dabigatran duration table(mydata2$vte_dabig, useNA = "always", dnn = "Dabigatran") mydata2 <- mydata2 %>% mutate(vte_dabig_ceased = if_else(vte_dabig_ceased == "Inf", 90, vte_dabig_ceased)) mydata2 <- mydata2 %>% mutate(vte_dabig_cess = if_else( 20 < vte_dabig_ceased & vte_dabig_ceased < 43, 1L, if_else( vte_dabig_ceased > 43, 2L, 0L))) table(mydata2$vte_dabig_cess, useNA = "always", dnn = "dabigatran etexilate ceased within 3-6 weeks") # None ceased within 3-6 weeks #table(mydata2$vte_dabig_ceased) # warfarin duration table(mydata2$vte_warf, useNA = "always", dnn = "Warfarin") mydata2 <- mydata2 %>% mutate(vte_warf_ceased = if_else( vte_warf_ceased == "Inf", 90, vte_warf_ceased)) table(mydata2$vte_warf_ceased) mydata2 <- mydata2 %>% mutate(vte_warf_cess = if_else( 20 < vte_warf_ceased & vte_warf_ceased < 43, 1L, if_else( vte_warf_ceased > 43, 2L, 0L))) table(mydata2$vte_warf_cess, useNA = "always", dnn = "warfarin ceased within 3-6 weeks") # 3 ceased within 3-6 weeks, 70 longer, # 68 Inf, max 55 # unfheparin duration table(mydata2$vte_unfhep, useNA = "always", dnn = "Unfract hep") mydata2 <- mydata2 %>% mutate(vte_unfhep_ceased = if_else(vte_unfhep_ceased == "Inf", 90L, vte_unfhep_ceased)) mydata2 <- mydata2 %>% mutate(vte_unfhep_cess = if_else( 20 < vte_unfhep_ceased & vte_unfhep_ceased < 43, 1L, if_else( vte_unfhep_ceased > 43, 2L, 0L))) table(mydata2$vte_unfhep_cess, useNA = "always", dnn = "unfheparin ceased within 3-6 weeks") # 0 ceased within 3-6 weeks, all 45 shorter than 3 weeks, # 68 Inf, max 55 # heparin duration table(mydata2$vte_hep, useNA = "always", dnn = "heparin") #table(mydata2$vte_hep_ceased) mydata2 <- mydata2 %>% mutate(vte_hep_cess = if_else( 20 < vte_hep_ceased & vte_hep_ceased < 43, 1L, if_else( vte_hep_ceased > 43, 2L, 0L))) table(mydata2$vte_hep_cess, useNA = "always", dnn = "heparin ceased within 3-6 weeks") # Combine hep and unf hep table(hepceased = mydata2$vte_hep_ceased, unfhepceased = mydata2$vte_unfhep_ceased, useNA = "always") #Received unfractionated heparin mydata2 <- mydata2 %>% mutate(vte_heparin = if_else( vte_unfhep == 1, vte_unfhep, if_else( vte_hep == 1, vte_hep, 0L))) table(mydata2$vte_heparin) # Recommended duration unfractionated heparin #table(mydata2$vte_unfhep_ceased) mydata2 <- mydata2 %>% mutate(vte_heparin_cess = if_else( (vte_hep == 1 & 0 <= vte_hep_ceased & vte_hep_ceased < 21 | vte_unfhep == 1 & 0 <= vte_unfhep_ceased & vte_unfhep_ceased < 21), 0L, if_else( (vte_unfhep == 1 & 20 < vte_unfhep_ceased & vte_unfhep_ceased < 43 | vte_hep == 1 & 20 < vte_hep_ceased & vte_hep_ceased < 43), 1L, 2L))) table(mydata2$vte_heparin_cess, useNA = "always", dnn = "Heparin ceased within 3-6 weeks") # Heparin duration mydata2$vte_hep_ceased <- as.integer(mydata2$vte_hep_ceased) mydata2$vte_unfhep_ceased <- as.integer(mydata2$vte_unfhep_ceased) # alt1 VTE med duration table(mydata2$vte_alt1, useNA = "always", dnn = "Alt 1 VTE") table(mydata2$vte_alt1_ceased) mydata2 <- mydata2 %>% mutate(vte_alt1_ceased = if_else( 20 < vte_alt1_ceased & vte_alt1_ceased < 43, 1L, if_else( vte_alt1_ceased > 43, 2L, 0L))) table(mydata2$vte_alt1_ceased, useNA = "always", dnn = "alt1 VTE med ceased within 3-6 weeks") # alt2 VTE med duration table(mydata2$vte_alt2_days, useNA = "always", dnn = "alt2 VTE med") # none ## Create table one to check cessation and start days VTE prophylaxis tab_durat <- CreateTableOne(data = mydata2, vars = c("vte_clex_ceased","vte_frag_ceased", "vte_riva_ceased", "vte_dabig_ceased", "vte_unfhep_ceased", "vte_hep_ceased", "vte_warf_ceased", "vte_alt1_ceased", "vte_aspir_ceased", "vte_drug_anydurat_90")) print(tab_durat, showAllLevels = TRUE) # CALCULATE DURATION USING MAXIMAL LAST DAY CEASED FOR INDIVIDUAL DRUGS mydata2$maxceased <- apply(cbind(mydata2$vte_clex_ceased, mydata2$vte_aspir_ceased, mydata2$vte_riva_ceased, mydata2$vte_unfhep_ceased, mydata2$vte_warf_ceased, mydata2$vte_hep_ceased, mydata2$vte_alt1_ceased, mydata2$vte_dabig_ceased), 1, max, na.rm = TRUE) str(mydata2$maxceased) head(mydata2$maxceased) summary(mydata2$maxceased) #mydata2 <- mydata2 %>% #mutate(vte_maxdurat_rec = if_else((20 < maxceased ) & (maxceased < 43), 1L, 0L)) #table(mydata2$vte_maxdurat_rec, useNA = "always", dnn = "Compliant VTE prophylaxis duration using indivdual drug durations, excluding Inf") mydata2 <- mydata2 %>% mutate(vte_maxdurat_rec = if_else( vte_chemo_yesno == 0 | 0 < maxceased & maxceased < 21, 0L, if_else( 20 < maxceased, 1L, 3L))) table(mydata2$vte_maxdurat_rec, useNA = "always", dnn = "Compliance with recommended minimum VTE prophylaxis duration, at least 21 days") #821 non compliant duration less than 21 days table(anydurat = mydata2$vte_drug_anydurat_cat, maxdurat = mydata2$vte_maxdurat_rec, useNA = "always") #Explore difference in days when VTE prophylaxis ceased vs treatment started table(mydata2$vte_rx, useNA = "always", dnn = " Did they start Rx VTE?") table(mydata2$vte_rx_comm, useNA = "always", dnn = "Day commenced VTE Rx") mydata2 <- mydata2 %>% mutate(vte_rx_minus_proph = vte_rx_comm - maxceased) table(mydata2$vte_rx_minus_proph, useNA = "always", dnn = "Difference days VTE treatment & prophylaxis ceased") mydata2 <- mydata2 %>% mutate(vte_rx_proph_days = (vte_rx_comm - maxceased) < 1, 0L, if_else( (vte_rx_comm - maxceased) == Inf, 0L, if_else( (vte_rx_comm - maxceased) > 0, 1L, NA_integer_))) table(mydata2$vte_rx_proph_days, useNA = "always", dnn = "Did VTE treatment commence after prophylaxis ceased") ``` ## Step 1.1.1.b. Calculate compliance with OTHER AOA General recommendations, excluding VTE prophylaxis duration ```{r AOA VTE General recs, others} # AOA 1 General Considerations- for all patients independent of risk assessment ## 1. Early mobilisation post arthroplasty, ## 2. Spinal anaesthesia, ## 4. Bleeding mitigation including tranexamic acid and delaying chemical anticoagulation until bleeding stabilises, ## 6. If patient already on warfarin or Plavix for a cardiac condition, recommend consultation with cardiologist, ## 7. Plavix (clopidegrol) should be ceased at 7 days from surgery and warfarin 5 days from intended surgery. Bridging medication may be appropriate (eg aspirin). ## 8. DOACs (direct oral anticoagulants eg Rivaroxaban, Apixaban) need to be stopped a few days before major surgery depending on renal function - ignore # NOTE: 5. VTE prophylaxis considered separately as this recommendation doesn't apply to people with high bleeding risk # Calculate individual variables for AOA 1 General Considerations ## 2. Create neuraxial variable mydata2 <- mydata2 %>% mutate(neurax = if_else( anaes_2 %in% c(0,3), 0L, if_else( anaes_2 %in% c(1,2,4,5,6,7,8,9), 1L, NA_integer_ ))) table(mydata2$neurax, useNA = "always", dnn = "Neuraxial anaesthetic before converting cases", exclude = NULL) ### recode anaes_2 variable response 8 (other) for six participants who did NOT have neuraxial anaesthesia mydata2 <- mydata2 %>% mutate(neurax = if_else(id_number %in% c(734, 1108, 1608, 1621, 1625, 1637), 0L, neurax)) #table(mydata2$neurax, useNA = "always", dnn = "Neuraxial anaesthetic", exclude = NULL) # 7. CESSATION PREOP CARDIOVASCULAR MEDICATIONS ## Warfarin ### Check data for people on preop warfarin table(mydata2$cardiac_warfarin, useNA = "always", dnn = "preop warfarin for CVD") #N is 68 table(mydata2$cardiac_warfarin_cease, useNA = "always", dnn = "preop warfarin for CVD ceased preop")#N is 61 ### Identify people on warfarin who ceased less than 7 days preop or did not cease, versus those who ceased >7 days preop or not on preop warfarin mydata2 <- mydata2 %>% mutate(cease_preop_warf = if_else( cardiac_warfarin == 1 & cardiac_warfarin_cease == 0, 0L, if_else( cardiac_warfarin == 1 & cardiac_warfarin_cease == 1 & cardiac_warfarin_cease_time %in% c("6 days", "7 days", "7days", "12 days", "14 days", "21 days", "28 days"), 1L, if_else( cardiac_warfarin == 1 & cardiac_warfarin_cease == 1 & cardiac_warfarin_cease_time %in% c("1 day", "2", "3 days", "4 days", "4days", "5 days"),0L, 2L)))) table(mydata2$cease_preop_warf, useNA = "always", dnn = "Warfarin ceased preop within 5 days") #8 NA ## Plavix ### Check data for people on preop plavix table(mydata2$cardiac_plavix, useNA = "always", dnn = "preop plavix for CVD") #N is 66 table(mydata2$cardiac_plavix_cease, useNA = "always", dnn = "did patient ceased preop plavix")#N is 56 ### Identify people on plavix ceased less than 5 days preop or did not cease, versus those who ceased >5 days preop or not on preop plavix mydata2 <- mydata2 %>% mutate(cease_preop_plavix = if_else( cardiac_plavix == 1 & cardiac_plavix_cease == 0, 0L, if_else( cardiac_plavix == 1 & cardiac_plavix_cease == 1 & cardiac_plavix_cease_time %in% c("3 -4days", "3 days", "2 days", "5 days"),0L, if_else( cardiac_plavix == 1 & cardiac_plavix_cease == 1 & cardiac_plavix_cease_time %in% c("10 days", "12 days", "13 days", "14 days", "23 days", "28 days", "30 days", "7 days", "8 days", "Aug-14"), 1L, 2L)))) table(mydata2$cease_preop_plavix, useNA = "always", dnn = "plavix ceased preop before 7 days preoperatively, or not taken") #9 NA #56 of 66 people taking plavix ceased it preop, 2 didn't cease and 9 unknown whether ceased or not ### Check data for people on preop DOACs mydata2 <- mydata2 %>% mutate(doac_preop = if_else(cardiac_drug_other_type %in% c("Dabigatran - Pradaxa", "Dabigatran etexilate", "dabigatran etexilate - pradaxa", "Dabigatran etexilate - Pradaxa", "Dabigatran - Pradaxa", "Dabigatran etexilate (Pradaxa)", "Pradaxa", "Rivaroxaban", "xarelto", "Xarelto"), 1L, 0L)) table(mydata2$doac_preop, dnn ="Took DOAC preoperatively for CVD", useNA = "always") # 8. Preop DOACs ceased preop # Recode one participant, ceased 4 days preop but cessation NA mydata2 <- mydata2 %>% mutate(cardiac_drug_other_cease = if_else(id_number %in% c(647), 1L, cardiac_drug_other_cease)) mydata2 <- mydata2 %>% mutate(doac_preop_ceased = if_else( doac_preop == 1 & cardiac_drug_other_cease_time %in% c("2 days", "3 days", "4 days", "5 days"), 0L, if_else( doac_preop == 1 & cardiac_drug_other_cease == 0, 0L, if_else( doac_preop == 1 & cardiac_drug_other_cease_time %in% c("10 days", "14 days", "30 days"), 1L, 2L)))) table(mydata2$doac_preop_ceased, useNA = "always", dnn ="Preop cessation DOAC taken preoperatively for CVD") # 2 didn't cease, 19 ceased but one NA how man days ### Cessation DOCS, AOA recommend MAY need to be stopped, and as no data on kidney function ignored for calculating compliance # COMPLIANCE WITH GENERAL RECS 1,2,4,6,7 # Calculate compliance with AOA 1. General recommendations, compliance including cessation of preop medications, excluding VTE prophylaxis duration mydata2 <- mydata2 %>% mutate(vte_aoa_general_rec = if_else(neurax == 1 & txa == 1 & (vte_1stmobil_day0 == 1 | vte_1stmobil_day1 == 1) & (!is.na(cease_preop_plavix) & cease_preop_plavix %in% c(1,2)) & (!is.na(cease_preop_warf) & cease_preop_warf %in% c(1,2)), 1L, 0L)) table(mydata2$vte_aoa_general_rec, useNA = "always", dnn = "Compliance with AOA general VTE prophylaxis recommendations, without duration prophylaxis") #6 NA ## Non compliance with general recommendations mydata2 <- mydata2 %>% mutate(non_compliance_aoa_general_rec = 1L - vte_aoa_general_rec) table(mydata2$non_compliance_aoa_general_rec, useNA = "always", dnn = "Non-compliance, General recommendations AOA") #6 NA ``` ## Step 1.1.2 Calculate RISK level for VTE and bleeding risk using AOA criteria ```{r create AOA VTE risk} # AOA Risk 1a. Increased Risk of PE: ## Major Criteria (one or more) # 1. Hypercoagulability conditions, *Hypercoagulability conditions (protein C and protein S deficiency, antiphospholipid antibodies, antithrombin deficiency, factor V Leiden, acquired or congenital thrombophilias, prothrombin mutation 20210A, SLE inhibitor) # 2. Metastatic cancer, not relevant for elective TJR # 3. Stroke (occlusion or stenosis with infarction), # 4. Chronic Obstructive Pulmonary Disease (COPD), # 5. Sepsis, not relevant for elective TJR # Calculate people considered at high risk of VTE due to major factors mydata2 <- mydata2 %>% mutate(cc_stroke = if_else(cc_stroke == 1 | cardiac_stroke == 1, 1L, 0L)) # 1 person identified as previous stroke not captured in comorbid conditions table(mydata2$cc_stroke, useNA = "always", dnn = "Stroke") mydata2 <- mydata2 %>% mutate(copd = if_else(cc_lud == 1 & (!is.na(cc_lud_describe) & cc_lud_describe == 1), 1L, 0L)) table(mydata2$copd, useNA = "always", dnn = "COPD or emphysema") mydata2 <- mydata2 %>% mutate(vte_highrisk_major = if_else( cc_stroke == 1 | cc_bleed == 1 & cc_bleed_type_cat == 2 | cc_bleed == 1 & cc_bleed_type_cat == 3 | cc_bleed == 1 & cc_bleed_type_cat == 4 | cc_lud == 1 & copd == 1, 1L, 0L)) table(mydata2$vte_highrisk_major, useNA = "always", dnn = "High risk VTE, major factor") # AOA Risk 1b. Increased Risk of PE: Minor Criteria (three or more) #Criteria (three or more) # 1. Immobility **, **Immobility, institutionalized patients, prolonged bed rest, severe pain, ileus, fracture # 2. History of VTE (PE and proximal DVT), # 3. Tamoxifen and oestrogen therapy ***, ***Tamoxifen and oestrogen therapy, recommend cease oestrogen and HRT 4 weeks pre op # 4. Medical comorbidities; Charlston index≥ 3 , cardiac failure, advanced renal impairment, # 5. Lymphoma, myeloproliferative disorder, # 6. Obesity, BMI > 30, 7. Severe weight loss, 8. Acute MI, 9. Knee replacement (greater risk than THR) ### Calculate individual minor risk factors for VTE and convert to numeric so can be summed as risk estimate #knee replacement mydata2 <- mydata2 %>% mutate(joint_vterisk = joint == 1, 1, 0) mydata2$joint_vterisk<- as.numeric(mydata2$joint_vterisk) table(mydata2$joint_vterisk, useNA = "always", dnn = "VTE risk factor, knee replacement") #took HRT preoperatively mydata2 <- mydata2 %>% mutate(hrt_vterisk = if_else(!is.na(vte_preopmeds_contratype) & vte_preopmeds_contratype == 2, 1L, 0L)) mydata2$hrt_vterisk<- as.numeric(mydata2$hrt_vterisk) table(mydata2$hrt_vterisk, useNA = "always", dnn = "VTE risk factor, HRT preop") #History previous VTE mydata2 <- mydata2 %>% mutate(vte_history_vterisk = if_else(!is.na(vte_prev_vte) & vte_prev_vte == 1, 1L, 0L)) mydata2$vte_history_vterisk <- as.numeric(mydata2$vte_history_vterisk) table(mydata2$vte_history_vterisk, useNA = "always", dnn = "VTE risk factor, preop meds contraindicated") # Premorbid kidney disease mydata2 <- mydata2 %>% mutate(cc_kidney_vterisk = if_else(!is.na(cc_kd) & cc_kd== 1, 1L, 0L)) mydata2$cc_kidney_vterisk <- as.numeric(mydata2$cc_kidney_vterisk) table(mydata2$cc_kidney_vterisk, useNA = "always", dnn = "VTE risk factor, Comorbid Kidney disease") # Premorbid Cardiac disease: 474 people had caridac condition but only 12 had cardiac failure. mydata2 <- mydata2 %>% mutate(cc_cardiac_vterisk = if_else(id_number %in% c(166, 288, 289, 454, 615, 676, 951, 1419, 1612, 1670, 1815, 1869), 1L, 0L)) mydata2$cc_cardiac_vterisk <- as.numeric(mydata2$cc_cardiac_vterisk) table(mydata2$cc_cardiac_vterisk, useNA = "always", dnn = "VTE risk factor, Comorbid Cardiac failure") ## Count how many minor risk factors a person has mydata2 <- mydata2 %>% mutate(vte_highrisk_minor_count = cc_cardiac_vterisk + cc_kidney_vterisk + joint_vterisk + hrt_vterisk + vte_history_vterisk) table(mydata2$vte_highrisk_minor_count, useNA = "always", dnn = "Count of minor high risk factors") ## Calculate whether they have 3 or more minor high risk factors # 7 people have 3 or more mydata2 <- mydata2 %>% mutate(vte_highrisk_minor = if_else( vte_highrisk_minor_count >= 3, 1L, 0L)) table(mydata2$vte_highrisk_minor, useNA = "always", dnn = "High risk VTE, minor factors") table(minor = mydata2$vte_highrisk_minor_count, major = mydata2$vte_highrisk_major, useNA = "always") # AOA Risk 2. CALCULATE WHO IS CONSIDERED AT ROUTINE VERSUS HIGH RISK OF VTE mydata2 <- mydata2 %>% mutate(high_vte_risk = if_else( vte_highrisk_minor_count >= 3 | vte_highrisk_major == 1, 1L, if_else( vte_highrisk_minor_count %in% c(0, 1,2) & vte_highrisk_major == 0, 0L, NA_integer_))) table(mydata2$high_vte_risk, useNA = "always", dnn = "High risk VTE, major factor") #184 high risk, 1691 routine VTE risk # AOA Risk 2. INCREASED RISK OF MAJOR BLEEDING # Limitations, data on risk of major bleeding may be insufficient to use in analyses, don't know full bleeding history or if premorbid strokes were haemmorrhagic or ischaemic ## a. Preoperative Conditions, 1. Known bleeding disorder, 2. History of bleeding on chemoprophylactic agents, 3. History of major gastrointestinal bleeding, 4. History of haemorrhagic stroke, 5. History of other major bleeding event table(bleedrisk = mydata2$vte_bleeding_risk_yesno, bleedcc = mydata2$cc_bleed, useNA = "always") # 1 NA for preop bleeding comorbid condition mydata2 <- mydata2 %>% mutate(vte_aoa_bleedrisk = if_else( vte_bleeding_risk_yesno == 1 | cc_bleed == 1, 1L, 0L)) table(mydata2$vte_aoa_bleedrisk, useNA = "always", dnn = "High bleeding risk") #54 high bleeding risk, 1 NA bleeding risk table(bleedhigh = mydata2$vte_aoa_bleedrisk, vtehigh = mydata2$high_vte_risk, useNA = "always") #27 people at high bleeding risk and high VTE risk, will be considered as high bleeding risk ## Separate vte and bleeding risk, SOME PEOPLE HAVE HIGHER BLEEDING RISK AND VTE RISK #184 high risk, 1691 routine VTE risk, high bleeding risk 54 mydata2 <- mydata2 %>% mutate(aoa_vte_bleed_risk = if_else( high_vte_risk == 0 & vte_aoa_bleedrisk == 0, 0L,if_else( high_vte_risk == 0 & vte_aoa_bleedrisk == 1, 2L, if_else( high_vte_risk == 1 & vte_aoa_bleedrisk == 0, 1L, if_else( high_vte_risk == 1 & vte_aoa_bleedrisk == 1, 2L, NA_integer_))))) table(mydata2$aoa_vte_bleed_risk, useNA = "always", dnn = "High bleeding and VTE Risk levels") # 1848 routine VTE risk, 157 high VTE risk, 54 high bleeding risk (counted as high bleeding risk regardless of VTE risk) 1 NA # OVERALL PARTICIPANT RISK, SEPARATING VTE AND BLEEDING RISK, 1 routine VTE risk, 2 high VTE risk, 0 high bleeding risk mydata2 <- mydata2 %>% mutate(aoa_pt_risk = if_else( aoa_vte_bleed_risk == 0, 1L, if_else( high_vte_risk == 1 & vte_aoa_bleedrisk == 0, 2L, 0L))) table(mydata2$aoa_pt_risk, useNA = "always", dnn = "Overall participant risk levels") #54 people at high bleeding risk, 157 at high VTE risk only, 1663 at routine VTE risk only, 54 bleeding risk, NA 1 ## b. Perioperative Events, 1. Revision THA/TKA with extensive exposure, 2. Major surgical bleeding, 3. Other major bleeding episode ### WE DON'T HAVE ENOUGH EVENTS TO include or CALCULATE THE surgical / post surgical bleeding ``` ## Step 1.1.3. Calculate compliance with ROUTINE risk VTE prophylaxis, AOA VTE Guidelines ```{r AOA 2. Routine risk VTE compliance} # AOA 2. Calculate elements for compliance with AOA 2. Patients with Routine Risk Of VTE ## Peri-operative options include:- ## 1. Sequential compression device (SCD), and ## AND 2. Aspirin- 100-300mg per day, OR ## OR 3. Potent anticoagulation (LMWH, Warfarin, DOAC), can have aspirin alone at right dose OR any other drug, heparin allowed #AOA 2.1. Sequential compression device (SCD) mydata2 <- mydata2 %>% mutate(vte_icp = if_else( (!is.na(vte_icp_foot) & vte_icp_foot == 1) | (!is.na(vte_icp_calf) & vte_icp_calf == 1), 1L, if_else( (!is.na(vte_icp_foot) & vte_icp_foot == 0) | (!is.na(vte_icp_calf) & vte_icp_calf == 0), 0L, NA_integer_))) table(mydata2$vte_icp, useNA = "always", dnn = "Received at least one ICP") #28 NA missing data for icp #AOA 2.2. Aspirin- 100-300mg per day OR 2.3. Potent anticoagulation (LMWH, Warfarin, DOAC), allow heparin ## If used aspirin needs to have been given at the right dose, ALLOW USE OF MUTLIPLE VTE AGENTS mydata2 <- mydata2 %>% mutate(vte_aoa_routine_chemo = if_else( vte_chemo_yesno == 0 |vte_aspir_firstdose %in% c("33.3 mg", "40", "50", "400", "75", "80"), 0L, if_else( vte_aspir_firstdose %in% c("100", "150", "200", "300") & vte_clex == 0 & vte_frag == 0 & vte_fondap == 0 & vte_riva == 0 & vte_dabig == 0 & vte_hep == 0 & vte_unfhep == 0 & vte_warf == 0, 1L, if_else( vte_aspir_firstdose %in% c("100", "150", "200", "250", "300") & (vte_clex == 1 | vte_frag == 1 | vte_fondap == 1 | vte_riva == 1 | vte_dabig == 1 | vte_hep == 1 | vte_unfhep == 1 | vte_warf == 1), 2L, if_else( vte_clex == 1 | vte_frag == 1 | vte_fondap == 1 | vte_riva == 1 | vte_dabig == 1 | vte_hep == 1 | vte_unfhep == 1 | vte_warf == 1, 3L, NA_integer_))))) table(mydata2$vte_aoa_routine_chemo, useNA = "always", dnn = "Received routine recommended VTE chemical prophylaxis") # 1 NA, 1778 had only aspirin and no dose recorded # NB dose aspirin "33.3mg" exlcuded as one person started this dose at 42 days postop, ## AOA 2. Calculate overall compliance with AOA 2. Patients with Routine Risk Of VTE, Recommended chemical and mechanical prophylaxis mydata2 <- mydata2 %>% mutate(aoa_routine_compliance = if_else( vte_icp == 1L & (!is.na(vte_aoa_routine_chemo) & vte_aoa_routine_chemo %in% c(1L,2L,3L)), 1L, if_else( vte_icp == 0L | (!is.na(vte_aoa_routine_chemo) & vte_aoa_routine_chemo == 0L), 0L, NA_integer_))) table(mydata2$aoa_routine_compliance, useNA = "always", dnn = "Received routine VTE risk compliant, VTE chemical and mechanical prophylaxis") #28 NA mydata2 <- mydata2 %>% mutate(noncompliance_vte_aoa_routine_prophyl = 1L - aoa_routine_compliance) table(mydata2$noncompliance_vte_aoa_routine_prophyl, useNA = "always", dnn = "Non-compliance, Routine VTE risk chemical and mechanical prophylaxis") #28 NA ## AOA 2 Patient level compliance - Patients with routine VTE risk received routine risk recommended and non-compliant AOA 2 prophylaxis mydata2 <- mydata2 %>% mutate(aoa_routine_riskpt_routine_compliance = if_else( aoa_pt_risk == 1 & aoa_routine_compliance == 1, 1L, if_else( aoa_pt_risk == 1 & aoa_routine_compliance == 0, 0L, if_else( aoa_pt_risk %in% c(0,2), 3L, NA_integer_)))) table(mydata2$aoa_routine_riskpt_routine_compliance, useNA = "always", dnn = "Patients at routine VTE risk, AOA routine compliance") # 27 NA, 1687 had appropriate prophylaxis mydata2 <- mydata2 %>% mutate(noncompliance_aoa_routine_riskpt_routine = if_else(aoa_routine_riskpt_routine_compliance == 0, 1L, 0L)) table(mydata2$noncompliance_aoa_routine_riskpt_routine, useNA = "always", dnn = "Patients at routine VTE risk, recevied non-compliant routine risk care") #vte_aoa_general_rec, vte_icp, vte_aoa_routine_chemo, aoa_routine_compliance, noncompliance_vte_aoa_routine_prophyl, aoa_routine_compliance2, aoa_routine_riskpt_routine_compliance, noncompliance_aoa_routine_riskpt_routine ``` # Step 1.1.4. Calculate compliance with HIGH VTE RISK prophylaxis, AOA VTE Guidelines ```{r AOA Overall VTE compliance, High risk} # Calculate compliance with AOA 3. Patients with with High Risk Of VTE recommendations ### Peri-operative options include:- 1. SCD in combination with: 2. Warfarin – return to pre op level or if not previously on warfarin ≥ 2 3. LMWH 4. DOAC (eg Rivaroxaban) and ignore 5. IVC filters (evidence for the benefits in arthroplasty patients is very weak) ### Limitation, INR values unknown mydata2 <- mydata2 %>% mutate(aoa_highrisk_prophyl = if_else( (vte_icp_foot == 1 | vte_icp_calf == 1) & (vte_warf == 1 | vte_clex == 1 | vte_frag == 1 | vte_fondap == 1 | vte_riva == 1 | vte_dabig == 1), 1L, 0L)) table(mydata2$aoa_highrisk_prophyl, useNA = "always", dnn = "Received recommended VTE prophylaxis for high risk pts") # 27 NA mydata2$aoa_highrisk_compliance <- mydata2$aoa_highrisk_prophyl # Calculate Overall compliance HIGH risk prophylaxis, EXCLUDING GENERAL RECS mydata2 <- mydata2 %>% mutate(noncompliance_aoa_highrisk = 1L - aoa_highrisk_compliance) table(mydata2$noncompliance_aoa_highrisk, useNA = "always", dnn = "Care compliant with HIGH VTE risk AOA recommendations, excluding general") # PATIENT LEVEL COMPLIANCE - Did patients get recommended prophylaxis according to identified risk ## Patients with high VTE risk received HIGH RISK recommended prophylaxis mydata2 <- mydata2 %>% mutate(aoa_highriskpt_highriskcompliance = if_else( aoa_pt_risk == 2 & (!is.na(aoa_highrisk_compliance) & aoa_highrisk_compliance == 1), 1L, if_else( aoa_pt_risk == 2 & (!is.na(aoa_highrisk_compliance) & aoa_highrisk_compliance == 0), 0L, if_else( aoa_pt_risk %in% c(0,1), 3L, NA_integer_)))) table(mydata2$aoa_highriskpt_highriskcompliance, useNA = "always", dnn = "Patients at HIGH VTE risk received AOA High VTE risk compliant prophylaxis") ## Noncompliant high risk patients mydata2 <- mydata2 %>% mutate(noncompliance_highriskpt_highrisk= if_else( aoa_highriskpt_highriskcompliance == 0, 1L, if_else( aoa_highriskpt_highriskcompliance == 1, 0L, NA_integer_))) table(mydata2$noncompliance_highriskpt_highrisk, useNA = "always", dnn = "Patients at HIGH VTE risk received AOA High VTE risk compliant prophylaxis") # 1720 NA ``` # Step 1.1.5. Calculate compliance with High Bleeding Risk recommendations, AOA VTE Guidelines ```{r AOA Overall VTE compliance, high bleeding risk} # Limitations, data on risk of major bleeding may be insufficient to use in analyses ## AOA 4. Mechanical prophylaxis only for high bleeding risk only, SCD only - missing NA, but as noone compliant this doesn't change results mydata2 <- mydata2 %>% mutate(aoa_bleed_risk_prophylcompliancel = if_else( (!is.na(vte_icp) & vte_icp_foot == 1 | !is.na(vte_icp) & vte_icp_calf == 1) & vte_chemo_yesno == 0, 1L, if_else( vte_icp_foot == 0 & vte_icp_calf == 0 | vte_chemo_yesno == 1, 0L, NA_integer_))) table(mydata2$aoa_bleed_risk_prophylcompliance, useNA = "always", dnn = "Received recommended VTE prophylaxis for high BLEEDING risk pts") # 27 NA mydata2 <- mydata2 %>% mutate(aoa_bleed_risk_prophylcompliance = if_else( vte_chemo_yesno == 0 & (!is.na(vte_icp) & (vte_icp_foot == 1 | vte_icp_calf == 1)), 1L, if_else( vte_chemo_yesno == 1 | !is.na(vte_icp) & vte_icp_foot == 0 & vte_icp_calf == 0, 0L, NA_integer_))) table(mydata2$aoa_bleed_risk_prophylcompliance, useNA = "always", dnn = "AOA VTE High bleeding risk compliance, no chemical prophylaxis, mechanical only") mydata2 <- mydata2 %>% mutate(noncompliance_aoa_bleed_risk_prophyl = 1L - aoa_bleed_risk_prophylcompliance) table(mydata2$noncompliance_aoa_bleed_risk_prophyl, useNA = "always", dnn = "Non-compliant HIGH bleeding risk VTE prophylaxis") # AOA 4 COMPLIANCE with relevant AOA 1. General and AOA 4.High bleeding risk recommendations, including cessation preop meds mydata2 <- mydata2 %>% mutate(vte_aoa_bleed_risk_compliance = if_else( aoa_bleed_risk_prophylcompliance == 1, 1L, if_else( aoa_bleed_risk_prophylcompliance == 0, 0L, NA_integer_))) table(mydata2$vte_aoa_bleed_risk_compliance, useNA = "always", dnn = "AOA VTE High bleeding risk compliant VTE and general prophylaxis") mydata2 <- mydata2 %>% mutate(noncompliance_aoa_bleed_risk_overall = 1L - vte_aoa_bleed_risk_compliance) table(mydata2$noncompliance_aoa_bleed_risk_overall, useNA = "always", dnn = "Patients at HIGH bleeding risk, recevied non-compliant HIGH bleeding risk VTE and general prophylaxis") # PATIENT LEVEL COMPLIANCE - Did patients get recommended prophylaxis according to identified risk ## Patients with high bleeding risk only received recommended prophylaxis, None of the 10 people at high bleeeding risk received compliant care, one person not considered at high bleeding risk received reocmmended high bleeding risk prophylaxis mydata2 <- mydata2 %>% mutate(aoa_bleedriskpt_bleedriskcompliance = if_else( aoa_pt_risk == 0 & vte_aoa_bleed_risk_compliance == 1, 1L,if_else( aoa_pt_risk == 0 & vte_aoa_bleed_risk_compliance == 0, 0L, if_else( aoa_pt_risk %in% c(1,2), 2L, NA_integer_)))) table(mydata2$aoa_bleedriskpt_bleedriskcompliance, useNA = "always", dnn = "AOA VTE High bleeding patient, received high bleeding risk compliant care") mydata2 <- mydata2 %>% mutate(noncompliance_aoa_bleedriskpt_bleedrisk = if_else( aoa_bleedriskpt_bleedriskcompliance == 1, 0L,if_else( aoa_bleedriskpt_bleedriskcompliance == 0, 1L, NA_integer_))) table(mydata2$noncompliance_aoa_bleedriskpt_bleedrisk, useNA = "always", dnn = "Patients at HIGH bleeding risk, recevied non-compliant HIGH bleeding risk prophylaxis") ``` ## Step 1.1.6 Overall cohort Patient risk-stratified AOA VTE prophylaxis compliance ```{r AOA Overall VTE compliance, whole cohort} # Check compliance for participants in each risk level, 1 compliant, 0 noncompliant, 3 indicates other level of risk table(mydata2$aoa_pt_risk, useNA = "always", dnn = "AOA Patient level of risk") # Overall cohort compliance and noncompliance with risk-stratified prophylaxis, How many people in cohort received risk-stratified complaint VTE prophylaxis mydata2 <- mydata2 %>% mutate(aoa_cohortcompliance = if_else( aoa_routine_riskpt_routine_compliance == 1 | aoa_highriskpt_highriskcompliance == 1 | aoa_bleedriskpt_bleedriskcompliance == 1, 1L, 0L)) table(mydata2$aoa_cohortcompliance, useNA = "always", dnn = "Received AOA VTE compliant prophylaxis according to level of risk") #29 NA mydata2 <- mydata2 %>% mutate(aoa_cohort_noncompliance = 1L - aoa_cohortcompliance) table(mydata2$aoa_cohort_noncompliance, useNA = "always", dnn = "Received AOA VTE NON-compliant prophylaxis according to level of risk") ## FILTER TO PEOPLE WITH PRIMARY PREDICTORs, COMPLIANCE DATA mydata2 <- mydata2 %>% mutate(missing_compliance = if_else(is.na(noncompliant_vte_prophyl_durat) | is.na(vte_aoa_general_rec) | is.na(aoa_cohortcompliance), 1L, 0L)) table(mydata2$missing_compliance) # 37 people with no compliance data mydata2 <- mydata2 %>% filter((noncompliant_vte_prophyl_durat %in% c(0,1) & vte_aoa_general_rec %in% c(0,1) & aoa_cohortcompliance %in% c(0,1))) table(mydata2$aoa_pt_risk) ``` # Step 1.2 OUTCOMES ```{r VTE outcomes, 90 days} ## Create VTE between 0-90 days, NA for timeframe ignored if cc_vte_yesno = 0, did not have a VTE mydata2 <- mydata2 %>% mutate(vte_90days = if_else( cc_vte_yesno == 1 & cc_vte_followup %in% c(0, 1, 2) == 1, 1L, 0L)) table(mydata2$vte_90days, useNA = "always", dnn = "VTE 0-90 days") # Identify Symptomatic VTE's within 90 days and name this variable "symptvte90", excludes if unknown or assymtpomatic mydata2 <- mydata2 %>% mutate(symptvte90 = if_else(vte_90days == 1 & cc_vte_first_type %in% c(0:2), "Yes", "No")) table(mydata2$symptvte90, useNA = "always", dnn = "Symptomatic VTE 0-90 days") # Check for missing cases with outcome AND primary predictor variables table(noncom_prophyl = mydata2$aoa_cohort_noncompliance, vtesympt90 = mydata2$symptvte90, useNA = "always") table(duratcom = mydata2$vte_drug_anydurat_cat, vtesympt90 = mydata2$symptvte90, useNA = "always") table(genreccom = mydata2$vte_aoa_general_rec, vtesympt90 = mydata2$symptvte90, useNA = "always") # Check association between VTE outcomes and difference between VTE prophylaxis duration and commencement Rx table(mydata2$symptvte90, mydata2$vte_rx_proph_days, useNA = "always") ``` ## Step 1.3. Create other predictor variables ```{r calculate other predictors} # Create demographics variables ### Convert ASA score into dichotomous variable, convert "9" to NA for variable "asa" and dichotomise into new variable "ASA" with two levels: #### zero is "1,2" and 1 is ASA "3,4" mydata2 <- mydata2 %>% mutate(ASA = if_else( asa %in% c(1L,2L), 0L, if_else( asa %in% c(3L,4L), 1L, NA_integer_ ) )) table(mydata2$ASA, exclude = NULL, dnn = "ASA grade dichotomised") ### Convert edu into dichotomous variable # 0, None | 1, Year 8 or below | 2, Year 10 or below | 3, Completed school | 4, TAFE | 5, University | 999, Not stated/Unknown mydata2 <- mydata2 %>% mutate(edu = if_else( edu %in% c(0,1,2,3), 0L, if_else( edu %in% c(4,5), 1L, NA_integer_ ))) table(mydata2$edu, exclude = NULL, dnn = "Education") ### Convert smoking status into dichotomous variable, #### Smoker: 0, Never smoked | 1, Ex smoker | 2, Current smoker | 999, Unkown/Not stated mydata2 <- mydata2 %>% mutate(smoker = (if_else( smoker == 2, 1L, if_else( smoker == 999, NA_integer_, 0L )))) table(mydata2$smoker, dnn = "Current smoker", exclude=NULL) ## Modify acute care variables ### Create new variable "bilat" (bilateral, yes/no) from variable "side" table(mydata2$side, exclude = NULL, dnn = "Operative side: L, R, bilateral") mydata2<- mydata2 %>% mutate(bilat = if_else( side < 2, 0L, if_else( side == 2, 1L, NA_integer_))) table(mydata2$bilat, exclude = NULL, dnn = "Bilateral") ``` ## Step 1.4. Create supplementary data ```{r Ab supplementary data} ### Collapse heparin prophylaxis, still small numbers, exclude mydata2 <- mydata2 %>% mutate(vte_heps = if_else( vte_hep == 0 & vte_unfhep == 0, 0L,if_else( (vte_hep == 1 | vte_unfhep == 1), 1L, NA_integer_))) table(mydata2$vte_heps, exclude = NULL, dnn = "Received Heparin VTE Prophylaxis") ## Explore tourniquet use, better to use original dichotomous tourn variable, note missing for hips ### TKR and tourniquet use including whether deflated, zero no tourn, 1 tourn not defl, 2 tourn delfated mydata2 <- mydata2 %>% mutate(tourniquet = if_else(joint == 1 & tourn == 0, 0L, if_else(joint == 1 & tourn == 1 & tourn_defl == 0, 1L, if_else(joint == 1 & tourn == 1 & tourn_defl ==1, 2L, NA_integer_)))) table(mydata2$tourniquet, dnn ="Use of tourniquet", exclude = NULL) ## Explore multiple VTE medications mydata2 <- mydata2 %>% mutate(vte_riva_count = vte_riva) mydata2$vte_riva_count <- as.numeric(mydata2$vte_riva_count) mydata2 <- mydata2 %>% mutate(vte_dabig_count = vte_dabig) mydata2$vte_dabig_count <- as.numeric(mydata2$vte_dabig_count) mydata2 <- mydata2 %>% mutate(vte_clex_count = vte_clex) mydata2$vte_clex_count <- as.numeric(mydata2$vte_clex_count) mydata2 <- mydata2 %>% mutate(vte_frag_count = vte_frag) mydata2$vte_frag_count <- as.numeric(mydata2$vte_frag_count) mydata2 <- mydata2 %>% mutate(vte_aspir_count = vte_aspir) mydata2$vte_aspir_count <- as.numeric(mydata2$vte_aspir_count) mydata2 <- mydata2 %>% mutate(vte_warf_count = vte_warf) mydata2$vte_warf_count <- as.numeric(mydata2$vte_warf_count) mydata2 <- mydata2 %>% mutate(vte_heps_count = vte_heps) mydata2$vte_vte_heps <- as.numeric(mydata2$vte_heps_count) ### Note noone had fondaparinux # Number pf VTE prophylais medications received by each person mydata2<- mydata2 %>% mutate(vte_meds_count = vte_riva_count + vte_dabig_count + vte_heps_count + vte_warf_count + vte_aspir_count + vte_clex_count + vte_frag_count) table(mydata2$vte_meds_count, dnn = "Number prophylactic VTE medications taken by each person") mydata2 <-mydata2 %>% mutate(vte_noac_count = vte_riva_count + vte_dabig_count) table(mydata2$vte_noac_count, dnn = "Number NOAC VTE medications taken by each person") table(noac = mydata2$vte_noac_count, clex = mydata2$vte_clex_count) table(noac = mydata2$vte_noac_count, frag = mydata2$vte_frag_count) table(noac = mydata2$vte_noac_count, aspir = mydata2$vte_aspir_count, clex = mydata2$vte_clex_count) ``` ##Step 2: Categorise variables ```{r categorise variables} # Categorise variables as needed catvars <- c("pers_sex", "hr_prev", "kr_prev", "ins_status", "vte_prev_vte", "cc_hd", "cc_diab", "cc_stroke", "cc_hbp", "cc_cholesterol", "cc_kd", "cc_lud", "copd", "cc_livd", "cc_cancer", "vte_noac_count", "ph_cancer", "cc_dep", "cc_mentalh", "cc_gord", "cc_sleep_apnoea", "cc_nc", "cc_msk", "cc_oth", "edu", "bilat", "smoker", "ASA", "hosp_name", "hosp_pub_priv", "cement_fix", "bld_transf", "txa", "idc", "joint", "neurax", "tourn", "drain", "arth_meds_none", "arth_meds_non_nsaids", "arth_meds_nsaids", "arth_meds_steroids", "arth_meds_antidep", "arth_meds_Opioids", "vte_preopmeds_contratype", "cc_death_yesno", "cc_vte_yesno", "vte_90days", "symptvte90", "cc_readmiss_yesno", "cc_reop_yesno", "cc_type_jtinfect", "vte_chemo_yesno", "vte_aoa_routine_chemo", "vte_icp", "vte_icp_foot", "vte_icp_calf", "vte_gcs", "vte_clex", "vte_frag", "vte_fondap", "vte_riva", "vte_dabig", "vte_hep", "vte_unfhep", "vte_warf", "vte_aspir", "vte_aspir_firstdose", "vte_highrisk_minor", "vte_highrisk_major", "vte_aoa_bleedrisk", "vte_1stmobil_day0", "vte_1stmobil_day1", "vte_dopp_pt", "aoa_pt_risk", "non_compliance_aoa_general_rec", "noncompliance_vte_aoa_routine_prophyl", "aoa_routine_compliance", "aoa_routine_riskpt_routine_compliance", "noncompliance_aoa_routine_riskpt_routine", "aoa_highrisk_prophyl", "aoa_highrisk_compliance", "aoa_highriskpt_highriskcompliance", "noncompliance_highriskpt_highrisk", "noncompliance_aoa_bleed_risk_prophyl", "aoa_bleed_risk_prophylcompliance", "vte_aoa_bleed_risk_compliance", "noncompliance_aoa_bleedriskpt_bleedrisk", "aoa_bleedriskpt_bleedriskcompliance", "aoa_cohort_noncompliance", "aoa_cohortcompliance", "vte_meds_count", "vte_highrisk_minor_count" ) mydata2[,catvars]<- lapply(mydata2[,catvars], factor) catvars2 <- c("vte_drug_anydurat_cat", "noncompliant_vte_prophyl_durat", "copd", "vte_mech_yesno", "cc_bleed", "cc_bleed_type_cat", "cardiac_plavix", "cardiac_plavix_cease", "cardiac_warfarin", "cardiac_warfarin_cease", "cease_preop_plavix", "cease_preop_warf", "vte_highrisk_minor", "vte_highrisk_major", "cc_death_surgeryrelated", "vte_heparin", "vte_heparin_cess" ) mydata2[,catvars2]<- lapply(mydata2[,catvars2], factor) # Combine hospitals 17 and 18 as they are from one surgical department and health service table(mydata2$hosp_name) levels(mydata2$hosp_name) <- c(1:17, 17, 19) ``` ##Step 3: Summarise and plot continuous variables ```{r plot cont variables} # Data summaries and visualisation hist(mydata2$age) boxplot(mydata2$age, vertical = TRUE) summary(mydata2$age, dnn = "Age") hist(mydata2$bmi) boxplot(mydata2$bmi, vertical = TRUE) summary(mydata2$bmi) hist(mydata2$vte_drug_anydurat_90) boxplot(mydata2$vte_drug_anydurat_90, vertical = TRUE) summary(mydata2$vte_drug_anydurat_90) ggplot(data = mydata2, aes(x = symptvte90, y = vte_drug_anydurat_90)) + geom_boxplot() mydata2$surg_duration <- as.numeric(mydata2$surg_duration) hist(mydata2$surg_duration) boxplot(mydata2$surg_duration, vertical = TRUE) summary(mydata2$surg_duration) mydata2$vte_anymech_time <- as.numeric(mydata2$vte_anymech_time) hist(mydata2$vte_anymech_time) boxplot(mydata2$vte_anymech_time, vertical = TRUE) summary(mydata2$vte_anymech_time) summary(mydata2$vte_clex_ceased) summary(mydata2$vte_frag_ceased) summary(mydata2$vte_riva_ceased) summary(mydata2$vte_dabig_ceased) summary(mydata2$vte_unfhep_ceased) summary(mydata2$vte_hep_ceased) summary(mydata2$vte_warf_ceased) summary(mydata2$vte_alt1_ceased) summary(mydata2$vte_aspir_ceased) summary(mydata2$vte_anymech_time, useNA = "always") summary(mydata2$vte_foot_durat, useNA = "always") summary(mydata2$vte_calf_durat, useNA = "always") table(mydata2$vte_alt1_name) #LOS considered a process or service outcome, not predictor of outcome hist(mydata2$los) boxplot(mydata2$los, vertical = TRUE) summary(mydata2$los) ``` ## Step 4.1: Describe data: Create Tables ```{r descriptive tables} ## Create Table One - used for bivariable analyses myvars_AOA <- c("pers_sex", "hr_prev", "kr_prev", "vte_prev_vte", "cc_hd", "cc_diab", "cc_bleed", "cc_stroke", "cc_hbp", "cc_cholesterol", "cc_kd", "ph_cancer", "cc_dep", "cc_sleep_apnoea", "cc_nc", "cc_oth", "edu", "bilat", "smoker", "ASA", "hosp_name", "hosp_pub_priv", "cement_fix", "bld_transf", "txa", "idc", "joint", "neurax", "tourn", "drain", "vte_dopp_pt", "arth_meds_none", "arth_meds_non_nsaids", "arth_meds_nsaids", "arth_meds_antidep", "arth_meds_Opioids", "vte_icp", "vte_gcs", "vte_clex", "vte_frag", "vte_riva", "vte_warf", "vte_aspir", "vte_1stmobil_day0", "vte_1stmobil_day1", "symptvte90", "aoa_pt_risk", "noncompliant_vte_prophyl_durat", "non_compliance_aoa_general_rec", "aoa_cohort_noncompliance", "age", "surg_duration", "bmi", "vte_anymech_time" ) tab1 <- CreateTableOne(data = mydata2, vars = myvars_AOA) summary(tab1, pDigits = 2) table(durat = mydata2$noncompliant_vte_prophyl_durat, joint = mydata2$joint) ## Create Table 3 and Supp Tables, AOA patient and compliance elements, and low event comorbidities (Table 2) mydata2 <- mydata2 %>% mutate(vte_lmwh = if_else( vte_clex == 1 | vte_frag == 1, 1L, 0L)) table(mydata2$vte_lmwh) myvars_prophyl <- c("ins_status", "cc_lud", "cc_livd", "cc_cancer", "cc_mentalh", "cc_gord", "cc_msk", "copd", "cc_bleed_type_cat", "arth_meds_steroids", "cc_bleed", "vte_aoa_bleedrisk", "vte_chemo_yesno", "vte_aoa_routine_chemo", "vte_icp_foot", "vte_icp_calf", "vte_mech_yesno", "vte_heparin", "vte_warf", "vte_alt1_name", "vte_aspir_firstdose", "vte_meds_count", "vte_noac_count", "vte_preopmeds_contratype", "vte_highrisk_minor", "vte_highrisk_major", "vte_aoa_bleedrisk", "vte_1stmobil_day0", "vte_1stmobil_day1", "cardiac_plavix", "cardiac_plavix_cease", "cardiac_plavix_cease_time", "cardiac_warfarin", "cardiac_warfarin_cease", "cardiac_warfarin_cease_time", "cease_preop_plavix", "cease_preop_warf", "vte_drug_anydurat_cat", "vte_drug_anydurat_90", "non_compliance_aoa_general_rec", "noncompliance_vte_aoa_routine_prophyl", "aoa_routine_compliance", "aoa_routine_riskpt_routine_compliance", "noncompliance_aoa_routine_riskpt_routine", "aoa_highrisk_prophyl", "aoa_highrisk_compliance", "aoa_highriskpt_highriskcompliance", "noncompliance_highriskpt_highrisk", "noncompliance_aoa_bleed_risk_prophyl", "aoa_bleed_risk_prophylcompliance", "vte_aoa_bleed_risk_compliance", "noncompliance_aoa_bleedriskpt_bleedrisk", "aoa_bleedriskpt_bleedriskcompliance", "aoa_cohort_noncompliance", "aoa_cohortcompliance", "vte_highrisk_minor_count", "vte_drug_anydurat" ) tab2 <- CreateTableOne(data = mydata2, vars = myvars_prophyl) summary(tab2, pDigits = 2) # Descriptive data for Table 4 myvars_aoa <- c("vte_heparin_cess", "vte_highrisk_minor", "vte_highrisk_major", "aoa_pt_risk", "non_compliance_aoa_general_rec", "noncompliance_vte_aoa_routine_prophyl", "aoa_routine_compliance", "aoa_routine_riskpt_routine_compliance", "noncompliance_aoa_routine_riskpt_routine", "aoa_highrisk_prophyl", "aoa_highrisk_compliance", "aoa_highriskpt_highriskcompliance", "noncompliance_highriskpt_highrisk", "noncompliance_aoa_bleed_risk_prophyl", "aoa_bleed_risk_prophylcompliance", "vte_aoa_bleed_risk_compliance", "noncompliance_aoa_bleedriskpt_bleedrisk", "aoa_bleedriskpt_bleedriskcompliance", "aoa_cohort_noncompliance", "aoa_cohortcompliance", "vte_highrisk_minor_count", "vte_drug_anydurat" ) tab3 <- CreateTableOne(data = mydata2, vars = myvars_aoa) summary(tab3, pDigits = 2) ``` ## Step 4.2: Describe Outcomes data: Create Tables ```{r descriptive tables} # Describe details of outcomes ## Create table to check timeframes of VTE diagnosis and duration VTE prophylaxis tab_outcomes <- CreateTableOne(data = mydata2, vars = c("cc_vte_followup", "vte_drug_anydurat_cat", "vte_clex_ceased","vte_frag_ceased", "vte_fondap_ceased", "vte_riva_ceased", "vte_dabig_ceased", "vte_unfhep_ceased", "vte_hep_ceased", "vte_warf_ceased", "vte_alt1_ceased", "vte_alt2_ceased", "vte_aspir_ceased", "vte_drug_anydurat_90", "vte_rx_comm"), strata = "symptvte90") print(tab_outcomes, showAllLevels = TRUE) ## VTE complications #0, PE and DVT | 1, PE only | 2, Symptomatic DVT | 3, Assymptomatic DVT | 4, DVT, unknown if symptomatic | 5, NONE, No VTE | 999, Not stated/Unknown ## Create table one to check timeframes of VTE diagnosis and duration VTE prophylaxis tab_outcomes <- CreateTableOne(data = mydata2, vars = c("cc_vte_yesno", "cc_vte_acute", "cc_vte_0_35days", "cc_vte_0_90days", "cc_vte_second_yesno", "cc_vte_third_yesno", "cc_vte_fourth_yesno", "cc_vte_first_type", "cc_vte_second_type", "cc_vte_third_type","cc_vte_fourth_type"), strata = "symptvte90") print(tab_outcomes, showAllLevels = TRUE) ## Type VTE on each occassion table(type1st = mydata2$cc_vte_first_type, symptvte = mydata2$symptvte90, useNA = "always") table(type2nd = mydata2$cc_vte_second_type, symptvte = mydata2$symptvte90, useNA = "always") table(type3rd = mydata2$cc_vte_third_type, symptvte = mydata2$symptvte90, useNA = "always") table(type4th = mydata2$cc_vte_fourth_type, symptvte = mydata2$symptvte90, useNA = "always") ## Timeframe VTE events table(type1st = mydata2$cc_vte_first_type, time_1stVTE = mydata2$cc_vte_followup, mydata2$symptvte90, useNA = "always") table(type2nd = mydata2$cc_vte_second_type, time_2ndVTE = mydata2$cc_vte_second_followup, mydata2$symptvte90, useNA = "always") table(type3rd = mydata2$cc_vte_third_type, time_3rdtVTE = mydata2$cc_vte_third_followup, mydata2$symptvte90, useNA = "always") table(type4th = mydata2$cc_vte_fourth_type, time_4thVTE = mydata2$cc_vte_fourth_followup, mydata2$symptvte90, useNA = "always") ### Followup period for VTE events table(time_1stVTE = mydata2$cc_vte_followup, symptvte = mydata2$symptvte90, useNA = "always") table(time_2ndVTE = mydata2$cc_vte_second_followup, symptvte = mydata2$symptvte90, useNA = "always") table(time_3rdtVTE = mydata2$cc_vte_third_followup, symptvte = mydata2$symptvte90, useNA = "always") table(time_4thVTE = mydata2$cc_vte_fourth_followup, symptvte = mydata2$symptvte90, useNA = "always") ## 1ST VTE EVENTS mydata2 <- mydata2 %>% mutate(vte_1st_acute = if_else( cc_vte_first_type == 0 & cc_vte_followup == 0, 0L, if_else( cc_vte_first_type == 1 & cc_vte_followup == 0, 1L, if_else( cc_vte_first_type == 2 & cc_vte_followup == 0, 2L, 5L)))) table(mydata2$vte_1st_acute, useNA = "always", dnn = "Type 1st VTE during acute admission", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_1st_dcto35days = if_else( cc_vte_first_type == 0 & cc_vte_followup == 1, 0L, if_else( cc_vte_first_type == 1 & cc_vte_followup == 1, 1L, if_else( cc_vte_first_type == 2 & cc_vte_followup == 1, 2L, 3L)))) table(mydata2$vte_1st_dcto35days, useNA = "always", dnn = "Type 1st VTE between acute admission and 35 days", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_1st_36to90days = if_else( cc_vte_first_type == 0 & cc_vte_followup == 2, 0L, if_else( cc_vte_first_type == 1 & cc_vte_followup == 2 , 1L, if_else( cc_vte_first_type == 2 & cc_vte_followup == 2, 2L, 3L)))) table(mydata2$vte_1st_36to90days, useNA = "always", dnn = "Type 1st VTE between acute admission and 35 days", exclude = NULL) ## SECOND VET EVENT mydata2 <- mydata2 %>% mutate(vte_2nd_acute = if_else( cc_vte_second_type == 0 & cc_vte_second_followup == 0, 0L, if_else( cc_vte_second_type == 1 & cc_vte_second_followup == 0, 1L, if_else( cc_vte_first_type == 2 & cc_vte_second_followup == 0, 2L, 3L)))) table(mydata2$vte_2nd_acute, useNA = "always", dnn = "Type 2nd VTE during acute admission", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_2nd_dcto35days = if_else( cc_vte_second_type == 0 & cc_vte_second_followup == 1, 0L, if_else( cc_vte_second_type == 1 & cc_vte_second_followup == 1, 1L, if_else( cc_vte_first_type == 2 & cc_vte_second_followup == 1, 2L, 3L)))) table(mydata2$vte_2nd_dcto35days, useNA = "always", dnn = "Type 2nd VTE between acute admission and 35 days", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_2nd_36to90days = if_else( cc_vte_second_type == 0 & cc_vte_second_followup == 2, 0L, if_else( cc_vte_second_type == 1 & cc_vte_second_followup == 2, 1L, if_else( cc_vte_first_type == 2 & cc_vte_second_followup == 2, 2L, 3L)))) table(mydata2$vte_2nd_36to90days, useNA = "always", dnn = "Type 2nd VTE between acute admission and 35 days", exclude = NULL) # Type of VTE event experienced during acute admission table(mydata2$cc_vte_followup, useNA = "always", dnn = "Time period for First VTE", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_2nd_acute = if_else( cc_vte_second_type == 0 & cc_vte_second_followup == 0, 0L, if_else( cc_vte_second_type == 1 & cc_vte_second_followup == 0, 1L, if_else( cc_vte_first_type == 2 & cc_vte_second_followup == 0, 2L, 3L)))) table(mydata2$vte_2nd_acute, useNA = "always", dnn = "Type 2nd VTE during acute admission", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_3rd_acute = if_else( cc_vte_third_type == 0 & cc_vte_third_followup == 0, 0L, if_else( cc_vte_third_type == 1 & cc_vte_third_followup == 0, 1L, if_else( cc_vte_third_type == 2 & cc_vte_third_followup == 0, 2L, 3L)))) table(mydata2$vte_3rd_acute, useNA = "always", dnn = "Type 3rd VTE during acute admission", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_4th_acute = if_else( cc_vte_fourth_type == 0 & cc_vte_fourth_followup == 0, 0L, if_else( cc_vte_fourth_type == 1 & cc_vte_fourth_followup == 0, 1L, if_else( cc_vte_fourth_type == 2 & cc_vte_fourth_followup == 0, 2L, 3L)))) table(mydata2$vte_4th_acute, useNA = "always", dnn = "Type 4th VTE during acute admission", exclude = NULL) ## VTE complications #0, PE and DVT | 1, PE only | 2, Symptomatic DVT | 3, Assymptomatic DVT | 4, DVT, unknown if symptomatic | 5, NONE, No VTE | 999, Not stated/Unknown # Type of VTE event experienced between acute admission and 35 days mydata2 <- mydata2 %>% mutate(vte_1st_dcto35days = if_else( cc_vte_first_type == 0 & cc_vte_followup == 1, 0L, if_else( cc_vte_first_type == 1 & cc_vte_followup == 1, 1L, if_else( cc_vte_first_type == 2 & cc_vte_followup == 1, 2L, 3L)))) table(mydata2$vte_1st_dcto35days, useNA = "always", dnn = "Type 1st VTE between acute admission and 35 days", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_2nd_dcto35days = if_else( cc_vte_second_type == 0 & cc_vte_second_followup == 1, 0L, if_else( cc_vte_second_type == 1 & cc_vte_second_followup == 1, 1L, if_else( cc_vte_first_type == 2 & cc_vte_second_followup == 1, 2L, 3L)))) table(mydata2$vte_2nd_dcto35days, useNA = "always", dnn = "Type 2nd VTE between acute admission and 35 days", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_3rd_dcto35days = if_else( cc_vte_third_type == 0 & cc_vte_third_followup == 1, 0L, if_else( cc_vte_third_type == 1 & cc_vte_third_followup == 1, 1L, if_else( cc_vte_third_type == 2 & cc_vte_third_followup == 1, 2L, 3L)))) table(mydata2$vte_3rd_dcto35days, useNA = "always", dnn = "Type 3rd VTE between acute admission and 35 days", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_4th_dcto35days = if_else( cc_vte_fourth_type == 0 & cc_vte_fourth_followup == 1, 0L, if_else( cc_vte_fourth_type == 1 & cc_vte_fourth_followup == 1, 1L, if_else( cc_vte_fourth_type == 2 & cc_vte_fourth_followup == 1, 2L, 3L)))) table(mydata2$vte_4th_dcto35days, useNA = "always", dnn = "Type 4th VTE between acute admission and 35 days", exclude = NULL) # Type of VTE event experienced between 36 to 90 days mydata2 <- mydata2 %>% mutate(vte_1st_36to90days = if_else( cc_vte_first_type == 0 & cc_vte_followup == 2, 0L, if_else( cc_vte_first_type == 1 & cc_vte_followup == 2 , 1L, if_else( cc_vte_first_type == 2 & cc_vte_followup == 2, 2L, 3L)))) table(mydata2$vte_1st_36to90days, useNA = "always", dnn = "Type 1st VTE between acute admission and 35 days", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_2nd_36to90days = if_else( cc_vte_second_type == 0 & cc_vte_second_followup == 2, 0L, if_else( cc_vte_second_type == 1 & cc_vte_second_followup == 2, 1L, if_else( cc_vte_first_type == 2 & cc_vte_second_followup == 2, 2L, 3L)))) table(mydata2$vte_2nd_36to90days, useNA = "always", dnn = "Type 2nd VTE between acute admission and 35 days", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_3rd_36to90days = if_else( cc_vte_third_type == 0 & cc_vte_third_followup == 2, 0L, if_else( cc_vte_third_type == 1 & cc_vte_third_followup == 2, 1L, if_else( cc_vte_third_type == 2 & cc_vte_third_followup == 2, 2L, 3L)))) table(mydata2$vte_3rd_36to90days, useNA = "always", dnn = "Type 3rd VTE between acute admission and 35 days", exclude = NULL) mydata2 <- mydata2 %>% mutate(vte_4th_36to90days = if_else( cc_vte_fourth_type == 0 & cc_vte_fourth_followup == 2, 0L, if_else( cc_vte_fourth_type == 1 & cc_vte_fourth_followup == 2, 1L, if_else( cc_vte_fourth_type == 2 & cc_vte_fourth_followup == 2, 2L, 3L)))) table(mydata2$vte_4th_36to90days, useNA = "always", dnn = "Type 4th VTE between acute admission and 35 days", exclude = NULL) #Bleeding outcomes - Joint and non-joint, within 36-90 days mydata2 <- mydata2 %>% mutate(cc_type_jtbleed90 = if_else( mydata2$cc_type_jtbleed == 1 & (cc_type_jtbleed_time___0 == 1 | cc_type_jtbleed_time___1 == 1 | cc_type_jtbleed_time___2 == 1), 1L, 0L)) table(mydata2$cc_type_jtbleed90, useNA = "always", dnn = "Joint related bleeding complications between 36 - 9 0 days", exclude = NULL) mydata2 <- mydata2 %>% mutate(cc_type_otherbleed90 = if_else( mydata2$cc_type_otherbleed == 1 & (cc_type_otherbleed_time___0 == 1 | cc_type_otherbleed_time___1 == 1 | cc_type_otherbleed_time___2 == 1), 1L, 0L)) table(mydata2$cc_type_otherbleed90, useNA = "always", dnn = "Other, non-Joint, related bleeding complications between 36 - 9 0 days", exclude = NULL) table(mydata2$cc_type_jtbleed,useNA = "always", dnn = "Joint related bleeding complications", exclude = NULL) table(mydata2$cc_type_jtbleed_type, useNA = "always", dnn = "Severity of joint related bleeding complications", exclude = NULL) table(mydata2$cc_type_otherbleed, useNA = "always", dnn = "Non-joint related bleeding complications", exclude = NULL) table(mydata2$cc_type_otherbleed_type, useNA = "always", dnn = "Severity of non-joint related bleeding complications", exclude = NULL) #Timeframe for bleeding is a checkbox variable - creates separate variable for each possible code: 0, During Acute admission | 1, Between acute discharge and 35 days | 2, Between 36-90 days | 3, Between 91-365 days | 999, Not stated/Unknown table(mydata2$cc_type_jtbleed_time___0, useNA = "always", dnn = " Experienced joint related bleeding complications during acute admission", exclude = NULL) table(mydata2$cc_type_jtbleed_time___1, useNA = "always", dnn = "Experienced joint related bleeding complications betweeen acute discharge and 35 days", exclude = NULL) table(mydata2$cc_type_jtbleed_time___2, useNA = "always", dnn = "Experienced joint related bleeding complications betweeen 36 - 90 days", exclude = NULL) table(mydata2$cc_type_otherbleed) #Timeframes non-joint bleeding table(mydata2$cc_type_otherbleed_time___0, useNA = "always", dnn = "Non-joint related bleeding complications duing acute admission", exclude = NULL) table(mydata2$cc_type_otherbleed_time___1, useNA = "always", dnn = "Non-joint related bleeding complications betwen acute discharge and 35 days", exclude = NULL) table(mydata2$cc_type_otherbleed_time___2, useNA = "always", dnn = "Non-joint related bleeding complications betwen 36-90 days", exclude = NULL) table(mydata2$cc_type_otherbleed_time___0, mydata2$cc_type_otherbleed_time___1, dnn = "Person with two episodes of other non-jt bleeding") ## Create outcomes Table catvarso <- c("cc_death_yesno", "cc_vte_yesno", "vte_90days", "symptvte90", "vte_1st_acute", "vte_2nd_acute", "vte_3rd_acute", "vte_1st_36to90days", "vte_2nd_36to90days", "vte_3rd_36to90days", "cc_vte_followup", "cc_vte_second_followup","cc_vte_third_followup", "cc_type_jtbleed90", "cc_type_otherbleed90", "cc_type_jtbleed", "cc_type_jtbleed_type", "cc_type_otherbleed", "cc_type_otherbleed_type", "cc_type_jtbleed_time___0", "cc_type_jtbleed_time___1", "cc_type_jtbleed_time___2","cc_type_otherbleed_time___0", "cc_type_otherbleed_time___1", "cc_type_otherbleed_time___2") mydata2[,catvarso]<- lapply(mydata2[,catvarso], factor) myvars_vte <- c("cc_death_yesno", "cc_death_surgeryrelated", "vte_1st_acute", "vte_2nd_acute", "vte_3rd_acute", "vte_1st_36to90days", "vte_2nd_36to90days", "vte_3rd_36to90days", "cc_vte_followup", "cc_vte_second_followup", "cc_vte_third_followup", "cc_type_jtbleed90", "cc_type_otherbleed90", "cc_type_jtbleed", "cc_type_jtbleed_type", "cc_type_otherbleed", "cc_type_otherbleed_type", "cc_type_jtbleed_time___0", "cc_type_jtbleed_time___1", "cc_type_jtbleed_time___2", "cc_type_otherbleed_time___0", "cc_type_otherbleed_time___1", "cc_type_otherbleed_time___2" ) tab3 <- CreateTableOne(data = mydata2, vars = myvars_vte, strata = "symptvte90") summary(tab3, pDigits = 2) ``` ## Step 5: Bivariable (unadjusted) analyses ```{r bivariable analyses, VTE} # Unadjusted models, Association between VTE and VTE noncompliance, VTE and other key confounders CrossTable(mydata2$non_compliance_aoa_general_rec, mydata2$symptvte90, prop.r = TRUE, prop.c = FALSE, prop.t = FALSE) chisq.test(mydata2$symptvte90,mydata2$non_compliance_aoa_general_rec,) fisher.test(mydata2$symptvte90,mydata2$non_compliance_aoa_general_rec,) CrossTable(mydata2$aoa_cohort_noncompliance, mydata2$symptvte90, prop.r = TRUE, prop.c = FALSE, prop.t = FALSE) chisq.test(mydata2$symptvte90,mydata2$aoa_cohort_noncompliance,) fisher.test(mydata2$symptvte90,mydata2$aoa_cohort_noncompliance,) CrossTable(mydata2$noncompliant_vte_prophyl_durat, mydata2$symptvte90, prop.r = TRUE, prop.c = FALSE, prop.t = FALSE) chisq.test(mydata2$symptvte90,mydata2$noncompliant_vte_prophyl_durat,) fisher.test(mydata2$symptvte90,mydata2$noncompliant_vte_prophyl_durat,) CrossTable(mydata2$joint, mydata2$symptvte90, prop.r = TRUE, prop.c = FALSE, prop.t = FALSE) chisq.test(mydata2$symptvte90,mydata2$joint,) fisher.test(mydata2$symptvte90,mydata2$joint,) CrossTable(mydata2$vte_dopp_pt, mydata2$symptvte90, prop.r = TRUE, prop.c = FALSE, prop.t = FALSE) chisq.test(mydata2$symptvte90,mydata2$vte_dopp_pt,) fisher.test(mydata2$symptvte90,mydata2$vte_dopp_pt,) CrossTable(mydata2$vte_prev_vte, mydata2$symptvte90, prop.r = TRUE, prop.c = FALSE, prop.t = FALSE) chisq.test(mydata2$symptvte90,mydata2$vte_prev_vte,) fisher.test(mydata2$symptvte90,mydata2$vte_prev_vte,) CrossTable(mydata2$neurax, mydata2$symptvte90, prop.r = TRUE, prop.c = FALSE, prop.t = FALSE) chisq.test(mydata2$neurax,mydata2$symptvte90,) fisher.test(mydata2$neurax,mydata2$symptvte90,) # Test unadjusted assiociations with continuous predictors t.test(age ~ symptvte90, mydata2) boxplot(age ~ symptvte90, mydata2) t.test(bmi ~ symptvte90, mydata2) boxplot(bmi ~ symptvte90, mydata2) t.test(surg_duration ~ symptvte90, mydata2) boxplot(surg_duration ~ symptvte90, mydata2) #NEED TO cHECK DISTRIBUTION OF DATA, MAY NEED TO USE NON PARAMETRIC TESTS table(mydata2$vte_rx_comm, mydata2$vte_dopp_pt) table(mydata2$vte_drug_anydurat_90, mydata2$vte_dopp_pt) # No significant difference in day VTE treatment started based on whether they had routine doppler t.test(vte_rx_comm ~ vte_dopp_pt, mydata2) boxplot(vte_rx_comm ~ vte_dopp_pt, mydata2) # Duration prophylaxis statistically significant shorter in routine doppler group, means 26.7 vs 22.9 days t.test(vte_drug_anydurat_90 ~ vte_dopp_pt, mydata2) boxplot(vte_drug_anydurat_90 ~ vte_dopp_pt, mydata2) table(durat = mydata2$vte_drug_anydurat,symptvte = mydata2$symptvte90) table(fu = mydata2$cc_vte_followup, durat = mydata2$vte_drug_anydurat_cat, mydata2$symptvte90) ## Check factor structure prior to running bivariable analyses a <- function(var) { str(mydata2[,var]) } for(v in myvars_AOA) a(v) # Bivariate analyses, symptomatic VTE outcomes at 90 days bivar_screen <- NULL screenvar.ab <- function(var) { f <- as.formula(paste("symptvte90", var, sep = " ~ ")) a <- as_tibble(anova(glm(f, family=binomial(), data=mydata2), test="Chisq"))[2,] a$varname <- var return(rbind(bivar_screen, a)) } for(v in myvars_AOA) { bivar_screen <- screenvar.ab(v) } bivar_screen %>% arrange(`Pr(>Chi)`) %>% knitr::kable() ``` ## Step 6: Missing data Detect and deal with missing data, if necessary. ```{r cut data} # shrink dataset to variables of interest sort(sapply(mydata2, function(x) 100*sum(is.na(x))/length(x))) cutdata <- mydata2%>% dplyr::select(pers_sex, hr_prev, kr_prev, vte_prev_vte, cc_hd, cc_diab, cc_bleed, cc_stroke, cc_hbp, cc_cholesterol, cc_kd, ph_cancer, cc_dep, cc_gord, cc_sleep_apnoea, cc_nc, cc_oth, edu, bilat, smoker, ASA, hosp_name, hosp_pub_priv, cement_fix, bld_transf, txa, idc, joint, neurax, drain, vte_dopp_pt, arth_meds_none, arth_meds_non_nsaids, arth_meds_nsaids, arth_meds_steroids, arth_meds_antidep, arth_meds_Opioids, vte_90days, symptvte90, vte_icp, vte_icp_foot ,vte_icp_calf, vte_clex, vte_frag, vte_fondap, vte_riva, vte_dabig, vte_hep, vte_unfhep, vte_warf, vte_aspir, vte_aoa_bleedrisk, vte_aspir, vte_1stmobil_day0, vte_1stmobil_day1, symptvte90, aoa_pt_risk, vte_drug_anydurat_90, noncompliant_vte_prophyl_durat, vte_drug_anydurat_cat, vte_drug_anydurat_90, non_compliance_aoa_general_rec, aoa_cohort_noncompliance, aoa_cohortcompliance, age, surg_duration, bmi, vte_anymech_time, surgeon, vte_rx_comm, vte_rx_proph_days, vte_rx_minus_proph) plot_str(cutdata) sort(sapply(cutdata, function(x) 100*sum(is.na(x))/length(x))) ncol(cutdata) #remove tourniquet, ASA # identify missing data library(Amelia) missmap(cutdata, main = "Missing values vs observed") length(cutdata) length(cutdata$age) nrow(cutdata) # library(VIM) # aggr(cutdata,numbers=TRUE, sortVars=TRUE) # impute missing data library(mice) set.seed(123) cutdata_imputed <- mice(cutdata, m=5, maxit=10, meth='pmm', seed=500, printFlag=FALSE) summary(cutdata_imputed) imputed_data <- complete(cutdata_imputed) #complete data set takes of of the 5 imputed data sets # generate dataset with missing data removed for sensitivity analysis using complete case analysis ( ) no_NAdata_aoa <- na.omit(cutdata) ``` ## Step 7: Modelling: Research Question 1: AOA VTE and VTE outomes *Predictor*: AOA VTE Prophylaxis non-compliance [variables: aoa_cohort_noncompliance] *Outcome*: Symptomatic VTE events between 0 - 90 days (variable:symptvte90) **Method**: backwards stepwise regression starting with the main predictor (symptomatic VTE events at 90 days), and any variable with p < 0.25 on bivariable analysis. Criteria: AIC. ```{r Model_AOA VTE prophylaxis & VTE} # Model with symptomatic 90 days VTE, excludes assymptomatic events, noncompliant_vte_prophyl_durat - minimum 21 days VTE duration modelAOA1 <- glm(symptvte90 ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + joint + cement_fix + bmi + vte_dopp_pt + hr_prev + vte_prev_vte + vte_aspir + cc_hd + pers_sex + drain + surg_duration + smoker + hosp_pub_priv + vte_1stmobil_day1, data = imputed_data, family = "binomial") summary(modelAOA1) stepAOA1 <- stepAIC(modelAOA1, trace = 0, direction = "backward", scope = list(upper = modelAOA1, lower = ~ joint + aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat)) summary(stepAOA1) exp(cbind(OR = coef(stepAOA1), confint(stepAOA1))) # final model AOA1_reg <- function(x){ glm(symptvte90 ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + joint + bmi + vte_prev_vte, data = complete(cutdata_imputed, x), family = "binomial") } for(i in 1:5) print(exp(cbind(OR = coef(AOA1_reg(i)), confint(AOA1_reg(i)))) ) # Run final model using each of the 5 imputed datasets, model 1 # model averaging using imputed datasets on final model of modelAOA1 ma_aoa1 <- with(data=cutdata_imputed, exp=glm(symptvte90 ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + joint + bmi + vte_prev_vte + neurax, family = binomial)) ma_aoa1_pool <- pool(ma_aoa1) summary(ma_aoa1_pool, conf.int=TRUE, exponentiate = TRUE) #Check with interaction terms - none significant with primary variable modelAOA1_interact <- glm(symptvte90 ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + joint + bmi + vte_prev_vte + aoa_cohort_noncompliance*noncompliant_vte_prophyl_durat + non_compliance_aoa_general_rec*noncompliant_vte_prophyl_durat + joint*noncompliant_vte_prophyl_durat + bmi*noncompliant_vte_prophyl_durat + vte_prev_vte*noncompliant_vte_prophyl_durat, data = imputed_data, family = "binomial") summary(modelAOA1_interact) ``` # Step 8: Model diagnostics AOA VTE prophylaxis model ```{r Diagnostics Model AOA VTE prophylaxis} ## Check assumptions for regression library(broom) # Predict the probability (p) of outcome pAOA1 <- predict(stepAOA1, type = "response") predicted_AOA1 <- ifelse(pAOA1 > 0.5, "pos", "neg") head(predicted_AOA1) plot(pAOA1) # is there a criterion for outliers, #Assumption 1: Linearity diag_data <- imputed_data %>% dplyr::select_if(is.numeric) predictors <- colnames(diag_data) # Bind the logit and tidying the data for plot diag_data_AOA1 <- diag_data %>% mutate(logit = log(pAOA1/(1-pAOA1))) %>% gather(key = "predictors", value = "predictor.value", -logit) ggplot(diag_data_AOA1, aes(logit, predictor.value))+ geom_point(size = 0.5, alpha = 0.5) + geom_smooth(method = "loess") + theme_bw() + facet_wrap(~predictors, scales = "free_y") #Assumption 2: no influential observations plot(stepAOA1, which = 4, id.n = 3) model.data <- augment(stepAOA1) %>% mutate(index = 1:n()) model.data %>% top_n(3, .cooksd) ggplot(model.data, aes(index, .std.resid)) + geom_point(aes(color = symptvte90), alpha = .5) + theme_bw() # Assumption 3: No collinearity car::vif(stepAOA1) # All results under 5, highest 1.13 # Assumption 4: independence of observations ## assumed due to nature of study (separate patients) but possible role of grouping at level of hospital (not significant in model) # Check model fit ## calculate the AUC library(pROC) ## Type 'citation("pROC")' for a citation. rocAOA1 <- roc(stepAOA1$y ~ pAOA1) auc(rocAOA1) plot(rocAOA1) # calculate H-L goodness of fit library(ResourceSelection) hoslem.test(stepAOA1$y, fitted(stepAOA1)) # calculate pseudo-R squared library(DescTools) PseudoR2(stepAOA1, which = c("McFadden", "Nagelkerke")) ``` # Step 9: Sensitivity analyses ```{r Sensitivity AOA VTE prophylaxis} # run final model with missing data removed (AOA complete case analysis 1, no imputation) AOAmodelcca1 <- glm(formula = symptvte90 ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + joint + bmi + vte_prev_vte, family = "binomial", data = no_NAdata_aoa) cbind(OR = exp(AOAmodelcca1$coefficients), exp(confint(AOAmodelcca1))) stepAOAmodelcca1 <- stepAIC(AOAmodelcca1, trace = 0, direction = "backward", scope = list(upper = modelAOA1, lower = ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + joint)) summary(stepAOAmodelcca1) # Decision not to remove any potential outliers at this stage #Check for change in estimates cbind(OR = exp(stepAOAmodelcca1$coefficients), exp(confint(stepAOAmodelcca1))) #Predict the probability (p) of outcome pAOAmain <- predict(stepAOAmodelcca1, type = "response") predicted_AOAmain <- ifelse(pAOAmain > 0.5, "pos", "neg") head(predicted_AOAmain) plot(pAOAmain) # no outlier/s noted #Model diagnostics Sensitivity analysis # 1. check linearity # Select numeric predictors diag_data <- no_NAdata_aoa %>% dplyr::select_if(is.numeric) predictors <- colnames(diag_data) # Bind the logit and tidying the data for plot diag_data <- diag_data %>% mutate(logit = log(pAOAmain/(1-pAOAmain))) %>% gather(key = "predictors", value = "predictor.value", -logit) ggplot(diag_data, aes(logit, predictor.value))+ geom_point(size = 0.5, alpha = 0.5) + geom_smooth(method = "loess") + theme_bw() + facet_wrap(~predictors, scales = "free_y") # linearity improved afer removal of... # 2. look for influential points plot(AOAmodelcca1, which = 4, id.n = 3) model.AOAdata <- augment(stepAOAmodelcca1) %>% mutate(index = 1:n()) model.AOAdata %>% top_n(3, .cooksd) ggplot(model.AOAdata, aes(index, .std.resid)) + geom_point(aes(color = symptvte90), alpha = .5) + theme_bw() ``` ## Step 9.a. Sensitivity analyses BIC criteria ```{r Sensitivity analyses BIC} # run Q1 main model using BIC criteria instead of AIC, AOA VTE prophylaxes stepAOA1BIC <- stepAIC(modelAOA1, k= log(1875), trace = 0, direction = "backward") summary(stepAOA1BIC) exp(cbind(OR = coef(stepAOA1BIC ), confint(stepAOA1BIC ))) ``` ## Step 9.b.Sensitivity analyses excluding participants who had ceased VTE prophylaxis to commence VTE treatment (i.e. day VTE prophyaxis ceased same as day VTE treatment started) ```{r Sensitivity analyses diff days} ## FILTER TO PEOPLE who commenced VTE treatment after ceasing prophylaxis imputed_data_rx_proph <- imputed_data %>% filter((symptvte90 == 0 | vte_rx_minus_proph > 0)) table(imputed_data_rx_proph$vte_rx_minus_proph) table(imputed_data_rx_proph$symptvte90) # N=37 # Model with symptomatic 90 days VTE, modelAOA1rx_proph <- glm(symptvte90 ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + joint + bmi + vte_prev_vte, data = imputed_data_rx_proph, family = "binomial") summary(modelAOA1rx_proph) stepAOA1rx_proph <- stepAIC(modelAOA1rx_proph, trace = 0, direction = "backward", scope = list(upper = modelAOA1rx_proph, lower = ~ joint + aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat)) summary(stepAOA1rx_proph) exp(cbind(OR = coef(stepAOA1rx_proph), confint(stepAOA1rx_proph))) # Predict the probability (p) of outcome pAOA1rx_proph <- predict(stepAOA1rx_proph, type = "response") predicted_AOA1rx_proph <- ifelse(pAOA1rx_proph > 0.5, "pos", "neg") head(predicted_AOA1rx_proph) rocAOA1rx_proph <- roc(stepAOA1rx_proph$y ~ pAOA1rx_proph) auc(rocAOA1rx_proph) plot(rocAOA1rx_proph) ## FILTER TO PEOPLE who commenced VTE treatment after 7 days imputed_data_rx_7 <- imputed_data %>% filter((symptvte90 == 0 | vte_rx_comm > 7)) table(imputed_data_rx_7$symptvte90) # N=28 # Model with symptomatic 90 days VTE, & PEOPLE who commenced VTE treatment after 7 days modelAOA1rx_7 <- glm(symptvte90 ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + joint + bmi + vte_prev_vte, data = imputed_data_rx_7, family = "binomial") summary(modelAOA1rx_7) stepAOA1rx_7 <- stepAIC(modelAOA1rx_7, trace = 0, direction = "backward", scope = list(upper = modelAOA1rx_7, lower = ~ joint + aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat)) summary(stepAOA1rx_7) exp(cbind(OR = coef(stepAOA1rx_7), confint(stepAOA1rx_7))) pAOA1rx_7 <- predict(stepAOA1rx_7, type = "response") predicted_AOA1rx_7 <- ifelse(pAOA1rx_7 > 0.5, "pos", "neg") head(predicted_AOA1rx_7) rocAOA1rx_7 <- roc(stepAOA1rx_7$y ~ pAOA1rx_7) auc(rocAOA1rx_7) plot(rocAOA1rx_7) ``` ## Step 9.c.Sensitivity analyses excluding participants with 1. History VTE and 2. Received routine DUS ```{r Sensitivity analyses} ## FILTER TO PEOPLE WITHOUT preop VTE, insufficient to run only this group imputed_data_prev <- imputed_data %>% filter((vte_prev_vte == 0)) table(imputed_data_prev$vte_prev_vte) # Model with symptomatic 90 days VTE, removed previous vte, vte_prev_vte modelAOA1prev <- glm(symptvte90 ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + joint + bmi, data = imputed_data_prev, family = "binomial") summary(modelAOA1prev) stepAOA1prev <- stepAIC(modelAOA1prev, trace = 0, direction = "backward", scope = list(upper = modelAOA1prev, lower = ~ joint + aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat)) summary(stepAOA1prev) exp(cbind(OR = coef(stepAOA1prev), confint(stepAOA1prev))) ### Compare final models with and without people with previous VTE# #anova(stepAOA1, stepAOA1prev, test = "Chisq") # No difference at all ## FILTER TO PEOPLE who didn't get routine DUS imputed_data_dopp <- imputed_data %>% filter((vte_dopp_pt == 0)) table(imputed_data_dopp$vte_dopp_pt) # Model with symptomatic 90 days VTE, without people who received DUS modelAOA1dopp <- glm(symptvte90 ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + joint + bmi + vte_prev_vte, data = imputed_data_dopp, family = "binomial") summary(modelAOA1dopp) stepAOA1dopp <- stepAIC(modelAOA1dopp, trace = 0, direction = "backward", scope = list(upper = modelAOA1dopp, lower = ~ joint + aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat)) summary(stepAOA1dopp) exp(cbind(OR = coef(stepAOA1dopp), confint(stepAOA1dopp))) # No difference in compliance variables, history previous vte no longer sig ``` ## Step 9.d. Model run for hips and knees separately ```{r hip and knee models} #KNEES ONLY imputed_data_k <- imputed_data %>% filter((joint == 1)) # knees table(imputed_data_k$joint) # Model with symptomatic 90 days VTE, excludes assymptomatic events, noncompliant_vte_prophyl_durat - minimum 21 days VTE duration # joint removed modelAOA1k <- glm(symptvte90 ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + bmi + vte_prev_vte, data = imputed_data_k, family = "binomial") summary(modelAOA1k) stepAOA1k <- stepAIC(modelAOA1k, trace = 0, direction = "backward", scope = list(upper = modelAOA1k, lower = ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat)) summary(stepAOA1k) exp(cbind(OR = coef(stepAOA1k), confint(stepAOA1k))) # HIPS ONLY imputed_data_h <- imputed_data %>% filter((joint == 0)) # HIPS table(imputed_data_h$joint) # Model with symptomatic 90 days VTE, excludes assymptomatic events, noncompliant_vte_prophyl_durat - minimum 21 days VTE duration # joint removed, hr_prev removed as destabilised model due to low event rate modelAOA1h <- glm(symptvte90 ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat + bmi + vte_prev_vte, data = imputed_data_h, family = "binomial") summary(modelAOA1h) stepAOA1h <- stepAIC(modelAOA1h, trace = 0, direction = "backward", scope = list(upper = modelAOA1h, lower = ~ aoa_cohort_noncompliance + non_compliance_aoa_general_rec + noncompliant_vte_prophyl_durat)) summary(stepAOA1h) exp(cbind(OR = coef(stepAOA1h), confint(stepAOA1h))) ``` ## Step 11. Supplementary data analyses ```{r surgeon data} # Supplementary data - Describe preop cardiac meds table(mydata2$cc_hd_meds, dnn = "Medication for heart disease", exclude = NULL) table(mydata2$cardiac_aspirin, dnn = "Preoperative medication commonly also used for VTE prophylaxis- Aspirin", exclude = NULL) table(mydata2$cardiac_warfarin , dnn = "Preoperative medication commonly also used for VTE prophylaxis- Warfarin", exclude = NULL) table(mydata2$cardiac_heparin, dnn = "Preoperative medication commonly also used for VTE prophylaxis- Heparin", exclude = NULL) table(mydata2$cardiac_drug_other, dnn = "Preoperative medication commonly also used for VTE prophylaxis- Other type", exclude = NULL) table(mydata2$cardiac_drug_other_type, dnn = "Name of other preoperative medication commonly also used for VTE prophylaxis", exclude = NULL) mydata2 <- mydata2 %>% mutate(cardiac_othermeds = if_else( cardiac_drug_other_type %in% c("Apixaban", "Eliquis"), 1L, if_else( cardiac_drug_other_type == "Adalat", 2L, if_else( cardiac_drug_other_type %in% c("Asasantin", "Asasantin (Dipyridamole and Aspirin)", "Assasantin", "Assassantin"), 3L, if_else( cardiac_drug_other_type == "atenolol", 4L, if_else( cardiac_drug_other_type == "lasix", 5L, if_else( cardiac_drug_other_type %in% c("clexane", "Clexane"), 6L, if_else( cardiac_drug_other_type %in% c("Dabigatran - Pradaxa", "Dabigatran etexilate", "dabigatran etexilate - pradaxa", "Dabigatran etexilate - Pradaxa", "Dabigatran etexilate (Pradaxa)", "Pradaxa"), 7L, if_else( cardiac_drug_other_type == "CQIO", 8L, if_else( cardiac_drug_other_type == "Heparin", 9L, if_else( cardiac_drug_other_type %in% c("Iscovar", "Isocover"), 10L, if_else( cardiac_drug_other_type %in% c("Rivaroxaban", "xarelto", "Xarelto"), 12L, NA_integer_)))))))))))) table(mydata2$cardiac_othermeds) # DESCRIBE INDIVIDUAL AGENT PROPHYLAXIS catvarsD <- c("vte_clex", "vte_clex_firstdose", "vte_clex_changedose", "ab_clex_changed_dose", "vte_clex_disrupt", "vte_clex_12hr", "vte_frag", "vte_frag_firstdose", "vte_frag_changedose", "ab_frag_changed_dose", "vte_frag_disrupt", "vte_frag_12hr", "vte_aspir", "vte_aspirrationale", "vte_aspir_firstdose", "vte_aspir_changedose", "ab_aspir_changed_dose", "vte_aspir_disrupt", "vte_riva", "vte_riva_othercondition", "vte_riva_other_reason", "vte_riva_firstdose", "vte_riva_changedose", "ab_riva_changed_dose", "vte_riva_disrupt", "vte_dabig", "vte_dabig_firstdose", "vte_dabig_changedose", "ab_dabig_changed_dose", "vte_dabig_disrupt", "vte_warf", "vte_warfrationale", "vte_warf_firstdose", "vte_warf_changedose", "ab_warf_changed_dose", "vte_warf_disrupt", "vte_alt1_name", "vte_alt1_firstdose", "vte_alt1_changedose", "ab_alt1_one_changed_dose", "vte_alt1_disrupt", "vte_mech", "vte_mech_surgpref", "vte_mech_yesno", "vte_icp_foot", "vte_foot_disrupt", "vte_foot_acutedur", "vte_icp_calf", "vte_calf_disrupt", "vte_calf_acutedur", "vte_gcs", "vte_gcs_type", "vte_gcs_disrupt", "vte_gcs_acutedur", "vte_gcs_cessation" ) mydata2[,catvarsD]<- lapply(mydata2[,catvarsD], factor) # expand to use all chekbox options #"vte_mech_reas", ## 0, Morbid obesity, BMI >40 | 1, Inflammatory condition lower leg | 2, Severe peripheral arterial disease/leg ulcers | 3, Diabetic neuropathy | 4, Severe leg oedema | 5, Severe lower limb deformity | 6, Surgeon preference | 7, Legs wrong shape | 89, Other | 999, Unknown/Not stated ## Describe clexane and fragmin prophylaxis table(mydata2$vte_frag_disrupt_days) mydata2$vte_frag_disrupt_days <- as.numeric(mydata2$vte_frag_disrupt_days) mydata2 <- mydata2 %>% mutate(vte_frag_disrupt_days = if_else(vte_frag_disrupt_days == "ceased early", 0, vte_frag_disrupt_days)) table(mydata2$vte_frag_disrupt_days) myvars_lmwh <- c("vte_clex", "vte_clex_firstdose", "vte_clex_changedose", "ab_clex_changed_dose", "vte_clex_start", "vte_clex_ceased", "vte_clex_days", "vte_clex_disrupt", "vte_clex_disrupt_days", "vte_clex_12hr", "vte_frag", "vte_frag_firstdose", "vte_frag_changedose", "ab_frag_changed_dose", "vte_frag_start", "vte_frag_ceased", "vte_frag_days", "vte_frag_disrupt", "vte_frag_disrupt_days", "vte_frag_12hr" ) tablmwh <- CreateTableOne(data = mydata2, vars = myvars_lmwh) summary(tablmwh, pDigits = 2) ## Describe aspirin prophylaxis myvars_asp <- c("vte_aspir", "vte_aspirrationale", "vte_aspir_firstdose", "vte_aspir_changedose", "ab_aspir_changed_dose", "vte_aspir_start", "vte_aspir_ceased", "vte_aspir_days", "vte_aspir_disrupt", "vte_aspir_disrupt_days" ) tabasp <- CreateTableOne(data = mydata2, vars = myvars_asp) summary(tabasp, pDigits = 2) table(mydata2$vte_aspir_days) mydata2 <- mydata2 %>% mutate(vte_aspir_days = if_else(vte_aspir_days >89, 90, vte_aspir_days)) table(mydata2$vte_riva_days) mydata2 <- mydata2 %>% mutate(vte_riva_days = if_else(vte_riva_days >89, 90, vte_riva_days)) table(mydata2$vte_dabig_days) mydata2 <- mydata2 %>% mutate(vte_dabig_days = if_else(vte_dabig_days >89, 90, vte_dabig_days)) table(mydata2$vte_warf_days) mydata2 <- mydata2 %>% mutate(vte_warf_days = if_else(vte_warf_days >89, 90, vte_warf_days)) table(mydata2$vte_alt1_days) mydata2 <- mydata2 %>% mutate(vte_alt1_days = if_else(vte_alt1_days >89, 90, vte_alt1_days)) ## Describe rivaroxaban prophylaxis & dabigatran prophylaxis myvars_riv <- c("vte_riva", "vte_riva_othercondition", "vte_riva_firstdose", "vte_riva_changedose", "ab_riva_changed_dose", "vte_riva_start", "vte_riva_ceased", "vte_riva_days", "vte_riva_disrupt", "vte_riva_disrupt_days", "vte_dabig", "vte_dabig_firstdose", "vte_dabig_changedose", "ab_dabig_changed_dose", "vte_dabig_start", "vte_dabig_ceased", "vte_dabig_days", "vte_dabig_disrupt", "vte_dabig_disrupt_days" ) tabriv <- CreateTableOne(data = mydata2, vars = myvars_riv) summary(tabriv, pDigits = 2) ## Describe warfarin prophylaxis #record warfarin disrupt day ID 91, 15:55 in excel, ? number of time mydata2$vte_warf_disrupt_days <- as.numeric(mydata2$vte_warf_disrupt_days) mydata2 <- mydata2 %>% mutate(vte_warf_disrupt_days = if_else(vte_warf_disrupt_days == "15:55", 0, vte_warf_disrupt_days)) myvars_warf <- c("vte_warf", "vte_warfrationale", "vte_warf_firstdose", "vte_warf_changedose", "ab_warf_changed_dose", "vte_warf_start", "vte_warf_ceased", "vte_warf_days", "vte_warf_disrupt", "vte_warf_disrupt_days", "vte_alt1", "vte_alt1_name", "vte_alt1_firstdose", "vte_alt1_changedose", "ab_alt1_one_changed_dose", "vte_alt1_start", "vte_alt1_ceased", "vte_alt1_days", "vte_alt1_disrupt", "vte_alt1_disrupt_days" ) tabwarf <- CreateTableOne(data = mydata2, vars = myvars_warf) summary(tabwarf, pDigits = 2) myvars_mec <- c("vte_mech", "vte_mech_surgpref", "vte_mech_yesno", "index_leg_vtemech", "other_leg_vtemech_spec", "vte_icp_foot", "vte_foot_start", "vte_foot_cease", "vte_foot_durat", "vte_foot_disrupt", "vte_foot_acutedur", "vte_icp_calf", "vte_calf_start", "vte_calf_cease", "vte_calf_durat", "vte_calf_disrupt", "vte_calf_acutedur", "vte_gcs", "vte_gcs_type", "vte_gcs_start", "vte_gcs_cease", "vte_gcs_durat", "vte_gcs_disrupt", "vte_gcs_acutedur", "vte_gcs_cessation", "vte_anymech_time" ) tabmec <- CreateTableOne(data = mydata2, vars = myvars_mec) summary(tabmec, pDigits = 2) ## Describe heparins prophylaxis table(mydata2$vte_hep, useNA = "always") table(mydata2$vte_unfhep, useNA = "always") mydata2 <- mydata2 %>% mutate(vte_heps = if_else( vte_hep == 1, 1L, if_else( vte_unfhep == 1, 1L, 0L))) table(mydata2$vte_heps) myvars_heps <- c("vte_hep_firstdose", "vte_hep_changedose", "ab_hep_changed_dose", "vte_hep_start", "vte_hep_ceased", "vte_hep_days", "vte_hep_disrupt", "vte_hep_disrupt_days", "vte_unfhep_firstdose", "vte_unfhep_changedose", "ab_unfhep_changed_dose", "vte_unfhep_start", "vte_unfhep_ceased", "vte_unfhep_days", "vte_unfhep_disrupt", "vte_unfhep_disrupt_days" ) tabheps <- CreateTableOne(data = mydata2, vars = myvars_heps) summary(tabheps, pDigits = 2) table(hep1st = mydata2$vte_hep_firstdose, useNA = "always") table(unfhep1st = mydata2$vte_unfhep_firstdose, useNA = "always") table(mydata2$vte_hep_changedose,useNA = "always") table(mydata2$vte_unfhep_changedose, useNA = "always") table(mydata2$vte_hep_disrupt, mydata2$vte_unfhep_disrupt, useNA = "always") # Combine duration heps mydata2 <- mydata2 %>% mutate(vte_heps_day = if_else( vte_hep == 1 & vte_hep_days > 0, vte_hep_days, if_else( vte_unfhep == 1 & vte_unfhep_days > 0, vte_unfhep_days, NA_integer_))) table(mydata2$vte_heps_day, useNA = "always", dnn = "total hep duration") summary(mydata2$vte_heps_day) #Combine start day mydata2$vte_hep_start <- as.numeric(mydata2$vte_hep_start) mydata2$vte_unfhep_start <- as.numeric(mydata2$vte_unfhep_start) mydata2 <- mydata2 %>% mutate(vte_heps_start = if_else( vte_hep == 1 & vte_hep_start == 0, 0, if_else( vte_hep == 1 & vte_hep_start > 0, vte_hep_start, if_else( vte_unfhep == 1 & vte_unfhep_start == 0, 0, if_else( vte_unfhep == 1 & vte_unfhep_start > 0, vte_unfhep_start, NA_character_))))) table(mydata2$vte_heps_start, useNA = "always", dnn = "total hep start day") summary(mydata2$vte_heps_start) summary(mydata2$vte_hep_start, useNA = "always") summary(mydata2$vte_unfhep_start, useNA = "always") summary(mydata2$vte_unfhep_days) table(mydata2$vte_hep_disrupt_days,useNA = "always") table(mydata2$vte_unfhep_disrupt_days, useNA = "always") ```