Assign UNIT NO ( auto incrementing) for each patient

Assign UNIT NO ( auto incrementing) for each patient.
How can i achieve this in forms > demographics

I want a patient no ot a unit no to be assigned to each pt which is unique and better auto incrementing.
eg pt 1 B112233, secong pt B112234 etc