library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(gtsummary)
library(survival)
library(labelled)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ readr     2.1.5
## ✔ ggplot2   3.5.1     ✔ stringr   1.5.1
## ✔ lubridate 1.9.4     ✔ tibble    3.2.1
## ✔ purrr     1.0.2     ✔ tidyr     1.3.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(broom)
library(ggplot2)
library(survminer)
## Loading required package: ggpubr
## 
## Attaching package: 'survminer'
## 
## The following object is masked from 'package:survival':
## 
##     myeloma
library(ggmap)
## ℹ Google's Terms of Service: <https://mapsplatform.google.com>
##   Stadia Maps' Terms of Service: <https://stadiamaps.com/terms-of-service/>
##   OpenStreetMap's Tile Usage Policy: <https://operations.osmfoundation.org/policies/tiles/>
## ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
library(censusapi)
## 
## Attaching package: 'censusapi'
## 
## The following object is masked from 'package:methods':
## 
##     getFunction
library(tidycensus)
library(tigris)
## To enable caching of data, set `options(tigris_use_cache = TRUE)`
## in your R script or .Rprofile.
library(jsonlite)
## 
## Attaching package: 'jsonlite'
## 
## The following object is masked from 'package:purrr':
## 
##     flatten
library(sf)
## Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(ndi)
## 
## Welcome to {ndi} version 0.1.5
## > help("ndi") # for documentation
## > citation("ndi") # for how to cite
library(tidygeocoder)
## 
## Attaching package: 'tidygeocoder'
## 
## The following object is masked from 'package:ggmap':
## 
##     geocode
rm(list = ls())  # Removes all objects
EAandVRData <- read.csv( ("EAVRAPSA.csv"))
library(dplyr)
library(stringi)

EAandVRData <- EAandVRData %>%
  mutate(across(where(is.character), ~ {
    # Remove line breaks and tabs
    x <- gsub("[\r\n\t]", " ", .)
    # Convert to ASCII, strip invalid bytes
    x <- stringi::stri_trans_general(x, "Latin-ASCII")
    # Remove remaining invisible characters
    x <- stringi::stri_replace_all_regex(x, "[[:cntrl:]]+", " ")
    # Trim whitespace
    trimws(x)
  }))
# Function to convert gestational age to weeks + days as numeric
convert_gestational_age <- function(ga) {
  # Convert to lowercase and remove whitespace for consistency
  ga_clean <- tolower(trimws(as.character(ga)))
  
  # Handle NA values
  if (is.na(ga_clean)) return(NA)
  
  # Handle "full term" cases (typically considered 39-40 weeks)
  if (grepl("full term", ga_clean)) return(39 + 0/7) # Using 39 weeks as default
  
  # Handle cases like "34W2D", "36W", "37w"
  if (grepl("[0-9]+w.*[0-9]*d", ga_clean)) {
    weeks <- as.numeric(gsub("([0-9]+)w.*", "\\1", ga_clean))
    days <- as.numeric(gsub(".*([0-9]+)d.*", "\\1", ga_clean))
    if (is.na(days)) days <- 0
    return(weeks + days/7)
  }
  
  # Handle cases like "36 W" or "34w"
  if (grepl("[0-9]+\\s*w", ga_clean)) {
    weeks <- as.numeric(gsub("([0-9]+).*", "\\1", ga_clean))
    return(weeks + 0/7)
  }
  
  # Handle cases like "33/3" or "35/5" (weeks/days)
  if (grepl("[0-9]+/[0-9]+", ga_clean)) {
    parts <- strsplit(ga_clean, "/")[[1]]
    weeks <- as.numeric(parts[1])
    days <- as.numeric(parts[2])
    return(weeks + days/7)
  }
  
  # Handle cases like "31 weeks" or "39weeks 6 days"
  if (grepl("weeks", ga_clean)) {
    weeks <- as.numeric(gsub("([0-9]+).*", "\\1", ga_clean))
    if (grepl("days", ga_clean)) {
      days <- as.numeric(gsub(".*([0-9]+)\\s*days.*", "\\1", ga_clean))
      if (is.na(days)) days <- 0
    } else {
      days <- 0
    }
    return(weeks + days/7)
  }
  
  # Handle simple numeric cases (assumed to be weeks)
  if (grepl("^[0-9]+$", ga_clean)) {
    return(as.numeric(ga_clean) + 0/7)
  }
  
  # If none of the patterns match, return NA
  return(NA)
}

# Apply the function to your data
EAandVRData$gestational_age_weeks <- sapply(EAandVRData$gestational_age, convert_gestational_age)
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
# Optional: Create a weeks + days character representation
EAandVRData$gestational_age_formatted <- ifelse(
  is.na(EAandVRData$gestational_age_weeks), 
  NA,
  paste0(
    floor(EAandVRData$gestational_age_weeks), "w ", 
    round((EAandVRData$gestational_age_weeks - floor(EAandVRData$gestational_age_weeks)) * 7), "d"
  )
)
# Create preterm birth classification
EAandVRData <- EAandVRData %>%
  mutate(preterm_category = case_when(
    gestational_age_weeks < 28 ~ "Extremely preterm birth (EPTB)",
    gestational_age_weeks >= 28 & gestational_age_weeks < 32 ~ "Very preterm birth (VPTB)",
    gestational_age_weeks >= 32 & gestational_age_weeks < 34 ~ "Moderate preterm birth (MPTB)",
    gestational_age_weeks >= 34 & gestational_age_weeks < 37 ~ "Late preterm birth (LPTB)",
    gestational_age_weeks >= 37 ~ "Term birth",
    TRUE ~ NA_character_  # For any NA values
  ))
EAandVRData <- EAandVRData %>%
  mutate(
    Birth_Weight = case_when(
      birth_weight < 1000 ~ "Extremely low birth weight (ELBW)",
      birth_weight >= 1000 & birth_weight < 1500 ~ "Very low birth weight (VLBW)",
      birth_weight >= 1500 & birth_weight < 2500 ~ "Low birth weight (LBW)",
      birth_weight >= 2500 & birth_weight < 4000 ~ "Normal birth weight (NBW)",
      birth_weight >= 4000 ~ "High birth weight (HBW)",
      TRUE ~ NA_character_  # For any NA values
    ))
EAandVRData
##    studyid      mrn   lastname firstname      dob gestational_age birth_weight
## 1        1  5448201       Holt      Mary 11/19/18             37W         2036
## 2        2  5659186       Bale      John  3/10/07            36 W           NA
## 3        3  4984934       Diaz      Amir  4/29/16            36 W           NA
## 4        4  5388315  Blanchard      Luca  7/16/19            36 W         2140
## 5        5  5819475      Cohen    Daniel   2/6/22             41W         2063
## 6        6  5641261  Cruzalves     Ethan  2/19/21           34W2D         2150
## 7        7  5377668       Dees      Gage   5/8/09       Full term           NA
## 8        8  5034786    Delemos   Gabriel 10/10/15              31         1050
## 9        9  4568872     Garcia     Lucas  3/28/12      Full term*         3170
## 10      10  5603595      Kuntz     Isaac 12/22/19            33/3           NA
## 11      11  5669113  Macconnie     Riley  5/28/21              32         1120
## 12      12  5783504     Monroe   Paisley  9/15/20            35/4         2500
## 13      13  5037025 Montgomery     Gavin  6/13/16            34/4         2020
## 14      14  4597429   Schurman   Lucinda   7/8/12            36/2         2353
## 15      15 71061323     Sharer     James  4/24/14              39         2551
## 16      16  5066210      Tamir      Liam 11/10/16              30         1261
## 17      17  6056733         Xu      Ella 10/10/23              37         2150
## 18      18  6033180    Zumwalt     Judah  9/15/21              36         2380
## 19      19  5347760        Arp  Benjamin 10/22/14              31         1525
## 20      20 71081255 Brouillard     Henry  7/31/24  39weeks 6 days         2489
## 21      21 71256250     Olivas    Damian  7/26/23       39W 1 day         3880
## 22      22 71472700      Creed  Vasilisa  6/11/25            38 W         2615
## 23      23 71528946      Aaron      Dahl   3/1/23          34wk4d         2380
##    sex type_ea dysphagia aspiration cyanotic_episode laryngealcleft
## 1    0       2         1          1                1              1
## 2    1       3         1          1                0              0
## 3    1       1         1          1                1              0
## 4    1       3         1          1                0              0
## 5    1       3         0          0                0              0
## 6    1       3         1          1                0              1
## 7    1       3         1          1                0              1
## 8    1       3         1          1                1              1
## 9    1       3         1          0                1              2
## 10   1       3         1          0                0              0
## 11   0       3         1          0                0              1
## 12   1       3         1          1                0              1
## 13   1       3         1          0                0              0
## 14   0       3         1          1                0              0
## 15   1       3         1          0                0              0
## 16   1       3         1          0                0              0
## 17   0       3         1          1                0              0
## 18   1       3         1          0                0              1
## 19   1       5         0          0                0              1
## 20   1       5         1          1                0              1
## 21   1       3         1          1                0              0
## 22   0       3         1          0                0              0
## 23   1       3         1          0                0              1
##    typelaryngealcleft laryngealcleftrepair recurrentrespiratoryinfection
## 1                   1                    0                             0
## 2                  NA                    0                             1
## 3                  NA                    0                             1
## 4                  NA                    0                             1
## 5                  NA                    0                             0
## 6                   1                    1                             1
## 7                   2                    1                             1
## 8                   1                    1                             1
## 9                  NA                    0                             1
## 10                 NA                   NA                             0
## 11                 NA                    0                             1
## 12                  1                    1                             1
## 13                 NA                    0                             1
## 14                 NA                   NA                             1
## 15                 NA                    0                             1
## 16                 NA                    0                             0
## 17                 NA                   NA                             0
## 18                  2                    1                             0
## 19                  1                    1                             1
## 20                  1                    0                             0
## 21                 NA                   NA                             0
## 22                 NA                   NA                             0
## 23                  1                    0                             0
##    vocalcorddysfunction geneticanomaly vacteryl_anomaly
## 1                     0              0                1
## 2                     0              1                1
## 3                     0              0                0
## 4                     1              1                1
## 5                     0              0                1
## 6                     1              1                1
## 7                     1              1                0
## 8                     1              0                0
## 9                     2              2                0
## 10                    0              0                1
## 11                    1              0                1
## 12                    1              0                1
## 13                    1              0                0
## 14                    0              1                1
## 15                    1              0                1
## 16                    0              0                1
## 17                    1              0                1
## 18                    0              0                1
## 19                    1              0                1
## 20                    0              0                1
## 21                    0              0                0
## 22                    0              0                1
## 23                    1              0                1
##                                                                                                                                                                                                                                                                                                              which_vacteryl_anomaly
## 1                                                                                                                                                                                                                                                                                                      VSD, low lying conus, EA/TEF
## 2                                                                                                                                 congenital scoliosis, vertebral anomalies, missing ribs bilaterally, RAA, VSD s/p patch closure, EA/TEF, horseshoe kidney, L radial anomaly with absent thumb (club hand) and developmental delay
## 3                                                                                                                                                                                                                                                                                                                                  
## 4                                                                                                                                                                                                         EA/TEF, solitary R kidney, hypospadias with chordee, absent right radius and thumb, PDA requiring ligation, 2 vessel cord
## 5                                                                                                                                                                                                           VACTERL: Hemivertebrae, fused ribs, DAA, VSDs, ASDs, EA/TEF, L radial club hand  Hypothyroidism, possible tethered cord
## 6                                                                                                                                                                                                                           Complete balanced AV canal, pHTN, EA/TEF, bilateral hydronephrosis with partial R sided UPJ obstruction
## 7                                                                                                                                                                                                                                                                                                                 Vertebral anomaly
## 8                                                                                                                                                                                                                                                                                                                                  
## 9                                                                                                                                                                                                                                                                                                                              <NA>
## 10                                                               bicuspid aortic valve, mild aortic root dilation, PDA, left solitary kidney, VUR, multilevel spinal segmentations including C4-C6 segmentation anomaly with rudimentary C5-C6 disc space and segmentation of right C7-T12 pedicles with focal levoconvex curvature
## 11                                                                                                                                                                                                                                                                                                 Sacral dimple, ToF,  EA/TEF, VSD
## 12 Congenital scoliosis, ASD (resolved), vascular ring, EA/TEF, hydronephrosis Myelomeningocele with shunted hydrocephalus Chiari malformation Type 2 Neurogenic bowel and bladder s/p suprapubic vesicostomy, recurrent UTIs, on bladder irrigations and prophylactic antibiotics; rectal prolapse UPJ obstruction s/p pyeloplasty
## 13                                                                                                                                                                                                                                                                                                                             <NA>
## 14                                                                                                                                                                                                                                                    Cong scoliosis, imperforate anus with perineal fistula, vascular ring, EA/TEF
## 15                                                                                                                                                                                                                                                     Stage I CKD and duplicate kidney VUR s/p ureter surgery Spinal abnormalities
## 16                                                                                                                                                                                                                                                                                                                  t4 hemivertebra
## 17                                                                              Rib anomalies, Butterfly vertebra at T4, sacral anomalies, low-lying conus, imperforate anus with rectovestibular fistula , ASD, PDA (s/p ligation), vascular ring (s/p division of atretic LAA), Bilateral SVC with LSVC to coronary sinus, EA/TEF
## 18                                                                                                                                                                                                                                                                         congenital heart defect, TE fistula, and solitary kidney
## 19                                                                                                                                                                             congenital subglottic stenosis, congenital severe tracheobronchomalacia, EA/TEF, double aortic arch, patulous atrial septum w/multiple fenestrations
## 20                                                                                                                                                                                                                                                                                   Thickened filum, vertebral anomalies, ToF, TEF
## 21                                                                                                                                                                                                                                                                                                                                 
## 22                                                                                                                                                                           VACTERL: Rib and vertebral anomalies including partial fusion of the anterior left first and second ribs and a T7 butterfly vertebra, RAA, PDA, EA/TEF
## 23                                                                                                                                                                                                                                                               H/o L hydronephrosis and small R kidney, tethered cord s/p release
##    trisomy21 charge geneticanomalyother doublearch rightaorticarch circumflex
## 1          0      0                   0          0               1          0
## 2          0      0                   0          0               1          0
## 3          0      1                   0          0               1          0
## 4          0      0                   0          0               1          0
## 5          0      0                   0          1               0          0
## 6          1      0                   0          0               1          0
## 7          0      0                   0          0               1          1
## 8          0      0                   0          0               1          0
## 9          0      0                   0          0               1          0
## 10         0      0                   2          0               1          0
## 11         0      0                   0          1               0          0
## 12         0      0                   0          0               1          0
## 13         0      0                   0          0               1          1
## 14         0      1                   2          0               1          0
## 15         0      0                   2          0               1          0
## 16         0      0                   0          0               1          0
## 17         0      0                   0          1               0          0
## 18         0      0                   0          0               1          0
## 19         0      0                   0          1               0          0
## 20         0      1                   0          0               1          0
## 21         0      0                   0          0               1          0
## 22         0      0                   0          0               1          0
## 23         0      0                   0          0               1          0
##    mirror_image_branching alsca arsca completevr bch_patient
## 1                       0     1     0          1           0
## 2                       0     1     0          1           0
## 3                       0     1     0          1           1
## 4                       0     1     0          1           0
## 5                       0     0     0          1           0
## 6                       0     1     0          1           0
## 7                       0     1     0          1           0
## 8                       0     1     0          1           0
## 9                       0     1     0          1           0
## 10                      0     1     0          1           0
## 11                      0     0     0          1           0
## 12                      0     1     0          1           0
## 13                      1     0     0          1           0
## 14                      0     1     0          1           0
## 15                      0     1     0          1           0
## 16                      0     1     0          1           0
## 17                      0     0     0          1           1
## 18                      0     1     0          1           0
## 19                      0     0     0          1           0
## 20                      0     1     0          1           1
## 21                      0     1     0          1           0
## 22                      1     1     0          1           1
## 23                      1     0     0          1           1
##    concomitant_congenital_heart_dx
## 1                                1
## 2                                1
## 3                                0
## 4                                0
## 5                                0
## 6                                1
## 7                                0
## 8                                0
## 9                                0
## 10                               1
## 11                               1
## 12                               0
## 13                               0
## 14                               0
## 15                               0
## 16                               0
## 17                               0
## 18                               1
## 19                               1
## 20                               1
## 21                               1
## 22                               0
## 23                               0
##                                                                                                                                concomitant_congenital_heart_daig
## 1                                                                                                                                                            VSD
## 2                                                                                                                                                            VSD
## 3                                                                                                                                                               
## 4                                                                                                                                                           <NA>
## 5                                                                                                                                                               
## 6                                                                                                                                                        ASD/VSD
## 7                                                                                                                                                               
## 8                                                                                                                                                               
## 9                                                                                                                                                           <NA>
## 10                                                                                                         bicuspid aortic valve, mild aortic root dilation, PDA
## 11                                                                                                                                                           ToF
## 12                                                                                                                                                          <NA>
## 13                                                                                                                                                          <NA>
## 14                                                                                                                                                          <NA>
## 15                                                                                                                                                              
## 16                                                                                                                                                              
## 17                                                                                                                                                          <NA>
## 18                                                                                                                                                VSD s/p repair
## 19                                                                                                                                   ASD, patulous atrial septum
## 20                                                                                                                                                           ToF
## 21                                                                                                                                                VSD s/p repair
## 22                                                                                                                                                              
## 23 Right aortic arch with a retrotracheal vascular diverticulum of Kommerell and ductus arteriosus (vascular ring); s/p aortopexy and ductus ligamentum ligation
##    prenatal_dx_vrorea eapreopechodiagvrorraa eapreopctdxvr eapreopmrdxvr
## 1                   2                      0             0             0
## 2                   2                      2             2             2
## 3                   2                      2             2            NA
## 4                   0                      2             2             2
## 5                   2                      0             0             1
## 6                   1                      1             1             0
## 7                   2                      0             0             0
## 8                   1                      2             2             2
## 9                   0                      0             0             0
## 10                  0                      0             0             0
## 11                  1                      1             0             0
## 12                  2                      1             1             0
## 13                  1                      0             0             0
## 14                  2                      0             0             0
## 15                  0                      2             2             2
## 16                  1                      1             2             2
## 17                  1                      1             1             0
## 18                  0                      2             2             2
## 19                  2                      2             2             2
## 20                  0                      1             1             0
## 21                  1                      0             1             0
## 22                  1                      0             1             0
## 23                 NA                      1             0             0
##    vr_repair_at_bch ea_vr_repair if_staged_which_first
## 1                 0            1                     3
## 2                 0            2                     1
## 3                 1            1                     3
## 4                 0            1                    NA
## 5                 1            1                     3
## 6                 0            1                     3
## 7                 0            1                     3
## 8                 0            1                     3
## 9                 0            3                     3
## 10                3            3                     3
## 11                0            1                     3
## 12                0            2                     1
## 13                0            2                     2
## 14                0            2                     2
## 15                1            2                     1
## 16                3            3                     3
## 17                1            1                     3
## 18                0            2                     1
## 19                0            1                     3
## 20                1            1                     3
## 21                0            3                    NA
## 22                1            1                    NA
## 23                0            0                    NA
##    vr_repair_at_the_time_of_pexy_or_reoperative_esophageal_surgery
## 1                                                                3
## 2                                                                3
## 3                                                                3
## 4                                                                1
## 5                                                                1
## 6                                                                0
## 7                                                                3
## 8                                                                1
## 9                                                                3
## 10                                                               3
## 11                                                               0
## 12                                                               1
## 13                                                               0
## 14                                                               0
## 15                                                               0
## 16                                                               3
## 17                                                               0
## 18                                                               0
## 19                                                               0
## 20                                                               0
## 21                                                               0
## 22                                                              NA
## 23                                                              NA
##    reoperative_vr_repair_at_bch stricture_resection timing_of_ea_repair
## 1                             0                   0                   2
## 2                             0                   1                   1
## 3                             0                   0                   2
## 4                             1                   1                   1
## 5                             0                   0                   2
## 6                             0                   0                   1
## 7                             0                   1                   1
## 8                             1                   0                   2
## 9                             3                   0                   1
## 10                            3                   1                   2
## 11                            0                   1                   1
## 12                            0                   0                   1
## 13                            1                   0                   1
## 14                            0                   0                   1
## 15                            1                   0                   1
## 16                            3                   0                   1
## 17                            0                   0                   1
## 18                            0                   0                   1
## 19                            0                   0                   1
## 20                            0                   0                   1
## 21                            0                   0                   1
## 22                            0                   0                   1
## 23                           NA                   0                   1
##    initial_esophageal_repair date_of_initial_ea_repair
## 1                          2                   1/24/19
## 2                          2                   3/11/07
## 3                          4                   7/29/16
## 4                          2                   7/19/19
## 5                          3                   2/10/22
## 6                          2                    3/5/21
## 7                          2                   5/10/09
## 8                          2                  10/13/15
## 9                          2                   3/30/12
## 10                         3                  12/26/19
## 11                         2                   5/29/21
## 12                        10                   9/15/20
## 13                         3                   6/30/16
## 14                         3                   8/10/12
## 15                         2                   4/26/14
## 16                         2                  11/12/16
## 17                         2                  10/10/23
## 18                         2                   9/20/21
## 19                         3                  11/10/14
## 20                         3                    8/8/24
## 21                         2                   7/28/23
## 22                         2                   6/12/25
## 23                         2                    3/6/23
##    initial_ea_repair_approach_side initial_ea_repair_loca
## 1                                1                      2
## 2                                1                      2
## 3                                1                      1
## 4                                1                      2
## 5                                2                      1
## 6                                1                      2
## 7                                1                      2
## 8                                1                      2
## 9                                2                      2
## 10                               2                      2
## 11                               4                      2
## 12                               2                      2
## 13                               1                      2
## 14                               1                      2
## 15                               1                      2
## 16                               2                      2
## 17                               1                      1
## 18                               2                      2
## 19                               1                      2
## 20                               1                      1
## 21                               2                      2
## 22                               1                      1
## 23                               1                      2
##    reop_esophageal_repair eareoperation_indication
## 1                       7                        7
## 2                       7                        7
## 3                       7                        7
## 4                       4                        2
## 5                      13                        6
## 6                       3                        1
## 7                       2                        1
## 8                       6                        4
## 9                       2                        1
## 10                      1                        6
## 11                      9                        4
## 12                     16                        6
## 13                      1                        6
## 14                      1                        6
## 15                      7                        7
## 16                     17                        3
## 17                      7                        7
## 18                      7                       NA
## 19                      3                        1
## 20                      7                        7
## 21                      7                        7
## 22                      7                       NA
## 23                      7                        7
##                                                                                                                                     reop_esophageal_other
## 1                                                                                                                                                        
## 2                                                                                                 roux-en-y esophago-jejunostom (not indicated due to EA)
## 3                                                                                                                                                 Foker 2
## 4                                                                                                                   traction-assisted stricture resection
## 5                                                                                                                                                        
## 6                                                                                                                                                        
## 7                                                                                                  Main indication was TEF but stricture was also related
## 8                                                                                                                                                        
## 9                                                                                                                         Recurrent fistula and stricture
## 10                                                                                                                                                       
## 11                                                                                                                     Stricture and vascular compression
## 12                                                                                            Prior Cervical esophagostomy revision/spit fistula revision
## 13                                                                                                                                                       
## 14 Initial operation c/b chyle leak requiring multiple chest tubes and thoracotomy for decortication and ligation of thoracic duct attempt c/b chyle leak
## 15                                                                                                                                                       
## 16               esophagopulmonary fistula with a large cystic cavity related to a chronic esophageal leak fistulized to the right upper lobe of the lung
## 17                                                                                                                                                       
## 18                                                                                                                                                       
## 19                                                                                                                                                       
## 20                                                                                                                                                       
## 21                                                                                                                                                    TBD
## 22                                                                                                                                                       
## 23                                                                                                                                                       
##    reop_ea_repair_loca date_of_reop_ea_repair first_reop_approach_side
## 1                   NA                                               3
## 2                   NA                                               3
## 3                   NA                                               3
## 4                    1                9/20/19                        1
## 5                    1                9/12/22                        1
## 6                    2                 6/5/21                        1
## 7                    2                 5/1/11                        1
## 8                    1                1/30/17                        1
## 9                    1                5/24/12                        2
## 10                   2                4/28/20                        2
## 11                   1               11/11/21                        2
## 12                   1                7/19/22                        1
## 13                   2                9/29/16                        1
## 14                   1               10/19/12                        1
## 15                  NA                                               3
## 16                   1                 7/6/17                        2
## 17                  NA                                               3
## 18                  NA                                               3
## 19                   2                8/21/15                        1
## 20                  NA                                               3
## 21                  NA                                               3
## 22                  NA                                              NA
## 23                  NA                                              NA
##    sec_reop_esophageal_repair_2 second_esophag_reop_indication
## 1                             7                              7
## 2                             7                              7
## 3                             7                              7
## 4                             2                              1
## 5                             7                              7
## 6                             7                              7
## 7                             5                              2
## 8                            15                              8
## 9                             7                              7
## 10                           14                              2
## 11                            7                              7
## 12                            4                              6
## 13                           11                              5
## 14                           NA                             NA
## 15                            7                              7
## 16                            7                              7
## 17                            7                              7
## 18                            7                              7
## 19                            3                              7
## 20                            7                              7
## 21                            7                              7
## 22                           NA                             NA
## 23                           NA                             NA
##                                                                           reop2_esophageal_other
## 1                                                                                               
## 2                                                                                           <NA>
## 3                                                                                               
## 4                                                                                               
## 5                                                                                               
## 6                                                                                               
## 7                                                                                               
## 8                                                                                               
## 9                                                                                               
## 10                                                                                              
## 11                                                                                              
## 12                                                                                              
## 13 Tracheal diverticulum resection with slide tracheoplasty, Anterior and posterior tracheopexy,
## 14                                                                                              
## 15                                                                                              
## 16                                                                                              
## 17                                                                                              
## 18                                                                                              
## 19                                                                                              
## 20                                                                                              
## 21                                                                                              
## 22                                                                                              
## 23                                                                                              
##    reop2ea_repair_loca date_of_sec_reop_ea_repair_2 second_eareop_approach_side
## 1                   NA                                                        3
## 2                   NA                                                        3
## 3                   NA                                                        3
## 4                    1                     10/22/20                          NA
## 5                   NA                                                        3
## 6                   NA                                                       NA
## 7                    1                      5/12/20                           1
## 8                   NA                                                        3
## 9                   NA                                                        3
## 10                   2                      9/18/21                           2
## 11                  NA                                                        3
## 12                   1                     10/18/22                           1
## 13                   1                       1/5/17                           5
## 14                  NA                                                       NA
## 15                  NA                                                       NA
## 16                  NA                                                        3
## 17                  NA                                                        3
## 18                  NA                                                        3
## 19                   1                       8/2/19                           2
## 20                  NA                                                        3
## 21                  NA                                                        3
## 22                  NA                                                       NA
## 23                  NA                                                       NA
##    third_reop_esophageal_repair third_esophag_reop_indication
## 1                             7                             7
## 2                             7                             7
## 3                             7                             7
## 4                             7                             7
## 5                             7                             7
## 6                            NA                            NA
## 7                             7                             7
## 8                             7                             7
## 9                             7                             7
## 10                            7                             7
## 11                            7                             7
## 12                            7                             7
## 13                           NA                            NA
## 14                            7                             7
## 15                            7                             7
## 16                            7                             7
## 17                            7                             7
## 18                            7                             7
## 19                            7                             7
## 20                            7                             7
## 21                            7                             7
## 22                           NA                            NA
## 23                           NA                            NA
##    reop3_esophageal_other reop3ea_repair_loca date_of_third_reop_ea_repair
## 1                      NA                  NA                           NA
## 2                      NA                  NA                           NA
## 3                      NA                  NA                           NA
## 4                      NA                  NA                           NA
## 5                      NA                  NA                           NA
## 6                      NA                  NA                           NA
## 7                      NA                  NA                           NA
## 8                      NA                  NA                           NA
## 9                      NA                  NA                           NA
## 10                     NA                  NA                           NA
## 11                     NA                  NA                           NA
## 12                     NA                  NA                           NA
## 13                     NA                  NA                           NA
## 14                     NA                  NA                           NA
## 15                     NA                  NA                           NA
## 16                     NA                  NA                           NA
## 17                     NA                  NA                           NA
## 18                     NA                  NA                           NA
## 19                     NA                  NA                           NA
## 20                     NA                  NA                           NA
## 21                     NA                  NA                           NA
## 22                     NA                  NA                           NA
## 23                     NA                  NA                           NA
##    third_eareop_approach_side initial_vr_repair date_of_initial_vr_repair
## 1                           3                 5                   1/24/19
## 2                           3                 2                   4/10/07
## 3                           3                 2                   7/29/16
## 4                           3                 1                   7/19/19
## 5                           3                 3                   9/12/22
## 6                          NA                 5                    3/5/21
## 7                           3                 5                   5/10/09
## 8                          NA                 1                  10/13/15
## 9                           3                 0                          
## 10                          3                 0                          
## 11                         NA                 3                   5/29/21
## 12                          3                 5                  11/11/20
## 13                         NA                 5                   6/30/16
## 14                         NA                 5                   8/10/12
## 15                         NA                 5                   2/16/18
## 16                          3                 0                          
## 17                          3                 5                  10/10/23
## 18                          3                 5                  11/23/21
## 19                          3                 3                  11/10/14
## 20                          3                 2                    8/8/24
## 21                          3                 2                   7/31/25
## 22                         NA                 5                   6/12/25
## 23                         NA                 5                    5/4/23
##    first_vr_repair_approach_side initial_vr_loca reop_vr_repair
## 1                              1               2              0
## 2                              1               2              0
## 3                              1               1              0
## 4                              1               2              2
## 5                              1               1              0
## 6                              1               2              0
## 7                              1               2              0
## 8                              1               2              1
## 9                              4              NA              0
## 10                             4              NA              0
## 11                             2               2              5
## 12                             1               2              0
## 13                             1               2              4
## 14                             1               2              0
## 15                             1               2              4
## 16                             4              NA              0
## 17                             4               7              0
## 18                             3               2              0
## 19                             1               2              0
## 20                             1               1              0
## 21                             1               1              0
## 22                             1               1              0
## 23                             5               2             NA
##    reop_vr_repair_approach_side_2 reop_vr_loca date_of_reop_vr_repair
## 1                               4           NA                       
## 2                               4           NA                       
## 3                               4           NA                       
## 4                               1            1                9/20/19
## 5                              NA           NA                       
## 6                               0           NA                       
## 7                              NA           NA                       
## 8                               1            1                1/30/17
## 9                               4           NA                       
## 10                              4           NA                       
## 11                              3            2                8/10/21
## 12                              4           NA                       
## 13                              3            1                 1/5/17
## 14                              4           NA                       
## 15                              3            1                       
## 16                              4           NA                       
## 17                              4           NA                       
## 18                              4           NA                       
## 19                              4           NA                       
## 20                              4           NA                       
## 21                              4           NA                       
## 22                              4           NA                       
## 23                             NA           NA                       
##    thoracoscopy tracheopexy descending_aortopexy esophageal_anastomotic_leak
## 1             0           6                    0                           0
## 2             0           6                    0                           2
## 3             0           1                    1                           0
## 4             0           2                    1                           0
## 5             0           1                    1                           0
## 6             0           3                    0                           1
## 7             0           3                    0                           1
## 8             0           5                    1                           1
## 9             0           6                    0                           1
## 10            0           6                    0                           0
## 11            0           5                    0                           0
## 12            0           2                    0                           0
## 13            0           4                    0                          NA
## 14            0           6                    0                           1
## 15            0           6                    0                           0
## 16            0           6                    0                           1
## 17            0           6                    1                           0
## 18            0           6                    0                           0
## 19            0           2                    1                           0
## 20            0           1                    1                           0
## 21            0           2                    1                           1
## 22            0           6                    1                           0
## 23            0           6                    1                           1
##    esophageal_anastomotic_stricture recurrent_esoph_fistula total_dilations
## 1                                 0                       0              18
## 2                                 0                      NA               0
## 3                                 0                       0               2
## 4                                 1                       1               1
## 5                                 0                       0               0
## 6                                 0                       1               1
## 7                                 1                       1             100
## 8                                 1                       0              12
## 9                                 1                       1               1
## 10                                1                       0               8
## 11                                1                       0               6
## 12                                0                       0               3
## 13                                1                      NA               4
## 14                                1                       0               8
## 15                                1                       0               6
## 16                                1                       1               0
## 17                                0                       0               1
## 18                                1                       0              10
## 19                                0                       0               0
## 20                                0                       0               0
## 21                                1                       0               1
## 22                                0                       0               0
## 23                                0                       0               0
##    g_tubeever g_tube_at_1_year_or_beyond date_of_last_f_u
## 1           1                          1          8/24/21
## 2           1                          1         11/13/23
## 3           1                          1          1/29/24
## 4           1                          1         10/17/23
## 5           1                          1         12/14/22
## 6           1                          1          6/23/22
## 7           1                          1                 
## 8           1                          1          3/17/21
## 9           0                          2          5/27/12
## 10          1                          1          5/26/21
## 11          1                          1          3/21/24
## 12          1                          1           5/1/23
## 13          1                          1          7/18/18
## 14          1                          1          3/31/21
## 15          0                          2           2/4/25
## 16          1                          1          7/17/24
## 17          0                          0          1/29/25
## 18          1                          1          12/9/24
## 19          1                          1           7/5/23
## 20          1                          1          2/12/25
## 21          0                          0           8/4/25
## 22          1                         NA           7/3/25
## 23          1                          1          10/1/25
##    feeding_status_at_last_f_u
## 1                           2
## 2                           3
## 3                           1
## 4                           2
## 5                           1
## 6                           1
## 7                           1
## 8                           3
## 9                            
## 10                          2
## 11                          1
## 12                          1
## 13                          3
## 14                          2
## 15                          2
## 16                          2
## 17                          2
## 18                          3
## 19                          2
## 20                          3
## 21                          2
## 22                          3
## 23                         GT
##                                           respiratory_status_at_last_f_u
## 1                                                                      1
## 2                                                                      1
## 3                                                                      1
## 4                                                                      1
## 5                                                                      1
## 6                                                                      1
## 7                                                                      4
## 8                                                                      1
## 9                                                                       
## 10                                                                     1
## 11                                                                     2
## 12                                                                     1
## 13                                                                     4
## 14                                                                     1
## 15                                                                     1
## 16                                                                     1
## 17                                                                     1
## 18                                                                     1
## 19                                                                     1
## 20                                                                     1
## 21                                                                     1
## 22                                                                     1
## 23 Trach dependent, cont HME during the day and humidified air overnight
##                      respiratory_last_fu_other tracheostomy
## 1                                                         0
## 2                                         <NA>            0
## 3                                                         1
## 4                                                         0
## 5                                                         0
## 6                                                         0
## 7                                                         1
## 8                                                         0
## 9                                    Intubated            0
## 10                                        <NA>            0
## 11 O2 during day (0.5 to 1L) / nocturnal BiPAP            0
## 12                                                        1
## 13                                                        1
## 14                                                        0
## 15                                                        0
## 16                                                        0
## 17                                                        0
## 18                                                        0
## 19                                                        0
## 20                                                        0
## 21                                      8/4/25            0
## 22                                                        0
## 23                                                        1
##                                                                                                                                                                                                                                                                                                                                                                          general_comments
## 1                                                                                                                                                                                                                                                                                                 Patient's distal esophageal stricture congenital issue and not related to the procedure
## 2                                                                                                                                                                                                                    His reoperations were all reflux related, not related truly to initial EA repair. Maybe something to consider if we have a column of need for antireflux surgery. BZ
## 3                                                                                                                                                                                                                                                                                                                                                                                        
## 4                                                                                                                                                                                                                                                                                          Another kid with distal congenital stricture, maybe worth a column separately if we find more?
## 5                                                                                                                                                                                                                                                                                        Error in chart, notes calling the procedure a foker 2 when it was in fact just a primary repair.
## 6                                                                                                                                                                                                                                                                             X2 TEF primary repair at OSH unknown approach side.VR and cardiac surgery done at BCH via median sternotomy
## 7                                                                                                                                                                                                                                                                                                                                                       Unknown initial VR repair in 2009
## 8                                                                                                                                                                                                                 Initial arch resection at OSH 12/17/2015. Redo VR repair with  BCH with ligatation of subclavian artery and the end of the diverticulum of kommerell  without resection
## 9                                                                                                                                                                                                                                                                         Deceased ICU 05/27/12. Right arch noted intraop during EA/TEF repair. Esophageal dilatation not perfomed at BCH
## 10 alsa arising from a Kommerell diverticulum. Focal narrowing as the esophagus courses to the right side of the aortic arch. Left lower paratracheal soft tissue mass (compatible with thymic tissue).Patient might have had more dilatations since last FU, his primary treatment is in CA, not at BCH. GT present but parents doesn't use GT for supplementation. Staged TEF/EA repair
## 11                                                                                                                                                                                                                                                    Vascular ring: DAA, ToF, LPA is tight (on diuretics) s/p repair at OSH. Tracheobronchomalacia Complete tracheal rings s/p resection
## 12                                                                                                                                                                                                                                                                     Vascular ring: RAA with aberrant LSCA and left ligamentum. Exact number of dilations on OSH unknown after 04/25/23
## 13                                                                                                                                                                                                                                                                                              HIE during cardiac arrest on DOL 1 during flex bronch at OSH and later had a tracheostomy
## 14                                                                                                                                                                                                                                                                 Considering the diagnosis of CHARGE, she doesn't have the classic CHARGE. Testing: Two variants not known to be causal
## 15                                                                                                                                                                                                                                                                                                                                                         Nissen Fundoplication 09/19/14
## 16                                                                                                                                                                                                                                                                                                                                                              esophagopulmonary fistula
## 17                                                                                                                                                                                                                                                                                                      Imperforate anus also s/p psarp; possible distal congenital esophageal stricture.
## 18                                                                                                                                                                                                                                                                                                                                                                                       
## 19                                                                                                                                                                                                                                                                                                                                                                                       
## 20                                                                                                                                                                                                                                                                                                  Aberrant left subclavian artery division and reimplantation, Ductal ligament division
## 21                                                                                                                                                                                                                                                                                                                                                                                       
## 22                                                                                                                                                                                                                                                                                                                                                                                       
## 23                                                                                                                                                                                                                                                                                                                                                                                       
##    vascular_ringea_project_complete anti.reflux.surgery
## 1                                 2                   2
## 2                                 2                   1
## 3                                 2                   2
## 4                                 2                   2
## 5                                 2                   2
## 6                                 2                   2
## 7                                 2                   1
## 8                                 2                   1
## 9                                 2                   2
## 10                                2                   2
## 11                                2                   2
## 12                                2                   2
## 13                                2                   2
## 14                                2                   2
## 15                                2                   1
## 16                                2                   2
## 17                                2                   2
## 18                                2                   2
## 19                                2                   1
## 20                                2                   2
## 21                               NA                   2
## 22                               NA                   2
## 23                               NA                   1
##    distal.congenital.stricture Death
## 1                            1     2
## 2                            2     2
## 3                            2     2
## 4                            1     2
## 5                            2     2
## 6                            2     2
## 7                            2     2
## 8                            1     2
## 9                            2     1
## 10                           1     2
## 11                           2     2
## 12                           2     2
## 13                           2     2
## 14                           2     2
## 15                           2     2
## 16                           2     2
## 17                           1     2
## 18                           2     2
## 19                           2     2
## 20                           2     2
## 21                           2     2
## 22                           2     2
## 23                           2     2
##                                                                                            Complications.of.initial.EA.and.or.VR.repair
## 1                                                                                                                                  None
## 2                                 esophageal/gastric perforation requiring repair (per mom in clinic but not reflected in chart review)
## 3                                                                                                                                  None
## 4                                  Tracheobronchomalacia, repairing her tracheal diverticulum, and tracheal injury causing pneumothorax
## 5                                                                                                                                     .
## 6                                        Recurrent TEF requiring reoperation at OSH and contained leak which was managed nonoperatively
## 7  Recurrent TEF requiring reoperation, chronic aspiration requiring tracheostomy, strictures requiring >100 dilations c/b perforations
## 8                                                                                                                                  None
## 9                                                                                Pinpoint stricture, possible residual type H stricture
## 10                                                                       After anastomosis, c/b chylothorax with chest tube (resolved).
## 11                          Severe tracheomalacia (100% tracheal collapse at carina), tracheal granulation tissue, esophageal stricture
## 12                                                                                                                                 None
## 13                                                                                                                Tracheal diverticulum
## 14                                                                       Severe chylothorax requiring repeat thoracotomies, chest tubes
## 15                                                        Pneumothorax 2/2 VR repair, recurrent esophageal stricture requiring dilation
## 16    Leak from prior EA anastomosis that persisted for 8 months, tracheal stricture proximal to carina with large complex diverticulum
## 17                                                                                                          Distal congenital stricture
## 18                                                                                    Esophageal stricture requiring multiple dilations
## 19                                                                      Recurrent TEF, posterior tracheal mass with pus, laryngomalacia
## 20                                                                                                                                 None
## 21                              Anastomotic leak, failed extubation d/t pneumothorax, Esophageal stricture requiring multiple dilations
## 22                                                                                                                                 None
## 23    failed lap fundo at OSH 12/2024, now s/p ex-lap, hiatal hernia repair with phasix mesh 2x2cm, & Nissen fundoplication 9/25 at BCH
##                                                                                                               Reason.s...symptoms.complications..describe.which..for.referral
## 1                                                                           Congential Stricture requiring EIT and multiple dilations c/b small leak requiring EVAC placement
## 2  Dysphagia and aspiration Severe GERD with esophagitis and metaplastic changes of distal esophagus requiring now s/p esophagogastric disconnection with roux-en-Y June 2023
## 3                                                                                                                                                                           .
## 4                                                                                 Transferred for further management of TBM and esophageal obstructiong requiring reoperation
## 5                                                                                                                                                                           .
## 6                                                                                                                     Referred to BCH for repair of his CAVC and repair of VR
## 7                                                                              Referred for further management due to strictures requriing multiple dilations c/b perforation
## 8                                              Persistent respiratory symptoms, aspiration pneumonias s/p OSH EA/TEF repair, vascular ring repair, and Nissen fundoplication.
## 9                                                                             Recurrent respiratory symptoms, pinhole esophageal stricture, suspected type H residual fistula
## 10                                                                                               Referred for anastomosis of previous long gap EA (s/p fistula ligation only)
## 11                                                                                                                   Severe tracheomalacia (100% tracheal collapse at carina)
## 12                                                                                   Referred for definitive repair of long-gap EA/TEF (originally ligated with spit fistula)
## 13             Respiratory due to severe tracheomalacia, presence of aortic arch with tracheobronchial compression as well as severe esophageal stricture requiring dilations
## 14                                                                                                                                     Referred for primary anastomosis of EA
## 15                                                                                                                                                       Recurrent pneumonias
## 16                                                                                                                                                 Persistent esophageal leak
## 17                                                                                                Delivery at BWH, prenatally diagnosed vascular ring with likely aortic arch
## 18                                                                                                                   Daily vomiting limiting PO intake ability, oral aversion
## 19                                                                                                                                   Recurrent pneumonias with tracheomalacia
## 20                                            Modified barium swallow study with contrast entering trachea concerning for distal TEF, known prenatally diagnosed ToF (at BCH)
## 21                                                                                                                           Pneumonias with recurrent respiratory admissions
## 22                                        Known vascular ring with polyhydramnios prenatally with R aortic arch, duodenal obstruction, possible blind ending esophageal pouch
## 23                                                                                                                                Referred for large, recurrent hiatal hernia
##            Age.at.the.time.of.referral
## 1     1 year, 6 months, and 9 days old
## 2       14 years, 7 months, and 3 Days
## 3                                    .
## 4              1 month and 12 days old
## 5                                    .
## 6             4 month and two days old
## 7  10 years, 4 months, and 19 days old
## 8    1 year, 3 months, and 20 days old
## 9              1 month and 20 days old
## 10             4 months and 6 days old
## 11             5 months and 9 days old
## 12   1 year, 7 months, and 24 days old
## 13            5 months and 21 days old
## 14                             30 days
## 15      9 years, 6 months, and 12 days
## 16                 6 months and 6 days
## 17                          0 days old
## 18      1 year, 11 months, and 10 days
## 19      4 years, 9 months, and 11 days
## 20                          0 days old
## 21      1 year, 11 months, and 29 days
## 22                          0 days old
## 23      2 years, 6 months, and 23 days
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 EA.Reoperations
## 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          None
## 2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          None
## 3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
## 4                                                                                                                                                                                                                                                                                                                                                                                                                                                 traction-induced/Foker Sept 2019, Division of acquired TEF and posterior tracheopexy Oct 2020
## 5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             .
## 6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     TEF repair at OSH 06/2021
## 7                                                                                                                                                                                                                                                                                                                                                                                                                                                      Left thoracotomy, esophageal resection and primary repair of recurrent TEF (OSH) 05/2011
## 8                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          None
## 9                                                                                                                                                                                                                                                                                                                                                                                                                               Repair attempt via R thoracotomy, injury to aortic arch with cardiopulmonary bypass and reinforced patch repair
## 10                                                                                                                                                                                                                                                                                                                                           R thoracotomy with anastomosis (4/2020), redo R thoracotomy with resection of esophageal stricture and reanastomosis (slide esophagoplasty), EGD with distal congenital stricture dilated (9/2021)
## 11                                                                                                                                                                                                                                                                                                                                                                                        Posterior tracheopexy, bronchopexy, divertiulectomy, stricturoplasty (11/2021), Redo sternotomy with tracheoresection, sliding tracheoplasty (1/2021)
## 12 Temporary tracheostomy closure, silver nitrate to trach site granuloma, cervical neck dissection with esophagostomy resiting, tracheostomy replacement (7/2022), Temporary tracheostomy closure with replacement, L thoracotomy, LoA, redo L neck dissection, cervical esophagostomy resiting to L chest, Foker 1 with external traction system, botox indo esophageal pouches (10/2022), temporary tracheostomy closure and replacement, redo L thoracotomy with LoA, takedown of external traction, slide esophageal anastomosis (Foker 2)
## 13                                                                                                                                                                                                                                                                                                                                                                                                      Posterior, anterior tracheopexy, tracheal diverteculectomy, tracheal resection with slide tracheoplasty (1/2017), tracheostomy (2/2017)
## 14                                                                                                                                                                                                                                                                                                                                                                                                               L thoracotomy with decortication, ligation of chyle leak (9/2012), L thoracotomy with LoA, primary anastomosis of EA (10/2012)
## 15                                                                                                                                                                                                                                                                                                                                                                                                                                Resection of tracheal diverticulum and tapering longitudinal tracheoplasty, esophageal mobilization (11/2024)
## 16                                                                                                                                                                                                                                                                                                                                                                                                     R thoracotomy, resection of esophageal diverticulum and rotational esophagoplasty, resection of lung cyst with esophagopulmonary fistula
## 17                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         None
## 18                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         None
## 19                                                                                                                                                                                                                                                                                                R neck dissection, rotation esophagoplasty, division of TEF, resection of cervical tracheal mass, repair of cervical esophagus, redo R thoracotomy, rotation cervical esophagoplasty, posterior tracheopexy, L mainstom posterior bronchopexy
## 20                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         None
## 21                                                                                                                                                                                                                                                                                                           L thoracotomy, resection of tracheal diverticulum with longitudinal repair, posterior thoracic tracheopexy, L sided rotational esophagoplasty (7/2025), redo L thoracotomy, takedown of tracheopexy and redo posterior tracheopexy
## 22                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         None
## 23                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Leak requiring reopening of L thoracotomy and chest tube placement
##                                                                                        VR.Reoperations
## 1                                                                                                 None
## 2                                                                                                 None
## 3                                                                                                     
## 4                                                     Division and reimplantation of Subclavian artery
## 5                                                                                                    .
## 6                                            ligation and division of the ligamentum arteriosum at BCH
## 7                                                                                                 None
## 8                                                                                                 None
## 9                                                                                                 None
## 10                                                                                                None
## 11                                                Redo sternotomy, aortic arch reconstruction (1/2021)
## 12                                                                                                None
## 13                                                            Aortic division with uncrossing (1/2017)
## 14                                                                                                None
## 15              Sternotomy, division of ductal ligament, aortic uncrossing with patch plasty (11/2024)
## 16                                                                                                None
## 17                                                                                                None
## 18                                                                                                None
## 19                                                            Redo R throacotomy, descending aortopexy
## 20                      Sternotomy, ligation of ligamentum arteriosum, enlargement of PFO, VSD closure
## 21 Redo L thoracotomy, repair of coarctation of aorta with patchplasty bovine, redo aortopexy (8/2025)
## 22                                                                                                None
## 23                                                                                                None
##                                                                                                                                                                                                         Outcome.of.reoperation.Current.Status
## 1                                                                                                                                                        She is tolerating a full PO diet with dysphagia occurring a couple of times a month.
## 2                                                                                                                                          Taking 2 PO small meals per day of variety of textures (steak, chicken, breads) without dysphagia.
## 3                                                                                                                                                                                 Predominantly G-tube fed but can tolerate pureed PO intake.
## 4  Reoperation at BCH complicated by large diverticulum requiring eVAC treatment in October 2019 Acquired/recurrent TEF and tracheomalacia requiring reoperation. Now tolerating PO intake and gaining weight appropriately with periodic EGD
## 5                                                                                                                                                                                                                                            
## 6                                                                                                                            Majority of feeds via G-tube, recurrent respiratory infections, nocturnal desaturation requiring prn O2 and CPAP
## 7                                                                                                                                 G-tube for feeds does not tolerate PO intake. Continues to have tracheostomy and requiring oxygen at night.
## 8                                                                                                                                                                                                              Tolerating PO and G-tube feeds
## 9                                                        Death due to injury to aortic arch resulting in massive exsanguination, massive pulmonary hemorrhage followed by significantly impaired cardiac, pulmonary, and neurologic function.
## 10                                                                                                                                                                                    Taking PO, g-tube removed, gaining weight appropriately
## 11                                                                                                                                      J tube feeds only d/t aspiration risk with b/l vocal cord paralysis, increasing G tube clamping times
## 12                                                                          Currently with esophageal stricture and concern for eosinophilic esophagitis currently on GJ tube formula. Being managed mostly at OSH so limited data available.
## 13                                                                                                                                                      Lost to follow up, had traversable upper esophageal stenosis, 70% narrowed L bronchus
## 14                                                                                                                                                                                                        Tolerating full PO diet, has reflux
## 15                                                                                                                                                                                                                 Full PO, occasional coughs
## 16                                                                                                                                                                                                       Mild reflux, tolerating full PO diet
## 17                                                                                                                                                                                                                     Tolerating solid foods
## 18                                                                                                                                                Receiving pyloric botox, eating pureed and limited solid foods, however limited weight gain
## 19                                                                                                                                                                                                 Tolerating solid foods with good appettite
## 20                                                                                                                                                                  Occasional reflux, tolerating G tube feeds, taking small amounts by mouth
## 21                                                                                                         Frequent vomiting with weakness but tolerating milk and some solids, continued URIs but improving off baseline respiratory regimen
## 22                                                                                                                                                                                         Tolerating PO feeds without issues, g tube removed
## 23                                                                                                                                           Currently s/p redo hiatal hernia repair after fundoplication migrated to chest. Trach dependent.
##    Lessons.Learned gestational_age_weeks gestational_age_formatted
## 1                .              37.00000                    37w 0d
## 2                .              36.00000                    36w 0d
## 3                .              36.00000                    36w 0d
## 4                .              36.00000                    36w 0d
## 5                .              41.00000                    41w 0d
## 6                               34.28571                    34w 2d
## 7                               39.00000                    39w 0d
## 8                               31.00000                    31w 0d
## 9                               39.00000                    39w 0d
## 10                              33.42857                    33w 3d
## 11                              32.00000                    32w 0d
## 12                              35.57143                    35w 4d
## 13                              34.57143                    34w 4d
## 14                              36.28571                    36w 2d
## 15                              39.00000                    39w 0d
## 16                              30.00000                    30w 0d
## 17                              37.00000                    37w 0d
## 18                              36.00000                    36w 0d
## 19                              31.00000                    31w 0d
## 20                              39.00000                    39w 0d
## 21                              39.00000                    39w 0d
## 22                              38.00000                    38w 0d
## 23                              34.57143                    34w 4d
##                 preterm_category                 Birth_Weight
## 1                     Term birth       Low birth weight (LBW)
## 2      Late preterm birth (LPTB)                         <NA>
## 3      Late preterm birth (LPTB)                         <NA>
## 4      Late preterm birth (LPTB)       Low birth weight (LBW)
## 5                     Term birth       Low birth weight (LBW)
## 6      Late preterm birth (LPTB)       Low birth weight (LBW)
## 7                     Term birth                         <NA>
## 8      Very preterm birth (VPTB) Very low birth weight (VLBW)
## 9                     Term birth    Normal birth weight (NBW)
## 10 Moderate preterm birth (MPTB)                         <NA>
## 11 Moderate preterm birth (MPTB) Very low birth weight (VLBW)
## 12     Late preterm birth (LPTB)    Normal birth weight (NBW)
## 13     Late preterm birth (LPTB)       Low birth weight (LBW)
## 14     Late preterm birth (LPTB)       Low birth weight (LBW)
## 15                    Term birth    Normal birth weight (NBW)
## 16     Very preterm birth (VPTB) Very low birth weight (VLBW)
## 17                    Term birth       Low birth weight (LBW)
## 18     Late preterm birth (LPTB)       Low birth weight (LBW)
## 19     Very preterm birth (VPTB)       Low birth weight (LBW)
## 20                    Term birth       Low birth weight (LBW)
## 21                    Term birth    Normal birth weight (NBW)
## 22                    Term birth    Normal birth weight (NBW)
## 23     Late preterm birth (LPTB)       Low birth weight (LBW)
library(dplyr)
EAandVRData <- EAandVRData %>%
  rename(
    Sex = sex,
    `Type of EA` = type_ea,
    Dysphagia = dysphagia,
    Aspiration = aspiration,
    `Cyanotic Episode` = cyanotic_episode,
    `Laryngeal Cleft` = laryngealcleft,
    `Laryngeal Cleft Repair` = laryngealcleftrepair,
    `VACTERL Anomaly` = vacteryl_anomaly,
    `Recurrent Respiratory Infection` = recurrentrespiratoryinfection,
    `Vocal Cord Dysfunction` = vocalcorddysfunction,
    `Genetic Anomaly` = geneticanomaly,
    `Which VACTERL Anomaly` = which_vacteryl_anomaly,
    `Trisomy 21` = trisomy21,
    CHARGE = charge,
    `Other Genetic Anomaly` = geneticanomalyother,
    `Double Arch` = doublearch,
    `Right Aortic Arch` = rightaorticarch,
    Circumflex = circumflex,
    `Mirror Image Branching` = mirror_image_branching,
    ALSCA = alsca,
    ARSCA = arsca,
    `Complete Vascular Ring` = completevr,
    `BCH Patient` = bch_patient,
    `Concomitant Congenital Heart Disease` = concomitant_congenital_heart_dx,
    `Prenatal Diagnosis VR Orea` = prenatal_dx_vrorea,
    `Preop Echo Diagnosis VR ORRAA` = eapreopechodiagvrorraa,
    `Preop CT Diagnosis VR` = eapreopctdxvr,
    `Preop MR Diagnosis VR` = eapreopmrdxvr,
    `Stricture Resection` = stricture_resection,
    `Timing of EA Repair` = timing_of_ea_repair,
    `VR Repair At BCH` = vr_repair_at_bch,
    `VR Repair at Pexy or Reop Esophageal Surgery` = vr_repair_at_the_time_of_pexy_or_reoperative_esophageal_surgery,
    `Reoperative VR Repair At BCH` = reoperative_vr_repair_at_bch,
    Thoracoscopy = thoracoscopy,
    `Descending Aortopexy` = descending_aortopexy,
    `Esophageal Anastomotic Leak` = esophageal_anastomotic_leak,
    `Esophageal Anastomotic Stricture` = esophageal_anastomotic_stricture,
    `Recurrent Esophageal Fistula` = recurrent_esoph_fistula,
    `G-Tube Ever` = g_tubeever,
    Tracheostomy = tracheostomy,
    `Anti-Reflux Surgery` = anti.reflux.surgery,
    `Distal Congenital Stricture` = distal.congenital.stricture,
    Death = Death,
    `Complications of Initial EA/VR Repair` = Complications.of.initial.EA.and.or.VR.repair,
    `Reason(s) for Referral (Symptoms/Complications)` = Reason.s...symptoms.complications..describe.which..for.referral,
    `Age at Time of Referral` = Age.at.the.time.of.referral,
    `Outcome of Reoperation/Current Status` = Outcome.of.reoperation.Current.Status,
    `Gestational Age (Weeks)` = gestational_age_weeks,
    `Gestational Age (Formatted)` = gestational_age_formatted,
    `Preterm Category` = preterm_category,
    `Birth Weight` = Birth_Weight,
    `EA Reoperations` = EA.Reoperations, 
    `VR Reoperations` = VR.Reoperations,
    `Lessons Learned` = Lessons.Learned
  )
# Recode sex
EAandVRData1 <- EAandVRData %>%
  mutate(Sex = case_when(
    Sex == 1 ~ "Male",
    Sex == 0 ~ "Female",
    TRUE ~ NA_character_
  ))

# Recode type_ea
EAandVRData2 <- EAandVRData1 %>%
  mutate(type_ea = case_when(
    `Type of EA` == 1 ~ "A",
    `Type of EA` == 2 ~ "B",
    `Type of EA` == 3 ~ "C",
    `Type of EA` == 4 ~ "D",
    `Type of EA` == 5 ~ "E",
    TRUE ~ NA_character_
  ))

variables_to_recode <- c(
  "Dysphagia", 
  "Aspiration", 
  "Cyanotic Episode", 
  "Laryngeal Cleft", 
  "VACTERL Anomaly", 
  "Recurrent Respiratory Infection", 
  "Vocal Cord Dysfunction", 
  "Genetic Anomaly", 
  "Which VACTERL Anomaly", 
  "Trisomy 21", 
  "CHARGE", 
  "Other Genetic Anomaly", 
  "Double Arch", 
  "Right Aortic Arch", 
  "Circumflex", 
  "Mirror Image Branching", 
  "ALSCA", 
  "ARSCA", 
  "Stricture Resection",
  "Complete Vascular Ring", 
  "Laryngeal Cleft Repair",
  "BCH Patient", 
  "Concomitant Congenital Heart Disease", 
  "Prenatal Diagnosis VR Orea", 
  "Preop Echo Diagnosis VR ORRAA", 
  "Preop CT Diagnosis VR", 
  "Preop MR Diagnosis VR", 
  "EA Repair At BCH", 
  "VR Repair At BCH", 
  "VR Repair at Pexy or Reop Esophageal Surgery", 
  "Reoperative VR Repair At BCH", 
  "Thoracoscopy", 
  "Descending Aortopexy", 
  "Esophageal Anastomotic Leak", 
  "Esophageal Anastomotic Stricture", 
  "Recurrent Esophageal Fistula", 
  "G-Tube Ever", 
  "Tracheostomy"
)

recode_ynu <- function(x) {
  x <- tolower(as.character(x))
  dplyr::case_when(
    x %in% c("no", "0", "false", "n") ~ "No",
    x %in% c("yes", "1", "true", "y") ~ "Yes",
    x %in% c("unknown", "2", "unk", "u", "") ~ "Unknown",
    TRUE ~ NA_character_
  )
}

for (var in variables_to_recode) {
  if (var %in% names(EAandVRData2)) {
    EAandVRData2[[var]] <- factor(recode_ynu(EAandVRData2[[var]]), levels = c("No", "Yes", "Unknown"))
  }
}

colnames(EAandVRData2)
##   [1] "studyid"                                        
##   [2] "mrn"                                            
##   [3] "lastname"                                       
##   [4] "firstname"                                      
##   [5] "dob"                                            
##   [6] "gestational_age"                                
##   [7] "birth_weight"                                   
##   [8] "Sex"                                            
##   [9] "Type of EA"                                     
##  [10] "Dysphagia"                                      
##  [11] "Aspiration"                                     
##  [12] "Cyanotic Episode"                               
##  [13] "Laryngeal Cleft"                                
##  [14] "typelaryngealcleft"                             
##  [15] "Laryngeal Cleft Repair"                         
##  [16] "Recurrent Respiratory Infection"                
##  [17] "Vocal Cord Dysfunction"                         
##  [18] "Genetic Anomaly"                                
##  [19] "VACTERL Anomaly"                                
##  [20] "Which VACTERL Anomaly"                          
##  [21] "Trisomy 21"                                     
##  [22] "CHARGE"                                         
##  [23] "Other Genetic Anomaly"                          
##  [24] "Double Arch"                                    
##  [25] "Right Aortic Arch"                              
##  [26] "Circumflex"                                     
##  [27] "Mirror Image Branching"                         
##  [28] "ALSCA"                                          
##  [29] "ARSCA"                                          
##  [30] "Complete Vascular Ring"                         
##  [31] "BCH Patient"                                    
##  [32] "Concomitant Congenital Heart Disease"           
##  [33] "concomitant_congenital_heart_daig"              
##  [34] "Prenatal Diagnosis VR Orea"                     
##  [35] "Preop Echo Diagnosis VR ORRAA"                  
##  [36] "Preop CT Diagnosis VR"                          
##  [37] "Preop MR Diagnosis VR"                          
##  [38] "VR Repair At BCH"                               
##  [39] "ea_vr_repair"                                   
##  [40] "if_staged_which_first"                          
##  [41] "VR Repair at Pexy or Reop Esophageal Surgery"   
##  [42] "Reoperative VR Repair At BCH"                   
##  [43] "Stricture Resection"                            
##  [44] "Timing of EA Repair"                            
##  [45] "initial_esophageal_repair"                      
##  [46] "date_of_initial_ea_repair"                      
##  [47] "initial_ea_repair_approach_side"                
##  [48] "initial_ea_repair_loca"                         
##  [49] "reop_esophageal_repair"                         
##  [50] "eareoperation_indication"                       
##  [51] "reop_esophageal_other"                          
##  [52] "reop_ea_repair_loca"                            
##  [53] "date_of_reop_ea_repair"                         
##  [54] "first_reop_approach_side"                       
##  [55] "sec_reop_esophageal_repair_2"                   
##  [56] "second_esophag_reop_indication"                 
##  [57] "reop2_esophageal_other"                         
##  [58] "reop2ea_repair_loca"                            
##  [59] "date_of_sec_reop_ea_repair_2"                   
##  [60] "second_eareop_approach_side"                    
##  [61] "third_reop_esophageal_repair"                   
##  [62] "third_esophag_reop_indication"                  
##  [63] "reop3_esophageal_other"                         
##  [64] "reop3ea_repair_loca"                            
##  [65] "date_of_third_reop_ea_repair"                   
##  [66] "third_eareop_approach_side"                     
##  [67] "initial_vr_repair"                              
##  [68] "date_of_initial_vr_repair"                      
##  [69] "first_vr_repair_approach_side"                  
##  [70] "initial_vr_loca"                                
##  [71] "reop_vr_repair"                                 
##  [72] "reop_vr_repair_approach_side_2"                 
##  [73] "reop_vr_loca"                                   
##  [74] "date_of_reop_vr_repair"                         
##  [75] "Thoracoscopy"                                   
##  [76] "tracheopexy"                                    
##  [77] "Descending Aortopexy"                           
##  [78] "Esophageal Anastomotic Leak"                    
##  [79] "Esophageal Anastomotic Stricture"               
##  [80] "Recurrent Esophageal Fistula"                   
##  [81] "total_dilations"                                
##  [82] "G-Tube Ever"                                    
##  [83] "g_tube_at_1_year_or_beyond"                     
##  [84] "date_of_last_f_u"                               
##  [85] "feeding_status_at_last_f_u"                     
##  [86] "respiratory_status_at_last_f_u"                 
##  [87] "respiratory_last_fu_other"                      
##  [88] "Tracheostomy"                                   
##  [89] "general_comments"                               
##  [90] "vascular_ringea_project_complete"               
##  [91] "Anti-Reflux Surgery"                            
##  [92] "Distal Congenital Stricture"                    
##  [93] "Death"                                          
##  [94] "Complications of Initial EA/VR Repair"          
##  [95] "Reason(s) for Referral (Symptoms/Complications)"
##  [96] "Age at Time of Referral"                        
##  [97] "EA Reoperations"                                
##  [98] "VR Reoperations"                                
##  [99] "Outcome of Reoperation/Current Status"          
## [100] "Lessons Learned"                                
## [101] "Gestational Age (Weeks)"                        
## [102] "Gestational Age (Formatted)"                    
## [103] "Preterm Category"                               
## [104] "Birth Weight"                                   
## [105] "type_ea"
library(dplyr)
library(forcats)
EAVRDataClean <- EAandVRData2 %>%
  # Recode Timing of EA Repair
  mutate(
    `Timing of EA Repair` = as.character(`Timing of EA Repair`),
    `Timing of EA Repair` = recode(`Timing of EA Repair`,
      `1` = "Early/Neonatal",
      `2` = "Delayed/Staged (Infant)")
  ) %>%
  
  # Rename and recode Initial Esophageal Repair
  rename(`Initial Esophageal Repair` = initial_esophageal_repair) %>%
  mutate(
    `Initial Esophageal Repair` = as.character(`Initial Esophageal Repair`),
    `Initial Esophageal Repair` = recode(`Initial Esophageal Repair`,
      `1` = "Primary repair Only",
      `2` = "Primary Repair with TEF",
      `3` = "TEF Only",
      `4` = "traction-induced/Foker",
      `5` = "replacement/interposition",
      `6` = "Esophagoplasty/Tracheopexy",
      `7` = "Not Performed",
      `8` = "Stricturoplasty",
      `9` = "Stricturoplasty/Tracheopexy",
      `10` = "Esophagostomy/Spit Fistula")
  ) %>%
  
  # Rename date_of_initial_ea_repair
  rename(`Date of Initial EA Repair` = date_of_initial_ea_repair) %>%
  
  # Recode initial_ea_repair_approach_side and rename
  mutate(initial_ea_repair_approach_side = as.character(initial_ea_repair_approach_side)) %>%
  mutate(initial_ea_repair_approach_side = recode(initial_ea_repair_approach_side,
    `1` = "Left",
    `2` = "Right",
    `3` = "Not Performed",
    `4` = "Unknown")
  ) %>%
  rename(`Initial EA Repair Approach Side` = initial_ea_repair_approach_side) %>%
  
  # Recode initial_ea_repair_loca and rename
  mutate(initial_ea_repair_loca = as.character(initial_ea_repair_loca)) %>%
  mutate(initial_ea_repair_loca = recode(initial_ea_repair_loca,
    `1` = "BCH",
    `2` = "OSH",
    `3` = "Unknown")
  ) %>%
  rename(`Initial EA Repair Location` = initial_ea_repair_loca) %>%
  
  # Rename and recode First Reoperative Esophageal Repair
  rename(`First Reoperative Esophageal Repair` = reop_esophageal_repair) %>%
  mutate(
    `First Reoperative Esophageal Repair` = as.character(`First Reoperative Esophageal Repair`),
    `First Reoperative Esophageal Repair` = recode(`First Reoperative Esophageal Repair`,
      `1` = "Primary repair Only",
      `2` = "Primary Repair with TEF",
      `3` = "TEF Only",
      `4` = "traction-induced/Foker",
      `5` = "replacement/interposition",
      `6` = "Esophagoplasty/Tracheopexy",
      `7` = "Not Performed",
      `8` = "Stricturoplasty",
      `9` = "Stricturoplasty/Tracheopexy",
      `10` = "Esophagostomy/Spit Fistula",
      `11` = "Tracheopexy",
      `12` = "Esophagoplasty",
      `13` = "Delayed Primary Repair",
      `14` = "Stricture Resection",
      `15` = "Anterior Aortopexy/Anterior Tracheopexy",
      `16` = "Esophagostomy/Spit Fistula Revision",
      `17` = "EPF Fistula")
  ) %>%
  
  # Rename and recode First Esophageal Reoperation Indication
  rename(`First Esophageal Reoperation Indication` = eareoperation_indication) %>%
  mutate(
    `First Esophageal Reoperation Indication` = as.character(`First Esophageal Reoperation Indication`),
    `First Esophageal Reoperation Indication` = recode(`First Esophageal Reoperation Indication`,
      `1` = "Recurrent Fistula",
      `2` = "Esophageal Stricture",
      `3` = "Esophageal leak",
      `4` = "Tracheomalacia",
      `5` = "Vascular Compression",
      `6` = "Unrepaired EA",
      `7` = "None",
      `8` = "Other")
  ) %>%
  
  # Recode and rename First Esophageal Repair Location
  mutate(reop_ea_repair_loca = as.character(reop_ea_repair_loca)) %>%
  mutate(reop_ea_repair_loca = recode(reop_ea_repair_loca,
    `1` = "BCH",
    `2` = "OSH",
    `3` = "Unknown")
  ) %>%
  rename(`First Esophageal Repair Location` = reop_ea_repair_loca) %>%
  
  # Rename date_of_reop_ea_repair
  rename(`Date of First Esophageal Reoperation Repair` = date_of_reop_ea_repair) %>%
  
  # Recode and rename First Esophageal Reoperation Approach
  mutate(first_reop_approach_side = as.character(first_reop_approach_side),
         first_reop_approach_side = recode(first_reop_approach_side,
           `1` = "Left",
           `2` = "Right",
           `3` = "Not Performed",
           `4` = "Unknown",
           `5` = "Sternotomy")) %>%
  rename(`First Esophageal Reoperation Approach` = first_reop_approach_side) %>%
  
  # Rename and recode Second Esophageal Reoperation
  rename(`Second Esophageal Reoperation` = sec_reop_esophageal_repair_2) %>%
  mutate(
    `Second Esophageal Reoperation` = as.character(`Second Esophageal Reoperation`),
    `Second Esophageal Reoperation` = recode(`Second Esophageal Reoperation`,
      `1` = "Primary repair Only",
      `2` = "Primary Repair with TEF",
      `3` = "TEF Only",
      `4` = "traction-induced/Foker",
      `5` = "replacement/interposition",
      `6` = "Esophagoplasty/Tracheopexy",
      `7` = "Not Performed",
      `8` = "Stricturoplasty",
      `9` = "Stricturoplasty/Tracheopexy",
      `10` = "Esophagostomy/Spit Fistula",
      `11` = "Tracheopexy",
      `12` = "Esophagoplasty",
      `13` = "Delayed Primary Repair",
      `14` = "Stricture Resection",
      `15` = "Anterior Aortopexy/Anterior Tracheopexy",
      `16` = "Esophagostomy/Spit Fistula Revision",
      `17` = "EPF Fistula")
  ) %>%
  
  # Rename and recode Second Esophageal Reoperation Indication
  rename(`Second Esophageal Reoperation Indication` = second_esophag_reop_indication) %>%
  mutate(
    `Second Esophageal Reoperation Indication` = as.character(`Second Esophageal Reoperation Indication`),
    `Second Esophageal Reoperation Indication` = recode(`Second Esophageal Reoperation Indication`,
      `1` = "Recurrent Fistula",
      `2` = "Esophageal Stricture",
      `3` = "Esophageal leak",
      `4` = "Tracheomalacia",
      `5` = "Vascular Compression",
      `6` = "Unrepaired EA",
      `7` = "None",
      `8` = "Other")
  ) %>%
  
  # Recode and rename Second Esophageal Reoperation Location
  mutate(reop2ea_repair_loca = as.character(reop2ea_repair_loca)) %>%
  mutate(reop2ea_repair_loca = recode(reop2ea_repair_loca,
    `1` = "BCH",
    `2` = "OSH",
    `3` = "Unknown")
  ) %>%
  rename(`Second Esophageal Reoperation Location` = reop2ea_repair_loca) %>%
  
  # Rename date_of_sec_reop_ea_repair_2
  rename(`Date Second Esophageal Reoperation` = date_of_sec_reop_ea_repair_2) %>%
  
  # Recode and rename Second Esophageal Repair Approach
  mutate(second_eareop_approach_side = as.character(second_eareop_approach_side),
         second_eareop_approach_side = recode(second_eareop_approach_side,
           `1` = "Left",
           `2` = "Right",
           `3` = "Not Performed",
           `4` = "Unknown",
           `5` = "Sternotomy")) %>%
  rename(`Second Esophageal Repair Approach` = second_eareop_approach_side) %>%
  
  # Rename and recode Initial VR Repair
  rename(`Initial VR Repair` = initial_vr_repair) %>%
  mutate(
    `Initial VR Repair` = as.character(`Initial VR Repair`),
    `Initial VR Repair` = recode(`Initial VR Repair`,
      `0` = "no repair",
      `1` = "divide only aberrant subclavian",
      `2` = "divide/reimplant",
      `3` = "arch resection",
      `4` = "arch reconstruction/bypass",
      `5` = "ductal ligament division only",
      `6` = "Unknown",
      `7` = "Division of Aortic Arch and Ductal Ligament Division")
  ) %>%
  
  # Rename date_of_initial_vr_repair
  rename(`Date of Initial VR Repair` = date_of_initial_vr_repair) %>%
  
  # Recode and rename Initial VR Repair Approach
  mutate(first_vr_repair_approach_side = as.character(first_vr_repair_approach_side),
         first_vr_repair_approach_side = recode(first_vr_repair_approach_side,
           `1` = "Left",
           `2` = "Right",
           `3` = "Sternotomy",
           `4` = "Not Performed",
           `5` = "Unknown")) %>%
  rename(`Initial VR Repair Approach` = first_vr_repair_approach_side) %>%
  
  # Recode and rename Initial VR Repair Location
  mutate(initial_vr_loca = as.character(initial_vr_loca)) %>%
  mutate(initial_vr_loca = recode(initial_vr_loca,
    `1` = "BCH",
    `2` = "OSH",
    `3` = "Unknown")
  ) %>%
  rename(`Initial VR Repair Location` = initial_vr_loca) %>%
  
  # Rename and recode First VR Reoperation
  rename(`First VR Reoperation` = reop_vr_repair) %>%
  mutate(
    `First VR Reoperation` = as.character(`First VR Reoperation`),
    `First VR Reoperation` = recode(`First VR Reoperation`,
      `0` = "no repair",
      `1` = "divide only aberrant subclavian",
      `2` = "divide/reimplant",
      `3` = "arch resection",
      `4` = "arch reconstruction/bypass",
      `5` = "ductal ligament division only",
      `6` = "Unknown")
  ) %>%
  
  # Recode and rename First Reoperation VR Repair Approach
  mutate(reop_vr_repair_approach_side_2 = as.character(reop_vr_repair_approach_side_2),
         reop_vr_repair_approach_side_2 = recode(reop_vr_repair_approach_side_2,
           `1` = "Left",
           `2` = "Right",
           `3` = "Sternotomy",
           `4` = "Not Performed",
           `5` = "Unknown")) %>%
  rename(`First Reoperation VR Repair Approach` = reop_vr_repair_approach_side_2) %>%
  
  # Recode and rename First VR Reoperation Location
  mutate(reop_vr_loca = as.character(reop_vr_loca)) %>%
  mutate(reop_vr_loca = recode(reop_vr_loca,
    `1` = "BCH",
    `2` = "OSH",
    `3` = "Unknown")
  ) %>%
  rename(`First VR Reoperation Location` = reop_vr_loca) %>%
  
  # Rename date_of_reop_vr_repair
  rename(`Date of First VR Reoperation` = date_of_reop_vr_repair) %>%
  
  # Recode Anti-Reflux Surgery, Distal Congenital Stricture, Death columns as Yes/No
  mutate(across(c(`Anti-Reflux Surgery`, `Distal Congenital Stricture`, Death),
                ~ as.character(.))) %>%
  mutate(across(c(`Anti-Reflux Surgery`, `Distal Congenital Stricture`, Death),
                ~ recode(., `1` = "Yes", `2` = "No")))
EAVRDataClean1 <- EAVRDataClean %>%
  mutate(
    Vascular_Ring = case_when(
      `Double Arch` == "Yes" ~ "Double Arch",
      `Right Aortic Arch` == "Yes" & `Mirror Image Branching` == "Yes" ~ "Circumflex Right Aortic Arch with Mirror Image Branching and Left Ligamentum Arteriosum",
      `Right Aortic Arch` == "Yes" & ALSCA == "Yes" ~ "Right Aortic Arch with Aberrant Left Subclavian Artery",
      TRUE ~ NA_character_
    )
  ) %>%
  filter(!is.na(Vascular_Ring)) %>%
  mutate(Vascular_Ring = factor(Vascular_Ring))
library(dplyr)
library(lubridate)

EAVRDataClean2 <- EAVRDataClean1 %>%
  select(
    # Existing columns
    mrn,
    `Birth Weight`,
    Sex,
    dob,
    type_ea,
    lastname,
    `Preterm Category`,
    BCH_Patient = `BCH Patient`,
    Dysphagia,
    Aspiration,
    `Cyanotic Episode`,
    `Laryngeal Cleft`,
    `Recurrent Respiratory Infection`,
    `Vocal Cord Dysfunction`,
    `Genetic Anomaly`,
    `VACTERL Anomaly`,
    `Trisomy 21`,
    CHARGE,
    `Other Genetic Anomaly`,
    `Double Arch`,
    `Right Aortic Arch`,
    Circumflex,
    ALSCA,
    ARSCA,
    `Complete Vascular Ring`,
    Vascular_Ring,
    `Concomitant Congenital Heart Disease`,
    `Prenatal Diagnosis VR Orea`,
    `Preop Echo Diagnosis VR ORRAA`,
    `Preop CT Diagnosis VR`,
    `Preop MR Diagnosis VR`,
    `Initial Esophageal Repair`,
    `Date of Initial EA Repair`,
    `Initial EA Repair Approach Side`,
    `Initial EA Repair Location`,
    `Initial VR Repair`,
    `Date of Initial VR Repair`,
    `Initial VR Repair Approach`,
    `Initial VR Repair Location`,
    `First VR Reoperation`,
    `First Reoperation VR Repair Approach`,
    `First VR Reoperation Location`,
    `Date of First VR Reoperation`,
    ea_vr_repair,
    if_staged_which_first,
    `VR Repair at Pexy or Reop Esophageal Surgery`,
    `Reoperative VR Repair At BCH`,
    `Timing of EA Repair`,
    tracheopexy,
    `Descending Aortopexy`,
    `First Reoperative Esophageal Repair`,
    `First Esophageal Reoperation Indication`,
    `First Esophageal Repair Location`,
    `Date of First Esophageal Reoperation Repair`,
    `First Esophageal Reoperation Approach`,
    `Second Esophageal Reoperation`,
    `Second Esophageal Reoperation Indication`,
    reop2_esophageal_other,
    `Second Esophageal Reoperation Location`,
    `Date Second Esophageal Reoperation`,
    `Second Esophageal Repair Approach`,
    `Esophageal Anastomotic Leak`,
    `Esophageal Anastomotic Stricture`,
    `Recurrent Esophageal Fistula`,
    total_dilations,
    `G-Tube Ever`,
    g_tube_at_1_year_or_beyond,
    feeding_status_at_last_f_u,
    respiratory_status_at_last_f_u,
    # ** NEW COLUMNS ADDED BELOW **
    Death,
    `Complications of Initial EA/VR Repair`,
    `Reason(s) for Referral (Symptoms/Complications)`,
    `Age at Time of Referral`,
    `First Reoperative Esophageal Repair`,
    `First VR Reoperation`,
    `EA Reoperations`,
    `VR Reoperations`,
    `Outcome of Reoperation/Current Status`,
    `Lessons Learned`
  ) %>%
  mutate(across(c(
    `Date of Initial EA Repair`,
    `Date of Initial VR Repair`,
    `Date of First VR Reoperation`,
    `Date of First Esophageal Reoperation Repair`,
    `Date Second Esophageal Reoperation`),
    ~ mdy(.x)
  ))
library(dplyr)

date_subset <- EAVRDataClean2 %>%
  select(
    `Date of Initial EA Repair`,
    `Date Second Esophageal Reoperation`,
    `Date of First Esophageal Reoperation Repair`,
    `Date of Initial VR Repair`,
    `Date of First VR Reoperation`
  )

# View the subset
head(date_subset)
##   Date of Initial EA Repair Date Second Esophageal Reoperation
## 1                2019-01-24                               <NA>
## 2                2007-03-11                               <NA>
## 3                2016-07-29                               <NA>
## 4                2019-07-19                         2020-10-22
## 5                2022-02-10                               <NA>
## 6                2021-03-05                               <NA>
##   Date of First Esophageal Reoperation Repair Date of Initial VR Repair
## 1                                        <NA>                2019-01-24
## 2                                        <NA>                2007-04-10
## 3                                        <NA>                2016-07-29
## 4                                  2019-09-20                2019-07-19
## 5                                  2022-09-12                2022-09-12
## 6                                  2021-06-05                2021-03-05
##   Date of First VR Reoperation
## 1                         <NA>
## 2                         <NA>
## 3                         <NA>
## 4                   2019-09-20
## 5                         <NA>
## 6                         <NA>
library(dplyr)
library(lubridate)  # for date handling

EAandVRTableConcurrent <- EAVRDataClean2 %>%
  # Convert date columns to Date class; adjust the format inside as.Date() if needed
  mutate(
    `Date of Initial VR Repair` = as.Date(`Date of Initial VR Repair`),
    `Date of First VR Reoperation` = as.Date(`Date of First VR Reoperation`),
    `Date of Initial EA Repair` = as.Date(`Date of Initial EA Repair`),
    `Date of First Esophageal Reoperation Repair` = as.Date(`Date of First Esophageal Reoperation Repair`),
    `Date Second Esophageal Reoperation` = as.Date(`Date Second Esophageal Reoperation`)
  ) %>%
  mutate(
    VR_repair_missing = is.na(`Date of Initial VR Repair`) & is.na(`Date of First VR Reoperation`),
    
    `First Operation Concurrent` = case_when(
      VR_repair_missing ~ "EA+/-TEF repair Only",
      `Date of Initial VR Repair` == `Date of Initial EA Repair` ~ "Concurrent",
      TRUE ~ "Staged"
    ),
    `First Reoperation Concurrent` = case_when(
      VR_repair_missing ~ "EA+/-TEF repair Only",
      `Date of Initial VR Repair` == `Date of First Esophageal Reoperation Repair` ~ "Concurrent",
      TRUE ~ "Staged"
    ),
    `Second Reoperation Concurrent` = case_when(
      VR_repair_missing ~ "EA+/-TEF repair Only",
      `Date of Initial VR Repair` == `Date Second Esophageal Reoperation` ~ "Concurrent",
      TRUE ~ "Staged"
    )
  ) %>%
  select(-VR_repair_missing)  # clean up temporary helper column
library(dplyr)
library(lubridate)

EAandVRTableDemo <- EAandVRTableConcurrent %>%
  mutate(
    dob = mdy(dob),  # Parses two digit years correctly
    # Date of Initial EA Repair is already Date, so no parsing needed
    `Age at Surgery` = as.numeric(difftime(`Date of Initial EA Repair`, dob, units = "days")) / 365.25
  )
library(dplyr)

EAandVRTableDemo <- EAandVRTableDemo %>%
  mutate(
    # Age already in years, convert to months
    `Age at Surgery (months)` = `Age at Surgery` * 12,
    
    # Categorize age groups based on months
    Age_Category = case_when(
      `Age at Surgery (months)` < 1 ~ "< 1 month",
      `Age at Surgery (months)` >= 1 & `Age at Surgery (months)` < 6 ~ "1 - 6 months",
      `Age at Surgery (months)` >= 6 & `Age at Surgery (months)` <= 12 ~ "6 months - 1 year",
      `Age at Surgery (months)` > 12 ~ "> 1 year",
      TRUE ~ NA_character_
    )
  )
library(dplyr)
library(gtsummary)

demo_data <- EAandVRTableDemo %>%
  select(
    Sex,
    `Age at Surgery (months)`,
    `Age at Surgery (months)`,
    type_ea,
    `Birth Weight`,
    `Preterm Category`,
    `Trisomy 21`,
    CHARGE,
    `Vascular_Ring`,
    `Concomitant Congenital Heart Disease`,
    `Initial EA Repair Approach Side`
  )

demo_table <- demo_data %>%
  tbl_summary(
    by = Vascular_Ring,
    missing = "no",
    label = list(
      `Birth Weight` ~ "Birth Weight (g)",
      Sex ~ "Sex",
      type_ea ~ "EA Type",
      `Preterm Category` ~ "Preterm Category",
      `Trisomy 21` ~ "Trisomy 21",
      CHARGE ~ "CHARGE Syndrome",
      `Concomitant Congenital Heart Disease` ~ "Concomitant Congenital Heart Disease"
    ),
    digits = all_continuous() ~ 2
  ) %>%
  add_overall() %>%
  add_p(pvalue_fun = ~style_pvalue(.x, digits = 2)) %>%
  bold_p() %>%
  modify_header(label ~ "**Variable**") %>%
  modify_spanning_header(all_stat_cols() ~ "**Demographic and Baseline Clinical Characteristics by Vascular Ring Status**")

demo_table
Variable
Demographic and Baseline Clinical Characteristics by Vascular Ring Status
p-value2
Overall
N = 23
1
Circumflex Right Aortic Arch with Mirror Image Branching and Left Ligamentum Arteriosum
N = 3
1
Double Arch
N = 4
1
Right Aortic Arch with Aberrant Left Subclavian Artery
N = 16
1
Sex



0.19
    Female 5 (22%) 1 (33%) 2 (50%) 2 (13%)
    Male 18 (78%) 2 (67%) 2 (50%) 14 (88%)
Age at Surgery (months) 0.10 (0.07, 0.46) 0.16 (0.03, 0.56) 0.08 (0.02, 0.38) 0.10 (0.07, 0.36) 0.76
EA Type



0.79
    A 1 (4.3%) 0 (0%) 0 (0%) 1 (6.3%)
    B 1 (4.3%) 0 (0%) 0 (0%) 1 (6.3%)
    C 19 (83%) 3 (100%) 3 (75%) 13 (81%)
    E 2 (8.7%) 0 (0%) 1 (25%) 1 (6.3%)
Birth Weight (g)



0.84
    Low birth weight (LBW) 11 (58%) 2 (67%) 3 (75%) 6 (50%)
    Normal birth weight (NBW) 5 (26%) 1 (33%) 0 (0%) 4 (33%)
    Very low birth weight (VLBW) 3 (16%) 0 (0%) 1 (25%) 2 (17%)
Preterm Category



0.55
    Late preterm birth (LPTB) 9 (39%) 2 (67%) 0 (0%) 7 (44%)
    Moderate preterm birth (MPTB) 2 (8.7%) 0 (0%) 1 (25%) 1 (6.3%)
    Term birth 9 (39%) 1 (33%) 2 (50%) 6 (38%)
    Very preterm birth (VPTB) 3 (13%) 0 (0%) 1 (25%) 2 (13%)
Trisomy 21



>0.99
    No 22 (96%) 3 (100%) 4 (100%) 15 (94%)
    Yes 1 (4.3%) 0 (0%) 0 (0%) 1 (6.3%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
CHARGE Syndrome



>0.99
    No 20 (87%) 3 (100%) 4 (100%) 13 (81%)
    Yes 3 (13%) 0 (0%) 0 (0%) 3 (19%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Concomitant Congenital Heart Disease



0.44
    No 14 (61%) 3 (100%) 2 (50%) 9 (56%)
    Yes 9 (39%) 0 (0%) 2 (50%) 7 (44%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Initial EA Repair Approach Side



0.31
    Left 15 (65%) 3 (100%) 2 (50%) 10 (63%)
    Right 7 (30%) 0 (0%) 1 (25%) 6 (38%)
    Unknown 1 (4.3%) 0 (0%) 1 (25%) 0 (0%)
1 n (%); Median (Q1, Q3)
2 Fisher’s exact test; Kruskal-Wallis rank sum test
library(dplyr)
library(gtsummary)

# Step 1: Subset the dataframe for manual viewing with clean and consistent column selection
ComplicationsData <- EAandVRTableConcurrent %>%
  select(
    `Esophageal Anastomotic Leak`,
    `Esophageal Anastomotic Stricture`,
    `Recurrent Esophageal Fistula`,
    `Initial EA Repair Location`,
    Dysphagia,
    `Vocal Cord Dysfunction`,
    `Initial Esophageal Repair`,
    `Initial EA Repair Approach Side`,
    `First Reoperative Esophageal Repair`,
    `First Esophageal Reoperation Indication`,
    `Second Esophageal Reoperation`,
    `Second Esophageal Reoperation Indication`,
    `Initial VR Repair`,
    `First VR Reoperation`
  )

# Now you can view the dataframe manually, e.g.
# View(ComplicationsData)
# head(ComplicationsData)

# Step 2: Create the summary table from the dataframe above
ComplicationsTable <- ComplicationsData %>%
  tbl_summary(
    by = `Initial EA Repair Location`,
    missing = "no",
    label = list(
      `Esophageal Anastomotic Leak` = "Esophageal Anastomotic Leak",
      `Esophageal Anastomotic Stricture` = "Esophageal Anastomotic Stricture",
      `Recurrent Esophageal Fistula` = "Recurrent Esophageal Fistula",
      Dysphagia = "Dysphagia",
      `Vocal Cord Dysfunction` = "Vocal Cord Dysfunction",
      `Initial Esophageal Repair` = "Initial Esophageal Repair",
      `Initial EA Repair Approach Side` = "Initial EA Repair Approach Side",
      `First Reoperative Esophageal Repair` = "First Reoperative Esophageal Repair",
      `First Esophageal Reoperation Indication` = "First Esophageal Reoperation Indication",
      `Second Esophageal Reoperation` = "Second Esophageal Reoperation",
      `Second Esophageal Reoperation Indication` = "Second Esophageal Reoperation Indication",
      `Initial VR Repair` = "Initial VR Repair",
      `First VR Reoperation` = "First VR Reoperation"
    )
  ) %>%
  add_overall() %>%
  add_p(pvalue_fun = ~style_pvalue(.x, digits = 2)) %>%
  bold_p() %>%
  modify_header(label ~ "**Variable**") %>%
  modify_spanning_header(all_stat_cols() ~ "**Specialized Center vs OSH**") %>%
  bold_labels()

# Print the summary table
ComplicationsTable
Variable
Specialized Center vs OSH
p-value2
Overall
N = 23
1
BCH
N = 5
1
OSH
N = 18
1
Esophageal Anastomotic Leak


0.14
    No 13 (59%) 5 (100%) 8 (47%)
    Yes 8 (36%) 0 (0%) 8 (47%)
    Unknown 1 (4.5%) 0 (0%) 1 (5.9%)
Esophageal Anastomotic Stricture


0.014
    No 11 (48%) 5 (100%) 6 (33%)
    Yes 12 (52%) 0 (0%) 12 (67%)
    Unknown 0 (0%) 0 (0%) 0 (0%)
Recurrent Esophageal Fistula


0.28
    No 16 (76%) 5 (100%) 11 (69%)
    Yes 5 (24%) 0 (0%) 5 (31%)
    Unknown 0 (0%) 0 (0%) 0 (0%)
Dysphagia


0.40
    No 2 (8.7%) 1 (20%) 1 (5.6%)
    Yes 21 (91%) 4 (80%) 17 (94%)
    Unknown 0 (0%) 0 (0%) 0 (0%)
Vocal Cord Dysfunction


0.46
    No 11 (48%) 4 (80%) 7 (39%)
    Yes 11 (48%) 1 (20%) 10 (56%)
    Unknown 1 (4.3%) 0 (0%) 1 (5.6%)
Initial Esophageal Repair


0.24
    Esophagostomy/Spit Fistula 1 (4.3%) 0 (0%) 1 (5.6%)
    Primary Repair with TEF 15 (65%) 2 (40%) 13 (72%)
    TEF Only 6 (26%) 2 (40%) 4 (22%)
    traction-induced/Foker 1 (4.3%) 1 (20%) 0 (0%)
Initial EA Repair Approach Side


>0.99
    Left 15 (65%) 4 (80%) 11 (61%)
    Right 7 (30%) 1 (20%) 6 (33%)
    Unknown 1 (4.3%) 0 (0%) 1 (5.6%)
First Reoperative Esophageal Repair


0.60
    Delayed Primary Repair 1 (4.3%) 1 (20%) 0 (0%)
    EPF Fistula 1 (4.3%) 0 (0%) 1 (5.6%)
    Esophagoplasty/Tracheopexy 1 (4.3%) 0 (0%) 1 (5.6%)
    Esophagostomy/Spit Fistula Revision 1 (4.3%) 0 (0%) 1 (5.6%)
    Not Performed 10 (43%) 4 (80%) 6 (33%)
    Primary repair Only 3 (13%) 0 (0%) 3 (17%)
    Primary Repair with TEF 2 (8.7%) 0 (0%) 2 (11%)
    Stricturoplasty/Tracheopexy 1 (4.3%) 0 (0%) 1 (5.6%)
    TEF Only 2 (8.7%) 0 (0%) 2 (11%)
    traction-induced/Foker 1 (4.3%) 0 (0%) 1 (5.6%)
First Esophageal Reoperation Indication


0.80
    Esophageal leak 1 (4.8%) 0 (0%) 1 (5.9%)
    Esophageal Stricture 1 (4.8%) 0 (0%) 1 (5.9%)
    None 8 (38%) 3 (75%) 5 (29%)
    Recurrent Fistula 4 (19%) 0 (0%) 4 (24%)
    Tracheomalacia 2 (9.5%) 0 (0%) 2 (12%)
    Unrepaired EA 5 (24%) 1 (25%) 4 (24%)
Second Esophageal Reoperation


>0.99
    Anterior Aortopexy/Anterior Tracheopexy 1 (5.0%) 0 (0%) 1 (6.3%)
    Not Performed 13 (65%) 4 (100%) 9 (56%)
    Primary Repair with TEF 1 (5.0%) 0 (0%) 1 (6.3%)
    replacement/interposition 1 (5.0%) 0 (0%) 1 (6.3%)
    Stricture Resection 1 (5.0%) 0 (0%) 1 (6.3%)
    TEF Only 1 (5.0%) 0 (0%) 1 (6.3%)
    Tracheopexy 1 (5.0%) 0 (0%) 1 (6.3%)
    traction-induced/Foker 1 (5.0%) 0 (0%) 1 (6.3%)
Second Esophageal Reoperation Indication


>0.99
    Esophageal Stricture 2 (10%) 0 (0%) 2 (13%)
    None 14 (70%) 4 (100%) 10 (63%)
    Other 1 (5.0%) 0 (0%) 1 (6.3%)
    Recurrent Fistula 1 (5.0%) 0 (0%) 1 (6.3%)
    Unrepaired EA 1 (5.0%) 0 (0%) 1 (6.3%)
    Vascular Compression 1 (5.0%) 0 (0%) 1 (6.3%)
Initial VR Repair


0.62
    arch resection 3 (13%) 1 (20%) 2 (11%)
    divide only aberrant subclavian 2 (8.7%) 0 (0%) 2 (11%)
    divide/reimplant 4 (17%) 2 (40%) 2 (11%)
    ductal ligament division only 11 (48%) 2 (40%) 9 (50%)
    no repair 3 (13%) 0 (0%) 3 (17%)
First VR Reoperation


>0.99
    arch reconstruction/bypass 2 (9.1%) 0 (0%) 2 (12%)
    divide only aberrant subclavian 1 (4.5%) 0 (0%) 1 (5.9%)
    divide/reimplant 1 (4.5%) 0 (0%) 1 (5.9%)
    ductal ligament division only 1 (4.5%) 0 (0%) 1 (5.9%)
    no repair 17 (77%) 5 (100%) 12 (71%)
1 n (%)
2 Fisher’s exact test
library(dplyr)

EAandVRTEFOnly <- EAandVRTableConcurrent %>%
  filter(`Initial Esophageal Repair` == "TEF Only") %>%
  select(
    `Initial Esophageal Repair`,
    `First Esophageal Repair Location`,
    `Initial VR Repair Location`,
    `Initial EA Repair Location`,
    `Second Esophageal Reoperation Location`
  )
library(dplyr)
library(gtsummary)

# Step 1: Subset the dataframe for manual viewing
ConcurrentvsStaged <- EAandVRTableConcurrent %>%
  select(
    `Esophageal Anastomotic Leak`,
    `Esophageal Anastomotic Stricture`,
    `Recurrent Esophageal Fistula`,
    `Initial EA Repair Location`,
    Dysphagia,
    `Vocal Cord Dysfunction`,
    `Initial Esophageal Repair`,
    `Initial EA Repair Approach Side`,
    `First Operation Concurrent`,
    `First Reoperative Esophageal Repair`,
    `First Esophageal Reoperation Indication`,
    `Second Esophageal Reoperation`,
    `Second Esophageal Reoperation Indication`,
    `Initial VR Repair`,
    `First VR Reoperation`,
    `First Reoperative Esophageal Repair` = "First Reoperative Esophageal Repair",
    `First Esophageal Reoperation Indication` = "First Esophageal Reoperation Indication",
    `Second Esophageal Reoperation` = "Second Esophageal Reoperation",
    `Second Esophageal Reoperation Indication` = "Second Esophageal Reoperation Indication",
    `Initial VR Repair` = "Initial VR Repair"
    
    
  )

# Now you can view the dataframe manually, e.g.
# View(ComplicationsData)
# head(ComplicationsData)

# Step 2: Create the summary table from the dataframe above
ConcurrentvsStaged <- ConcurrentvsStaged %>%
  tbl_summary(
    by = `First Operation Concurrent`,
    missing = "no",
    label = list(
      `Esophageal Anastomotic Leak` = "Esophageal Anastomotic Leak",
      `Esophageal Anastomotic Stricture` = "Esophageal Anastomotic Stricture",
      `Recurrent Esophageal Fistula` = "Recurrent Esophageal Fistula",
      `First Operation Concurrent` = "First Operation Concurrent Status"
    )
  ) %>%
  add_overall() %>%
  add_p(pvalue_fun = ~style_pvalue(.x, digits = 2)) %>%
  bold_p() %>%
  modify_header(label ~ "**Variable**") %>%
  modify_spanning_header(all_stat_cols() ~ "**Concurrent Vs Staged**") %>%
  bold_labels()

# Print the summary table
ConcurrentvsStaged
Variable
Concurrent Vs Staged
p-value2
Overall
N = 23
1
Concurrent
N = 13
1
EA+/-TEF repair Only
N = 3
1
Staged
N = 7
1
Esophageal Anastomotic Leak



0.53
    No 13 (59%) 8 (67%) 1 (33%) 4 (57%)
    Yes 8 (36%) 4 (33%) 2 (67%) 2 (29%)
    Unknown 1 (4.5%) 0 (0%) 0 (0%) 1 (14%)
Esophageal Anastomotic Stricture



0.30
    No 11 (48%) 7 (54%) 0 (0%) 4 (57%)
    Yes 12 (52%) 6 (46%) 3 (100%) 3 (43%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Recurrent Esophageal Fistula



0.081
    No 16 (76%) 9 (75%) 1 (33%) 6 (100%)
    Yes 5 (24%) 3 (25%) 2 (67%) 0 (0%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Initial EA Repair Location



0.64
    BCH 5 (22%) 4 (31%) 0 (0%) 1 (14%)
    OSH 18 (78%) 9 (69%) 3 (100%) 6 (86%)
Dysphagia



>0.99
    No 2 (8.7%) 1 (7.7%) 0 (0%) 1 (14%)
    Yes 21 (91%) 12 (92%) 3 (100%) 6 (86%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Vocal Cord Dysfunction



0.12
    No 11 (48%) 5 (38%) 2 (67%) 4 (57%)
    Yes 11 (48%) 8 (62%) 0 (0%) 3 (43%)
    Unknown 1 (4.3%) 0 (0%) 1 (33%) 0 (0%)
Initial Esophageal Repair



0.73
    Esophagostomy/Spit Fistula 1 (4.3%) 0 (0%) 0 (0%) 1 (14%)
    Primary Repair with TEF 15 (65%) 8 (62%) 2 (67%) 5 (71%)
    TEF Only 6 (26%) 4 (31%) 1 (33%) 1 (14%)
    traction-induced/Foker 1 (4.3%) 1 (7.7%) 0 (0%) 0 (0%)
Initial EA Repair Approach Side



<0.001
    Left 15 (65%) 12 (92%) 0 (0%) 3 (43%)
    Right 7 (30%) 0 (0%) 3 (100%) 4 (57%)
    Unknown 1 (4.3%) 1 (7.7%) 0 (0%) 0 (0%)
First Reoperative Esophageal Repair



0.18
    Delayed Primary Repair 1 (4.3%) 0 (0%) 0 (0%) 1 (14%)
    EPF Fistula 1 (4.3%) 0 (0%) 1 (33%) 0 (0%)
    Esophagoplasty/Tracheopexy 1 (4.3%) 1 (7.7%) 0 (0%) 0 (0%)
    Esophagostomy/Spit Fistula Revision 1 (4.3%) 0 (0%) 0 (0%) 1 (14%)
    Not Performed 10 (43%) 5 (38%) 0 (0%) 5 (71%)
    Primary repair Only 3 (13%) 2 (15%) 1 (33%) 0 (0%)
    Primary Repair with TEF 2 (8.7%) 1 (7.7%) 1 (33%) 0 (0%)
    Stricturoplasty/Tracheopexy 1 (4.3%) 1 (7.7%) 0 (0%) 0 (0%)
    TEF Only 2 (8.7%) 2 (15%) 0 (0%) 0 (0%)
    traction-induced/Foker 1 (4.3%) 1 (7.7%) 0 (0%) 0 (0%)
First Esophageal Reoperation Indication



0.31
    Esophageal leak 1 (4.8%) 0 (0%) 1 (33%) 0 (0%)
    Esophageal Stricture 1 (4.8%) 1 (8.3%) 0 (0%) 0 (0%)
    None 8 (38%) 4 (33%) 0 (0%) 4 (67%)
    Recurrent Fistula 4 (19%) 3 (25%) 1 (33%) 0 (0%)
    Tracheomalacia 2 (9.5%) 2 (17%) 0 (0%) 0 (0%)
    Unrepaired EA 5 (24%) 2 (17%) 1 (33%) 2 (33%)
Second Esophageal Reoperation



0.87
    Anterior Aortopexy/Anterior Tracheopexy 1 (5.0%) 1 (9.1%) 0 (0%) 0 (0%)
    Not Performed 13 (65%) 6 (55%) 2 (67%) 5 (83%)
    Primary Repair with TEF 1 (5.0%) 1 (9.1%) 0 (0%) 0 (0%)
    replacement/interposition 1 (5.0%) 1 (9.1%) 0 (0%) 0 (0%)
    Stricture Resection 1 (5.0%) 0 (0%) 1 (33%) 0 (0%)
    TEF Only 1 (5.0%) 1 (9.1%) 0 (0%) 0 (0%)
    Tracheopexy 1 (5.0%) 1 (9.1%) 0 (0%) 0 (0%)
    traction-induced/Foker 1 (5.0%) 0 (0%) 0 (0%) 1 (17%)
Second Esophageal Reoperation Indication



0.84
    Esophageal Stricture 2 (10%) 1 (9.1%) 1 (33%) 0 (0%)
    None 14 (70%) 7 (64%) 2 (67%) 5 (83%)
    Other 1 (5.0%) 1 (9.1%) 0 (0%) 0 (0%)
    Recurrent Fistula 1 (5.0%) 1 (9.1%) 0 (0%) 0 (0%)
    Unrepaired EA 1 (5.0%) 0 (0%) 0 (0%) 1 (17%)
    Vascular Compression 1 (5.0%) 1 (9.1%) 0 (0%) 0 (0%)
Initial VR Repair



0.023
    arch resection 3 (13%) 2 (15%) 0 (0%) 1 (14%)
    divide only aberrant subclavian 2 (8.7%) 2 (15%) 0 (0%) 0 (0%)
    divide/reimplant 4 (17%) 2 (15%) 0 (0%) 2 (29%)
    ductal ligament division only 11 (48%) 7 (54%) 0 (0%) 4 (57%)
    no repair 3 (13%) 0 (0%) 3 (100%) 0 (0%)
First VR Reoperation



>0.99
    arch reconstruction/bypass 2 (9.1%) 1 (7.7%) 0 (0%) 1 (17%)
    divide only aberrant subclavian 1 (4.5%) 1 (7.7%) 0 (0%) 0 (0%)
    divide/reimplant 1 (4.5%) 1 (7.7%) 0 (0%) 0 (0%)
    ductal ligament division only 1 (4.5%) 1 (7.7%) 0 (0%) 0 (0%)
    no repair 17 (77%) 9 (69%) 3 (100%) 5 (83%)
1 n (%)
2 Fisher’s exact test
library(dplyr)
library(gtsummary)

# Step 1: Subset patients with 'EA+/-TEF repair Only'
EAandVRTableEATEFRepair <- EAandVRTableConcurrent %>%
  filter(`First Operation Concurrent` == "EA+/-TEF repair Only")

# Step 2: Select variables for analysis 
EATEFRepair <- EAandVRTableEATEFRepair %>%
  select(
    `Esophageal Anastomotic Leak`,
    `Esophageal Anastomotic Stricture`,
    `Recurrent Esophageal Fistula`,
    `Initial EA Repair Location`,
    Dysphagia,
    `Vocal Cord Dysfunction`,
    `Initial Esophageal Repair`,
    `Initial EA Repair Approach Side`,
    `First Operation Concurrent`,
    `First Reoperative Esophageal Repair`,
    `First Esophageal Reoperation Indication`,
    `Second Esophageal Reoperation`,
    `Second Esophageal Reoperation Indication`,
    `Initial VR Repair`,
    `First VR Reoperation`
  )

# Step 3: Create summary table grouped by 'First Operation Concurrent'
# (Note: since all patients have same value, this grouping will just present overall data)
EATEFRepair <- EATEFRepair %>%
  tbl_summary(
    by = `Initial EA Repair Location`,
    missing = "no",
    label = list(
      `Esophageal Anastomotic Leak` = "Esophageal Anastomotic Leak",
      `Esophageal Anastomotic Stricture` = "Esophageal Anastomotic Stricture",
      `Recurrent Esophageal Fistula` = "Recurrent Esophageal Fistula",
      `First Operation Concurrent` = "First Operation Concurrent Status"
    )
  ) %>%
  add_overall() %>%
  add_p(pvalue_fun = ~style_pvalue(.x, digits = 2)) %>%
  bold_p() %>%
  modify_header(label ~ "**Variable**") %>%
  modify_spanning_header(all_stat_cols() ~ "**Concurrent Vs Staged (EA+/-TEF repair Only patients)**") %>%
  bold_labels()
## The following errors were returned during `modify_spanning_header()`:
## ✖ For variable `Dysphagia` (`Initial EA Repair Location`) and "estimate",
##   "p.value", "conf.low", and "conf.high" statistics: 'x' and 'y' must have at
##   least 2 levels
## ✖ For variable `Esophageal Anastomotic Leak` (`Initial EA Repair Location`) and
##   "estimate", "p.value", "conf.low", and "conf.high" statistics: 'x' and 'y'
##   must have at least 2 levels
## ✖ For variable `Esophageal Anastomotic Stricture` (`Initial EA Repair
##   Location`) and "estimate", "p.value", "conf.low", and "conf.high" statistics:
##   'x' and 'y' must have at least 2 levels
## ✖ For variable `First Esophageal Reoperation Indication` (`Initial EA Repair
##   Location`) and "estimate", "p.value", "conf.low", and "conf.high" statistics:
##   'x' and 'y' must have at least 2 levels
## ✖ For variable `First Operation Concurrent` (`Initial EA Repair Location`) and
##   "estimate", "p.value", "conf.low", and "conf.high" statistics: 'x' and 'y'
##   must have at least 2 levels
## ✖ For variable `First Reoperative Esophageal Repair` (`Initial EA Repair
##   Location`) and "estimate", "p.value", "conf.low", and "conf.high" statistics:
##   'x' and 'y' must have at least 2 levels
## ✖ For variable `First VR Reoperation` (`Initial EA Repair Location`) and
##   "estimate", "p.value", "conf.low", and "conf.high" statistics: 'x' and 'y'
##   must have at least 2 levels
## ✖ For variable `Initial EA Repair Approach Side` (`Initial EA Repair Location`)
##   and "estimate", "p.value", "conf.low", and "conf.high" statistics: 'x' and
##   'y' must have at least 2 levels
## ✖ For variable `Initial Esophageal Repair` (`Initial EA Repair Location`) and
##   "estimate", "p.value", "conf.low", and "conf.high" statistics: 'x' and 'y'
##   must have at least 2 levels
## ✖ For variable `Initial VR Repair` (`Initial EA Repair Location`) and
##   "estimate", "p.value", "conf.low", and "conf.high" statistics: 'x' and 'y'
##   must have at least 2 levels
## ✖ For variable `Recurrent Esophageal Fistula` (`Initial EA Repair Location`)
##   and "estimate", "p.value", "conf.low", and "conf.high" statistics: 'x' and
##   'y' must have at least 2 levels
## ✖ For variable `Second Esophageal Reoperation` (`Initial EA Repair Location`)
##   and "estimate", "p.value", "conf.low", and "conf.high" statistics: 'x' and
##   'y' must have at least 2 levels
## ✖ For variable `Second Esophageal Reoperation Indication` (`Initial EA Repair
##   Location`) and "estimate", "p.value", "conf.low", and "conf.high" statistics:
##   'x' and 'y' must have at least 2 levels
## ✖ For variable `Vocal Cord Dysfunction` (`Initial EA Repair Location`) and
##   "estimate", "p.value", "conf.low", and "conf.high" statistics: 'x' and 'y'
##   must have at least 2 levels
# Step 4: Print or view the summary table
EATEFRepair
Variable
Concurrent Vs Staged (EA+/-TEF repair Only patients)
p-value
Overall
N = 3
1
OSH
N = 3
1
Esophageal Anastomotic Leak


    No 1 (33%) 1 (33%)
    Yes 2 (67%) 2 (67%)
    Unknown 0 (0%) 0 (0%)
Esophageal Anastomotic Stricture


    No 0 (0%) 0 (0%)
    Yes 3 (100%) 3 (100%)
    Unknown 0 (0%) 0 (0%)
Recurrent Esophageal Fistula


    No 1 (33%) 1 (33%)
    Yes 2 (67%) 2 (67%)
    Unknown 0 (0%) 0 (0%)
Dysphagia


    No 0 (0%) 0 (0%)
    Yes 3 (100%) 3 (100%)
    Unknown 0 (0%) 0 (0%)
Vocal Cord Dysfunction


    No 2 (67%) 2 (67%)
    Yes 0 (0%) 0 (0%)
    Unknown 1 (33%) 1 (33%)
Initial Esophageal Repair


    Primary Repair with TEF 2 (67%) 2 (67%)
    TEF Only 1 (33%) 1 (33%)
Initial EA Repair Approach Side


    Right 3 (100%) 3 (100%)
First Operation Concurrent Status


    EA+/-TEF repair Only 3 (100%) 3 (100%)
First Reoperative Esophageal Repair


    EPF Fistula 1 (33%) 1 (33%)
    Primary repair Only 1 (33%) 1 (33%)
    Primary Repair with TEF 1 (33%) 1 (33%)
First Esophageal Reoperation Indication


    Esophageal leak 1 (33%) 1 (33%)
    Recurrent Fistula 1 (33%) 1 (33%)
    Unrepaired EA 1 (33%) 1 (33%)
Second Esophageal Reoperation


    Not Performed 2 (67%) 2 (67%)
    Stricture Resection 1 (33%) 1 (33%)
Second Esophageal Reoperation Indication


    Esophageal Stricture 1 (33%) 1 (33%)
    None 2 (67%) 2 (67%)
Initial VR Repair


    no repair 3 (100%) 3 (100%)
First VR Reoperation


    no repair 3 (100%) 3 (100%)
1 n (%)
library(dplyr)
library(gtsummary)

# Step 1: Subset the dataframe for manual viewing
RightvsLeftApproach <- EAandVRTableConcurrent %>%
  select(
    `Esophageal Anastomotic Leak`,
    `Esophageal Anastomotic Stricture`,
    `Recurrent Esophageal Fistula`,
    `Initial EA Repair Location`,
    Dysphagia,
    `Vocal Cord Dysfunction`,
    `Initial Esophageal Repair`,
    `Initial EA Repair Approach Side`,
    `First Operation Concurrent`,
    `First Reoperative Esophageal Repair`,
    `First Esophageal Reoperation Indication`,
    `Second Esophageal Reoperation`,
    `Second Esophageal Reoperation Indication`,
    `Initial VR Repair`,
    `First VR Reoperation`
    
  )

# Now you can view the dataframe manually, e.g.
# View(ComplicationsData)
# head(ComplicationsData)

# Step 2: Create the summary table from the dataframe above
RightvsLeftApproach <- RightvsLeftApproach %>%
  tbl_summary(
    by = `Initial EA Repair Approach Side`,
    missing = "no",
    label = list(
      `Esophageal Anastomotic Leak` = "Esophageal Anastomotic Leak",
      `Esophageal Anastomotic Stricture` = "Esophageal Anastomotic Stricture",
      `Recurrent Esophageal Fistula` = "Recurrent Esophageal Fistula",
      `First Operation Concurrent` = "First Operation Concurrent Status",
      `First Reoperative Esophageal Repair` = "First Reoperative Esophageal Repair",
      `First Esophageal Reoperation Indication` = "First Esophageal Reoperation Indication",
      `Second Esophageal Reoperation` = "Second Esophageal Reoperation",
      `Second Esophageal Reoperation Indication` = "Second Esophageal Reoperation Indication",
      `Initial VR Repair` = "Initial VR Repair",
      `First VR Reoperation` = "First VR Reoperation"
      
    )
  ) %>%
  add_overall() %>%
  add_p(pvalue_fun = ~style_pvalue(.x, digits = 2)) %>%
  bold_p() %>%
  modify_header(label ~ "**Variable**") %>%
  modify_spanning_header(all_stat_cols() ~ "**Right vs Left**") %>%
  bold_labels()

# Print the summary table
RightvsLeftApproach
Variable
Right vs Left
p-value2
Overall
N = 23
1
Left
N = 15
1
Right
N = 7
1
Unknown
N = 1
1
Esophageal Anastomotic Leak



>0.99
    No 13 (59%) 8 (57%) 4 (57%) 1 (100%)
    Yes 8 (36%) 5 (36%) 3 (43%) 0 (0%)
    Unknown 1 (4.5%) 1 (7.1%) 0 (0%) 0 (0%)
Esophageal Anastomotic Stricture



0.27
    No 11 (48%) 9 (60%) 2 (29%) 0 (0%)
    Yes 12 (52%) 6 (40%) 5 (71%) 1 (100%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Recurrent Esophageal Fistula



>0.99
    No 16 (76%) 10 (77%) 5 (71%) 1 (100%)
    Yes 5 (24%) 3 (23%) 2 (29%) 0 (0%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Initial EA Repair Location



>0.99
    BCH 5 (22%) 4 (27%) 1 (14%) 0 (0%)
    OSH 18 (78%) 11 (73%) 6 (86%) 1 (100%)
Dysphagia



>0.99
    No 2 (8.7%) 1 (6.7%) 1 (14%) 0 (0%)
    Yes 21 (91%) 14 (93%) 6 (86%) 1 (100%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Vocal Cord Dysfunction



0.10
    No 11 (48%) 6 (40%) 5 (71%) 0 (0%)
    Yes 11 (48%) 9 (60%) 1 (14%) 1 (100%)
    Unknown 1 (4.3%) 0 (0%) 1 (14%) 0 (0%)
Initial Esophageal Repair



0.74
    Esophagostomy/Spit Fistula 1 (4.3%) 0 (0%) 1 (14%) 0 (0%)
    Primary Repair with TEF 15 (65%) 10 (67%) 4 (57%) 1 (100%)
    TEF Only 6 (26%) 4 (27%) 2 (29%) 0 (0%)
    traction-induced/Foker 1 (4.3%) 1 (6.7%) 0 (0%) 0 (0%)
First Operation Concurrent Status



<0.001
    Concurrent 13 (57%) 12 (80%) 0 (0%) 1 (100%)
    EA+/-TEF repair Only 3 (13%) 0 (0%) 3 (43%) 0 (0%)
    Staged 7 (30%) 3 (20%) 4 (57%) 0 (0%)
First Reoperative Esophageal Repair



0.16
    Delayed Primary Repair 1 (4.3%) 0 (0%) 1 (14%) 0 (0%)
    EPF Fistula 1 (4.3%) 0 (0%) 1 (14%) 0 (0%)
    Esophagoplasty/Tracheopexy 1 (4.3%) 1 (6.7%) 0 (0%) 0 (0%)
    Esophagostomy/Spit Fistula Revision 1 (4.3%) 0 (0%) 1 (14%) 0 (0%)
    Not Performed 10 (43%) 8 (53%) 2 (29%) 0 (0%)
    Primary repair Only 3 (13%) 2 (13%) 1 (14%) 0 (0%)
    Primary Repair with TEF 2 (8.7%) 1 (6.7%) 1 (14%) 0 (0%)
    Stricturoplasty/Tracheopexy 1 (4.3%) 0 (0%) 0 (0%) 1 (100%)
    TEF Only 2 (8.7%) 2 (13%) 0 (0%) 0 (0%)
    traction-induced/Foker 1 (4.3%) 1 (6.7%) 0 (0%) 0 (0%)
First Esophageal Reoperation Indication



0.14
    Esophageal leak 1 (4.8%) 0 (0%) 1 (17%) 0 (0%)
    Esophageal Stricture 1 (4.8%) 1 (7.1%) 0 (0%) 0 (0%)
    None 8 (38%) 7 (50%) 1 (17%) 0 (0%)
    Recurrent Fistula 4 (19%) 3 (21%) 1 (17%) 0 (0%)
    Tracheomalacia 2 (9.5%) 1 (7.1%) 0 (0%) 1 (100%)
    Unrepaired EA 5 (24%) 2 (14%) 3 (50%) 0 (0%)
Second Esophageal Reoperation



0.92
    Anterior Aortopexy/Anterior Tracheopexy 1 (5.0%) 1 (8.3%) 0 (0%) 0 (0%)
    Not Performed 13 (65%) 7 (58%) 5 (71%) 1 (100%)
    Primary Repair with TEF 1 (5.0%) 1 (8.3%) 0 (0%) 0 (0%)
    replacement/interposition 1 (5.0%) 1 (8.3%) 0 (0%) 0 (0%)
    Stricture Resection 1 (5.0%) 0 (0%) 1 (14%) 0 (0%)
    TEF Only 1 (5.0%) 1 (8.3%) 0 (0%) 0 (0%)
    Tracheopexy 1 (5.0%) 1 (8.3%) 0 (0%) 0 (0%)
    traction-induced/Foker 1 (5.0%) 0 (0%) 1 (14%) 0 (0%)
Second Esophageal Reoperation Indication



0.95
    Esophageal Stricture 2 (10%) 1 (8.3%) 1 (14%) 0 (0%)
    None 14 (70%) 8 (67%) 5 (71%) 1 (100%)
    Other 1 (5.0%) 1 (8.3%) 0 (0%) 0 (0%)
    Recurrent Fistula 1 (5.0%) 1 (8.3%) 0 (0%) 0 (0%)
    Unrepaired EA 1 (5.0%) 0 (0%) 1 (14%) 0 (0%)
    Vascular Compression 1 (5.0%) 1 (8.3%) 0 (0%) 0 (0%)
Initial VR Repair



0.039
    arch resection 3 (13%) 1 (6.7%) 1 (14%) 1 (100%)
    divide only aberrant subclavian 2 (8.7%) 2 (13%) 0 (0%) 0 (0%)
    divide/reimplant 4 (17%) 3 (20%) 1 (14%) 0 (0%)
    ductal ligament division only 11 (48%) 9 (60%) 2 (29%) 0 (0%)
    no repair 3 (13%) 0 (0%) 3 (43%) 0 (0%)
First VR Reoperation



0.16
    arch reconstruction/bypass 2 (9.1%) 2 (14%) 0 (0%) 0 (0%)
    divide only aberrant subclavian 1 (4.5%) 1 (7.1%) 0 (0%) 0 (0%)
    divide/reimplant 1 (4.5%) 1 (7.1%) 0 (0%) 0 (0%)
    ductal ligament division only 1 (4.5%) 0 (0%) 0 (0%) 1 (100%)
    no repair 17 (77%) 10 (71%) 7 (100%) 0 (0%)
1 n (%)
2 Fisher’s exact test
library(dplyr)
library(gtsummary)

# Step 1: Subset the dataframe for patients with Initial Esophageal Repair == "OSH"
RightvsLeftApproach_OSH <- EAandVRTableConcurrent %>%
  filter(`Initial EA Repair Location` == "OSH") %>%
  select(
    `Esophageal Anastomotic Leak`,
    `Esophageal Anastomotic Stricture`,
    `Recurrent Esophageal Fistula`,
    `Initial EA Repair Location`,
    Dysphagia,
    `Vocal Cord Dysfunction`,
    `Initial Esophageal Repair`,
    `Initial EA Repair Approach Side`,
    `First Operation Concurrent`,
    `First Reoperative Esophageal Repair`,
    `First Esophageal Reoperation Indication`,
    `Second Esophageal Reoperation`,
    `Second Esophageal Reoperation Indication`,
    `Initial VR Repair`,
    `First VR Reoperation`
  )

# Step 2: Create summary table grouped by Initial EA Repair Approach Side
RightvsLeftApproach_OSH <- RightvsLeftApproach_OSH %>%
  tbl_summary(
    by = `Initial EA Repair Approach Side`,
    missing = "no",
    label = list(
      `Esophageal Anastomotic Leak` = "Esophageal Anastomotic Leak",
      `Esophageal Anastomotic Stricture` = "Esophageal Anastomotic Stricture",
      `Recurrent Esophageal Fistula` = "Recurrent Esophageal Fistula",
      `First Operation Concurrent` = "First Operation Concurrent Status",
      `First Reoperative Esophageal Repair` = "First Reoperative Esophageal Repair",
      `First Esophageal Reoperation Indication` = "First Esophageal Reoperation Indication",
      `Second Esophageal Reoperation` = "Second Esophageal Reoperation",
      `Second Esophageal Reoperation Indication` = "Second Esophageal Reoperation Indication",
      `Initial VR Repair` = "Initial VR Repair",
      `First VR Reoperation` = "First VR Reoperation"
    )
  ) %>%
  add_overall() %>%
  add_p(pvalue_fun = ~style_pvalue(.x, digits = 2)) %>%
  bold_p() %>%
  modify_header(label ~ "**Variable**") %>%
  modify_spanning_header(all_stat_cols() ~ "**Right vs Left EA Repair Approach (OSH Patients)**") %>%
  bold_labels()
## The following errors were returned during `modify_spanning_header()`:
## ✖ For variable `Initial EA Repair Location` (`Initial EA Repair Approach Side`)
##   and "estimate", "p.value", "conf.low", and "conf.high" statistics: 'x' and
##   'y' must have at least 2 levels
# Print the summary table
RightvsLeftApproach_OSH
Variable
Right vs Left EA Repair Approach (OSH Patients)
p-value2
Overall
N = 18
1
Left
N = 11
1
Right
N = 6
1
Unknown
N = 1
1
Esophageal Anastomotic Leak



>0.99
    No 8 (47%) 4 (40%) 3 (50%) 1 (100%)
    Yes 8 (47%) 5 (50%) 3 (50%) 0 (0%)
    Unknown 1 (5.9%) 1 (10%) 0 (0%) 0 (0%)
Esophageal Anastomotic Stricture



0.56
    No 6 (33%) 5 (45%) 1 (17%) 0 (0%)
    Yes 12 (67%) 6 (55%) 5 (83%) 1 (100%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Recurrent Esophageal Fistula



>0.99
    No 11 (69%) 6 (67%) 4 (67%) 1 (100%)
    Yes 5 (31%) 3 (33%) 2 (33%) 0 (0%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Initial EA Repair Location




    OSH 18 (100%) 11 (100%) 6 (100%) 1 (100%)
Dysphagia



>0.99
    No 1 (5.6%) 1 (9.1%) 0 (0%) 0 (0%)
    Yes 17 (94%) 10 (91%) 6 (100%) 1 (100%)
    Unknown 0 (0%) 0 (0%) 0 (0%) 0 (0%)
Vocal Cord Dysfunction



0.072
    No 7 (39%) 3 (27%) 4 (67%) 0 (0%)
    Yes 10 (56%) 8 (73%) 1 (17%) 1 (100%)
    Unknown 1 (5.6%) 0 (0%) 1 (17%) 0 (0%)
Initial Esophageal Repair



0.64
    Esophagostomy/Spit Fistula 1 (5.6%) 0 (0%) 1 (17%) 0 (0%)
    Primary Repair with TEF 13 (72%) 8 (73%) 4 (67%) 1 (100%)
    TEF Only 4 (22%) 3 (27%) 1 (17%) 0 (0%)
First Operation Concurrent Status



0.004
    Concurrent 9 (50%) 8 (73%) 0 (0%) 1 (100%)
    EA+/-TEF repair Only 3 (17%) 0 (0%) 3 (50%) 0 (0%)
    Staged 6 (33%) 3 (27%) 3 (50%) 0 (0%)
First Reoperative Esophageal Repair



0.54
    EPF Fistula 1 (5.6%) 0 (0%) 1 (17%) 0 (0%)
    Esophagoplasty/Tracheopexy 1 (5.6%) 1 (9.1%) 0 (0%) 0 (0%)
    Esophagostomy/Spit Fistula Revision 1 (5.6%) 0 (0%) 1 (17%) 0 (0%)
    Not Performed 6 (33%) 4 (36%) 2 (33%) 0 (0%)
    Primary repair Only 3 (17%) 2 (18%) 1 (17%) 0 (0%)
    Primary Repair with TEF 2 (11%) 1 (9.1%) 1 (17%) 0 (0%)
    Stricturoplasty/Tracheopexy 1 (5.6%) 0 (0%) 0 (0%) 1 (100%)
    TEF Only 2 (11%) 2 (18%) 0 (0%) 0 (0%)
    traction-induced/Foker 1 (5.6%) 1 (9.1%) 0 (0%) 0 (0%)
First Esophageal Reoperation Indication



0.57
    Esophageal leak 1 (5.9%) 0 (0%) 1 (20%) 0 (0%)
    Esophageal Stricture 1 (5.9%) 1 (9.1%) 0 (0%) 0 (0%)
    None 5 (29%) 4 (36%) 1 (20%) 0 (0%)
    Recurrent Fistula 4 (24%) 3 (27%) 1 (20%) 0 (0%)
    Tracheomalacia 2 (12%) 1 (9.1%) 0 (0%) 1 (100%)
    Unrepaired EA 4 (24%) 2 (18%) 2 (40%) 0 (0%)
Second Esophageal Reoperation



>0.99
    Anterior Aortopexy/Anterior Tracheopexy 1 (6.3%) 1 (11%) 0 (0%) 0 (0%)
    Not Performed 9 (56%) 4 (44%) 4 (67%) 1 (100%)
    Primary Repair with TEF 1 (6.3%) 1 (11%) 0 (0%) 0 (0%)
    replacement/interposition 1 (6.3%) 1 (11%) 0 (0%) 0 (0%)
    Stricture Resection 1 (6.3%) 0 (0%) 1 (17%) 0 (0%)
    TEF Only 1 (6.3%) 1 (11%) 0 (0%) 0 (0%)
    Tracheopexy 1 (6.3%) 1 (11%) 0 (0%) 0 (0%)
    traction-induced/Foker 1 (6.3%) 0 (0%) 1 (17%) 0 (0%)
Second Esophageal Reoperation Indication



>0.99
    Esophageal Stricture 2 (13%) 1 (11%) 1 (17%) 0 (0%)
    None 10 (63%) 5 (56%) 4 (67%) 1 (100%)
    Other 1 (6.3%) 1 (11%) 0 (0%) 0 (0%)
    Recurrent Fistula 1 (6.3%) 1 (11%) 0 (0%) 0 (0%)
    Unrepaired EA 1 (6.3%) 0 (0%) 1 (17%) 0 (0%)
    Vascular Compression 1 (6.3%) 1 (11%) 0 (0%) 0 (0%)
Initial VR Repair



0.034
    arch resection 2 (11%) 1 (9.1%) 0 (0%) 1 (100%)
    divide only aberrant subclavian 2 (11%) 2 (18%) 0 (0%) 0 (0%)
    divide/reimplant 2 (11%) 1 (9.1%) 1 (17%) 0 (0%)
    ductal ligament division only 9 (50%) 7 (64%) 2 (33%) 0 (0%)
    no repair 3 (17%) 0 (0%) 3 (50%) 0 (0%)
First VR Reoperation



0.13
    arch reconstruction/bypass 2 (12%) 2 (20%) 0 (0%) 0 (0%)
    divide only aberrant subclavian 1 (5.9%) 1 (10%) 0 (0%) 0 (0%)
    divide/reimplant 1 (5.9%) 1 (10%) 0 (0%) 0 (0%)
    ductal ligament division only 1 (5.9%) 0 (0%) 0 (0%) 1 (100%)
    no repair 12 (71%) 6 (60%) 6 (100%) 0 (0%)
1 n (%)
2 Fisher’s exact test
library(dplyr)
library(gtsummary)

# Subset concurrent patients
concurrent_df <- EAandVRTableConcurrent %>%
  filter(`First Operation Concurrent` == "Concurrent")

# 1. Complications Table
complications_vars <- c(
  "Esophageal Anastomotic Leak",
  "Esophageal Anastomotic Stricture",
  "Recurrent Esophageal Fistula",
  "Dysphagia",
  "Vocal Cord Dysfunction",
  "Initial EA Repair Location"
)

complications_table <- concurrent_df %>%
  select(all_of(complications_vars)) %>%
  tbl_summary(
    by = `Initial EA Repair Location`,  # BCH vs OSH
    missing = "no",
    label = list(
      `Esophageal Anastomotic Leak` = "Esophageal Anastomotic Leak",
      `Esophageal Anastomotic Stricture` = "Esophageal Anastomotic Stricture",
      `Recurrent Esophageal Fistula` = "Recurrent Esophageal Fistula",
      Dysphagia = "Dysphagia",
      `Vocal Cord Dysfunction` = "Vocal Cord Dysfunction",
      `Initial EA Repair Location` = "Center"
    )
  ) %>%
  add_p(test = list(all_categorical() ~ "fisher.test"),
        pvalue_fun = ~style_pvalue(.x, digits = 2)) %>%
  add_overall() %>%
  bold_p() %>%
  modify_header(label ~ "**Complications**") %>%
  modify_spanning_header(all_stat_cols() ~ "**Concurrent Patients: Complications (BCH vs OSH)**") %>%
  bold_labels()

# 2. Esophageal Reoperations Table
esophageal_reop_vars <- c(
  "Initial Esophageal Repair",
  "First Reoperative Esophageal Repair",
  "First Esophageal Reoperation Indication",
  "Second Esophageal Reoperation",
  "Second Esophageal Reoperation Indication",
  "Initial EA Repair Location"
)

esophageal_reop_table <- concurrent_df %>%
  select(all_of(esophageal_reop_vars)) %>%
  tbl_summary(
    by = `Initial EA Repair Location`,
    missing = "no",
    label = list(
      `Initial Esophageal Repair` = "Initial Esophageal Repair",
      `First Reoperative Esophageal Repair` = "First Reoperative Esophageal Repair",
      `First Esophageal Reoperation Indication` = "First Esophageal Reoperation Indication",
      `Second Esophageal Reoperation` = "Second Esophageal Reoperation",
      `Second Esophageal Reoperation Indication` = "Second Esophageal Reoperation Indication",
      `Initial EA Repair Location` = "Center"
    )
  ) %>%
  add_p(test = list(all_categorical() ~ "fisher.test"),
        pvalue_fun = ~style_pvalue(.x, digits = 2)) %>%
  add_overall() %>%
  bold_p() %>%
  modify_header(label ~ "**Esophageal Reoperations**") %>%
  modify_spanning_header(all_stat_cols() ~ "**Concurrent Patients: Esophageal Reoperations (BCH vs OSH)**") %>%
  bold_labels()

# 3. Vascular Ring Reoperations Table
vascular_reop_vars <- c(
  "Initial VR Repair",
  "First VR Reoperation",
  "Initial EA Repair Location"
)

vascular_reop_table <- concurrent_df %>%
  select(all_of(vascular_reop_vars)) %>%
  tbl_summary(
    by = `Initial EA Repair Location`,
    missing = "no",
    label = list(
      `Initial VR Repair` = "Initial VR Repair",
      `First VR Reoperation` = "First VR Reoperation",
      `Initial EA Repair Location` = "Center"
    )
  ) %>%
  add_p(test = list(all_categorical() ~ "fisher.test"),
        pvalue_fun = ~style_pvalue(.x, digits = 2)) %>%
  add_overall() %>%
  bold_p() %>%
  modify_header(label ~ "**Vascular Ring Reoperations**") %>%
  modify_spanning_header(all_stat_cols() ~ "**Concurrent Patients: Vascular Ring Reoperations (BCH vs OSH)**") %>%
  bold_labels()

# Print the tables separately
complications_table
Complications
Concurrent Patients: Complications (BCH vs OSH)
p-value2
Overall
N = 13
1
BCH
N = 4
1
OSH
N = 9
1
Esophageal Anastomotic Leak


0.21
    No 8 (67%) 4 (100%) 4 (50%)
    Yes 4 (33%) 0 (0%) 4 (50%)
    Unknown 0 (0%) 0 (0%) 0 (0%)
Esophageal Anastomotic Stricture


0.070
    No 7 (54%) 4 (100%) 3 (33%)
    Yes 6 (46%) 0 (0%) 6 (67%)
    Unknown 0 (0%) 0 (0%) 0 (0%)
Recurrent Esophageal Fistula


0.49
    No 9 (75%) 4 (100%) 5 (63%)
    Yes 3 (25%) 0 (0%) 3 (38%)
    Unknown 0 (0%) 0 (0%) 0 (0%)
Dysphagia


>0.99
    No 1 (7.7%) 0 (0%) 1 (11%)
    Yes 12 (92%) 4 (100%) 8 (89%)
    Unknown 0 (0%) 0 (0%) 0 (0%)
Vocal Cord Dysfunction


0.22
    No 5 (38%) 3 (75%) 2 (22%)
    Yes 8 (62%) 1 (25%) 7 (78%)
    Unknown 0 (0%) 0 (0%) 0 (0%)
1 n (%)
2 Fisher’s exact test
esophageal_reop_table
Esophageal Reoperations
Concurrent Patients: Esophageal Reoperations (BCH vs OSH)
p-value2
Overall
N = 13
1
BCH
N = 4
1
OSH
N = 9
1
Initial Esophageal Repair


0.45
    Primary Repair with TEF 8 (62%) 2 (50%) 6 (67%)
    TEF Only 4 (31%) 1 (25%) 3 (33%)
    traction-induced/Foker 1 (7.7%) 1 (25%) 0 (0%)
First Reoperative Esophageal Repair


0.19
    Esophagoplasty/Tracheopexy 1 (7.7%) 0 (0%) 1 (11%)
    Not Performed 5 (38%) 4 (100%) 1 (11%)
    Primary repair Only 2 (15%) 0 (0%) 2 (22%)
    Primary Repair with TEF 1 (7.7%) 0 (0%) 1 (11%)
    Stricturoplasty/Tracheopexy 1 (7.7%) 0 (0%) 1 (11%)
    TEF Only 2 (15%) 0 (0%) 2 (22%)
    traction-induced/Foker 1 (7.7%) 0 (0%) 1 (11%)
First Esophageal Reoperation Indication


0.15
    Esophageal Stricture 1 (8.3%) 0 (0%) 1 (11%)
    None 4 (33%) 3 (100%) 1 (11%)
    Recurrent Fistula 3 (25%) 0 (0%) 3 (33%)
    Tracheomalacia 2 (17%) 0 (0%) 2 (22%)
    Unrepaired EA 2 (17%) 0 (0%) 2 (22%)
Second Esophageal Reoperation


>0.99
    Anterior Aortopexy/Anterior Tracheopexy 1 (9.1%) 0 (0%) 1 (13%)
    Not Performed 6 (55%) 3 (100%) 3 (38%)
    Primary Repair with TEF 1 (9.1%) 0 (0%) 1 (13%)
    replacement/interposition 1 (9.1%) 0 (0%) 1 (13%)
    TEF Only 1 (9.1%) 0 (0%) 1 (13%)
    Tracheopexy 1 (9.1%) 0 (0%) 1 (13%)
Second Esophageal Reoperation Indication


>0.99
    Esophageal Stricture 1 (9.1%) 0 (0%) 1 (13%)
    None 7 (64%) 3 (100%) 4 (50%)
    Other 1 (9.1%) 0 (0%) 1 (13%)
    Recurrent Fistula 1 (9.1%) 0 (0%) 1 (13%)
    Vascular Compression 1 (9.1%) 0 (0%) 1 (13%)
1 n (%)
2 Fisher’s exact test
vascular_reop_table
Vascular Ring Reoperations
Concurrent Patients: Vascular Ring Reoperations (BCH vs OSH)
p-value2
Overall
N = 13
1
BCH
N = 4
1
OSH
N = 9
1
Initial VR Repair


0.23
    arch resection 2 (15%) 0 (0%) 2 (22%)
    divide only aberrant subclavian 2 (15%) 0 (0%) 2 (22%)
    divide/reimplant 2 (15%) 2 (50%) 0 (0%)
    ductal ligament division only 7 (54%) 2 (50%) 5 (56%)
First VR Reoperation


>0.99
    arch reconstruction/bypass 1 (7.7%) 0 (0%) 1 (11%)
    divide only aberrant subclavian 1 (7.7%) 0 (0%) 1 (11%)
    divide/reimplant 1 (7.7%) 0 (0%) 1 (11%)
    ductal ligament division only 1 (7.7%) 0 (0%) 1 (11%)
    no repair 9 (69%) 4 (100%) 5 (56%)
1 n (%)
2 Fisher’s exact test
library(dplyr)
library(gtsummary)

# Subset data for OSH patients only and select operation variables
ComplicationsData_OSH <- EAandVRTableConcurrent %>%
  filter(`Initial EA Repair Location` == "OSH") %>%
  select(
    `Initial Esophageal Repair`,
    `Initial EA Repair Approach Side`,
    `First Reoperative Esophageal Repair`,
    `First Esophageal Reoperation Indication`,
    `Second Esophageal Reoperation`,
    `Second Esophageal Reoperation Indication`,
    `Initial VR Repair`,
    `First VR Reoperation`,
  )

# Create summary table without grouping or overall column
ComplicationsTable_OSH <- ComplicationsData_OSH %>%
  tbl_summary(
    missing = "no",
    label = list(
      `Initial Esophageal Repair` = "Initial Esophageal Repair",
      `Initial EA Repair Approach Side` = "Initial EA Repair Approach Side",
      `First Reoperative Esophageal Repair` = "First Reoperative Esophageal Repair",
      `First Esophageal Reoperation Indication` = "First Esophageal Reoperation Indication",
      `Second Esophageal Reoperation` = "Second Esophageal Reoperation",
      `Second Esophageal Reoperation Indication` = "Second Esophageal Reoperation Indication",
      `Initial VR Repair` = "Initial VR Repair",
      `First VR Reoperation` = "First VR Reoperation"
    )
  ) %>%
  bold_labels()

# Print the table
ComplicationsTable_OSH
Characteristic N = 181
Initial Esophageal Repair
    Esophagostomy/Spit Fistula 1 (5.6%)
    Primary Repair with TEF 13 (72%)
    TEF Only 4 (22%)
Initial EA Repair Approach Side
    Left 11 (61%)
    Right 6 (33%)
    Unknown 1 (5.6%)
First Reoperative Esophageal Repair
    EPF Fistula 1 (5.6%)
    Esophagoplasty/Tracheopexy 1 (5.6%)
    Esophagostomy/Spit Fistula Revision 1 (5.6%)
    Not Performed 6 (33%)
    Primary repair Only 3 (17%)
    Primary Repair with TEF 2 (11%)
    Stricturoplasty/Tracheopexy 1 (5.6%)
    TEF Only 2 (11%)
    traction-induced/Foker 1 (5.6%)
First Esophageal Reoperation Indication
    Esophageal leak 1 (5.9%)
    Esophageal Stricture 1 (5.9%)
    None 5 (29%)
    Recurrent Fistula 4 (24%)
    Tracheomalacia 2 (12%)
    Unrepaired EA 4 (24%)
Second Esophageal Reoperation
    Anterior Aortopexy/Anterior Tracheopexy 1 (6.3%)
    Not Performed 9 (56%)
    Primary Repair with TEF 1 (6.3%)
    replacement/interposition 1 (6.3%)
    Stricture Resection 1 (6.3%)
    TEF Only 1 (6.3%)
    Tracheopexy 1 (6.3%)
    traction-induced/Foker 1 (6.3%)
Second Esophageal Reoperation Indication
    Esophageal Stricture 2 (13%)
    None 10 (63%)
    Other 1 (6.3%)
    Recurrent Fistula 1 (6.3%)
    Unrepaired EA 1 (6.3%)
    Vascular Compression 1 (6.3%)
Initial VR Repair
    arch resection 2 (11%)
    divide only aberrant subclavian 2 (11%)
    divide/reimplant 2 (11%)
    ductal ligament division only 9 (50%)
    no repair 3 (17%)
First VR Reoperation
    arch reconstruction/bypass 2 (12%)
    divide only aberrant subclavian 1 (5.9%)
    divide/reimplant 1 (5.9%)
    ductal ligament division only 1 (5.9%)
    no repair 12 (71%)
1 n (%)
library(dplyr)
library(flextable)
## 
## Attaching package: 'flextable'
## The following objects are masked from 'package:ggpubr':
## 
##     border, font, rotate
## The following object is masked from 'package:purrr':
## 
##     compose
## The following object is masked from 'package:gtsummary':
## 
##     continuous_summary
# Revised Table with the requested columns and correct names
LLTable <- EAandVRTableConcurrent %>%
  filter(`Initial EA Repair Location` == "OSH") %>%
  select(
    mrn,                                                      # Assuming mrn exists
    type_ea,                                                  # Assuming exists
    lastname,
    `Initial Esophageal Repair`,                              # Initial EA/TEF repair method
    `Initial EA Repair Approach Side`,                        # Initial EA/TEF repair side
    Vascular_Ring,                                            # VR anatomy
    `First Operation Concurrent`,                             # Initial VR repair strategy
    `Initial VR Repair`,                                      # Initial VR repair method
    `Complications of Initial EA/VR Repair`,        
    `Reason(s) for Referral (Symptoms/Complications)`,
    `Age at Time of Referral`,
    `EA Reoperations`,                    # Reoperative EA procedures
    `VR Reoperations`,                                   # Reoperative VR procedures
    `Outcome of Reoperation/Current Status`,
    `Lessons Learned`
  )

# Create formatted flextable with proper headers
LL_flextable <- LLTable %>%
  flextable() %>%
  set_header_labels(
    mrn = "MRN",
type_ea = "Type of EA",
lastname = "lastname",
initial_ea_tef_repair_method = "Initial EA/TEF repair method",
initial_ea_tef_repair_side = "Initial EA/TEF repair side",
vr_anatomy = "VR anatomy",
initial_vr_repair_strategy = "Initial VR repair strategy (concurrent vs staged)",
initial_vr_repair_method = "Initial VR repair method",
complications_initial_repair = "Complications of initial EA and/or VR repair",
reason_for_referral = "Reason(s) (symptoms/complications, describe which) for referral",
age_at_referral = "Age at the time of referral",
`EA Reoperations` = "EA Reoperations", 
`VR Reoperations` = "VR Reoperations",
outcome_reoperation = "Outcome of reoperation/Current Status",
lessons_learned = "Lesson Learned"
  ) %>%
  autofit() %>%
  theme_booktabs() %>%
  bold(part = "header") %>%
  fontsize(size = 10)

# Preview table
LL_flextable

MRN

Type of EA

lastname

Initial Esophageal Repair

Initial EA Repair Approach Side

Vascular_Ring

First Operation Concurrent

Initial VR Repair

Complications of Initial EA/VR Repair

Reason(s) for Referral (Symptoms/Complications)

Age at Time of Referral

EA Reoperations

VR Reoperations

Outcome of Reoperation/Current Status

Lessons Learned

5,448,201

B

Holt

Primary Repair with TEF

Left

Right Aortic Arch with Aberrant Left Subclavian Artery

Concurrent

ductal ligament division only

None

Congential Stricture requiring EIT and multiple dilations c/b small leak requiring EVAC placement

1 year, 6 months, and 9 days old

None

None

She is tolerating a full PO diet with dysphagia occurring a couple of times a month.

.

5,659,186

C

Bale

Primary Repair with TEF

Left

Right Aortic Arch with Aberrant Left Subclavian Artery

Staged

divide/reimplant

esophageal/gastric perforation requiring repair (per mom in clinic but not reflected in chart review)

Dysphagia and aspiration Severe GERD with esophagitis and metaplastic changes of distal esophagus requiring now s/p esophagogastric disconnection with roux-en-Y June 2023

14 years, 7 months, and 3 Days

None

None

Taking 2 PO small meals per day of variety of textures (steak, chicken, breads) without dysphagia.

.

5,388,315

C

Blanchard

Primary Repair with TEF

Left

Right Aortic Arch with Aberrant Left Subclavian Artery

Concurrent

divide only aberrant subclavian

Tracheobronchomalacia, repairing her tracheal diverticulum, and tracheal injury causing pneumothorax

Transferred for further management of TBM and esophageal obstructiong requiring reoperation

1 month and 12 days old

traction-induced/Foker Sept 2019, Division of acquired TEF and posterior tracheopexy Oct 2020

Division and reimplantation of Subclavian artery

Reoperation at BCH complicated by large diverticulum requiring eVAC treatment in October 2019 Acquired/recurrent TEF and tracheomalacia requiring reoperation. Now tolerating PO intake and gaining weight appropriately with periodic EGD

.

5,641,261

C

Cruzalves

Primary Repair with TEF

Left

Right Aortic Arch with Aberrant Left Subclavian Artery

Concurrent

ductal ligament division only

Recurrent TEF requiring reoperation at OSH and contained leak which was managed nonoperatively

Referred to BCH for repair of his CAVC and repair of VR

4 month and two days old

TEF repair at OSH 06/2021

ligation and division of the ligamentum arteriosum at BCH

Majority of feeds via G-tube, recurrent respiratory infections, nocturnal desaturation requiring prn O2 and CPAP

5,377,668

C

Dees

Primary Repair with TEF

Left

Right Aortic Arch with Aberrant Left Subclavian Artery

Concurrent

ductal ligament division only

Recurrent TEF requiring reoperation, chronic aspiration requiring tracheostomy, strictures requiring >100 dilations c/b perforations

Referred for further management due to strictures requriing multiple dilations c/b perforation

10 years, 4 months, and 19 days old

Left thoracotomy, esophageal resection and primary repair of recurrent TEF (OSH) 05/2011

None

G-tube for feeds does not tolerate PO intake. Continues to have tracheostomy and requiring oxygen at night.

5,034,786

C

Delemos

Primary Repair with TEF

Left

Right Aortic Arch with Aberrant Left Subclavian Artery

Concurrent

divide only aberrant subclavian

None

Persistent respiratory symptoms, aspiration pneumonias s/p OSH EA/TEF repair, vascular ring repair, and Nissen fundoplication.

1 year, 3 months, and 20 days old

None

None

Tolerating PO and G-tube feeds

4,568,872

C

Garcia

Primary Repair with TEF

Right

Right Aortic Arch with Aberrant Left Subclavian Artery

EA+/-TEF repair Only

no repair

Pinpoint stricture, possible residual type H stricture

Recurrent respiratory symptoms, pinhole esophageal stricture, suspected type H residual fistula

1 month and 20 days old

Repair attempt via R thoracotomy, injury to aortic arch with cardiopulmonary bypass and reinforced patch repair

None

Death due to injury to aortic arch resulting in massive exsanguination, massive pulmonary hemorrhage followed by significantly impaired cardiac, pulmonary, and neurologic function.

5,603,595

C

Kuntz

TEF Only

Right

Right Aortic Arch with Aberrant Left Subclavian Artery

EA+/-TEF repair Only

no repair

After anastomosis, c/b chylothorax with chest tube (resolved).

Referred for anastomosis of previous long gap EA (s/p fistula ligation only)

4 months and 6 days old

R thoracotomy with anastomosis (4/2020), redo R thoracotomy with resection of esophageal stricture and reanastomosis (slide esophagoplasty), EGD with distal congenital stricture dilated (9/2021)

None

Taking PO, g-tube removed, gaining weight appropriately

5,669,113

C

Macconnie

Primary Repair with TEF

Unknown

Double Arch

Concurrent

arch resection

Severe tracheomalacia (100% tracheal collapse at carina), tracheal granulation tissue, esophageal stricture

Severe tracheomalacia (100% tracheal collapse at carina)

5 months and 9 days old

Posterior tracheopexy, bronchopexy, divertiulectomy, stricturoplasty (11/2021), Redo sternotomy with tracheoresection, sliding tracheoplasty (1/2021)

Redo sternotomy, aortic arch reconstruction (1/2021)

J tube feeds only d/t aspiration risk with b/l vocal cord paralysis, increasing G tube clamping times

5,783,504

C

Monroe

Esophagostomy/Spit Fistula

Right

Right Aortic Arch with Aberrant Left Subclavian Artery

Staged

ductal ligament division only

None

Referred for definitive repair of long-gap EA/TEF (originally ligated with spit fistula)

1 year, 7 months, and 24 days old

Temporary tracheostomy closure, silver nitrate to trach site granuloma, cervical neck dissection with esophagostomy resiting, tracheostomy replacement (7/2022), Temporary tracheostomy closure with replacement, L thoracotomy, LoA, redo L neck dissection, cervical esophagostomy resiting to L chest, Foker 1 with external traction system, botox indo esophageal pouches (10/2022), temporary tracheostomy closure and replacement, redo L thoracotomy with LoA, takedown of external traction, slide esophageal anastomosis (Foker 2)

None

Currently with esophageal stricture and concern for eosinophilic esophagitis currently on GJ tube formula. Being managed mostly at OSH so limited data available.

5,037,025

C

Montgomery

TEF Only

Left

Circumflex Right Aortic Arch with Mirror Image Branching and Left Ligamentum Arteriosum

Concurrent

ductal ligament division only

Tracheal diverticulum

Respiratory due to severe tracheomalacia, presence of aortic arch with tracheobronchial compression as well as severe esophageal stricture requiring dilations

5 months and 21 days old

Posterior, anterior tracheopexy, tracheal diverteculectomy, tracheal resection with slide tracheoplasty (1/2017), tracheostomy (2/2017)

Aortic division with uncrossing (1/2017)

Lost to follow up, had traversable upper esophageal stenosis, 70% narrowed L bronchus

4,597,429

C

Schurman

TEF Only

Left

Right Aortic Arch with Aberrant Left Subclavian Artery

Concurrent

ductal ligament division only

Severe chylothorax requiring repeat thoracotomies, chest tubes

Referred for primary anastomosis of EA

30 days

L thoracotomy with decortication, ligation of chyle leak (9/2012), L thoracotomy with LoA, primary anastomosis of EA (10/2012)

None

Tolerating full PO diet, has reflux

71,061,323

C

Sharer

Primary Repair with TEF

Left

Right Aortic Arch with Aberrant Left Subclavian Artery

Staged

ductal ligament division only

Pneumothorax 2/2 VR repair, recurrent esophageal stricture requiring dilation

Recurrent pneumonias

9 years, 6 months, and 12 days

Resection of tracheal diverticulum and tapering longitudinal tracheoplasty, esophageal mobilization (11/2024)

Sternotomy, division of ductal ligament, aortic uncrossing with patch plasty (11/2024)

Full PO, occasional coughs

5,066,210

C

Tamir

Primary Repair with TEF

Right

Right Aortic Arch with Aberrant Left Subclavian Artery

EA+/-TEF repair Only

no repair

Leak from prior EA anastomosis that persisted for 8 months, tracheal stricture proximal to carina with large complex diverticulum

Persistent esophageal leak

6 months and 6 days

R thoracotomy, resection of esophageal diverticulum and rotational esophagoplasty, resection of lung cyst with esophagopulmonary fistula

None

Mild reflux, tolerating full PO diet

6,033,180

C

Zumwalt

Primary Repair with TEF

Right

Right Aortic Arch with Aberrant Left Subclavian Artery

Staged

ductal ligament division only

Esophageal stricture requiring multiple dilations

Daily vomiting limiting PO intake ability, oral aversion

1 year, 11 months, and 10 days

None

None

Receiving pyloric botox, eating pureed and limited solid foods, however limited weight gain

5,347,760

E

Arp

TEF Only

Left

Double Arch

Concurrent

arch resection

Recurrent TEF, posterior tracheal mass with pus, laryngomalacia

Recurrent pneumonias with tracheomalacia

4 years, 9 months, and 11 days

R neck dissection, rotation esophagoplasty, division of TEF, resection of cervical tracheal mass, repair of cervical esophagus, redo R thoracotomy, rotation cervical esophagoplasty, posterior tracheopexy, L mainstom posterior bronchopexy

Redo R throacotomy, descending aortopexy

Tolerating solid foods with good appettite

71,256,250

C

Olivas

Primary Repair with TEF

Right

Right Aortic Arch with Aberrant Left Subclavian Artery

Staged

divide/reimplant

Anastomotic leak, failed extubation d/t pneumothorax, Esophageal stricture requiring multiple dilations

Pneumonias with recurrent respiratory admissions

1 year, 11 months, and 29 days

L thoracotomy, resection of tracheal diverticulum with longitudinal repair, posterior thoracic tracheopexy, L sided rotational esophagoplasty (7/2025), redo L thoracotomy, takedown of tracheopexy and redo posterior tracheopexy

Redo L thoracotomy, repair of coarctation of aorta with patchplasty bovine, redo aortopexy (8/2025)

Frequent vomiting with weakness but tolerating milk and some solids, continued URIs but improving off baseline respiratory regimen

71,528,946

C

Aaron

Primary Repair with TEF

Left

Circumflex Right Aortic Arch with Mirror Image Branching and Left Ligamentum Arteriosum

Staged

ductal ligament division only

failed lap fundo at OSH 12/2024, now s/p ex-lap, hiatal hernia repair with phasix mesh 2x2cm, & Nissen fundoplication 9/25 at BCH

Referred for large, recurrent hiatal hernia

2 years, 6 months, and 23 days

Leak requiring reopening of L thoracotomy and chest tube placement

None

Currently s/p redo hiatal hernia repair after fundoplication migrated to chest. Trach dependent.