You can replace the cage - it's held in place on the pivot by a circlip - you need to be careful about releasing that circlip though as the cage is spring loaded and if it's still tensioned, it will whip round pretty darn hard!
If it's not still tensioned, check that the stop moulded into the mech body, that the tensioned cage would normally rest against, hasn't been skimmed off, in amongst the other damage.
In general we advise against repair in these cases and also against second-hand mechs. The upper pivot is retained in a housing made of glass-reinforced techno-polymer ( GRTP, like fibreglass-plastic, basically). If subject to excessive stress (as in this type of accident but it can also happen other ways), the GRTP can micro-fracture in a fashion you can't see - this can lead to failure later, usually when the mech is in the biggest sprocket (that stresses the area around the top pivot to the maximum) so leaving you with another RD-wheel interface scenario - likely to cost you another rear wheel as well as the RD and, as may previously have happened, a new chain and if you are unlucky, a cassette to replace, too.
HTH
Graeme