Mercurial > hgweb > health
changeset 1978:f49b62f22358
bug #45307: Add searcher to patient_status field
| author | Chris Zimmerman <siv@riseup.net> |
|---|---|
| date | Thu, 11 Jun 2015 21:12:36 -0700 |
| parents | 9e886b48a6b0 |
| children | 2d4c69f341cd |
| files | tryton/health_inpatient/health_inpatient.py |
| diffstat | 1 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health_inpatient/health_inpatient.py +++ b/tryton/health_inpatient/health_inpatient.py @@ -345,7 +345,7 @@ patient_status = fields.Function(fields.Boolean('Hospitalized', help="Show the hospitalization status of the patient"), - 'get_patient_status') + 'get_patient_status', searcher='search_patient_status') def get_patient_status(self, name): @@ -374,6 +374,22 @@ result = get_hospitalization_status(patient_dbid) return result + @classmethod + def search_patient_status(cls, name, clause): + p = Pool().get('gnuhealth.inpatient.registration') + table = p.__table__() + pat = cls.__table__() + _, _, value = clause + + # Find hospitalized patient ids + j = pat.join(table, condition = pat.id == table.patient) + s = j.select(pat.id, where = table.state == 'hospitalized') + + # It's a boolean field + if value is True: + return [('id', 'in', s)] + else: + return [('id', 'not in', s)] class InpatientMedication (ModelSQL, ModelView): 'Inpatient Medication'
