report medical summary : filtery by branch & department
parent
157f76bf05
commit
deb6672b9d
|
@ -1,6 +1,8 @@
|
|||
<form model="clinic.report.medical.summary">
|
||||
<field name="date" span="3" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="3"/>
|
||||
<field name="date_to" span="3"/>
|
||||
<field name="prod_categ_id" span="3"/>
|
||||
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="prod_categ_id" span="2"/>
|
||||
<field name="branch_id" span="2"/>
|
||||
<field name="department_id" span="2"/>
|
||||
</form>
|
||||
|
|
|
@ -2,7 +2,7 @@ import time
|
|||
from calendar import monthrange
|
||||
|
||||
from netforce.model import Model,fields,get_model
|
||||
from netforce.access import get_active_company
|
||||
from netforce.access import get_active_company, get_active_user
|
||||
from . import utils
|
||||
|
||||
class ReportMedicalSummary(Model):
|
||||
|
@ -15,6 +15,8 @@ class ReportMedicalSummary(Model):
|
|||
"date_from": fields.Date("From", required=True),
|
||||
"date_to": fields.Date("To", required=True),
|
||||
"prod_categ_id": fields.Many2One("product.categ","Category"),
|
||||
"branch_id": fields.Many2One("clinic.branch","Branch"),
|
||||
"department_id": fields.Many2One("clinic.department","Department"),
|
||||
}
|
||||
|
||||
def _get_date_from(self,context={}):
|
||||
|
@ -33,11 +35,25 @@ class ReportMedicalSummary(Model):
|
|||
categ_id=ids[0]
|
||||
return categ_id
|
||||
|
||||
def _get_branch(self,context={}):
|
||||
user_id=get_active_user()
|
||||
staff=get_model("clinic.staff").search_browse([['user_id','=',user_id]])
|
||||
if staff:
|
||||
return staff[0].branch_id.id
|
||||
|
||||
def _get_department(self,context={}):
|
||||
user_id=get_active_user()
|
||||
staff=get_model("clinic.staff").search_browse([['user_id','=',user_id]])
|
||||
if staff:
|
||||
return staff[0].department_id.id
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'date_from': _get_date_from,
|
||||
'date_to': _get_date_to,
|
||||
'prod_categ_id': _get_prod_categ,
|
||||
'branch_id':_get_branch,
|
||||
'department_id': _get_department,
|
||||
}
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
|
@ -54,12 +70,21 @@ class ReportMedicalSummary(Model):
|
|||
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
|
||||
|
||||
prod_categ_id=None
|
||||
prod_ids=get_model("product.categ").search([['code','=','EPO']])
|
||||
if prod_ids:
|
||||
prod_categ_id=prod_ids[0]
|
||||
branch_id=None
|
||||
department_id=None
|
||||
res=get_model("clinic.report.medical.summary").default_get()
|
||||
if res:
|
||||
if res.get("prod_categ_id"):
|
||||
prod_categ_id=res.get("prod_categ_id")[0]
|
||||
if res.get("branch_id"):
|
||||
branch_id=res.get("branch_id")[0]
|
||||
if res.get("department_id"):
|
||||
department_id=res.get("department_id")[0]
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
prod_categ_id=obj.prod_categ_id.id
|
||||
branch_id=obj.branch_id.id
|
||||
department_id=obj.department_id.id
|
||||
month=obj.date_from.split("-")[1]
|
||||
time_start=obj.date_from
|
||||
time_stop=obj.date_to
|
||||
|
@ -86,6 +111,10 @@ class ReportMedicalSummary(Model):
|
|||
dom=[]
|
||||
dom.append(['time_start','>=','%s 00:00:00'%time_start])
|
||||
dom.append(['time_stop','<=','%s 23:59:59'%time_stop])
|
||||
if branch_id:
|
||||
dom.append(['branch_id','=',branch_id])
|
||||
if department_id:
|
||||
dom.append(['department_id','=',department_id])
|
||||
for hd_case in get_model('clinic.hd.case').search_browse(dom):
|
||||
patient_type_id=hd_case.patient_id.type_id.id
|
||||
for line in hd_case.lines:
|
||||
|
|
Loading…
Reference in New Issue