Even trying to base what people are paid on such factors opens the door to claims of discrimination in pay practices in the U.S.
It is very unfortunate if you were promised a salary increase for passing boards or obtaining specific certifications and then were not given the raise.
If the practice of giving a standard kind of increase to salary is a standard past practice for passing specific tests, it is possible that you have a legitimate claim of discrimination. But without knowing more, I cannot fully advise you on that.
To answer your actual question, it may be legal for the HR director to ask such a question. But it does show extremely poor judgment, as the question is totally irrelevant regarding how much you should be paid for the work that you do and the value that you provide to the hospital.
Asking questions like this also opens the door to a claim of discriminatory pay practices, as I mentioned above.