conv_bal
watcha.h 2015-03-13 23:31:58 +07:00
parent 0baec7195b
commit 5670f49144
16 changed files with 179 additions and 88 deletions

View File

@ -1,4 +1,4 @@
<form model="clinic.dialyzer" attrs='{"readonly":[["state","in",["cancelled","drop","active"]]]}' show_company="1"> <form model="clinic.dialyzer" attrs='{"readonly":[["state","in",["cancelled","drop","active","expire"]]]}' show_company="1">
<head> <head>
<field name="state"/> <field name="state"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">

View File

@ -1,5 +1,7 @@
<inherit inherit="gen_menu"> <inherit inherit="gen_menu">
<item string="Users" position="after"> <item string="Audit Log" position="after">
<divider/>
<header string="CUSTOMIZE"/>
<item string="Department Profiles" action="clinic_department_profile"/> <item string="Department Profiles" action="clinic_department_profile"/>
</item> </item>
</inherit> </inherit>

View File

@ -12,14 +12,12 @@
<field name="card_no" required="1"/> <field name="card_no" required="1"/>
<field name="type_id"/> <field name="type_id"/>
<field name="title_id" required="1"/> <field name="title_id" required="1"/>
<field name="reg_date"/>
<field name="first_name" required="1"/> <field name="first_name" required="1"/>
<field name="last_name" required="1"/> <field name="last_name" required="1"/>
<field name="reg_date"/>
<field name="doctor_id"/>
<field name="categ_id"/>
<!--<field name="branch_id" required="1"/>-->
<!--<field name="department_id" required="1" domain='[["branch_id","=",branch_id]]'/>-->
<field name="department_id" required="1"/> <field name="department_id" required="1"/>
<field name="categ_id"/>
<field name="doctor_id"/>
<field name="walkin"/> <field name="walkin"/>
<field name="active" invisible="1"/> <field name="active" invisible="1"/>
<tabs> <tabs>

View File

@ -1,5 +1,5 @@
<inherit model="product" inherit="product_search"> <inherit model="product" inherit="product_search">
<field name="categs" position="before"> <!--<field name="categs" position="before">-->
<field name="categ_id" child_of="1"/> <!--<field name="categ_id" child_of="1"/>-->
</field> <!--</field>-->
</inherit> </inherit>

View File

@ -1,9 +1,9 @@
<form model="clinic.report.cycle.item"> <form model="clinic.report.cycle.item">
<field name="date" span="2" mode="month" onchange="onchange_date"/> <field name="date" span="2" mode="month" onchange="onchange_date"/>
<field name="date_from" span="2"/> <field name="date_from" onchange="onchange_datefrom" span="2"/>
<field name="date_to" span="2"/> <field name="date_to" span="2"/>
<field name="cycle_id" span="2"/> <field name="cycle_id" span="2"/>
<field name="branch_id" span="2"/> <field name="branch_id" onchange="onchange_type" span="2"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/> <field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
<group span="6" columns="1"> <group span="6" columns="1">
<template> <template>

View File

@ -8,5 +8,13 @@
<field name="branch_id" onchange="onchange_branch" span="2"/> <field name="branch_id" onchange="onchange_branch" span="2"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/> <field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
<button string='Confirm Visits' method="confirm" type="success" icon="arrow-right"/> <button string='Confirm Visits' method="confirm" type="success" icon="arrow-right"/>
<separator string="Note: Please Click 'Run Report' Before Confirm Visits"/> <group span="6" columns="1">
<template>
<div>
<p></p>
<b>Note: </b>Please Click<b style="color:#3477b0"> "Run Report"</b> Before Confirm Visits.</div>
</template>
</group>
<group span="6" columns="1">
</group>
</form> </form>

View File

@ -71,11 +71,26 @@ class HDCase(Model):
} }
return res return res
def _get_epo(self,ids,context={}): def _get_expense(self,ids,context={}):
res={} res={}
for obj in self.browse(ids): for obj in self.browse(ids):
dlz_use=0
dlz_max=0
dlz_name=[]
dlz_id=None
for dlz in obj.dialyzers:
dz=dlz.dialyzer_id
dlz_id=dz.id
name=dz.name or ""
name=name.split()[-1]
dlz_name.append(name)
dlz_use+=dlz.use_time or 0
dlz_max+=dlz.max_use_time or 0
dlz_name=','.join([dlz for dlz in dlz_name])
names=[] names=[]
fee=0
for line in obj.lines: for line in obj.lines:
amt=line.amount or 0
prod=line.product_id prod=line.product_id
categ=line.product_categ_id categ=line.product_categ_id
if categ and prod and line.reimbursable=='yes': if categ and prod and line.reimbursable=='yes':
@ -85,12 +100,26 @@ class HDCase(Model):
if name: if name:
name=name[0].title() name=name[0].title()
names.append(name) names.append(name)
res[obj.id]=','.join([n for n in names]) elif categ.code=='FEE':
fee+=amt
res[obj.id]={
'epo': ','.join([n for n in names]),
'fee': fee,
'dlz_id': dlz_id,
'dlz_name': dlz_name,
'dlz_use': dlz_use,
'dlz_max': dlz_max,
}
return res return res
_fields={ _fields={
"number": fields.Char("Number",required=True,search=True), "number": fields.Char("Number",required=True,search=True),
"epo": fields.Char("EPO",function="_get_epo"), "epo": fields.Char("EPO",function="_get_expense",function_multi=True),
"fee": fields.Float("Fee",function="_get_expense",function_multi=True),
"dlz_name": fields.Float("DZ",function="_get_expense",function_multi=True),
"dlz_use": fields.Float("DZ Use",function="_get_expense",function_multi=True),
"dlz_max": fields.Float("DZ Max",function="_get_expense",function_multi=True),
"dlz_id": fields.Float("DZ ID",function="_get_expense",function_multi=True),
'sickbed_id': fields.Many2One("clinic.sickbed",'Sickbed'), 'sickbed_id': fields.Many2One("clinic.sickbed",'Sickbed'),
"ref": fields.Char("Ref",search=True), "ref": fields.Char("Ref",search=True),
"time_start": fields.DateTime("Start Time",required=True), "time_start": fields.DateTime("Start Time",required=True),

View File

@ -53,6 +53,8 @@ class MakeAPT(Model):
if not pcs: if not pcs:
# Create patient cycle with that department # Create patient cycle with that department
for pt in get_model("clinic.patient").search_browse([['department_id','=',obj.department_id.id]]): for pt in get_model("clinic.patient").search_browse([['department_id','=',obj.department_id.id]]):
if pt.walkin=='yes':
continue
for pc in pt.cycles: for pc in pt.cycles:
vals={ vals={
'patient_id': pt.id, 'patient_id': pt.id,

View File

@ -182,29 +182,35 @@ class Patient(Model):
break break
return ptype_id return ptype_id
def _get_branch(self,context={}): def _get_departments(self,context={}):
b_ids=get_model('clinic.branch').search([])
if b_ids:
return b_ids[0]
def _get_dpts(self,context={}):
return get_model("clinic.department").search([]) return get_model("clinic.department").search([])
def _get_department(self,context={}):
res=get_model('select.company').get_select()
if res:
return res['department_id']
def _get_branch(self,context={}):
res=get_model('select.company').get_select()
if res:
return res['branch_id']
_defaults={ _defaults={
#"number": _get_number, #"number": _get_number,
"number": "", "number": "",
"reg_date": lambda *a: time.strftime("%Y-%m-%d"), "reg_date": lambda *a: time.strftime("%Y-%m-%d"),
"company_id": lambda *a: get_active_company(), "company_id": lambda *a: get_active_company(),
'branch_id': _get_branch, 'branch_id': _get_branch,
'department_id': _get_department,
'card_type': 'identification', 'card_type': 'identification',
'type_id': _get_type, 'type_id': _get_type,
"active" : True, "active" : True,
'state': 'admit', 'state': 'admit',
'walkin': 'no', 'walkin': 'no',
'departments': _get_dpts, 'departments': _get_departments,
} }
_sql_constraints=("clinic_patient_key_uniq","unique(name_check,branch_id)","name should be unique"), _sql_constraints=("clinic_patient_key_uniq","unique(name_check)","name should be unique"),
_order="reg_date desc" _order="reg_date desc"
def check_idcard(self,idcard=''): def check_idcard(self,idcard=''):

View File

@ -26,11 +26,22 @@ class ReportCycleItem(Model):
year,month=time.strftime("%Y-%m").split("-") year,month=time.strftime("%Y-%m").split("-")
date_from=defaults.get('date_from','%s-%s-01'%(year,month)) date_from=defaults.get('date_from','%s-%s-01'%(year,month))
date_to=defaults.get('date_to','%s-%s-01'%(year,month)) date_to=defaults.get('date_to','%s-%s-01'%(year,month))
branch_id=defaults.get('branch_id')
department_id=defaults.get('department_id')
res=get_model('select.company').get_select()
if res:
if not branch_id:
branch_id=res['branch_id']
if not department_id:
department_id=res['department_id']
res={ res={
'date': date, 'date': date,
'date_from': date_from, 'date_from': date_from,
'date_to': date_to, 'date_to': date_to,
'branch_id': branch_id,
'department_id': department_id,
} }
print('res', res)
return res return res
def get_report_data(self,ids,context={}): def get_report_data(self,ids,context={}):
@ -39,9 +50,9 @@ class ReportCycleItem(Model):
defaults=self.default_get(context=context) defaults=self.default_get(context=context)
date_from=defaults.get("date_from") date_from=defaults.get("date_from")
date_to=defaults.get("date_to") date_to=defaults.get("date_to")
branch_id=defaults.get("branch_id")
department_id=defaults.get("department_id")
month=date_from.split("-")[1] month=date_from.split("-")[1]
branch_id=None
department_id=None
cycle_id=None cycle_id=None
if ids: if ids:
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
@ -62,34 +73,48 @@ class ReportCycleItem(Model):
dom.append(['branch_id','=',branch_id]) dom.append(['branch_id','=',branch_id])
if department_id: if department_id:
dom.append(['department_id','=',department_id]) dom.append(['department_id','=',department_id])
no=1
lines=[] lines=[]
cycles={}
for citem in get_model('clinic.cycle.item').search_browse(dom,order="date"): for citem in get_model('clinic.cycle.item').search_browse(dom,order="date"):
cycle=citem.cycle_id
if cycle.id not in cycles.keys():
cycles[cycle.id]=[]
for line in citem.lines:
nurse=line.nurse_id
cycles[cycle.id].append(nurse.name)
for hdcase in citem.hd_cases: for hdcase in citem.hd_cases:
patient=hdcase.patient_id patient=hdcase.patient_id
ptype=patient.type_id ptype=patient.type_id
doctor=hdcase.doctor_id doctor=hdcase.doctor_id
cycle=hdcase.cycle_id cycle=hdcase.cycle_id
dpt=hdcase.department_id dpt=hdcase.department_id
dlz_use=hdcase.dlz_use or 0
if dlz_use==hdcase.dlz_max:
dlz_use="%sทิ้ง"%dlz_use
lines.append({ lines.append({
'no': no,
'pname': patient.name or '', 'pname': patient.name or '',
'pid': patient.id or '', 'pid': patient.id or '',
'hn': patient.hn_no, 'hn': patient.hn_no,
'did': doctor.id, 'did': doctor.id,
'dname': doctor.name or "", 'dname': doctor.name or "",
#'date': utils.date2thai(hdcase.date or '',format='%(Td)s %(d)s/%(m)s/%(BY)s'),
'date': hdcase.date, 'date': hdcase.date,
'epo': hdcase.epo, 'epo': hdcase.epo,
'fee': hdcase.fee,
'dlz_name': hdcase.dlz_name,
'dlz_use': dlz_use,
'dlz_id': hdcase.dlz_id,
'cseq': cycle.sequence or 0,
'cid': cycle.id,
'hdcase_id': hdcase.id,
'note': hdcase.note or "",
'cname': cycle.name or '', 'cname': cycle.name or '',
'cid': citem.id or '', 'ctid': citem.id or '',
'hct': hdcase.hct or 0, 'hct': hdcase.hct or 0,
'tname': ptype.name or '', 'tname': ptype.name or '',
'tid': ptype.id, 'tid': ptype.id,
'dpt_id': dpt.id, 'dpt_id': dpt.id,
'dpt_name': dpt.name or "", 'dpt_name': dpt.name or "",
}) })
no+=1
month_str=utils.MONTHS['th_TH'][int(month)] month_str=utils.MONTHS['th_TH'][int(month)]
company_name=company.name or "" company_name=company.name or ""
if department_id: if department_id:
@ -98,9 +123,27 @@ class ReportCycleItem(Model):
elif branch_id: elif branch_id:
branch=get_model("clinic.branch").browse(branch_id) branch=get_model("clinic.branch").browse(branch_id)
company_name+=" ("+branch.name+")" company_name+=" ("+branch.name+")"
no=1
nlines=[]
index=0
old=[]
for line in sorted(lines,key=lambda x:(x['date'],x['cseq'])):
cid=line['cid']
if not cid in old:
old.append(cid)
index=0
else:
index+=1
cres=cycles[cid]
line['nurse']=''
if index < len(cres):
line['nurse']=cres[index]
line['no']=no
nlines.append(line)
no+=1
data={ data={
'company_name': company_name or "", 'company_name': company_name or "",
'lines': lines, 'lines': nlines,
'month': month_str, 'month': month_str,
'date_from': date_from, 'date_from': date_from,
'date_to': date_to, 'date_to': date_to,
@ -116,4 +159,14 @@ class ReportCycleItem(Model):
data['date_to']="%s-%s-%s"%(year,month,total_day) data['date_to']="%s-%s-%s"%(year,month,total_day)
return data return data
def onchange_type(self,context={}):
data=context['data']
data['department_id']=None
return data
def onchange_datefrom(self,context={}):
data=context['data']
data['date_to']=data['date_from']
return data
ReportCycleItem.register() ReportCycleItem.register()

View File

@ -66,13 +66,12 @@ class SelectCompany(Model):
def get_select(self,context={}): def get_select(self,context={}):
user_id=get_active_user() user_id=get_active_user()
db=get_connection()
department_id=None department_id=None
branch_id=None branch_id=None
user=get_model("base.user").browse(user_id) user=get_model("base.user").browse(user_id)
dpt=user.department_id dpt=user.department_id
department_id=dpt.id department_id=dpt.id
res={} branch_id=dpt.branch_id.id
return { return {
'department_id': department_id, 'department_id': department_id,
'branch_id': branch_id, 'branch_id': branch_id,

View File

@ -1,8 +1,7 @@
import time import time
from calendar import monthrange from calendar import monthrange
from datetime import datetime, timedelta from datetime import datetime, timedelta
#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, get_active_user, set_active_user from netforce.access import get_active_company, get_active_user, set_active_user
@ -40,6 +39,7 @@ class VisitBoard(Model):
def _get_branch(self,context={}): def _get_branch(self,context={}):
res=get_model('select.company').get_select() res=get_model('select.company').get_select()
if res: if res:
print('res ', res)
return res['branch_id'] return res['branch_id']
def _get_department(self,context={}): def _get_department(self,context={}):
@ -70,9 +70,8 @@ class VisitBoard(Model):
branch_id=defaults.get("branch_id",None) branch_id=defaults.get("branch_id",None)
if branch_id: if branch_id:
branch_id=branch_id[0] branch_id=branch_id[0]
#user_id=get_active_user()
user_id=get_active_user() #set_active_user(1) #FIXME to allow user to see doctor different department
set_active_user(1) #FIXME to allow user to see doctor different department
if ids: if ids:
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
@ -305,7 +304,7 @@ class VisitBoard(Model):
'date_from': utils.date2thai(date_from,format='%(d)s %(Tm)s %(By)s',lang="th_TH2"), 'date_from': utils.date2thai(date_from,format='%(d)s %(Tm)s %(By)s',lang="th_TH2"),
'date_to': utils.date2thai(date_to,format='%(d)s %(Tm)s %(By)s',lang="th_TH2"), 'date_to': utils.date2thai(date_to,format='%(d)s %(Tm)s %(By)s',lang="th_TH2"),
} }
set_active_user(user_id) #set_active_user(user_id)
return data return data
def onchange_date(self,context={}): def onchange_date(self,context={}):

View File

@ -1,8 +1,5 @@
<center> <center>
<h2>สรุปรอบการรักษา</h2> <h3>{{company_name}}</h3>
<h3>
{{company_name}}<br/>
</h3>
<h4> <h4>
ระหว่างวันที่ {{date_from}} ถึง {{date_to}} ระหว่างวันที่ {{date_from}} ถึง {{date_to}}
</h4> </h4>
@ -12,27 +9,31 @@
<th>#</th> <th>#</th>
<th>วันที่</th> <th>วันที่</th>
<th>รอบ</th> <th>รอบ</th>
<th>HN</th> <th>ชื่อ-สกุล</th>
<th>ผู้ป่วย</th>
<th>สิทธ์</th>
<th>ชั้น</th>
<th>แพทย์</th> <th>แพทย์</th>
<th>EPO</th> <th>สิทธ์</th>
<th>HCT</th> <th>จ.น.เงิน</th>
<th>ยาฉีด</th>
<th>DZ</th>
<th>N/U</th>
<th>พยาบาล</th>
<!--<th>หมายเหตุ</th>-->
</thead> </thead>
<tbody> <tbody>
{{#each lines }} {{#each lines }}
<tr> <tr>
<td>{{no}}</td> <td>{{no}}</td>
<td><a href="/ui#name=clinic_visit&active_id={{vid}}&mode=form">{{date}}</a></td> <td><a href="/ui#name=clinic_hd_case&active_id={{hdcase_id}}&mode=form">{{date}}</a></td>
<td><a href="/ui#name=clinic_cycle_item&active_id={{cid}}&mode=form">{{cname}}</a></td> <td>{{cname}}</td>
<td>{{hn}}</td>
<td><a href="/ui#name=clinic_patient&active_id={{pid}}&mode=form">{{pname}}</a></td> <td><a href="/ui#name=clinic_patient&active_id={{pid}}&mode=form">{{pname}}</a></td>
<td><a href="/ui#name=clinic_patient_type&active_id={{tid}}&mode=form">{{tname}}</a></td>
<td><a href="/ui#name=clinic_department&active_id={{dpt_id}}&mode=form">{{dpt_name}}</a></td>
<td><a href="/ui#name=clinic_staff&active_id={{did}}&mode=form">{{dname}}</a></td> <td><a href="/ui#name=clinic_staff&active_id={{did}}&mode=form">{{dname}}</a></td>
<td><a href="/ui#name=clinic_patient_type&active_id={{tid}}&mode=form">{{tname}}</a></td>
<td>{{currency fee zero=""}}</td>
<td>{{epo}}</td> <td>{{epo}}</td>
<td>{{hct}}</td> <td><a href="/ui#name=clinic_dialyzer&active_id={{dlz_id}}&mode=form">{{dlz_name}}</a></td>
<td>{{dlz_use}}</td>
<td><a href="/ui#name=clinic_cycle_item&active_id={{ctid}}&mode=form">View</a></td>
<!--<td>{{note}}</td>-->
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>

View File

@ -1,34 +1,18 @@
<center> <center>
<!-- <span>&nbsp;&nbsp;</span>
<h2>ตารางนัดผู้ป่วย</h2>
<h3>
{{parent_company_name}}&nbsp;{{company_name}}<br/>
</h3>
<h4>
{{#if has_duration}}
ระหว่างวันที่ {{date_from}} ถึง {{date_to}}
{{else}}
{{date}}
{{/if}}
</h4>
-->
</center> </center>
<table class="table table-condensed table-striped"> <table class="table table-condensed table-striped">
<thead> <thead>
<th>รอบ</th> <th style="text-align:center">รอบ</th>
<th>#</th> <th style="text-align:center">#</th>
<th>ใบนัด</th> <th style="text-align:center">ใบนัด</th>
<th>HN</th> <th style="text-align:center">HN</th>
<th>ผู้ป่วย</th> <th style="text-align:center">ผู้ป่วย</th>
<!-- <th style="text-align:center">สิทธ์</th>
<th>สาขา</th> <th style="text-align:center">แพทย์</th>
--> <th style="text-align:center">ชั้น</th>
<th>สิทธ์</th> <th style="text-align:center">เตียง</th>
<th>แพทย์</th> <th style="text-align:center">บันทึกการรักษา</th>
<th>ชั้น</th>
<th>เตียง</th>
<th>บันทึกการรักษา</th>
<th>หมายเหตุ</th>
</thead> </thead>
<tbody> <tbody>
{{#each lines }} {{#each lines }}
@ -52,8 +36,8 @@
{{else}} {{else}}
<tr style="background-color:{{visit_color}}"> <tr style="background-color:{{visit_color}}">
{{#if title}} {{#if title}}
<td style="background-color:#ddddff"><b>{{cycle_name}}</b></td> <td style="background-color:#ddddff" colspan="4"><b>{{cycle_name}}</b></td>
<td style="background-color:#ddddff" colspan="10"></td> <td style="background-color:#ddddff" colspan="7"></td>
{{else}} {{else}}
<td style="background-color:{{cycle_color}};color:white;width:6%"><center>{{cycle_name}}</center></td> <td style="background-color:{{cycle_color}};color:white;width:6%"><center>{{cycle_name}}</center></td>
<td style="background-color:{{visit_color}}">{{no}}</td> <td style="background-color:{{visit_color}}">{{no}}</td>
@ -72,7 +56,6 @@
<td style="background-color:{{visit_color}}">{{sickbed_name}}</td> <td style="background-color:{{visit_color}}">{{sickbed_name}}</td>
{{/if}} {{/if}}
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_hd_case&active_id={{hd_case_id}}&mode=form">{{hd_case_number}}</a></td> <td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_hd_case&active_id={{hd_case_id}}&mode=form">{{hd_case_number}}</a></td>
<td style="background-color:{{visit_color}}">{{note}}</td>
{{/if}} {{/if}}
</tr> </tr>
{{/if}} {{/if}}

View File

@ -11,5 +11,16 @@ report:
- reciept: - reciept:
- remove border line - remove border line
merge doctor: - merge doctor: **
- ทวีชัย
- merge patient
- สมเศียร
- ** sequence invoice
- LS, LK
- Extract number (Invoice) *
- prevent to gen walk in
- prevent to create visit
- report P. Moo
- update patient for K. Ekk