changeset 4960:ce8df108f14b

Include header argument on reports get_context methods
author Luis Falcon <falcon@gnuhealth.org>
date Wed, 19 Jan 2022 19:39:43 +0000
parents 4fd5269daf35
children 759f4f181ab5
files tryton/health/report/immunization_status_report.py tryton/health_dentistry/report/odontogram_report.py tryton/health_dentistry/report/procedures_report.py tryton/health_pediatrics_growth_charts_who/report/report_health_pediatrics_growth_charts_who.py tryton/health_reporting/report/epidemics_report.py tryton/health_reporting/report/summary_report.py
diffstat 6 files changed, 48 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/tryton/health/report/immunization_status_report.py
+++ b/tryton/health/report/immunization_status_report.py
@@ -19,82 +19,76 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
-from datetime import date
 from trytond.report import Report
 from trytond.pool import Pool
-from trytond.transaction import Transaction
-from dateutil.relativedelta import relativedelta
 
 __all__ = ['ImmunizationStatusReport']
 
+
 class ImmunizationStatusReport(Report):
     __name__ = 'gnuhealth.immunization_status_report'
 
-
     @classmethod
-    def get_context(cls, records, data):
+    def get_context(cls, records, header, data):
         Sched = Pool().get('gnuhealth.immunization_schedule')
         Patient = Pool().get('gnuhealth.patient')
         patient = Patient(data['patient_id'])
-        
-        context = super(ImmunizationStatusReport, cls).get_context(records,
-            data)
-            
+
+        context = super(ImmunizationStatusReport, cls).get_context(
+            records, header, data)
+
         context['patient'] = patient
         sched = Sched(data['immunization_schedule_id'])
-        
+
         context['immunization_schedule'] = sched
 
         immunizations_to_check = \
             cls.get_immunizations_for_age(patient, sched)
-        
+
         immunization_status = \
             cls.verify_status(immunizations_to_check)
-        
+
         context['immunization_status'] = immunization_status
-        
-        return context 
+
+        return context
 
     @classmethod
-    def get_immunizations_for_age(cls,patient,immunization_schedule):
-        
+    def get_immunizations_for_age(cls, patient, immunization_schedule):
+
         immunizations_for_age = []
-        
+
         for vaccine in immunization_schedule.vaccines:
-            
+
             for dose in vaccine.doses:
                 dose_number, dose_age, age_unit = dose.dose_number, \
                     dose.age_dose, dose.age_unit
-                
-                #TODO : For 3.2, use the generic raw_age argument
-                # from compute_age_from_dates
 
-                p_age = [patient.age.split(' ')[0][:-1], 
-                    patient.age.split(' ')[1][:-1], 
-                    patient.age.split(' ')[2][:-1]]                
+                p_age = [patient.age.split(' ')[0][:-1],
+                         patient.age.split(' ')[1][:-1],
+                         patient.age.split(' ')[2][:-1]]
 
-                #Age of the person in years and months
-                pyears,pmonths = int(p_age[0]),int(p_age[1])
+                # Age of the person in years and months
+                pyears, pmonths = int(p_age[0]), int(p_age[1])
 
                 pmonths = (pyears*12)+pmonths
-                
+
                 if ((age_unit == 'months' and pmonths >= dose_age) or
-                    (age_unit == 'years' and pyears >= dose_age)):
-                        immunization_info = {
-                            'patient' : patient,
-                            'vaccine' : vaccine,
-                            'dose' : dose_number,
-                            'dose_age' : dose_age,
-                            'age_unit' : age_unit,
-                            'status' : None}
-                        
-                        # Add to the list of this person immunization check
-                        immunizations_for_age.append(immunization_info)
+                        (age_unit == 'years' and pyears >= dose_age)):
+                    immunization_info = {
+                        'patient': patient,
+                        'vaccine': vaccine,
+                        'dose': dose_number,
+                        'dose_age': dose_age,
+                        'age_unit': age_unit,
+                        'status': None}
+
+                    # Add to the list of this person immunization check
+                    immunizations_for_age.append(immunization_info)
 
         return immunizations_for_age
 
     @classmethod
-    def verify_status(cls,immunizations_to_check):
+    def verify_status(cls, immunizations_to_check):
         Vaccination = Pool().get('gnuhealth.vaccination')
 
         result = []
@@ -105,12 +99,10 @@
                 ('dose', '=', immunization['dose']),
                 ('vaccine.name', '=', immunization['vaccine'].vaccine.name),
                 ])
-           
+
             if res:
                 immunization['status'] = 'ok'
-            
+
             result.append(immunization)
-        
+
         return result
-        
-
--- a/tryton/health_dentistry/report/odontogram_report.py
+++ b/tryton/health_dentistry/report/odontogram_report.py
@@ -143,9 +143,9 @@
         return (image_png)
 
     @classmethod
-    def get_context(cls, records, data):
+    def get_context(cls, records, header, data):
         context = super(Odontogram, cls).get_context(
-            records, data)
+            records, header, data)
 
         dental_schema = \
             Pool().get('gnuhealth.patient')(data['id']).dental_schema
--- a/tryton/health_dentistry/report/procedures_report.py
+++ b/tryton/health_dentistry/report/procedures_report.py
@@ -44,11 +44,11 @@
         return result
 
     @classmethod
-    def get_context(cls, records, data):
+    def get_context(cls, records, header, data):
         pool = Pool()
         Date = pool.get('ir.date')
         context = super(DentistryProcedureReport, cls).get_context(
-            records, data)
+            records, header, data)
         context['today'] = Date.today()
         context['digest_treatments'] = cls.digest_treatments
 
--- a/tryton/health_pediatrics_growth_charts_who/report/report_health_pediatrics_growth_charts_who.py
+++ b/tryton/health_pediatrics_growth_charts_who/report/report_health_pediatrics_growth_charts_who.py
@@ -51,14 +51,15 @@
     __name__ = 'gnuhealth.pediatrics.growth.charts.who.report'
 
     @classmethod
-    def get_context(cls, records, data):
+    def get_context(cls, records, header, data):
         pool = Pool()
         GrowthChartsWHO = pool.get('gnuhealth.pediatrics.growth.charts.who')
         Patient = pool.get('gnuhealth.patient')
         Evaluation = pool.get('gnuhealth.patient.evaluation')
 
         context = super(
-            PediatricsGrowthChartsWHOReport, cls).get_context(records, data)
+            PediatricsGrowthChartsWHOReport, cls).get_context(
+                records, header, data)
 
         patient = Patient(data['patient'])
 
--- a/tryton/health_reporting/report/epidemics_report.py
+++ b/tryton/health_reporting/report/epidemics_report.py
@@ -336,7 +336,7 @@
         return (image_png)
 
     @classmethod
-    def get_context(cls, records, data):
+    def get_context(cls, records, header, data):
 
         Condition = Pool().get('gnuhealth.pathology')
 
@@ -353,8 +353,8 @@
         for ses_group in ses_groups:
             ses_count[ses_group] = 0
 
-        context = super(InstitutionEpidemicsReport, cls).get_context(records,
-                                                                     data)
+        context = super(InstitutionEpidemicsReport, cls).get_context(
+            records, header, data)
 
         start_date = data['start_date']
         context['start_date'] = data['start_date']
--- a/tryton/health_reporting/report/summary_report.py
+++ b/tryton/health_reporting/report/summary_report.py
@@ -157,9 +157,9 @@
         return(res)
 
     @classmethod
-    def get_context(cls, records, data):
+    def get_context(cls, records, header, data):
         context = super(
-            InstitutionSummaryReport, cls).get_context(records, data)
+            InstitutionSummaryReport, cls).get_context(records, header, data)
 
         start_date = data['start_date']
         end_date = data['end_date']