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?

3 Likes

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 ?

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

8 Likes