It's not a 7 day exit stamp, it's an extension denial. Anytime you apply for an extension and are denied you get 7 days. It has no effect on reentering the country in the future.
I assume Ambian is a controlled drug in Thailand, requiring a prescription. Any doctor could write you one, but an ER physician probably won't because of liability. Call a couple clinics to see if they will write you one.