Barcode / QR code as ID for a Patient

Hey Guys,

I want to generate a barcode for a patient after registration of a patient which I can later on scan to pull up the patient information, any ideas?


Use Barcode generator to create barcodes, create a Barcode DocType, link it on Patient DocType.
Add a Standard filter to pull up the Patient Information. :slight_smile:

Thanks for the response, I know how to create the doctype but the rest I don’t get rest :frowning: I am a newbie

Hello @Dev_Thagichu

Here i am sharing sample example to generate the QR Code with Custom Information.
This example is for Sales Invoice. Simply add one new field “qr_code” in sales invoice doctype and then create doc event to call method.
Our Function / method will generate the QR and Update in our doctype.

from pyqrcode import create as qrcreate

sale_invoice : Is the document.

qrdata =

doctype = sale_invoice.doctype
docname =
filename = ‘{}_QRCODE.png’.format(docname).replace(os.path.sep, “__”)

qr_image = io.BytesIO()
url = qrcreate(str(qrcode), error=‘L’)
url.png(qr_image, scale=2, quiet_zone=1)
_file = frappe.get_doc({
“doctype”: “File”,
“file_name”: filename,
“attached_to_doctype”: doctype,
“attached_to_name”: docname,
“attached_to_field”: “qr_code”,
“is_private”: 0,
“content”: qr_image.getvalue()})
sale_invoice.qr_code = _file.file_url
frappe.db.sql(""“Update tabSales Invoice set qr_code = %s
where name = %s”"", (_file.file_url,


Hey, did you solve the issue? Or want me to help you out with this ?

Here’s a demo app, that shows how to integrate QR codes into any form and printouts: