2014-11-17 00:59:19 +00:00
|
|
|
import time
|
|
|
|
import urllib.parse as urllib
|
|
|
|
|
|
|
|
from datetime import datetime
|
|
|
|
from calendar import monthrange
|
|
|
|
from netforce.model import Model, fields, get_model
|
|
|
|
from netforce.access import get_active_company
|
|
|
|
|
|
|
|
from . import utils
|
2014-11-13 06:30:51 +00:00
|
|
|
|
|
|
|
class VisitDialy(Model):
|
|
|
|
_name="clinic.visit.dialy"
|
|
|
|
_string="Visit Dialy"
|
|
|
|
_transient=True
|
2014-11-17 00:59:19 +00:00
|
|
|
|
2014-11-13 06:30:51 +00:00
|
|
|
_fields={
|
2014-11-21 16:11:57 +00:00
|
|
|
"date": fields.Date("Date", required=True),
|
2014-11-13 06:30:51 +00:00
|
|
|
}
|
|
|
|
|
2014-11-17 00:59:19 +00:00
|
|
|
_defaults={
|
|
|
|
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
|
|
|
}
|
|
|
|
|
|
|
|
def get_report_data(self,ids,context={}):
|
|
|
|
company_id=get_active_company()
|
|
|
|
company=get_model("company").browse(company_id)
|
|
|
|
|
|
|
|
date=datetime.now().strftime("%Y-%m-%d")
|
|
|
|
if ids:
|
|
|
|
obj=self.browse(ids)[0]
|
|
|
|
date=obj.date
|
|
|
|
month=int(date[5:7])
|
|
|
|
day=date[8:10]
|
|
|
|
year=date[0:4]
|
|
|
|
month_str=utils.MONTHS['th_TH'][month]
|
|
|
|
dom=[]
|
|
|
|
dom.append(['time_start','>=','%s 00:00:00'%date])
|
|
|
|
dom.append(['time_stop','<=','%s 23:59:59'%date])
|
|
|
|
lines=[]
|
|
|
|
for obj in get_model("clinic.visit").search_browse(dom):
|
|
|
|
hd_case_id=None
|
|
|
|
hd_case_number=''
|
|
|
|
if obj.hd_cases:
|
|
|
|
hd_case=obj.hd_cases[0]
|
|
|
|
hd_case_id=hd_case.id,
|
|
|
|
hd_case_number=hd_case.number,
|
|
|
|
number=obj.number
|
|
|
|
if number=='/':
|
|
|
|
number='รอการรรักษา'
|
|
|
|
line={
|
|
|
|
'number': number,
|
|
|
|
'visit_id': obj.id,
|
|
|
|
'cycle_name': obj.cycle_id.name,
|
|
|
|
'cycle_color': obj.cycle_id.color,
|
|
|
|
'patient_name': obj.patient_id.name,
|
|
|
|
'doctor_name': obj.doctor_id.name,
|
|
|
|
'hd_case_number': hd_case_number,
|
|
|
|
'hd_case_id': hd_case_id,
|
|
|
|
'success_color': obj.state=='confirmed' and '#99ff99' or ''
|
|
|
|
}
|
|
|
|
lines.append(line)
|
|
|
|
# XXX
|
|
|
|
year=int(year)+543
|
|
|
|
date_str='%s %s %s'%(day,month_str,year)
|
|
|
|
data={
|
|
|
|
'lines': lines,
|
|
|
|
#'date': date,
|
|
|
|
'date': date_str,
|
|
|
|
'company_name': company.name,
|
|
|
|
'company_parent_name': company.parent_id.name,
|
|
|
|
}
|
|
|
|
return data
|
|
|
|
|
2014-11-13 06:30:51 +00:00
|
|
|
VisitDialy.register()
|