Has anyone been prescribed anxiety meds to take just as need vs everyday?

.

I’m 29 weeks pregnant and struggle with ptsd/anxiety from having a prior 26 weeker preemie and usually only have anxiety and panic attacks when coming to appointments or the hospital. So they prescribed me buspirone to take 3 times a day only as needed instead of everyday. Does anyone else take anxiety meds only as needed? Has it helped you?