is it possible to write an application that can block call, disable writing text messages if you are driving
No, iPhone apps do not have access to the phone or sms text systems.

There may be such apps in the jailbreak community, but nothing like it will be in the App Store.