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"> <form model="clinic.visit.dialy">
<field name="date" span="2"/> <field name="date_from" span="2"/>
<field name="date_to" span="2"/>
</form> </form>

View File

@ -76,6 +76,8 @@ class HDCase(Model):
"total_doctor": fields.Integer("Total Doctor",function="get_personal",function_multi=True), "total_doctor": fields.Integer("Total Doctor",function="get_personal",function_multi=True),
"total_nurse": fields.Integer("Total Nurse",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), '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={}): 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_start','>=','%s 00:00:00'%date])
dom.append(['time_stop','<=','%s 23:59:59'%date]) dom.append(['time_stop','<=','%s 23:59:59'%date])
lines=[] lines=[]
for obj in get_model("clinic.hd.case").search_browse(dom): for obj in get_model("clinic.hd.case").search_browse(dom):
patient_type=utils.PATIENT_TYPE[obj.patient_id.type] patient_type=utils.PATIENT_TYPE[obj.patient_id.type]
dlz_number="" dlz_number=""
@ -61,19 +62,26 @@ class HDCaseDialy(Model):
'dlz_id': dlz_id, 'dlz_id': dlz_id,
'success_color': obj.state=='completed' and '#99ff99' or '', 'success_color': obj.state=='completed' and '#99ff99' or '',
'note': obj.note or "", 'note': obj.note or "",
'last': False,
} }
lines.append(line) lines.append(line)
# XXX
year=int(year)+543 year=int(year)+543
date_str='%s %s %s'%(day,month_str,year) date_str='%s %s %s'%(day,month_str,year)
slines=[]
no=1 no=1
slines=[]
cycles=[]
for line in sorted(lines,key=lambda x: (x['cycle_sequence'],x['hd_case_number'])): for line in sorted(lines,key=lambda x: (x['cycle_sequence'],x['hd_case_number'])):
line['no']=no line['no']=no
slines.append(line) slines.append(line)
no+=1 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={ data={
'lines': slines, 'lines': slines,
'date': date_str, 'date': date_str,

View File

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

View File

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

View File

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

View File

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

View File

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