To swim and flip in whitewater sports sometimes is part of the game. Everybody is swimming or flipping sometimes.
You do not have to be afraid of it, it is possible to swim safely between to rocks of the rivers. It is possible to learn and after a while it is necessary to learn, of course. It is possible to turn back upside up, with a flipped kayak as well, and it is not super difficult, everybody can learn. To learn it easily it is better to learn some stokes and stroke combinations.
When you swim in a rapid, you have to lay on your back on the surface of the river, with feet ahead. In this case you can see what is infront of you, and you can protect your all body, with your feet. Always keep the feet on the surface, and try to rise your bottom. Hitting the rocks with your bottom is a bad experience.
When you are in a more calm section, you can turn to active swim position, keeping you head upstreem and you can swim towards the shore. Active swimming should be like ferry gliding with your kayak. You have to keep on angle to the current, it will push you to the side.
Once a rapid is comming, you just turn your body laying on your back, and you are in the passive safty position.