Article
YURI MARX GOMES · Aug 9, 2020 2m read

Generate QRCodes and vCards to FHIR resources and any other data

In the past, reading information from a bar code was limited to a simple alphanumeric code. The creation of a bar code with more than one dimension (2D), especially the QR Code, allowed to increase the amount and variety of data stored in a bar code. While conventional bar codes are capable of storing a maximum of approximately 20 digits, the QR Code is capable of handling several tens to hundreds of times more information. This revolutionized the markets. Now QR codes are everywhere and can be very useful for storing textual, numeric, alphanumeric and even binary data.
This article and the sample application demonstrate how to store a patient's contact data in a QR Code. It is possible to apply this to any FHIR resource.
As the QR Code also stores binary data, it is also shown how to store a stream from a vcf file (vCard). The vCard allows you to automatically create a contact in the contact list of the cell phone or computer and when associated with the QR Code, just point the cell phone and then the patient's contact will go to the contact list of your personal doctor, for example.

My sample is using React. React has an open source component to generate QR Codes: qrcode.react.

It can be installed from following npmjs: https://www.npmjs.com/package/qrcode.react.

To install this package in your react app run:

npm install qrcode.react

To use the component, these instructions are sufficient:

import QRCode from 'qrcode.react';
...
render() {
        return (<QRCode value={this.state.patient.name} />)
}

To generate vCards use library vCards.js. It can be installed from: https://www.npmjs.com/package/vcards-js.

To use the vCard, these instructions  are sufficient:

import vCardsJS from 'vcards-js';
...

getVsCard() {
        var vCard = vCardsJS();
        vCard.firstName = this.state.patient.name;
        vCard.cellPhone = this.state.patient.phone;
        return vCard.getFormattedString();
    }

render() {
        return (<QRCode value={this.getVsCard()} />)
}

vCard can receive many other personal data information, like e-mail, address, see in the vCard.js documentation.

All souce code and running sample can be found in the Open Exchange: https://openexchange.intersystems.com/package/QR-FHIR.

I will participate in the InterSystems IRIS for Health contest with this application. I hope to get your vote. Thank you.

PS: @Eduard Lebedyuk give me a good tip, It is possible generate QR Codes from %SYS.QRCode class too (It is a backend option).
 

 

40
1 3 2 318
Log in or sign up to continue

Replies

Good option @Eduard Lebedyuk, this article add an alternative to generate directly from client. But I will use your tip to a future scenario, where a FHIR resource retuns the results in a QRCode instead XML or JSON. Thanks the tip!

The %SYS.QRCode depends from Java JVM, I used a lib that is generating on the client, no need to go to the server, same to the vCard:

Doc ref: Use of this class requires that Java be installed on your system, and that the Java executable be accessible. The location of the Java executable which is used is determined in the following order: 1) The directory location returned by the configuration parameter JavaHome, located in the [SQL] section of the .cpf configuration file.
2) The directory location returned by the environment variable "JAVA_HOME".
3) Determined by your path variables. The minimum required Java version to run this package is 1.7. This method is not supported on VMS platforms and will return an error if called. This implementation depends on the open source ZXing ("zebra crossing") product. The needed jar files, fop/lib/fop-zxing-0.1.2-jar-with-dependencies.jar and fop/lib/javase-2.0.jar and are distributed in /fop/lib. ZXing uses the same Apache 2.0 license as other jars which are already redistributed with InterSystems IRIS.