Mercurial > hgweb > health
changeset 4867:d484c58618cd
task #16043: Migration to GNU Health 4.0: Migrate and cleanup health_qrcodes
| author | Luis Falcon <falcon@gnuhealth.org> |
|---|---|
| date | Sat, 15 Jan 2022 07:42:24 +0000 |
| parents | 61425e2fd7b0 |
| children | b7f8a757b534 |
| files | tryton/health_qrcodes/__init__.py tryton/health_qrcodes/health_qrcodes.py tryton/health_qrcodes/tryton.cfg |
| diffstat | 3 files changed, 30 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health_qrcodes/__init__.py +++ b/tryton/health_qrcodes/__init__.py @@ -22,13 +22,13 @@ ############################################################################## from trytond.pool import Pool -from .health_qrcodes import * +from .import health_qrcodes def register(): Pool.register( - Patient, - Appointment, - Newborn, - LabTest, + health_qrcodes.Patient, + health_qrcodes.Appointment, + health_qrcodes.Newborn, + health_qrcodes.LabTest, module='health_qrcodes', type_='model')
--- a/tryton/health_qrcodes/health_qrcodes.py +++ b/tryton/health_qrcodes/health_qrcodes.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ############################################################################## # # GNU Health: The Free Health and Hospital Information System @@ -26,7 +25,7 @@ from trytond.model import ModelView, ModelSQL, fields -__all__ = ['Patient', 'Appointment', 'Newborn','LabTest'] +__all__ = ['Patient', 'Appointment', 'Newborn', 'LabTest'] # Add the QR field and QR image in the patient model @@ -39,7 +38,7 @@ qr = fields.Function(fields.Binary('QR Code'), 'make_qrcode') def make_qrcode(self, name): - # Create the QR code + # Create the QR code patient_puid = self.puid or '' @@ -60,16 +59,15 @@ qr_string = 'ID: ' + patient_id \ + '\nName: ' + patient_lastname + ',' \ - + self.name.name \ + + self.name.name \ + '\nPUID: ' + patient_puid \ + '\nGender: ' + patient_gender \ + '\nDoB: ' + str(patient_dob) \ + '\nBlood Type: ' + patient_blood_type \ - + ' ' + patient_rh + + ' ' + patient_rh - qr_image = qrcode.make(qr_string) - + # Make a PNG image from PIL without the need to create a temp file holder = io.BytesIO() @@ -78,7 +76,7 @@ holder.close() return bytearray(qr_png) - + # Add the QR field and QR image in the appointment model @@ -89,7 +87,7 @@ qr = fields.Function(fields.Binary('QR Code'), 'make_qrcode') def make_qrcode(self, name): - # Create the QR code + # Create the QR code appointment_healthprof = '' appointment_patient = '' @@ -97,7 +95,7 @@ appointment_specialty = '' appointment_date = '' appointment = '' - + if (self.name): appointment = self.name @@ -107,7 +105,7 @@ if (self.patient): appointment_patient = self.patient.rec_name or '' patient_puid = self.patient.puid - + if (self.appointment_date): appointment_date = str(self.appointment_date) @@ -120,9 +118,9 @@ + '\nSpecialty: ' + appointment_specialty \ + '\nhealth Prof: ' + appointment_healthprof or ''\ + '\nDate: ' + appointment_date or '' - + qr_image = qrcode.make(qr_string) - + # Make a PNG image from PIL without the need to create a temp file holder = io.BytesIO() @@ -133,7 +131,6 @@ return bytearray(qr_png) - class Newborn(ModelSQL, ModelView): 'NewBorn' __name__ = 'gnuhealth.newborn' @@ -142,7 +139,7 @@ qr = fields.Function(fields.Binary('QR Code'), 'make_qrcode') def make_qrcode(self, name): - # Create the QR code + # Create the QR code if self.mother: if self.mother.name.lastname: @@ -172,9 +169,8 @@ + '\nSex: ' + newborn_sex \ + '\nDoB: ' + str(newborn_birth_date) + qr_image = qrcode.make(qr_string) - qr_image = qrcode.make(qr_string) - # Make a PNG image from PIL without the need to create a temp file holder = io.BytesIO() @@ -184,16 +180,16 @@ return bytearray(qr_png) - + class LabTest(ModelSQL, ModelView): __name__ = 'gnuhealth.lab' # Add the QR Code to the Lab Test qr = fields.Function(fields.Binary('QR Code'), 'make_qrcode') bar = fields.Function(fields.Binary('Bar Code39'), 'make_barcode') - + def make_qrcode(self, name): - # Create the QR code + # Create the QR code labtest_id = self.name or '' labtest_type = self.test or '' @@ -207,10 +203,10 @@ + 'Test: ' + labtest_type.rec_name \ + 'Patient ID: ' + patient_puid \ + '\nPatient: ' + patient_name \ - + '\nRequestor: ' + requestor_name - + + '\nRequestor: ' + requestor_name + qr_image = qrcode.make(qr_string) - + # Make a PNG image from PIL without the need to create a temp file holder = io.BytesIO() @@ -220,16 +216,15 @@ return bytearray(qr_png) + def make_barcode(self, name): + # Create the Code39 bar code to encode the TEST ID - def make_barcode(self, name): - # Create the Code39 bar code to encode the TEST ID - labtest_id = self.name or '' - + CODE39 = barcode.get_barcode_class('code39') - + code39 = CODE39(labtest_id, add_checksum=False) - + # Make a PNG image from PIL without the need to create a temp file holder = io.BytesIO()
