changeset 3618:e497d459b853

HMIS . Fix bug #58358: Need current SES in main patient info
author Luis Falcon <falcon@gnuhealth.org>
date Tue, 12 May 2020 18:02:43 +0100
parents eccd61ce503e
children ea39c2582e55
files tryton/health_socioeconomics/health_socioeconomics.py tryton/health_socioeconomics/view/gnuhealth_patient.xml
diffstat 2 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/tryton/health_socioeconomics/health_socioeconomics.py
+++ b/tryton/health_socioeconomics/health_socioeconomics.py
@@ -64,12 +64,11 @@
 
     assessment_date = fields.DateTime('Date', help="Assessment date",
         states = STATES)
-        
+
     computed_age = fields.Function(fields.Char(
             'Age',
             help="Computed patient age at the moment of the evaluation"),
             'patient_age_at_assessment')
-            
     health_professional = fields.Many2One(
         'gnuhealth.healthprofessional', 'Health Professional', readonly=True,
         help="Health professional"
@@ -229,7 +228,7 @@
         occupation=education=du=housing=None
         if (self.patient and self.patient.name.occupation):
             occupation = self.patient.name.occupation
-        
+
         if (self.patient and self.patient.name.education):
             education = self.patient.name.education
 
@@ -259,7 +258,6 @@
     @classmethod
     @ModelView.button
     def end_assessment(cls, assessments):
-        
         assessment_id = assessments[0]
 
         # Change the state of the assessment to "Done"
@@ -271,7 +269,6 @@
             'state': 'done',
             'signed_by': signing_hp,
             })
-        
 
     def patient_age_at_assessment(self, name):
         if (self.patient.name.dob and self.assessment_date):
@@ -309,7 +306,8 @@
     __name__ = 'gnuhealth.patient'
 
 
-    occupation = fields.Function(fields.Many2One('gnuhealth.occupation','Occupation'), 'get_patient_occupation')
+    occupation = fields.Function(fields.Many2One('gnuhealth.occupation'
+        ,'Occupation'), 'get_patient_occupation')
 
     education = fields.Function(fields.Selection([
         (None, ''),
@@ -319,7 +317,8 @@
         ('3', 'Incomplete Secondary School'),
         ('4', 'Secondary School'),
         ('5', 'University'),
-        ], 'Education Level', help="Education Level", sort=False), 'get_patient_education')
+        ], 'Education Level', help="Education Level", sort=False),
+        'get_patient_education')
 
 
     housing = fields.Function(fields.Selection([
@@ -329,7 +328,18 @@
         ('2', 'Comfortable and good sanitary conditions'),
         ('3', 'Roomy and excellent sanitary conditions'),
         ('4', 'Luxury and excellent sanitary conditions'),
-        ], 'Housing conditions', help="Housing and sanitary living conditions", sort=False), 'get_patient_housing')
+        ], 'Housing conditions', help="Housing and sanitary living conditions",
+        sort=False), 'get_patient_housing')
+
+    ses = fields.Function(fields.Selection([
+        (None, ''),
+        ('0', 'Lower'),
+        ('1', 'Lower-middle'),
+        ('2', 'Middle'),
+        ('3', 'Middle-upper'),
+        ('4', 'Higher'),
+        ], 'SES', help="Current Socioeconomic Status", sort=False),
+        'get_patient_ses')
 
 
     ses_assessments = fields.One2Many('gnuhealth.ses.assessment',
@@ -378,3 +388,7 @@
     def get_patient_housing(self, name):
         if (self.name.du):
             return self.name.du.housing
+
+    def get_patient_ses(self, name):
+        if (self.ses_assessments):
+            return self.ses_assessments[0].ses
--- a/tryton/health_socioeconomics/view/gnuhealth_patient.xml
+++ b/tryton/health_socioeconomics/view/gnuhealth_patient.xml
@@ -2,13 +2,15 @@
 <data>
     <xpath expr="/form/notebook/page[@id=&quot;general_info&quot;]" position="after">
         <page string="Socioeconomics" id="page_socioeconomics">
-            <group string="Current Status" colspan="4" col="6" id="group_ses_holder2">
+            <group string="Current Status" colspan="4" col="8" id="group_ses_holder2">
                 <label name="occupation"/>
                 <field name="occupation"/>
                 <label name="education"/>
                 <field name="education"/>
                 <label name="housing"/>
                 <field name="housing"/>
+                <label name="ses"/>
+                <field name="ses"/>
             </group>
             <newline/>
             <field name="ses_assessments"/>