unique key check on form submisstion

I have to introduce a unique key constrains into the from.

Lets say i added,

PersonalIdentityNumber as a customized form field.

I need add the functionality so that no one can book another appointment with the same PersonalIdentityNumber. it should only check with the current approved appointment.

Let me know how can i proceed.

Thank you