Staff at Edinburgh Royal Infirmary ended up treating one of the main filmmakers who worked on the long-awaited sequel.
He was cared for after the film’s location managers secured rare permission for several T2 Trainspotting scenes to be shot there.
Boyle, revealed that his crew member almost lost a leg during the making of T2 last summer, also praised the National Health Service for the level of care his colleague had received.
The director made his name with the Edinburgh-set thriller Shallow Grave and the original Trainspotting.
He had previously paid tribute to the NHS in a special sequence in the opening ceremony of the London Olympics, in 2012, which he masterminded.
He later claimed that he came under pressure to drop the tribute, which featured dancing doctors and nurses surrounded by hundreds of luminous beds which spelt out the letters “NHS.”
Robert Carlyle, who plays Begbie, filmed a number of scenes in the real-life hospital, as well as Saughton Prison, in T2 Trainspotting, which reunited him with Ewan McGregor, Jonny Lee Miller and Ewen Bremner.
The film sees violent psychopath Begbie leave person and then attempt to seek revenge on McGregor’s character Renton for betraying his friends at the end of the previous movie by fleeing the country after a drug deal.
Speaking at the world premiere, Boyle said a number of agencies in Edinburgh had helped with the making of the film, which is released on Friday, but said a “more important” contribution had been made by NHS.
He also pointed out that John Hodge, the screenwriter of both Trainspotting and its sequel, was a former NHS worker.
Born in Glasgow, Hodge studied medicine at Edinburgh University and only started writing screenplays as a junior doctor after meeting film producer Andrew Macdonald at the capital’s film festival in 1991.
Boyle said: “One of our key workers was taken very, very seriously ill.
“The care and attention he received when we were making the film, right the way through the film, saved his life and then saved his leg.
“He is working again on a new Paul Thomas Anderson film with Daniel Day Lewis. That’s all down to the NHS and Edinburgh Royal Infirmary.”
Dr David Farquharson, medical director, NHS Lothian, said: “We would like to thank Danny Boyle for praising the NHS at the premiere of T2 Trainspotting and thanking Edinburgh Royal Infirmary for taking care of one of the crew members working on the film.
“We were pleased to have worked with the film crew last May when they used the hospital for some key scenes and we’re glad to hear that the crew member has now fully recovered and is back at work.”