You got the chat working. Congratulations. Now you need to write the code to generate a pass word and create multiple Tags that point to secure patient/doctor chat rooms.
Before you code the access code @superdojo it would be wise to create the code to create separate chat rooms for the doctor and each user. See
and
Once you can create these 'rooms', you can decide how to create a unique identifier/password that you can send to the patient as a QRcode image.
You can use simple ways to generate this number perhaps using a random number generator or a more sophisticated way for better security. Here are some suggestions: Search results for 'unique' - MIT App Inventor Community .
Before your create a QR code image you need to create the pass code value that the QR code will contain.
Before you create the password/number you need to be able to create multiple chat rooms. Kaustuba's suggestion is a good one. There are examples in the link I provided earlier.
Here is a similar, current chat where someone is building a similar app How do I retrieve only users name from firebase to load them in list in another screen? .