Hospitals ordered to take action to stop ambulances waiting longer than half an hour