So we had an incident where a batsmen was struck on his head and his bat flew back leaving from his hands and went into his wicket.
Is it out?
Assuming an appeal is made, yes. Law 29 The wicket is down:
The wicket is put down if a bail is completely removed from the top of the stumps, or a stump is struck out of the ground [...] by the striker's bat not in hand
and Law 35 Hit wicket:
The striker is out Hit wicket if, after the bowler has entered the delivery stride and while the ball is in play, his/her wicket is put down by either the striker’s bat or person [...] in any of the following circumstances:
in the course of any action taken by him/her in preparing to receive or in receiving a delivery,