/* One year transplant and patient surivial James Medcalf 04-Mar-2007 Leicester General Hospital, Leicester, U.K. */ type clear type tab(10), "Patient and Graft survial", nl,nl $%dstart := 01.01.2006 /* start of transplant period of interest */ $%dend := 31.12.2006 /* end of transplant period of interest */ $%time := 365 /* days survival */ if TODAY < $%dend + $%time then type "Warning: Not all patients will have completed ",$%time, " days F/U", nl, nl $%tldate := 4126 /* timeline date item */ $%tlevt := 4127 /* timeline event item */ $%cad := "Cada*" /* Cadaver transplant timeline term */ $%liv := "Living*" /* Live donor transplant term */ $%died:= "Died" /* Patient died term */ $%tran:= "Trans*" /* Transfered out term */ $%hd := "Hosp*" /* Haemodialysis term */ $%pd := "C.*" /* PD term */ select all do begin type index scan var($%tldate)[$%a] from $%dstart to $%dend do if eq(var($%tlevt)[$%a], $%cad, $%liv) then begin inc $%txnum /* number of transplants during this time period */ $%txdate := var($%tldate)[$%a] /* does anything now happen in the next period? */ scan var($%tldate)[$%b] from $%txdate+1 to $%txdate + $%time do /* enter any terms to ignore */ if not eq(var($%tlevt)[$%b],"Transp*") then begin $%evt := var($%tlevt)[$%b] report ID.HNO, tab(10), ID.NAM, tab(50), $%evt, nl if eq($%evt, $%hd, $%pd) then inc $%fail if $%evt = $%died then inc $%rip if $%evt = $%tran then inc $%lost break /* ignore any further events */ end /* if graft failed, re-check if died within the time none the less in this analysis we are NOT censoring death for graft failure */ if eq($%evt, $%hd, $%pd) then scan var($%tldate)[$%b] from $%txdate+1 to $%txdate + $%time do if var($%tlevt)[$%b] = $%died then begin inc $%rip report ID.HNO, tab(10), ID.NAM, tab(50), $%died, nl end /* break /* if you want to ignore any further transplants */ end end type "Number of transplants between: ",$%dstart," and ",$%dend, " = ", $%txnum, nl type "Number of patients who's graft failed: ", $%fail, nl type "Number of patients who died: ", $%rip, nl type "Number of patients lost to F/U: ", $%lost, nl type nl $%granum := $%txnum-$%rip-$%lost /* censored graft survival */ $%ptnum := $%txnum-$%lost /* censored patient survial */ type "Graft survival at ", $%time, " days: ", real(100*($%granum-$%fail)/$%granum)%3.1, " % of ", $%granum, " patients", nl type "Patient survival at ", $%time, " days: ", real(100*($%ptnum-$%rip)/$%ptnum)%3.1, " % of ", $%ptnum, " patients", nl type nl, nl type tab(10), "Graft Survival Censored for Death and Lost to Follow-up" ,nl type tab(10), "Patient Survival Censored for lost to Follow-up", nl type tab(10), "Details of the patients who have an event ", "are in the report file", nl, nl