There’s big difference between travel and full insurance policy.
If you’re using accident (travel) insurance – you would be stabilized, provided necessary medical assistance and sent back home for a further treatment.
If you’re using full insurance you would be fully treated. You can purchase it outside or inside Thailand. The main thing is international policy.
Quite common practice is to purchase insurance right in the hospital.