Scrawls from Preston...

Powered by Pelican.

Mon 08 March 2010

Integrating a paper based stage in a digital workflow with Django and QR code

There are several procedural things at work that still involve a signature, or hand written note on a piece of paper. This reality has made it hard to digitize these practices. While much of the process could be replace with a web app, with plenty of benefits. The reality is that because the paper step is required, the process would become disjointed. One way to reconcile the paper with the digital record, is to scan in the signed document and attach it to the digital record. However this doesn't pass my "ugh" test in that even with ajax, manually attaching scanned documents to the correct record is still a tedious process. That is where qrcode comes in.

[QR Code](http://en.wikipedia.org/wiki/QRcode) is a 2 dimensional matrix code invented in Japan that has qualities of easy machine recognition. The idea is that if the paper document is printed with a qrcode, then a computer could later do the work of attaching the scan back to the record. So the qrcode becomes the bridge between the digital and paper steps of the process. The item could even switch between the two multiple times (ie to get multiple signatures in different locations).

I put together a quick django proof of concept that illustrates all the steps.

Briefly:

* a Django view prints a item-document with a generated qrcode in a corner of the page

* an item has a filefield to store a scanned document

* a cron script that loads up the Django environment looks through the scanned documents, decodes the qrcode, and matches them up with the django object

The qrencoding is done with google charts (no hassle of a cached image), and the decode is done with [pyqrcode](http://pyqrcode.sourceforge.net/). Note that the pyqrcode project doesn't have an egg for 10.6, but I put one together [here](https://ptone.com/temp/qrcode-0.2.1-py2.6-macosx-10.6-universal.egg.gz). A little ghostscript love can be used to convert PDF for the decoding step.

Many workplaces now have copiers with built in scanners that can scan a pile of documents with ease, making the effort to attach documents back to the object from where they came pretty easy. There are also iPhone and phone apps that will open the embedded URL, which could be used to pull up a "quick action" list for the item. I haven't seen anything like that for iSight cameras - which is too bad.

So if you are interested in the proof of concept (it is bare bones, but does cover all the core steps you can grab it [here](https://ptone.com/temp/qrcode-experiment.tgz) (if you don't know python/django - you're going to be a bit lost if you download it - sorry). There is one hardcoded path in the link.py script which is what you run to do the importing (ie called from cron). Now I just have to see if I can find time to actually get some apps that use this written.


https://ptone.com/dablog