How to display the two-word name health code?

The two-word name health code shows a surname and a *. The name and ID number are displayed on the health code. If the first name is two words, only the last name and the * sign are displayed. If the first name is three words, the last word of the first and last names will be displayed, and the middle word will be replaced by an *. As for the ID number, the last four digits of the province and ID number are displayed, and all the middle digits are replaced with *.