conv_bal
watcha.h 2014-11-25 12:24:51 +07:00
parent 65c1a36df5
commit 4440a5a312
8 changed files with 81 additions and 35 deletions

View File

@ -1,3 +1,4 @@
<form model="clinic.visit.dialy">
<field name="date" span="2"/>
<field name="date_from" span="2"/>
<field name="date_to" span="2"/>
</form>

View File

@ -76,6 +76,8 @@ class HDCase(Model):
"total_doctor": fields.Integer("Total Doctor",function="get_personal",function_multi=True),
"total_nurse": fields.Integer("Total Nurse",function="get_personal",function_multi=True),
'doctor_id': fields.Many2One("clinic.personal","Doctor",domain=[['type','=','doctor']],function="get_personal",function_multi=True),
# XXX
#"payment_term": fields.Selection([("fee_prod","Invoice Fee & Product"),("x","In Progress"),("completed","Completed"),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("in_completed","In completed")],"Status",required=True),
}
def _get_number(self,context={}):

View File

@ -37,6 +37,7 @@ class HDCaseDialy(Model):
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.hd.case").search_browse(dom):
patient_type=utils.PATIENT_TYPE[obj.patient_id.type]
dlz_number=""
@ -61,19 +62,26 @@ class HDCaseDialy(Model):
'dlz_id': dlz_id,
'success_color': obj.state=='completed' and '#99ff99' or '',
'note': obj.note or "",
'last': False,
}
lines.append(line)
# XXX
year=int(year)+543
date_str='%s %s %s'%(day,month_str,year)
slines=[]
no=1
slines=[]
cycles=[]
for line in sorted(lines,key=lambda x: (x['cycle_sequence'],x['hd_case_number'])):
line['no']=no
slines.append(line)
no+=1
# find all nurse for each cycle
items=get_model("clinic.cycle.item").search_browse([['date','=',date]])
for item in sorted(items,key=lambda x: x.cycle_id.sequence):
pass
data={
'lines': slines,
'date': date_str,

View File

@ -23,7 +23,6 @@ class ClinicSetting(Model):
"company_id": lambda *a: get_active_company(),
}
def read_excel(self,fpath=None):
data={}
if fpath:

View File

@ -135,7 +135,7 @@ class Visit(Model):
'type': 'fee',
'product_id': product.id,
'description': product.name or "",
'qty': 1,
'qty': 2,
'price': product.sale_price or 0.0,
'amount': product.sale_price or 0.0,
'uom_id': product.uom_id.id,
@ -192,7 +192,7 @@ class Visit(Model):
dom=[]
dom.append(['date','=',date])
dom.append(['cycle_id','=',cycle.id])
dom.append(['state','=','draft'])
#dom.append(['state','=','draft'])
item_obj=get_model('clinic.cycle.item')
item_ids=item_obj.search(dom)
@ -218,10 +218,12 @@ class Visit(Model):
# clear old nurse in cycle item
item_id=item_ids[0]
item=item_obj.browse(item_id)
if item.state!='draft':
for nurse in item.nurses:
nurse.delete()
item=item_obj.browse(item_id)
if item.state!='draft':
schedule=get_schedule(date)
if schedule:
for line in schedule.lines:
@ -231,7 +233,6 @@ class Visit(Model):
'nurse_id': nurse.id,
'level_id': nurse.level_id.id,
}))
item.write(item_vals)
obj.write({

View File

@ -1,7 +1,6 @@
import time
import urllib.parse as urllib
from datetime import datetime
from datetime import datetime, timedelta
from calendar import monthrange
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
@ -14,29 +13,50 @@ class VisitDialy(Model):
_transient=True
_fields={
"date": fields.Date("Date", required=True),
"date_from": fields.Date("From", required=True),
"date_to": fields.Date("To", required=True),
}
_defaults={
'date': lambda *a: time.strftime("%Y-%m-%d"),
'date_from': lambda *a: time.strftime("%Y-%m-%d"),
'date_to': lambda *a: (datetime.now()+timedelta(days=7)).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")
date_from=datetime.now().strftime("%Y-%m-%d")
date_to=(datetime.now()+timedelta(days=7)).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]
date_from=obj.date_from
date_to=obj.date_to
time_start='%s 00:00:00'%(date_from)
time_stop='%s 23:59:59'%(date_to)
month=int(date_from[5:7])
year=date_from[0:4]
day=date_from[8:10]
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])
dom.append(['time_start','>=','%s'%time_start])
dom.append(['time_stop','<=','%s'%time_stop])
lines=[]
empty_line={
'number': '',
'visit_id': None,
'cycle_name': '',
'cycle_color': '',
'patient_name': '',
'doctor_name': '',
'hd_case_number': '',
'hd_case_id': None,
'success_color': '',
}
for obj in get_model("clinic.visit").search_browse(dom):
hd_case_id=None
hd_case_number=''
@ -47,11 +67,12 @@ class VisitDialy(Model):
number=obj.number
if number=='/':
number='รอการรรักษา'
cycle=obj.cycle_id
line={
'number': number,
'visit_id': obj.id,
'cycle_name': obj.cycle_id.name,
'cycle_color': obj.cycle_id.color,
'cycle_name': cycle.name,
'cycle_color': cycle.color,
'patient_name': obj.patient_id.name,
'doctor_name': obj.doctor_id.name,
'hd_case_number': hd_case_number,
@ -59,16 +80,23 @@ class VisitDialy(Model):
'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)
has_duration=False
if date_from != date_to:
has_duration=True
data={
'lines': lines,
#'date': date,
'date': date_str,
'company_name': company.name,
'company_parent_name': company.parent_id.name,
'has_duration': has_duration,
'date_from': date_from,
'date_to': date_to,
}
return data
VisitDialy.register()

View File

@ -4,7 +4,11 @@
{{parent_company_name}}&nbsp;{{company_name}}<br/>
</h3>
<h4>
{{#if has_duration}}
ระหว่างวันที่ {{date_from}} ถึง {{date_to}}
{{else}}
ประจำวันที่ {{date}}
{{/if}}
</h4>
</center>
<table class="table table-hover">

View File

@ -3,6 +3,9 @@
- auto complete hd after time out
- create payment for each type of patient
- invoice
- reports
- visitl dialy
- summary total for each cycle
- define rule to get
- fee product
- invoice