Offline
If Sherlock had been shot, wouldn’t the police be investigating it. Being shot is still considered a crime so I would think that they would be asking Sherlock about what had happened when he was in Magnussen’s office (or for that matter why he had been there at all). They probably never did get a chance to talk to him because he had escaped from the Hospital.
Offline
I think he could tell the story without saying who shot him. That's presumably what Magnusson did. I don't know how it works, but as they had Magnusson as a seemingly reliable witness, they didn't need Sherlock's testimony so urgently and could wait until he had recovered a little. There was no reason to think that Sherlock would know the attacker, because she was breaking into Magnusson's office and supposedly after him (and shot Sherlock because he surprised her and she needed to escape). I don't think anybody else would suspect Lady Smallwood, as only Magnusson and Sherlock knew she was a possibility.
They could have questioned Sherlock in hospital (up until he escaped, there was Mary's threat, so he wouldn't have told, and afterwards there was the agreement with Mary and John, so he wouldn't have told), either before or after escaping, or after he was discharged.