1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (c) 2007 EVI. All Rights Reserved.
6
# WARNING: This program as such is intended to be used by professional
7
# programmers who take the whole responsability of assessing all potential
8
# consequences resulting from its eventual inadequacies and bugs
9
# End users who are looking for a ready-to-use solution with commercial
10
# garantees and support are strongly adviced to contract a Free Software
13
# This program is Free Software; you can redistribute it and/or
14
# modify it under the terms of the GNU General Public License
15
# as published by the Free Software Foundation; either version 2
16
# of the License, or (at your option) any later version.
18
# This program is distributed in the hope that it will be useful,
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
# GNU General Public License for more details.
23
# You should have received a copy of the GNU General Public License
24
# along with this program; if not, write to the Free Software
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27
##############################################################################
32
from report import report_sxw
34
class presence(report_sxw.rml_parse):
35
def __init__(self, cr, uid, name, context):
36
super(presence, self).__init__(cr, uid, name, context)
37
self.localcontext.update( {
39
'_entree':self._entree,
41
self.context = context
43
def _entree(self,form):
45
patient_obj = self.pool.get('health.patient')
46
patient_ids = patient_obj.search(self.cr,self.uid,[ ('active','in', ['f','t'])])
47
for a in patient_obj.read(self.cr, self.uid, patient_ids, ['name', 'room_id','provenance','date_sortie','motif_sortie','admission_date','girage']):
48
if a['admission_date']:
49
anneeadmission=int(a['admission_date'][0:4])
50
moisadmission=int(a['admission_date'][5:7])
51
jouradmission = int(a['admission_date'][8:10])
54
anneesortie=int(a['date_sortie'][0:4])
55
moissortie=int(a['date_sortie'][5:7])
56
joursortie = int(a['date_sortie'][8:10])
64
anneeperiodedebut=int(form['datedebut'][0:4])
65
moisperiodedebut=int(form['datedebut'][5:7])
66
jourperiodedebut = int(form['datedebut'][8:10])
68
anneeperiodefin=int(form['datefin'][0:4])
69
moisperiodefin=int(form['datefin'][5:7])
70
jourperiodefin = int(form['datefin'][8:10])
72
periodefin=datetime.datetime(anneeperiodefin,moisperiodefin,jourperiodefin)
73
periodedebut=datetime.datetime(anneeperiodefin,moisperiodedebut,jourperiodedebut)
74
admission=datetime.datetime(anneeadmission,moisadmission,jouradmission)
75
datesortie=datetime.datetime(anneesortie,moissortie,joursortie)
77
destination=a['motif_sortie'][1]
81
chambre=a['room_id'][1]
83
chambre = "Non defini"
84
if not sortie or ((datesortie <= periodefin) and (datesortie >=periodedebut)):
85
res.append({'name':a['name'],'chambre':chambre,'entree':a['admission_date'],'provenance':a['provenance'],'sortie':a['date_sortie'],'destination':destination,'gir':a['girage']})
86
res.sort(lambda x, y: cmp(x['name'],y['name']))
89
def _absences(self,form):
91
absences_obj = self.pool.get('health.absences')
92
abs_ids = absences_obj.search(self.cr,self.uid,[('du','>=',form['datedebut']),('du','<=',form['datefin'])])+absences_obj.search(self.cr,self.uid,[('au','>=',form['datedebut']),('au','<=',form['datefin'])])
93
absences = absences_obj.read(self.cr,self.uid,abs_ids)
94
patient_obj = self.pool.get('health.patient')
96
for a in patient_obj.read(self.cr, self.uid, [ab['partner_id'][0]]):
97
if ab['categorie'] == '1' :
98
motif= 'Hospitalisation'
99
if ab['categorie'] == '2' :
100
motif= 'Convenance Personelle'
101
if ab['categorie'] == '3' :
104
chambre=a['room_id'][1]
106
chambre = "Non defini"
108
res.append({'name':a['name'],'chambre':chambre,'entree':ab['du'],'sortie':ab['au'],'motif_sortie':motif,'gir':a['girage']})
109
res.sort(lambda x, y: cmp(x['name'],y['name']))
112
def age(self,annee,annee2):
113
return int(annee[0:4])-int(annee2[0:4])
117
report_sxw.report_sxw('report.health.presence.report', 'health.patient','addons/health/report/presence.rml', parser=presence, header=False)