ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

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?

1 Like

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 = sale_invoice.name

doctype = sale_invoice.doctype
docname = sale_invoice.name
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()})
_file.save()
frappe.db.commit()
sale_invoice.qr_code = _file.file_url
frappe.db.sql(""“Update tabSales Invoice set qr_code = %s
where name = %s”"", (_file.file_url,
sale_invoice.name))
frappe.db.commit()

Thanks

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