I wouldn't completely discount the safety engineering application, but for sure it is always easier to deal with the intellectual property question up-front, so the dental app is more straightforward.
Firstly, don't assume because somebody is paying you to solve their problem that the IP automatically belongs to them. There are plenty of products in the marketplace that started off as custom developments to solve a specific customer's problem, but by careful IP management became real money-spinners for their developers. (Consider MS-DOS as the prime example, and Microsoft didn't even build the original).
Put yourself in the customer's shoes for one minute. In most cases they are interested in getting their problem solved, not in branching out into the software business. However, everyone wants to feel that they got a fair deal. So sometimes charging a high daily consulting rate to build an app, and then going off and marketing the app to others without giving anything back to the original customer maybe doesn't seem quite fair. There are plenty of ways to address this - you can develop the original software at a discounted rate (at cost, for example), you can give them reduced cost maintenance, you can allow them a certain amount of free hours of consulting for enhancements, etc, etc. - the key is to be able to leave the negotiating table with both sides feeling they have got a fair deal.
Of course, a side effect of getting your original customer on your side is that you can then potentially use them as a reference customer, often a really valuable commodity in the early days of any product business.
Coming back to the safety engineering application, I would see whether they would consider some sort of joint venture with you in offering the app to other firms. I am assuming that there is nothing explicit about IP in your current contract with them (obviously a mistake to avoid in the future) so things are a bit up in the air. If this is true, then they're in a sticky position due to the uncertainty, and you could use that fact to initiate a dialogue on the subject. They may be interested in having you as development partner for the software, providing bug fixes and enhancements in return for a revenue share. (If this works, obviously be careful that you don't ge sucked into doing tons of work speculatively). If you can't negotiate with these guys because they're not interested, personally I would walk away - it sounds like it could just turn into an almighty headache.
In short, be fair in your dealings with all your customers and you can't go too far wrong. Good luck in any case!