changeset 472:05f495481488

health_gyneco : PEP8
author Sebastian Marro <smarro@thymbra.com>
date Mon, 24 Dec 2012 17:09:30 -0300
parents e23bd923393c
children 6663a4b94191
files tryton/health_gyneco/health_gyneco.py
diffstat 1 files changed, 116 insertions(+), 142 deletions(-) [+]
line wrap: on
line diff
--- a/tryton/health_gyneco/health_gyneco.py
+++ b/tryton/health_gyneco/health_gyneco.py
@@ -36,23 +36,23 @@
     __name__ = 'gnuhealth.patient.pregnancy'
 
     name = fields.Many2One('gnuhealth.patient', 'Patient ID')
-    gravida = fields.Integer ('Pregnancy #', required=True)
-    warning = fields.Boolean ('Warn', help="Check this box if this is pregancy is or was NOT normal")
-    lmp = fields.Date ('LMP', help="Last Menstrual Period", required=True)
-    pdd = fields.Function (fields.Date('Pregnancy Due Date'), 'get_pregnancy_data')
-
-    prenatal_evaluations = fields.One2Many('gnuhealth.patient.prenatal.evaluation', 'name', 'Prenatal Evaluations')
-
-    perinatal = fields.One2Many('gnuhealth.perinatal', 'name', 'Perinatal Info')
-
-    puerperium_monitor = fields.One2Many('gnuhealth.puerperium.monitor', 'name', 'Puerperium monitor')
-
-    current_pregnancy = fields.Boolean('Current Pregnancy', help="This field marks the current pregnancy")
-
-
-    fetuses = fields.Integer ('Fetuses', required=True)
+    gravida = fields.Integer('Pregnancy #', required=True)
+    warning = fields.Boolean('Warn', help='Check this box if this is pregancy'
+        ' is or was NOT normal')
+    lmp = fields.Date('LMP', help="Last Menstrual Period", required=True)
+    pdd = fields.Function(fields.Date('Pregnancy Due Date'),
+        'get_pregnancy_data')
+    prenatal_evaluations = fields.One2Many(
+        'gnuhealth.patient.prenatal.evaluation', 'name',
+        'Prenatal Evaluations')
+    perinatal = fields.One2Many('gnuhealth.perinatal', 'name',
+        'Perinatal Info')
+    puerperium_monitor = fields.One2Many('gnuhealth.puerperium.monitor',
+        'name', 'Puerperium monitor')
+    current_pregnancy = fields.Boolean('Current Pregnancy', help='This field'
+        ' marks the current pregnancy')
+    fetuses = fields.Integer('Fetuses', required=True)
     monozygotic = fields.Boolean('Monozygotic')
-
     pregnancy_end_result = fields.Selection([
         ('live_birth', 'Live birth'),
         ('abortion', 'Abortion'),
@@ -63,18 +63,13 @@
             'invisible': Bool(Eval('current_pregnancy')),
             'required': Not(Bool(Eval('current_pregnancy'))),
             })
-
-
-
-    pregnancy_end_date = fields.DateTime ('End of Pregnancy',
+    pregnancy_end_date = fields.DateTime('End of Pregnancy',
         states={
             'invisible': Bool(Eval('current_pregnancy')),
             'required': Not(Bool(Eval('current_pregnancy'))),
             })
-
-    pregnancy_end_age = fields.Function(fields.Char('Weeks',help="Weeks at the end of pregnancy"),
-        'get_pregnancy_data')
-
+    pregnancy_end_age = fields.Function(fields.Char('Weeks', help='Weeks at'
+        ' the end of pregnancy'), 'get_pregnancy_data')
     iugr = fields.Selection([
         ('symmetric', 'Symmetric'),
         ('assymetric', 'Assymetric'),
@@ -86,20 +81,20 @@
         cls._constraints += [
             ('check_patient_current_pregnancy', 'patient_already_pregnant'),
         ]
-
         cls._sql_constraints = [
-            ('gravida_uniq', 'UNIQUE(name,gravida)', 'The pregancy number must be unique for this patient !'),
+            ('gravida_uniq', 'UNIQUE(name,gravida)', 'The pregancy number must'
+                ' be unique for this patient !'),
         ]
-
         cls._error_messages.update({
-            'patient_already_pregnant': 'Our records indicate that the patient is already pregnant !'})
+            'patient_already_pregnant': 'Our records indicate that the patient'
+                ' is already pregnant !'})
 
     def check_patient_current_pregnancy(self):
         ''' Check for only one current pregnancy in the patient '''
         cursor = Transaction().cursor
-        cursor.execute("SELECT count(name) " \
+        cursor.execute("SELECT count(name) "
             "FROM " + self._table + "  \
-            WHERE (name = %s AND current_pregnancy)", \
+            WHERE (name = %s AND current_pregnancy)",
             (str(self.name.id),))
         if cursor.fetchone()[0] > 1:
             return False
@@ -114,96 +109,95 @@
             return self.lmp + datetime.timedelta(days=280)
         if name == 'pregnancy_end_age':
             if self.pregnancy_end_date:
-                gestational_age = datetime.datetime.date(self.pregnancy_end_date) - self.lmp
-                return (gestational_age.days)/7
+                gestational_age = datetime.datetime.date(
+                    self.pregnancy_end_date) - self.lmp
+                return (gestational_age.days) / 7
             else:
                 return 0
 
+
 class PrenatalEvaluation(ModelSQL, ModelView):
     'Prenatal and Antenatal Evaluations'
     __name__ = 'gnuhealth.patient.prenatal.evaluation'
 
     name = fields.Many2One('gnuhealth.patient.pregnancy', 'Patient Pregnancy')
-    evaluation = fields.Many2One('gnuhealth.patient.evaluation', 'Patient Evaluation', readonly=True)
-
+    evaluation = fields.Many2One('gnuhealth.patient.evaluation',
+        'Patient Evaluation', readonly=True)
     evaluation_date = fields.DateTime('Date', required=True)
     gestational_weeks = fields.Function(fields.Integer('Gestational Weeks'),
         'get_patient_evaluation_data')
-
     gestational_days = fields.Function(fields.Integer('Gestational days'),
         'get_patient_evaluation_data')
-
-
-    hypertension = fields.Boolean('Hypertension', help="Check this box if the mother has hypertension")
-    preeclampsia = fields.Boolean('Preeclampsia', help="Check this box if the mother has pre-eclampsia")
-    overweight = fields.Boolean('Overweight', help="Check this box if the mother is overweight or obesity")
-    diabetes = fields.Boolean('Diabetes', help="Check this box if the mother has glucose intolerance or diabetes")
-
+    hypertension = fields.Boolean('Hypertension', help='Check this box if the'
+        ' mother has hypertension')
+    preeclampsia = fields.Boolean('Preeclampsia', help='Check this box if the'
+        ' mother has pre-eclampsia')
+    overweight = fields.Boolean('Overweight', help='Check this box if the'
+        ' mother is overweight or obesity')
+    diabetes = fields.Boolean('Diabetes', help='Check this box if the mother'
+        ' has glucose intolerance or diabetes')
     invasive_placentation = fields.Selection([
         ('normal', 'Normal decidua'),
         ('accreta', 'Accreta'),
         ('increta', 'Increta'),
         ('percreta', 'Percreta'),
         ], 'Placentation', sort=False)
-
     placenta_previa = fields.Boolean('Placenta Previa')
     vasa_previa = fields.Boolean('Vasa Previa')
-
     fundal_height = fields.Integer('Fundal Height',
-        help="Distance between the symphysis pubis and the uterine fundus " \
+        help="Distance between the symphysis pubis and the uterine fundus "
         "(S-FD) in cm")
-
-    fetus_heart_rate = fields.Integer('Fetus heart rate', help="Fetus heart rate")
-    efw= fields.Integer('EFW', help="Estimated Fetal Weight")
-    fetal_bpd= fields.Integer('BPD', help="Fetal Biparietal Diameter")
-    fetal_ac= fields.Integer('AC', help="Fetal Abdominal Circumference")
-    fetal_hc= fields.Integer('HC', help="Fetal Head Circumference")
-    fetal_fl= fields.Integer('FL', help="Fetal Femur Length")
-
+    fetus_heart_rate = fields.Integer('Fetus heart rate', help='Fetus heart'
+        ' rate')
+    efw = fields.Integer('EFW', help="Estimated Fetal Weight")
+    fetal_bpd = fields.Integer('BPD', help="Fetal Biparietal Diameter")
+    fetal_ac = fields.Integer('AC', help="Fetal Abdominal Circumference")
+    fetal_hc = fields.Integer('HC', help="Fetal Head Circumference")
+    fetal_fl = fields.Integer('FL', help="Fetal Femur Length")
     oligohydramnios = fields.Boolean('Oligohydramnios')
-    polihydramnios= fields.Boolean('Polihydramnios')
-    iugr= fields.Boolean('IUGR',help="Intra Uterine Growth Restriction")
+    polihydramnios = fields.Boolean('Polihydramnios')
+    iugr = fields.Boolean('IUGR', help="Intra Uterine Growth Restriction")
 
     def get_patient_evaluation_data(self, name):
         if name == 'gestational_weeks':
-            gestational_age = datetime.datetime.date(self.evaluation_date) - self.name.lmp
-            return (gestational_age.days)/7
+            gestational_age = datetime.datetime.date(self.evaluation_date) - \
+                self.name.lmp
+            return (gestational_age.days) / 7
         if name == 'gestational_days':
-            gestational_age = datetime.datetime.date(self.evaluation_date) - self.name.lmp
+            gestational_age = datetime.datetime.date(self.evaluation_date) - \
+                self.name.lmp
             return gestational_age.days
 
+
 class PuerperiumMonitor(ModelSQL, ModelView):
     'Puerperium Monitor'
     __name__ = 'gnuhealth.puerperium.monitor'
 
     name = fields.Many2One('gnuhealth.patient.pregnancy', 'Patient Pregnancy')
     date = fields.DateTime('Date and Time', required=True)
-# Deprecated in 1.6.4 All the clinical information will be taken at the main evaluation.
-# systolic / diastolic / frequency / temperature
+    # Deprecated in 1.6.4 All the clinical information will be taken at the
+    # main evaluation.
+    # systolic / diastolic / frequency / temperature
     systolic = fields.Integer('Systolic Pressure')
     diastolic = fields.Integer('Diastolic Pressure')
     frequency = fields.Integer('Heart Frequency')
     temperature = fields.Float('Temperature')
-
     lochia_amount = fields.Selection([
         ('n', 'normal'),
         ('e', 'abundant'),
         ('h', 'hemorrhage'),
         ], 'Lochia amount', sort=False)
-
     lochia_color = fields.Selection([
         ('r', 'rubra'),
         ('s', 'serosa'),
         ('a', 'alba'),
         ], 'Lochia color', sort=False)
-
     lochia_odor = fields.Selection([
         ('n', 'normal'),
         ('o', 'offensive'),
         ], 'Lochia odor', sort=False)
-
     uterus_involution = fields.Integer('Fundal Height',
-        help="Distance between the symphysis pubis and the uterine fundus " \
+        help="Distance between the symphysis pubis and the uterine fundus "
         "(S-FD) in cm")
 
 
@@ -213,34 +207,27 @@
 
     name = fields.Many2One('gnuhealth.patient.pregnancy', 'Patient Pregnancy')
     admission_code = fields.Char('Code')
-
-# 1.6.4 Gravida number and abortion information go now in the pregnancy header
-# It will be calculated as a function if needed
+    # 1.6.4 Gravida number and abortion information go now in the pregnancy
+    # header. It will be calculated as a function if needed
     gravida_number = fields.Integer('Gravida #')
-
-# Deprecated. Use End of Pregnancy as a general concept in the pregnancy model
-# Abortion / Stillbirth / Live Birth
+    # Deprecated. Use End of Pregnancy as a general concept in the pregnancy
+    # model
+    # Abortion / Stillbirth / Live Birth
     abortion = fields.Boolean('Abortion')
-
     stillbirth = fields.Boolean('Stillbirth')
-
     admission_date = fields.DateTime('Admission',
         help="Date when she was admitted to give birth", required=True)
-
-# Prenatal evaluations deprecated in 1.6.4. Will be computed automatically
-    prenatal_evaluations = fields.Integer('Prenatal evaluations', \
+    # Prenatal evaluations deprecated in 1.6.4. Will be computed automatically
+    prenatal_evaluations = fields.Integer('Prenatal evaluations',
         help="Number of visits to the doctor during pregnancy")
-
     start_labor_mode = fields.Selection([
         ('v', 'Vaginal - Spontaneous'),
         ('ve', 'Vaginal - Vacuum Extraction'),
         ('vf', 'Vaginal - Forceps Extraction'),
         ('c', 'C-section'),
         ], 'Delivery mode', sort=False)
-
     gestational_weeks = fields.Function(fields.Integer('Gestational wks'),
         'get_perinatal_information')
-
     gestational_days = fields.Integer('Days')
     fetus_presentation = fields.Selection([
         ('cephalic', 'Cephalic'),
@@ -248,19 +235,18 @@
         ('shoulder', 'Shoulder'),
         ], 'Fetus Presentation', sort=False)
     dystocia = fields.Boolean('Dystocia')
-    placenta_incomplete = fields.Boolean('Incomplete', help='Incomplete Placenta')
+    placenta_incomplete = fields.Boolean('Incomplete',
+        help='Incomplete Placenta')
     placenta_retained = fields.Boolean('Retained', help='Retained Placenta')
-    abruptio_placentae = fields.Boolean('Abruptio Placentae',help='Abruptio Placentae')
+    abruptio_placentae = fields.Boolean('Abruptio Placentae',
+        help='Abruptio Placentae')
     episiotomy = fields.Boolean('Episiotomy')
-
-#Vaginal tearing and forceps variables are deprecated in 1.6.4.
-#They are included in laceration and delivery mode respectively
-
+    #Vaginal tearing and forceps variables are deprecated in 1.6.4.
+    #They are included in laceration and delivery mode respectively
     vaginal_tearing = fields.Boolean('Vaginal tearing')
     forceps = fields.Boolean('Forceps')
     monitoring = fields.One2Many('gnuhealth.perinatal.monitor', 'name',
         'Monitors')
-
     laceration = fields.Selection([
         ('perineal', 'Perineal'),
         ('vaginal', 'Vaginal'),
@@ -271,29 +257,22 @@
         ('bladder', 'Bladder'),
         ('urethral', 'Urethral'),
         ], 'Lacerations', sort=False)
-
     hematoma = fields.Selection([
         ('vaginal', 'Vaginal'),
         ('vulvar', 'Vulvar'),
         ('retroperitoneal', 'Retroperitoneal'),
         ], 'Hematoma', sort=False)
-
-
-# Deprecated in 1.6.4. Puerperium is now a separate entity from perinatal
-# and is included in the obstetric evaluation history
-
-#    puerperium_monitor = fields.One2Many('gnuhealth.puerperium.monitor', 'name',
-#        'Puerperium monitor')
-
-
-# Deprecated in 1.6.4. The medication and procedures will be done in the nursing and surgery modules
+    # Deprecated in 1.6.4. Puerperium is now a separate entity from perinatal
+    # and is included in the obstetric evaluation history
+    # puerperium_monitor = fields.One2Many('gnuhealth.puerperium.monitor',
+    #     'name', 'Puerperium monitor')
+    # Deprecated in 1.6.4. The medication and procedures will be done in the
+    # nursing and surgery modules
     medication = fields.One2Many('gnuhealth.patient.medication', 'name',
         'Medication and anesthesics')
     dismissed = fields.DateTime('Discharged')
-
-
-# Deprecated in 1.6.4 . Use the death information in the patient model
-# Date and cause of death
+    # Deprecated in 1.6.4 . Use the death information in the patient model
+    # Date and cause of death
     place_of_death = fields.Selection([
         ('ho', 'Hospital'),
         ('dr', 'At the delivery room'),
@@ -301,23 +280,24 @@
         ('th', 'Being transferred to other hospital'),
         ], 'Place of Death', help="Place where the mother died",
         states={'invisible': Not(Bool(Eval('mother_deceased')))},
-        depends=['mother_deceased'],sort=False)
-
+        depends=['mother_deceased'], sort=False)
     mother_deceased = fields.Boolean('Maternal death',
         help="Mother died in the process")
-
     notes = fields.Text('Notes')
 
     def get_perinatal_information(self, name):
         if name == 'gestational_weeks':
-            gestational_age = datetime.datetime.date(self.admission_date) - self.name.lmp
-            return (gestational_age.days)/7
+            gestational_age = datetime.datetime.date(self.admission_date) - \
+                self.name.lmp
+            return (gestational_age.days) / 7
+
 
 class PerinatalMonitor(ModelSQL, ModelView):
     'Perinatal Monitor'
     __name__ = 'gnuhealth.perinatal.monitor'
 
-    name = fields.Many2One('gnuhealth.perinatal', 'Patient Perinatal Evaluation')
+    name = fields.Many2One('gnuhealth.perinatal',
+        'Patient Perinatal Evaluation')
     date = fields.DateTime('Date and Time')
     systolic = fields.Integer('Systolic Pressure')
     diastolic = fields.Integer('Diastolic Pressure')
@@ -342,7 +322,8 @@
     'gynecological and obstetric fields.'
     __name__ = 'gnuhealth.patient'
 
-    currently_pregnant = fields.Function(fields.Boolean('Pregnant'),'get_pregnancy_info')
+    currently_pregnant = fields.Function(fields.Boolean('Pregnant'),
+        'get_pregnancy_info')
     fertile = fields.Boolean('Fertile',
         help="Check if patient is in fertile age")
     menarche = fields.Integer('Menarche age')
@@ -362,44 +343,38 @@
         help="Check if the patient has done a colposcopy exam")
     colposcopy_last = fields.Date('Last colposcopy',
         help="Enter the date of the last colposcopy")
-
     gravida = fields.Integer('Pregnancies', help="Number of pregnancies")
     premature = fields.Integer('Premature', help="Premature Deliveries")
     abortions = fields.Integer('Abortions')
     stillbirths = fields.Integer('Stillbirths')
     full_term = fields.Integer('Full Term', help="Full term pregnancies")
-
-# GPA Deprecated in 1.6.4. It will be used as a function or report from the other fields
-#    gpa = fields.Char('GPA',
-#        help="Gravida, Para, Abortus Notation. For example G4P3A1 : 4 " \
-#        "Pregnancies, 3 viable and 1 abortion")
-
-# Deprecated. The born alive number will be calculated from pregnancies - abortions - stillbirths
-#    born_alive = fields.Integer('Born Alive')
-# Deceased in 1st week or after 2nd weeks are deprecated since 1.6.4 . The information will
-# be retrieved from the neonatal or infant record
-
-#    deaths_1st_week = fields.Integer('Deceased during 1st week',
-#        help="Number of babies that die in the first week")
-#    deaths_2nd_week = fields.Integer('Deceased after 2nd week',
-#        help="Number of babies that die after the second week")
-
-# Perinatal Deprecated since 1.6.4 - Included in the obstetric history
-#    perinatal = fields.One2Many('gnuhealth.perinatal', 'name', 'Perinatal Info')
-
+    # GPA Deprecated in 1.6.4. It will be used as a function or report from the
+    # other fields
+    #    gpa = fields.Char('GPA',
+    #        help="Gravida, Para, Abortus Notation. For example G4P3A1 : 4 " \
+    #        "Pregnancies, 3 viable and 1 abortion")
+    # Deprecated. The born alive number will be calculated from pregnancies -
+    # abortions - stillbirths
+    #    born_alive = fields.Integer('Born Alive')
+    # Deceased in 1st week or after 2nd weeks are deprecated since 1.6.4 .
+    # The information will be retrieved from the neonatal or infant record
+    #    deaths_1st_week = fields.Integer('Deceased during 1st week',
+    #        help="Number of babies that die in the first week")
+    #    deaths_2nd_week = fields.Integer('Deceased after 2nd week',
+    #        help="Number of babies that die after the second week")
+    # Perinatal Deprecated since 1.6.4 - Included in the obstetric history
+    #    perinatal = fields.One2Many('gnuhealth.perinatal', 'name',
+    #        'Perinatal Info')
     menstrual_history = fields.One2Many('gnuhealth.patient.menstrual_history',
         'name', 'Menstrual History')
-
-    mammography_history = fields.One2Many( \
+    mammography_history = fields.One2Many(
         'gnuhealth.patient.mammography_history', 'name', 'Mammography History')
-
     pap_history = fields.One2Many('gnuhealth.patient.pap_history', 'name',
         'PAP smear History')
-
-    colposcopy_history = fields.One2Many('gnuhealth.patient.colposcopy_history',
-        'name', 'Colposcopy History')
-
-    pregnancy_history = fields.One2Many('gnuhealth.patient.pregnancy', 'name', 'Pregnancies')
+    colposcopy_history = fields.One2Many(
+        'gnuhealth.patient.colposcopy_history', 'name', 'Colposcopy History')
+    pregnancy_history = fields.One2Many('gnuhealth.patient.pregnancy', 'name',
+        'Pregnancies')
 
     def get_pregnancy_info(self, name):
         if name == 'currently_pregnant':
@@ -408,6 +383,7 @@
                     return True
         return False
 
+
 class PatientMenstrualHistory(ModelSQL, ModelView):
     'Menstrual History'
     __name__ = 'gnuhealth.patient.menstrual_history'
@@ -416,7 +392,8 @@
         required=True)
     evaluation = fields.Many2One('gnuhealth.patient.evaluation', 'Evaluation',
         domain=[('patient', '=', Eval('name'))])
-    evaluation_date = fields.Date('Date', help="Evaluation Date", required=True)
+    evaluation_date = fields.Date('Date', help="Evaluation Date",
+        required=True)
     lmp = fields.Date('LMP', help="Last Menstrual Period", required=True)
     lmp_length = fields.Integer('Length', required=True)
     is_regular = fields.Boolean('Regular')
@@ -427,7 +404,6 @@
         ('eumenorrhea', 'eumenorrhea'),
         ('polymenorrhea', 'polymenorrhea'),
         ], 'frequency', sort=False)
-
     volume = fields.Selection([
         ('hypomenorrhea', 'hypomenorrhea'),
         ('normal', 'normal'),
@@ -463,7 +439,6 @@
         ('abnormal', 'abnormal'),
         ], 'result', help="Please check the lab test results if the module is \
             installed", sort=False)
-
     comments = fields.Char('Remarks')
 
     @staticmethod
@@ -495,7 +470,6 @@
         ('g4', 'AIS'),
         ], 'result', help="Please check the lab results if the module is \
             installed", sort=False)
-
     comments = fields.Char('Remarks')
 
     @staticmethod
@@ -516,13 +490,13 @@
     evaluation = fields.Many2One('gnuhealth.patient.evaluation', 'Evaluation',
         domain=[('patient', '=', Eval('name'))])
     evaluation_date = fields.Date('Date', help=" Date")
-    last_colposcopy = fields.Date('Date', help="Last colposcopy", required=True)
+    last_colposcopy = fields.Date('Date', help="Last colposcopy",
+        required=True)
     result = fields.Selection([
         ('normal', 'normal'),
         ('abnormal', 'abnormal'),
         ], 'result', help="Please check the lab test results if the module is \
             installed", sort=False)
-
     comments = fields.Char('Remarks')
 
     @staticmethod