Mercurial > hgweb > health
changeset 4874:df3ca2fbe9af
task #16043: Migration to GNU Health 4.0: Migrate and cleanup health_ophthalmology
| author | Luis Falcon <falcon@gnuhealth.org> |
|---|---|
| date | Sat, 15 Jan 2022 09:24:08 +0000 |
| parents | e4964527e597 |
| children | 1450878cb7f1 |
| files | tryton/health_ophthalmology/__init__.py tryton/health_ophthalmology/health_ophthalmology.py tryton/health_ophthalmology/tryton.cfg |
| diffstat | 3 files changed, 139 insertions(+), 130 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health_ophthalmology/__init__.py +++ b/tryton/health_ophthalmology/__init__.py @@ -1,8 +1,8 @@ from trytond.pool import Pool -from .health_ophthalmology import * +from . import health_ophthalmology def register(): Pool.register( - OphthalmologyEvaluation, - OphthalmologyFindings, + health_ophthalmology.OphthalmologyEvaluation, + health_ophthalmology.OphthalmologyFindings, module='health_ophthalmology', type_='model')
--- a/tryton/health_ophthalmology/health_ophthalmology.py +++ b/tryton/health_ophthalmology/health_ophthalmology.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ############################################################################## # # GNU Health: The Free Health and Hospital Information System @@ -22,16 +21,12 @@ ############################################################################## from trytond.model import ModelView, ModelSQL, fields -from trytond.pool import Pool from dateutil.relativedelta import relativedelta -from datetime import datetime, timedelta, date +from datetime import datetime from trytond.pyson import Eval, Equal +from trytond.modules.health.core import get_health_professional -__all__ = [ - 'OphthalmologyEvaluation', - 'OphthalmologyFindings', - ] - +__all__ = ['OphthalmologyEvaluation', 'OphthalmologyFindings'] class OphthalmologyEvaluation(ModelSQL, ModelView): @@ -77,9 +72,9 @@ ('1_meter_fc', '1 Meter FC'), ('1_2_meter_fc', '1/2 Meter FC'), ('hmfc', 'HMCF'), - ('p_l', 'P/L'), + ('p_l', 'P/L'), ] - + # Near vision chart near_vision_chart = [ (None, ''), @@ -92,128 +87,151 @@ ('N60', 'N60'), ] # vision test using snellen chart - rdva = fields.Selection(snellen_chart, 'RDVA', - help="Right Eye Vision of Patient without aid", - sort=False, states = STATES) + rdva = fields.Selection( + snellen_chart, 'RDVA', + help="Right Eye Vision of Patient without aid", + sort=False, states=STATES) + ldva = fields.Selection(snellen_chart, 'LDVA', help="Left Eye Vision of Patient without aid", - sort=False, states = STATES) + sort=False, states=STATES) # vision test using pinhole accurate manual testing rdva_pinhole = fields.Selection(snellen_chart, 'RDVA', help="Right Eye Vision Using Pin Hole", - sort=False, states = STATES) + sort=False, states=STATES) ldva_pinhole = fields.Selection(snellen_chart, 'LDVA', help="Left Eye Vision Using Pin Hole", - sort=False, states = STATES) + sort=False, states=STATES) # vison testing with glasses just to assess what the patient sees with # his existing aid # useful esp with vision syndromes that are not # happening because of the lens rdva_aid = fields.Selection(snellen_chart, 'RDVA AID', help="Vision with glasses or contact lens", - sort=False, states = STATES) + sort=False, states=STATES) ldva_aid = fields.Selection(snellen_chart, 'LDVA AID', help="Vision with glasses or contact lens", - sort=False, states = STATES) + sort=False, states=STATES) # spherical - rspherical = fields.Float('SPH',help='Right Eye Spherical', states = STATES) - lspherical = fields.Float('SPH',help='Left Eye Spherical', states = STATES) + rspherical = fields.Float('SPH', help='Right Eye Spherical', states=STATES) + lspherical = fields.Float('SPH', help='Left Eye Spherical', states=STATES) # cylinder - rcylinder = fields.Float('CYL',help='Right Eye Cylinder', states = STATES) - lcylinder = fields.Float('CYL',help='Left Eye Cylinder', states = STATES) - - #axis - raxis = fields.Float('Axis',help='Right Eye Axis', states = STATES) - laxis = fields.Float('Axis',help='Left Eye Axis', states = STATES) + rcylinder = fields.Float('CYL', help='Right Eye Cylinder', states=STATES) + lcylinder = fields.Float('CYL', help='Left Eye Cylinder', states=STATES) + + # axis + raxis = fields.Float('Axis', help='Right Eye Axis', states=STATES) + laxis = fields.Float('Axis', help='Left Eye Axis', states=STATES) # near vision testing .... you will get it when u cross 40 :) # its also thinning of the lens.. the focus falls behind the retina # in case of distant vision the focus does not reach retina - - rnv_add = fields.Float('NV Add', help='Right Eye Best Corrected NV Add', - states = STATES) - lnv_add = fields.Float('NV Add', help='Left Eye Best Corrected NV Add' - , states = STATES) - - rnv = fields.Selection(near_vision_chart, 'RNV', - help="Right Eye Near Vision", sort=False, - states = STATES) - lnv = fields.Selection(near_vision_chart, 'LNV', - help="Left Eye Near Vision", sort=False, - states = STATES) - # after the above tests the optometrist or doctor comes to a best conclusion - # best corrected visual acuity + rnv_add = fields.Float( + 'NV Add', help='Right Eye Best Corrected NV Add', + states=STATES) + lnv_add = fields.Float( + 'NV Add', help='Left Eye Best Corrected NV Add', + states=STATES) + + rnv = fields.Selection( + near_vision_chart, 'RNV', + help="Right Eye Near Vision", sort=False, + states=STATES) + + lnv = fields.Selection( + near_vision_chart, 'LNV', + help="Left Eye Near Vision", sort=False, + states=STATES) + + # after the above tests the optometrist or doctor comes to a best + # conclusion best corrected visual acuity # the above values are from autorefraction # the doctors decision is final # and there could be changes in values of cylinder, spherical and axis # these values will go into final prescription of glasses or contact lens - # by default these values should be auto populated + # by default these values should be auto populated # and should be modifiable by an ophthalmologist - rbcva_spherical = fields.Float('SPH', - help='Right Eye Best Corrected Spherical', states = STATES) - lbcva_spherical = fields.Float('SPH', - help='Left Eye Best Corrected Spherical', states = STATES) - rbcva_cylinder = fields.Float('CYL', - help='Right Eye Best Corrected Cylinder', states = STATES) - lbcva_cylinder = fields.Float('CYL', - help='Left Eye Best Corrected Cylinder', states = STATES) + rbcva_spherical = fields.Float( + 'SPH', + help='Right Eye Best Corrected Spherical', states=STATES) + lbcva_spherical = fields.Float( + 'SPH', + help='Left Eye Best Corrected Spherical', states=STATES) - rbcva_axis = fields.Float('Axis', - help='Right Eye Best Corrected Axis', states = STATES) - lbcva_axis = fields.Float('Axis', - help='Left Eye Best Corrected Axis', states = STATES) + rbcva_cylinder = fields.Float( + 'CYL', + help='Right Eye Best Corrected Cylinder', states=STATES) + lbcva_cylinder = fields.Float( + 'CYL', + help='Left Eye Best Corrected Cylinder', states=STATES) - rbcva = fields.Selection(snellen_chart, 'RBCVA', - help="Right Eye Best Corrected VA", sort=False, states = STATES) - lbcva = fields.Selection(snellen_chart, 'LBCVA', - help="Left Eye Best Corrected VA", sort=False, states = STATES) - - rbcva_nv_add = fields.Float('BCVA - Add', - help='Right Eye Best Corrected NV Add', states = STATES) - lbcva_nv_add = fields.Float('BCVA - Add', - help='Left Eye Best Corrected NV Add', states = STATES) + rbcva_axis = fields.Float( + 'Axis', + help='Right Eye Best Corrected Axis', states=STATES) + lbcva_axis = fields.Float( + 'Axis', + help='Left Eye Best Corrected Axis', states=STATES) - rbcva_nv = fields.Selection(near_vision_chart, 'RBCVANV', - help="Right Eye Best Corrected Near Vision", - sort=False, states = STATES) - lbcva_nv = fields.Selection(near_vision_chart, 'LBCVANV' , - help="Left Eye Best Corrected Near Vision", - sort=False, states = STATES) - - #some other tests of the eyes - #useful for diagnosis of glaucoma a disease that builds up - #pressure inside the eye and destroy the retina - #its also called the silent vision stealer - #intra ocular pressure - #there are three ways to test iop + rbcva = fields.Selection( + snellen_chart, 'RBCVA', + help="Right Eye Best Corrected VA", sort=False, states=STATES) + lbcva = fields.Selection( + snellen_chart, 'LBCVA', + help="Left Eye Best Corrected VA", sort=False, states=STATES) + + rbcva_nv_add = fields.Float( + 'BCVA - Add', + help='Right Eye Best Corrected NV Add', states=STATES) + lbcva_nv_add = fields.Float( + 'BCVA - Add', + help='Left Eye Best Corrected NV Add', states=STATES) + + rbcva_nv = fields.Selection( + near_vision_chart, 'RBCVANV', + help="Right Eye Best Corrected Near Vision", + sort=False, states=STATES) + + lbcva_nv = fields.Selection( + near_vision_chart, 'LBCVANV', + help="Left Eye Best Corrected Near Vision", + sort=False, states=STATES) + + # some other tests of the eyes + # useful for diagnosis of glaucoma a disease that builds up + # pressure inside the eye and destroy the retina + # its also called the silent vision stealer + # intra ocular pressure + # there are three ways to test iop # SCHIOTZ # NONCONTACT TONOMETRY # GOLDMANN APPLANATION TONOMETRY - #notes by the ophthalmologist or optometrist - notes = fields.Text ('Notes', states = STATES) + # notes by the ophthalmologist or optometrist + notes = fields.Text('Notes', states=STATES) - #Intraocular Pressure + # Intraocular Pressure iop_method = fields.Selection([ - (None,''), + (None, ''), ('nct', 'Non-contact tonometry'), ('schiotz', 'Schiotz tonometry'), ('goldmann', 'Goldman tonometry'), ], 'Method', help='Tonometry / Intraocular pressure reading method', - states = STATES) - - riop = fields.Float('RIOP',digits=(2,1), - help="Right Intraocular Pressure in mmHg", states = STATES) + states=STATES) - liop = fields.Float('LIOP',digits=(2,1), - help="Left Intraocular Pressure in mmHg", states = STATES) - + riop = fields.Float( + 'RIOP', digits=(2, 1), + help="Right Intraocular Pressure in mmHg", states=STATES) + + liop = fields.Float( + 'LIOP', digits=(2, 1), + help="Left Intraocular Pressure in mmHg", states=STATES) + findings = fields.One2Many( 'gnuhealth.ophthalmology.findings', 'name', - 'Findings', states = STATES) + 'Findings', states=STATES) state = fields.Selection([ (None, ''), @@ -226,10 +244,10 @@ states={'invisible': Equal(Eval('state'), 'in_progress')}, help="Health Professional that finished the patient evaluation") - def patient_age_at_evaluation(self, name): if (self.patient.name.dob and self.visit_date): - rdelta = relativedelta(self.visit_date.date(), + rdelta = relativedelta( + self.visit_date.date(), self.patient.name.dob) years_months_days = str(rdelta.years) + 'y ' \ + str(rdelta.months) + 'm ' \ @@ -267,11 +285,11 @@ @fields.depends('raxis') def on_change_with_rbcva_axis(self): return self.raxis - + @fields.depends('laxis') def on_change_with_lbcva_axis(self): - return self.laxis - + return self.laxis + @fields.depends('rspherical') def on_change_with_rbcva_spherical(self): return self.rspherical @@ -279,11 +297,11 @@ @fields.depends('lspherical') def on_change_with_lbcva_spherical(self): return self.lspherical - + @fields.depends('rnv_add') def on_change_with_rbcva_nv_add(self): return self.rnv_add - + @fields.depends('lnv_add') def on_change_with_lbcva_nv_add(self): return self.lnv_add @@ -306,38 +324,26 @@ @staticmethod def default_health_professional(): - pool = Pool() - HealthProf= pool.get('gnuhealth.healthprofessional') - health_professional = HealthProf.get_health_professional() - return health_professional + return get_health_professional() - - # Show the gender and age upon entering the patient + # Show the gender and age upon entering the patient # These two are function fields (don't exist at DB level) @fields.depends('patient') def on_change_patient(self): - gender=None - age='' self.gender = self.patient.gender self.computed_age = self.patient.age - @classmethod @ModelView.button def end_evaluation(cls, evaluations): - - evaluation_id = evaluations[0] + # Change the state of the evaluation to "Done" - # Change the state of the evaluation to "Done" - HealthProf= Pool().get('gnuhealth.healthprofessional') - - signing_hp = HealthProf.get_health_professional() + signing_hp = get_health_professional() cls.write(evaluations, { 'state': 'done', 'signed_by': signing_hp, }) - @classmethod def __setup__(cls): @@ -348,16 +354,16 @@ }) -#this class model contains the detailed assesment of patient by an -#ophthalmologist +class OphthalmologyFindings(ModelSQL, ModelView): + 'Ophthalmology Findings' + __name__ = 'gnuhealth.ophthalmology.findings' + # This class model contains the detailed assesment of patient by an + # ophthalmologist -class OphthalmologyFindings(ModelSQL, ModelView): #model class - 'Ophthalmology Findings' - __name__ = 'gnuhealth.ophthalmology.findings' #model Name - # Findings associated to a particular evaluation - name = fields.Many2One('gnuhealth.ophthalmology.evaluation', + name = fields.Many2One( + 'gnuhealth.ophthalmology.evaluation', 'Evaluation', readonly=True) # Structure @@ -379,14 +385,17 @@ ('other', 'Other'), ] - eye_structure = fields.Selection(structure, - 'Structure',help="Affected eye structure",sort=False) + eye_structure = fields.Selection( + structure, + 'Structure', help="Affected eye structure", sort=False) - affected_eye = fields.Selection([ - (None,''), - ("right","right"), - ("left","left"), - ("both","both"), - ],'Eye',help="Affected eye",sort=False) + affected_eye = fields.Selection( + [ + (None, ''), + ("right", "right"), + ("left", "left"), + ("both", "both"), + ], + 'Eye', help="Affected eye", sort=False) - finding = fields.Char('Finding') + finding = fields.Char('Finding')
