def make_qrcode(self, name):
# Create the QR code
patient_puid = self.puid or ''
patient_blood_type = self.blood_type or ''
patient_rh = self.rh or ''
patient_gender = self.gender or ''
patient_dob = self.dob or ''
patient_id = self.puid or ''
if self.lastname:
patient_lastname = self.lastname + ', '
else:
patient_lastname = ''
qr_string = 'ID: ' + patient_id \
+ '\nName: ' + patient_lastname + ',' \
+ self.name.name \
+ '\nPUID: ' + patient_puid \
+ '\nGender: ' + patient_gender \
+ '\nDoB: ' + str(patient_dob) \
+ '\nBlood Type: ' + patient_blood_type \
+ ' ' + patient_rh
qr_image = qrcode.make(qr_string)
# Make a PNG image from PIL without the need to create a temp file
holder = StringIO.StringIO()
qr_image.save(holder)
qr_png = holder.getvalue()
holder.close()
return bytearray(qr_png)
# Add the QR code field and image to the Newborn
评论列表
文章目录