-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommunity_strategy_survival_analysis.qmd
1905 lines (1243 loc) · 65.7 KB
/
community_strategy_survival_analysis.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
editor: visual
execute:
echo: false
message: false
warning: false
cache: false
title: "Community Services Strategy: Survival analysis"
lang: en-GB
author: Sarah Lucas
date: last-modified
date-format: "YYYY-MM-DD"
title-block-banner: "#f9bf07"
title-block-banner-color: "#333739"
format:
html:
page-layout: full
embed-resources: true
smooth-scroll: true
theme: cosmo
fontcolor: black
toc: true
toc-location: left
toc-title: Summary
toc-depth: 3
css: styles.css
---
```{r set up}
library(targets)
library(odbc)
library(tidyr)
library(dplyr)
library(stringr)
library(janitor)
library(ggplot2)
library(StrategyUnitTheme)
library(survival)
library(ggfortify)
library(survminer)
library(ggsurvfit)
library(RColorBrewer)
library(forcats)
library(flextable)
library(finalfit)
library(plotly)
library(cowplot)
library(eha)
library(gridExtra)
library(furniture)
source("R/Plots.R")
source("R/Tables.R")
# Load data (saved files to save time on rerunning the initial formatting)
survival_data<-tar_read(survival_data)
survival_data_2223<-tar_read(survival_data_2223)
survival_data_first_readmission_2223<-tar_read(survival_data_first_readmission_2223)
deaths_data_2223<-tar_read(deaths_data_2223)
#survival_data_2223_survived_1yr<-tar_read(survival_data_2223_survived_1yr)
```
```{r data science server formatting, eval=FALSE}
# Fetch, format and save data
con <- dbConnect(odbc(),
Driver = "SQL Server",
server = "PRODNHSESQL101",
Database = "NHSE_Sandbox_StrategyUnit")
raw_data_survival_analysis <-
as_tibble(
dbGetQuery(con, '
SELECT *
FROM [NHSE_Sandbox_StrategyUnit].[dbo].[nhse_comm_strat_time_to_readmission_final]
')) |>
clean_names()|>
filter(der_financial_year!="2024/25") |> #Remove most recent yr as incomplete
filter(!is.na(der_pseudo_nhs_number))|> # Remove those without pseudo_nhs_number as can't link readmissions
filter(time_to_readmission>0| is.na(time_to_readmission)) #Some have negative or 0 values think it is linked to date errors and also transfers to different hospitals which starts a new spell.
# Disconnect! #
dbDisconnect(con)
load("Z:/Strategic Analytics/Projects 2024/NHSE Community Strategy/raw_data_survival_analysis.RData")
survival_data<-raw_data_survival_analysis|>
rename(icb=icb_name_short)|>
mutate(imd_decile=as.character(imd_decile))|>
mutate(imd_decile=fct_relevel(imd_decile,c("1","2","3", "4","5","6","7","8","9", "10")))|>
mutate(sex=case_when(sex==1 ~ "male",
sex==2 ~ "female"))|>
mutate(age_range=(case_when(der_age_at_cds_activity_date<60 ~"<60",
der_age_at_cds_activity_date>=60 & der_age_at_cds_activity_date<65 ~ "60-64",
der_age_at_cds_activity_date>=65 & der_age_at_cds_activity_date<70~ "65-69",
der_age_at_cds_activity_date>=70 & der_age_at_cds_activity_date<75~ "70-74",
der_age_at_cds_activity_date>=75 & der_age_at_cds_activity_date<80 ~ "75-79",
der_age_at_cds_activity_date>=80 & der_age_at_cds_activity_date<85~ "80-84",
der_age_at_cds_activity_date>=85 & der_age_at_cds_activity_date<90~ "85-89",
der_age_at_cds_activity_date>=90 ~ "90+" )))|>
select(-der_age_at_cds_activity_date)|>
mutate(ethnicity=case_when(grepl("^A", ethnic_group) ~ "White British",
grepl("^B", ethnic_group)|grepl("^C", ethnic_group) ~ "White Other",
grepl("^D", ethnic_group)|grepl("^E", ethnic_group)| grepl("^F", ethnic_group)|grepl("^G", ethnic_group) ~ "Mixed",
grepl("^H", ethnic_group)|grepl("^J", ethnic_group)| grepl("^K", ethnic_group)|grepl("^L", ethnic_group) ~ "Asian/Asian British",
grepl("^M", ethnic_group)|grepl("^N", ethnic_group)| grepl("^P", ethnic_group) ~ "Black/Black British",
grepl("^R", ethnic_group)|grepl("^S", ethnic_group) ~ "Other",
grepl("^9", ethnic_group)|grepl("^Z", ethnic_group)|is.na(ethnic_group) ~ "Unknown"))|>
mutate(ethnicity=fct_relevel(ethnicity, c("Asian/Asian British", "Black/Black British", "Mixed", "Other", "White British", "White Other", "Unknown")))|>
mutate(flag_falls=ifelse(!is.na(flag_falls_exp)|!is.na(flag_fall_imp_frac)|!is.na(flag_fall_imp_tend), "falls", NA))|> # Single flag for falls
mutate(remove=ifelse((is.na(flag_falls) & is.na(flag_elderly_emergency) & is.na(flag_frail)), "delete", NA))|> #select records that are solely eol for removal as eol patients can't have readmissions as they will have died
# mutate(elderly_non_frail=ifelse(is.na(flag_frail) & !is.na(flag_elderly_emergency), "elderly_non_frail", NA))|> #Flag those that are elderly emergency admission but not frail
filter(is.na(remove))|>
select(-flag_falls_exp, -flag_fall_imp_frac, -flag_fall_imp_tend, -flag_eol, -remove, -ethnic_group, -time_to_death_from_discharge, -reg_date_of_death)|>
pivot_longer( cols = -c("der_financial_year", "sex", "age_range","ethnicity","imd_decile","time_to_readmission", "admission_date", "icb", "der_pseudo_nhs_number", "time_to_death"),
names_to = "name", values_to="cohort")|>
select(-name)|>
filter(!is.na(cohort))|>
mutate(readmit_28days=ifelse(time_to_readmission>28|is.na(time_to_readmission), 0,1))|>
mutate(readmit_1yr=ifelse(time_to_readmission>365|is.na(time_to_readmission), 0,1))|>
mutate(time_to_readmit_28days=ifelse((time_to_readmission>28 | is.na(time_to_readmission)), 30, time_to_readmission))|>
mutate(time_to_readmit_1yr=ifelse((time_to_readmission>365 | is.na(time_to_readmission)), 370, time_to_readmission))|>
mutate(mortality_28days=ifelse(time_to_death>28|is.na(time_to_death), 0,1))|>
mutate(mortality_1yr=ifelse(time_to_death>365|is.na(time_to_death), 0,1))|>
mutate(time_to_death_28days=ifelse((time_to_death>28 | is.na(time_to_death)), 30, time_to_death))|>
mutate(time_to_death_1yr=ifelse((time_to_death>365 | is.na(time_to_death)), 370, time_to_death))|>
mutate(remove=ifelse((cohort=="frail" & age_range=="60-64")|(cohort=="frail" & age_range=="<60")|(cohort=="elderly emergency" & age_range=="70-74"), 1,0))|>
filter(remove==0)|>
select(-remove)|>
distinct(der_pseudo_nhs_number, admission_date, cohort, .keep_all = TRUE)
save(survival_data, file="Z:/Strategic Analytics/Projects 2024/NHSE Community Strategy/survival_data.RData")
```
## Aims
This analysis aims to investigate the risk of death or subsequent readmission in patients who have had an emergency hospital admission. It will help us understand what factors influence the risk of death or readmission, including determining variability between ICB area. This could help identify where activity might be mitigated through appropriate community services provision.
## Methodology
Three patient cohorts are included within this analysis:
- **Elderly emergency**: those 75 or over with an emergency admission.
- **Frail**: those 65 or over with an emergency admission and a frailty score over 5. The frailty score is calculated from ICD-10 diagnoses recorded for admissions during the previous 2 years and using the risk scores in *Gilbert et al (2018), Development and validation of a Hospital Frailty Risk Score focusing on older people in acute care settings using electronic hospital records: an observational study. The Lancet, 391(10132), pp.1775-1782.* (Note these patients are a subset for those in the elderly emergency cohort)
- **Falls**: those 65 or over with an emergency admission related to a fall.
The **End of life** cohort are not included as by definition they die during their hospital admission.
Survival analysis has been conducted using data from 2022/23 for
- Time to death (mortality)
- Time to readmission (time to readmission from the first admission for all patients including some that will have died in the year post-admission)
- Time to readmission- excluding those who died prior to readmission
Note: Frimley ICB has been removed from the analysis due to missing data.
# Mortality
The time from when a patient first had an emergency admission and first entered the cohort until death was calculated. Those who died on the same day as their emergency admission when they first entered the cohort were excluded.
## Trends in the percentage of deaths over time
```{r fig.width=12, fig.height=4}
## Percentage of admissions with a subsequent readmission between 2019-2024
p1<-tar_read(deaths_over_time_28days)
p2<-tar_read(deaths_over_time_1yr)
grid.arrange(p1, p2, ncol=2)
```
The proportion of patients who die is higher within the elderly emergency and frail cohorts compared to the falls cohort.
Generally the proportion of deaths within either 28 days or 1 year have remained stable over time. A slightly lower percentage of deaths within 1 year is to be expected for those first admitted in 2023/24 as there is not a full year of follow-up and some deaths will have not yet occurred.
## Summary of percentage of patients dying within 1 year (2022/23)
```{r, fig.height=8, fig.width=8}
mortality<-furniture::table1(deaths_data_2223|>
filter(cohort=="falls")|>mutate(cohort="Total"),
sex, age_range, ethnicity, imd_decile, cohort,
splitby= ~factor(mortality_1yr)*cohort,
row_wise=TRUE,
format_number = TRUE)|>
as.data.frame()|>
select(-`0`)|>
filter(.!="")|>
rename(`Falls`=`1`)|>
full_join(furniture::table1(deaths_data_2223|>
filter(cohort=="frail")|>mutate(cohort="Total"),
sex, age_range, ethnicity, imd_decile, cohort,
splitby= ~factor(mortality_1yr)*cohort,
row_wise=TRUE,
format_number = TRUE)|>
as.data.frame()|>
select(-`0`)|>
filter(.!="")|>
rename(`Frail`=`1`))|>
full_join(furniture::table1(deaths_data_2223|>
filter(cohort=="elderly emergency")|>mutate(cohort="Total"),
sex, age_range, ethnicity, imd_decile,cohort,
splitby= ~factor(mortality_1yr)*cohort,
row_wise=TRUE,
format_number = TRUE)|>
as.data.frame()|>
select(-`0`)|>
filter(.!="")|>
rename(`Elderly Emergency`=`1`))%>%
replace(is.na(.), "N/A")|>
select(., `Elderly Emergency`, Frail, Falls)|>
rename(variable=.)|>
mutate(variable = str_replace_all(variable, "sex", "Sex"))|>
mutate(variable= str_replace_all(variable, "age_range", "Age"))|>
mutate(variable = str_replace_all(variable, "ethnicity", "Ethnicity"))|>
mutate(variable= str_replace_all(variable, "imd_decile", "IMD decile"))|>
mutate(variable=ifelse(variable=="cohort", "", variable))
mortality|>
flextable()|>
set_header_labels(variable="")|>
bg(bg = "#f9bf07", part = "header") |>
align(part = "body", align = "right")|>
align(j=1, part = "body", align = "left")|>
align(part = "header", align = "right")|>
fontsize(size = 11, part = "all")|>
padding(padding = 2, part = "all", padding.top=NULL) |>
bold(bold = TRUE, part="header")|>
bold(i=1, bold = TRUE, part="body")|>
bold(i=4, bold = TRUE, part="body")|>
bold(i=11, bold = TRUE, part="body")|>
bold(i=19, bold = TRUE, part="body")|>
bold(i=31, bold = TRUE, part="body")|>
line_spacing(space = 1.2, part = "body")|>
autofit()|>
htmltools_value(ft.align = "left")
```
## Comparing time to death between the cohorts using Kaplan-meier plot (2022/23)
For those first admitted in 2022/23 we considered the time to death from when the person was first admitted. The most recent year 2023/2024 was not used as there has not be sufficient time for those that entered the cohort at the end of this year to have a full year of follow-up time.
```{r comparing cohorts deaths, fig.width=10, fig.height=6}
tar_read(comparing_cohorts_deaths)
# log rank
#survdiff(Surv(time_to_death_1yr, death_1yr) ~ cohort, data = deaths_data)
```
The risk of death is highest in the frail cohort, followed by the elderly emergency cohort, with those in the falls cohort have a lowest risk of death.
## Kaplan Meier survival plots of time to death (2022/23)
::: panel-tabset
#### Elderly emergency cohort
::: {.callout-note icon="false"}
#### Summary
The risk of death is increased:
- with age
- in males
- with increasing deprivation
- in those who are White British, compared to all other those of other ethnicities
There is some variation between ICBs in the risk of death with the lowest risk seen in the North West London ICB area.
:::
```{r, fig.width=8, fig.height=5}
tar_read(km_age_elderly_emergency_deaths)
```
```{r, eval=FALSE}
dataset<-deaths_data|>
filter(cohort=="elderly emergency")
fit <- survfit2(Surv(time_to_death_1yr, mortality_1yr) ~icb, data = dataset)
plotly::ggplotly(
km_graph(fit, "icb=", "death") +
labs(title=paste0("Survival time to "," by ICB for the "," cohort"))+
theme(legend.position = "none",
axis.text=element_text(size=12),
axis.title=element_text(size=14),
title=element_text(size=12, hjust = 0, face="bold" ),
plot.margin = margin(0.5, 0.2, 0.5, 0.2, "cm")),
width=800, height=500)
```
```{r, fig.width=8, fig.height=5}
tar_read(km_sex_elderly_emergency_deaths)
```
```{r, fig.width=10, fig.height=6.5}
tar_read(km_ethnicity_elderly_emergency_deaths)
```
```{r, fig.width=8, fig.height=6.5}
tar_read(km_imd_elderly_emergency_deaths)
```
```{r, fig.width=7.5, fig.height=4.5}
tar_read(km_icb_elderly_emergency_deaths)
```
<br>
```{r}
tar_read(icb_table_deaths_elderly_emergency)
```
#### Falls cohort
::: {.callout-note icon="false"}
#### Summary
The risk of death is increased:
- with age
- in males
- with increasing deprivation
- in those who are White British, compared to all other those of other ethnicities
There is some variation between ICBs in the risk of death, with many of the London ICB areas having a lower risk of death.
:::
```{r, fig.width=8, fig.height=5}
tar_read(km_age_falls_deaths)
```
```{r, fig.width=8, fig.height=5}
tar_read(km_sex_falls_deaths)
```
```{r, fig.width=10, fig.height=6.5}
tar_read(km_ethnicity_falls_deaths)
```
```{r, fig.width=8, fig.height=6.5}
tar_read(km_imd_falls_deaths)
```
```{r, fig.width=7.5, fig.height=4.5}
tar_read(km_icb_falls_deaths)
```
<br>
```{r}
tar_read(icb_table_deaths_falls)
```
#### Frail cohort
::: {.callout-note icon="false"}
#### Summary
The risk of death is increased:
- with age
- in males
- with increasing deprivation
- in those who are White British, compared to all other those of other ethnicities
There is some variation between ICBs in the risk of death, with the lowest risk of death seen in the North West London ICB area.
:::
```{r, fig.width=8, fig.height=5}
tar_read(km_age_frail_deaths)
```
```{r, fig.width=8, fig.height=5}
tar_read(km_sex_frail_deaths)
```
```{r, fig.width=10, fig.height=6.5}
tar_read(km_ethnicity_frail_deaths)
```
```{r, fig.width=8, fig.height=6.5}
tar_read(km_imd_frail_deaths)
```
```{r, fig.width=7.5, fig.height=4.5}
tar_read(km_icb_frail_deaths)
```
<br>
```{r}
tar_read(icb_table_deaths_frail)
```
:::
## Multivariate survival analysis of time to death (2022/23)
For this analysis we have taken only data from 2022-2023, and only the first admission for each patient. We have excluded admissions where the person died on the day of admission.
We have fitted multivariate Cox proportional hazard models to our data to assess how various factors independently affect the risk of readmission occurring over time.
### Assumptions of Cox proportional hazards models {#sec-Assumptions-of-Cox-proportional-hazards-models}
Cox proportional hazards models assume that the hazard rate (in this case risk of death) for a person with one set of covariates is proportional to the hazard rate for a person with a different set of covariates, so that the hazard ratio is assumed to be constant over time.
The proportional hazards (PH) assumption can be checked using statistical tests and graphical diagnostics based on the scaled Schoenfeld residuals.
We find significant p-values for some covariates, particularly for ICBs, indicating that the data violates the proportional hazards assumption. This is unsurprising as we have very high number of patients included within our dataset, which means even very small deviations in the residuals over time can result in significant p-values.
Plotting a smoothed fit to the Schoenfeld residuals allows us to determine, where p-values are significant, whether the changes in the beta coefficient over time are large enough to meaningfully impact our analyses. Deviations from a horizontal line indicate non-proportional hazards, and that the hazard ratio will be changing over time.
There are alternatives when the proportional hazards assumption is violated such as adding a time interaction into the model or using an alternative accelerated failure model. With the size of our dataset and the number of covariates (over 40 ICBs) the alternatives do not appear feasible and would unlikely add useful information to our conclusions.
Considering these factors and that for this analysis the degree of variation and trends are more important than the absolute hazard ratios we have used a Cox proportional hazards models, and the calculated hazard ratios can be considered as a time-averaged hazard ratio. We have modelled the risk of death within 28 days and within 1 yr. Considering the first 28 day period alongside the 1 year time period means we can check for any initial differences in the first 28 days that might be averaged out in the long 1 year period. There are some differences in the hazard ratios calculated for the two models, but the general trends are consistent.
### Elderly emergency
::: panel-tabset
#### Cox proportional hazards model 28 days
::: columns
::: {.column width="75%"}
```{r, fig.width=10, fig.height=11}
grid::grid.newpage()
grid::grid.draw(tar_read(cox_forestplot_death_28days_elderly_emergency))
```
::: {style="font-size: 80%;"}
Forest plot of hazard ratios. Black indicates no significant difference compared to the reference group, red indicates a significant increase in the hazard ratio (risk) and green indicates a significant decrease. The size of the point gives an indication of the relative number of people in each group.
:::
:::
:::
#### Testing assumptions
```{r, fig.width=10, fig.height=8}
# Testing Proportional Hazards Assumption (proportional hazards assumption is reasonable if p-values are non-sig)
#tar_read(ph_individual_variables_28days_elderly_emergency)
tar_read(ph_categories_death_28days_elderly_emergency)
#Deviation from a zero-slope line is evidence that the proportional hazards assumption is violated
tar_read(schoenfeld_residuals_death_28days_elderly_emergency)
# Testing Influential Observations
#ggcoxdiagnostics(fit_elderly_emergency_28days, type = "dfbeta",
# linear.predictions = FALSE, ggtheme = theme_bw())
#ggcoxdiagnostics(fit_elderly_emergency_28days, type = "deviance",
# linear.predictions = FALSE, ggtheme = theme_bw())
```
#### Cox proportional hazards model 1 year
::: columns
::: {.column width="75%"}
```{r, fig.width=10, fig.height=11}
grid::grid.newpage()
grid::grid.draw(tar_read(cox_forestplot_death_1yr_elderly_emergency))
```
::: {style="font-size: 80%;"}
Forest plot of hazard ratios. Black indicates no significant difference compared to the reference group, red indicates a significant increase in the hazard ratio (risk) and green indicates a significant decrease. The size of the point gives an indication of the relative number of people in each group.
:::
:::
:::
#### Testing assumptions
```{r, fig.width=10, fig.height=8}
#tar_read(ph_individual_variables_1yr_elderly_emergency)
tar_read(ph_categories_death_1yr_elderly_emergency)
tar_read(schoenfeld_residuals_death_1yr_elderly_emergency)
```
:::
::: {.callout-note icon="false"}
#### Summary
In the elderly emergency cohort the risk of death post-admission:
- is higher in males.
- increases with increasing age.
- up to 28 days those who are Black/Black British or White Other ethnicity have a lower risk of death compared to White British, while Other and Unknown ethnicities have an increased risk. In the 1 year post-admission the risk of death is lower compared to White British for all other ethnicities, apart from Unknown.
- increases with increasing deprivation, those living in the most deprived areas (IMD decile 1) have a higher risk of death than those living in the least deprived areas (IMD decile 10).
- varies by ICB area. The risk of death is lowest in the North West London ICB area and highest in the Norfolk and Waveney ICB area.
:::
### Falls
::: panel-tabset
#### Cox proportional hazards model 28 days
::: columns
::: {.column width="75%"}
```{r, fig.width=10, fig.height=11}
grid::grid.newpage()
grid::grid.draw(tar_read(cox_forestplot_death_28days_falls))
```
::: {style="font-size: 80%;"}
Forest plot of hazard ratios. Black indicates no significant difference compared to the reference group, red indicates a significant increase in the hazard ratio (risk) and green indicates a significant decrease. The size of the point gives an indication of the relative number of people in each group.
:::
:::
:::
#### Testing assumptions
```{r, fig.width=10, fig.height=8}
# Testing Proportional Hazards Assumption (proportional hazards assumption is reasonable if p-values are non-sig)
#tar_read(ph_individual_variables_28days_falls)
tar_read(ph_categories_death_28days_falls)
tar_read(schoenfeld_residuals_death_28days_falls)
```
#### Cox proportional hazards model 1 year
::: columns
::: {.column width="75%"}
```{r, fig.width=10, fig.height=11}
grid::grid.newpage()
grid::grid.draw(tar_read(cox_forestplot_death_1yr_falls))
```
::: {style="font-size: 80%;"}
Forest plot of hazard ratios. Black indicates no significant difference compared to the reference group, red indicates a significant increase in the hazard ratio (risk) and green indicates a significant decrease. The size of the point gives an indication of the relative number of people in each group.
:::
:::
:::
#### Testing assumptions
```{r, fig.width=10, fig.height=8}
# Testing Proportional Hazards Assumption (proportional hazards assumption is reasonable if p-values are non-sig)
#tar_read(ph_individual_variables_1yr_falls)
tar_read(ph_categories_death_1yr_falls)
tar_read(schoenfeld_residuals_death_1yr_falls)
```
:::
::: {.callout-note icon="false"}
#### Summary
In the falls cohort the risk of death post-admission:
- is higher in males.
- increases with increasing age.
- up to 28 days those who are Asian/Asian British, Black/Black British, Other or Unknown ethnicity have a lower risk of death compared to White British. In the year post-admission the risk of death is lower for those who are Black/Black British or White Other ethnicities compared to White British.
- up to 28days is not as clearly correlated with deprivation. However, in the year post-admission risk of death increases with increasing deprivation, those living in the most deprived areas (IMD decile 1) have a higher risk of death than those living in the least deprived areas (IMD decile 10).
- varies by ICB area. The risk of death in the year post-admission is lowest in the North West London ICB and North Central London ICB areas, and highest in the Gloucestershire ICB and Mind and South Essex ICB areas. In the 28 days post-admission the risk of readmission is lowest in the South East London ICB area, and highest in the Gloucestershire ICB area.
:::
### Frail
::: panel-tabset
#### Cox proportional hazards model 28 days
::: columns
::: {.column width="75%"}
```{r, fig.width=10, fig.height=11}
grid::grid.newpage()
grid::grid.draw(tar_read(cox_forestplot_death_28days_frail))
```
::: {style="font-size: 80%;"}
Forest plot of hazard ratios. Black indicates no significant difference compared to the reference group, red indicates a significant increase in the hazard ratio (risk) and green indicates a significant decrease. The size of the point gives an indication of the relative number of people in each group.
:::
:::
:::
#### Testing assumptions
```{r, fig.width=10, fig.height=8}
# Testing Proportional Hazards Assumption (proportional hazards assumption is reasonable if p-values are non-sig)
#tar_read(ph_individual_variables_28days_frail)
tar_read(ph_categories_death_28days_frail)
tar_read(schoenfeld_residuals_death_28days_frail)
```
#### Cox proportional hazards model 1 year
::: columns
::: {.column width="75%"}
```{r, fig.width=10, fig.height=11}
grid::grid.newpage()
grid::grid.draw(tar_read(cox_forestplot_death_1yr_frail))
```
::: {style="font-size: 80%;"}
Forest plot of hazard ratios. Black indicates no significant difference compared to the reference group, red indicates a significant increase in the hazard ratio (risk) and green indicates a significant decrease. The size of the point gives an indication of the relative number of people in each group.
:::
:::
:::
#### Testing assumptions
```{r, fig.width=10, fig.height=8}
# Testing Proportional Hazards Assumption (proportional hazards assumption is reasonable if p-values are non-sig)
#tar_read(ph_individual_variables_1yr_frail)
tar_read(ph_categories_death_1yr_frail)
tar_read(schoenfeld_residuals_death_1yr_frail)
```
:::
::: {.callout-note icon="false"}
#### Summary
In the frail cohort the risk of death post-admission:
- is higher in males.
- increases with increasing age.
- up to 28 days those who are of Unknown ethnicity have a higher risk of death compared to White British. While in the 1 year post-admission the risk of death is lower for those of Asian/Asian British, Black/Black British and Other ethnicities compared to White British.
- increases with increasing deprivation, those living in the most deprived areas (IMD decile 1) have a higher risk of death than those living in the least deprived areas (IMD decile 10).
- varies by ICB area. The risk of death in the year post-admission is lowest in the North West London ICB and Dorset ICB areas and highest in the Humber and North Yorkshire ICB and Hereford and Worcestershire ICB areas. In the 28 days post-admission the risk of readmission is lowest in the North West London ICB and Bristol, North Somerset and South Gloucestershire ICB areas, and highest in the Hereford and Worcestershire ICB and Cornwall and Isles of Scilly ICB areas.
:::
### Number of deaths on day of admission by ethnicity
For the survival analysis we excluded anyone who died on the day of first admission, so given the differences seen in the risk of death by ethnicity we have checked whether there are differences in the percentage of patients who die on the day of first admission by ethnicity.
```{r}
survival_data_first_readmission_2223|>
group_by(ethnicity)|>
summarise(total=n())|>
left_join(survival_data_first_readmission_2223|>
filter(time_to_death==0)|>
group_by(ethnicity)|>
summarise(number_died=n()), by=c("ethnicity"))|>
mutate(percentage=round((number_died/total)*100,2))|>
select(ethnicity, percentage)|>
flextable() |>
set_header_labels(ethnicity="Ethnicity",
percentage="Percentage who die on day of admissions")|>
align(part = "header", align = "center")|>
align(j=1, align = "left")|>
align(part = "body", align = "center")|>
align(j=1, part="body", align="left")|>
align(j=1, part="header", align="left")|>
bg(bg = "#f9bf07", part = "header") |>
bold(i = 1, bold = TRUE, part="header")|>
fontsize(size = 11, part = "all")|>
padding(padding = 1, part = "all", padding.top=NULL) |>
autofit()|>
htmltools_value(ft.align = "left")
```
The percentage of patient who die on the day of admission is slightly higher for those who are Asian/Asian British and of Unknown ethnicity compared to those who are White British.
# Readmissions
```{r readmission barchart 28days, fig.width=8, fig.height=3, eval=FALSE }
## Percentage of admissions with a subsequent readmission between 2019-2024
p1<-tar_read(readmission_barchart_28days)
p2<-tar_read(readmission_barchart_1yr)
grid.arrange(p1, p2, ncol=2)
```
## Trends in the percentage of admissions with a subsequent readmission over time
```{r readmission over time 28days, fig.width=12, fig.height=4}
p1<-tar_read(readmission_over_time_28days)
p2<-tar_read(readmission_over_time_1yr)
grid.arrange(p1, p2, ncol=2)
```
Generally the proportion of admissions that have resulted in a readmission within either 28 days or 1 year have remained stable over time.
The proportion of patient with a readmission is higher in the elderly emergency and frail cohorts compared to the falls cohort.
A lower percentage of readmissions within 1 year is to be expected for those admitted in 2023/24 as there is not a full year of follow-up and some readmissions will have not yet occurred.
## Summary of percentage of patients readmitted within 1 year (2022/23)
All admissions are counted an individual events, so some patients with multiple admissions will be included more than once.
```{r, fig.height=8, fig.width=8}
readmit<-furniture::table1(survival_data_2223|>
filter(cohort=="falls")|>mutate(cohort="Total"),
sex, age_range, ethnicity, imd_decile, cohort,
splitby= ~factor(mortality_1yr)*cohort,
row_wise=TRUE,
format_number = TRUE)|>
as.data.frame()|>
select(-`0`)|>
filter(.!="")|>
rename(`Falls`=`1`)|>
full_join(furniture::table1(survival_data_2223|>
filter(cohort=="frail")|>mutate(cohort="Total"),
sex, age_range, ethnicity, imd_decile, cohort,
splitby= ~factor(mortality_1yr)*cohort,
row_wise=TRUE,
format_number = TRUE)|>
as.data.frame()|>
select(-`0`)|>
filter(.!="")|>
rename(`Frail`=`1`))|>
full_join(furniture::table1(survival_data_2223|>
filter(cohort=="elderly emergency")|>mutate(cohort="Total"),
sex, age_range, ethnicity, imd_decile,cohort,
splitby= ~factor(mortality_1yr)*cohort,
row_wise=TRUE,
format_number = TRUE)|>
as.data.frame()|>
select(-`0`)|>
filter(.!="")|>
rename(`Elderly Emergency`=`1`))%>%
replace(is.na(.), "N/A")|>
select(., `Elderly Emergency`, Frail, Falls)|>
rename(variable=.)|>
mutate(variable = str_replace_all(variable, "sex", "Sex"))|>
mutate(variable= str_replace_all(variable, "age_range", "Age"))|>
mutate(variable = str_replace_all(variable, "ethnicity", "Ethnicity"))|>
mutate(variable= str_replace_all(variable, "imd_decile", "IMD decile"))|>
mutate(variable=ifelse(variable=="cohort", "", variable))
readmit|>
flextable()|>
set_header_labels(variable="")|>
bg(bg = "#f9bf07", part = "header") |>
align(part = "body", align = "right")|>
align(j=1, part = "body", align = "left")|>
align(part = "header", align = "right")|>
fontsize(size = 11, part = "all")|>
padding(padding = 2, part = "all", padding.top=NULL) |>
bold(bold = TRUE, part="header")|>
bold(i=1, bold = TRUE, part="body")|>
bold(i=4, bold = TRUE, part="body")|>
bold(i=11, bold = TRUE, part="body")|>
bold(i=19, bold = TRUE, part="body")|>
bold(i=31, bold = TRUE, part="body")|>
line_spacing(space = 1.2, part = "body")|>
autofit()|>
htmltools_value(ft.align = "left")
```
## Number of readmissions in 2022/2023
```{r mean and median}
mean_median_admissions<-tar_read(mean_median_admissions)
mean_median_admissions|>
select(cohort, mean, median, min, lower_quartile, upper_quartile, max)|>
flextable() |>
set_header_labels(lower_quartile="lower quartile",
upper_quartile="upper quartile")|>
align(part = "header", align = "center")|>
align(j=1, align = "left")|>
align(part = "body", align = "center")|>
align(j=1, part="body", align="left")|>
align(j=1, part="header", align="left")|>
bg(bg = "#f9bf07", part = "header") |>
bold(i = 1, bold = TRUE, part="header")|>
fontsize(size = 11, part = "all")|>
padding(padding = 1, part = "all", padding.top=NULL) |>
autofit()|>
htmltools_value(ft.align = "left")
#tar_read(numbers_of_readmissions)
```
The majority of patients have no readmission within a year, and of those that do have a readmission it is most common to just have a single readmission. A small number of patients are having more regular emergency admissions; those with a highest rates appear to be often admitted and discharged on the same day.
## Comparing time to readmission between the cohorts using Kaplan-meier plots (2022/23)
::: panel-tabset
#### All readmissions included
Survival analysis was conducted where each admission is treated as an independent event. This means some patients who had multiple admissions within 2022/23 will be included multiple times.
```{r comparing cohorts, fig.width=10, fig.height=6}
tar_read(comparing_cohorts)
# log rank
#survdiff(Surv(time_to_readmit_1yr, readmit_1yr) ~ cohort, data = survival_data_2223)
```
#### Only first readmission
Survival analysis was conducted using a patient's first admission within 2022/23, so only one event is included per patient, even if the patient has multiple admissions over the year.
```{r comparing cohorts first readmission only, fig.width=10, fig.height=6}
# Without duplicates
tar_read(comparing_cohorts_without_duplicates)
```
:::
The risk of readmission is very similar between the elderly emergency and frail cohorts (note the frail cohort is a subset of the elderly emergency cohort). Those in the falls cohort have a lower risk of readmission.
The risk of admissions is increased slightly by a small subset of patients that have multiple readmissions, as the risk of readmission decreases if only the first admission/ readmission is included for each patient.
## Kaplan Meier survival plots of time to readmission (2022/23)
For these plots each admission in 2022/23 was treated as an independent event, meaning that some patients who had multiple admissions within 2022/23 will be included multiple times.
::: panel-tabset
#### Elderly emergency cohort
::: {.callout-note icon="false"}
#### Summary
The risk of readmission is higher in those who are:
- aged 80-89, compared to those aged 75-79 or 90+.
- male
- Asian/Asian British or Black/Black British compared to White British
- living in a more deprived area
The risk of readmission varies by ICB area, with a lower risk of readmission in the Dorset, Gloucestershire and Cornwall and Isles of Scilly ICB areas and a higher risk in the North West London ICB area.
:::
```{r, fig.width=8, fig.height=5}
tar_read(km_age_elderly_emergency)
```
```{r, fig.width=8, fig.height=5}
tar_read(km_sex_elderly_emergency)
```
```{r, fig.width=10, fig.height=6.5}
tar_read(km_ethnicity_elderly_emergency)
```
```{r, fig.width=8, fig.height=6.5}
tar_read(km_imd_elderly_emergency)
```
```{r, fig.width=7.5, fig.height=4.5}
tar_read(km_icb_elderly_emergency)
```
<br>
```{r}
tar_read(icb_table_elderly_emergency)
```
#### Falls cohort
::: {.callout-note icon="false"}
#### Summary
The risk of readmission is higher in those who are:
- aged over 75 years.
- male
- Black/Black British
In this falls cohort there is no clear association between deprivation and risk of readmission.
The risk of readmission varies by ICB area.
:::
```{r, fig.width=8, fig.height=5}
tar_read(km_age_falls)
```
```{r, fig.width=8, fig.height=5}
tar_read(km_sex_falls)
```
```{r, fig.width=10, fig.height=6.5}
tar_read(km_ethnicity_falls)
```
```{r, fig.width=8, fig.height=6.5}
tar_read(km_imd_falls)
```
```{r, fig.width=7.5, fig.height=4.5}
tar_read(km_icb_falls)
```