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>
<field name="state"/>
<button string="Options" dropdown="1">

View File

@ -1,5 +1,7 @@
<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>
</inherit>

View File

@ -12,14 +12,12 @@
<field name="card_no" required="1"/>
<field name="type_id"/>
<field name="title_id" required="1"/>
<field name="reg_date"/>
<field name="first_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="categ_id"/>
<field name="doctor_id"/>
<field name="walkin"/>
<field name="active" invisible="1"/>
<tabs>

View File

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

View File

@ -1,9 +1,9 @@
<form model="clinic.report.cycle.item">
<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="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"/>
<group span="6" columns="1">
<template>

View File

@ -8,5 +8,13 @@
<field name="branch_id" onchange="onchange_branch" span="2"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
<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>

View File

@ -71,11 +71,26 @@ class HDCase(Model):
}
return res
def _get_epo(self,ids,context={}):
def _get_expense(self,ids,context={}):
res={}
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=[]
fee=0
for line in obj.lines:
amt=line.amount or 0
prod=line.product_id
categ=line.product_categ_id
if categ and prod and line.reimbursable=='yes':
@ -85,12 +100,26 @@ class HDCase(Model):
if name:
name=name[0].title()
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
_fields={
"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'),
"ref": fields.Char("Ref",search=True),
"time_start": fields.DateTime("Start Time",required=True),

View File

@ -53,6 +53,8 @@ class MakeAPT(Model):
if not pcs:
# Create patient cycle with that department
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:
vals={
'patient_id': pt.id,

View File

@ -182,29 +182,35 @@ class Patient(Model):
break
return ptype_id
def _get_branch(self,context={}):
b_ids=get_model('clinic.branch').search([])
if b_ids:
return b_ids[0]
def _get_dpts(self,context={}):
def _get_departments(self,context={}):
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={
#"number": _get_number,
"number": "",
"reg_date": lambda *a: time.strftime("%Y-%m-%d"),
"company_id": lambda *a: get_active_company(),
'branch_id': _get_branch,
'department_id': _get_department,
'card_type': 'identification',
'type_id': _get_type,
"active" : True,
'state': 'admit',
'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"
def check_idcard(self,idcard=''):

View File

@ -26,11 +26,22 @@ class ReportCycleItem(Model):
year,month=time.strftime("%Y-%m").split("-")
date_from=defaults.get('date_from','%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={
'date': date,
'date_from': date_from,
'date_to': date_to,
'branch_id': branch_id,
'department_id': department_id,
}
print('res', res)
return res
def get_report_data(self,ids,context={}):
@ -39,9 +50,9 @@ class ReportCycleItem(Model):
defaults=self.default_get(context=context)
date_from=defaults.get("date_from")
date_to=defaults.get("date_to")
branch_id=defaults.get("branch_id")
department_id=defaults.get("department_id")
month=date_from.split("-")[1]
branch_id=None
department_id=None
cycle_id=None
if ids:
obj=self.browse(ids)[0]
@ -62,34 +73,48 @@ class ReportCycleItem(Model):
dom.append(['branch_id','=',branch_id])
if department_id:
dom.append(['department_id','=',department_id])
no=1
lines=[]
cycles={}
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:
patient=hdcase.patient_id
ptype=patient.type_id
doctor=hdcase.doctor_id
cycle=hdcase.cycle_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({
'no': no,
'pname': patient.name or '',
'pid': patient.id or '',
'hn': patient.hn_no,
'did': doctor.id,
'dname': doctor.name or "",
#'date': utils.date2thai(hdcase.date or '',format='%(Td)s %(d)s/%(m)s/%(BY)s'),
'date': hdcase.date,
'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 '',
'cid': citem.id or '',
'ctid': citem.id or '',
'hct': hdcase.hct or 0,
'tname': ptype.name or '',
'tid': ptype.id,
'dpt_id': dpt.id,
'dpt_name': dpt.name or "",
})
no+=1
month_str=utils.MONTHS['th_TH'][int(month)]
company_name=company.name or ""
if department_id:
@ -98,9 +123,27 @@ class ReportCycleItem(Model):
elif branch_id:
branch=get_model("clinic.branch").browse(branch_id)
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={
'company_name': company_name or "",
'lines': lines,
'lines': nlines,
'month': month_str,
'date_from': date_from,
'date_to': date_to,
@ -116,4 +159,14 @@ class ReportCycleItem(Model):
data['date_to']="%s-%s-%s"%(year,month,total_day)
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()

View File

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

View File

@ -1,8 +1,7 @@
import time
from calendar import monthrange
from datetime import datetime, timedelta
#from calendar import monthrange
from netforce.model import Model, fields, get_model
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={}):
res=get_model('select.company').get_select()
if res:
print('res ', res)
return res['branch_id']
def _get_department(self,context={}):
@ -70,9 +70,8 @@ class VisitBoard(Model):
branch_id=defaults.get("branch_id",None)
if branch_id:
branch_id=branch_id[0]
user_id=get_active_user()
set_active_user(1) #FIXME to allow user to see doctor different department
#user_id=get_active_user()
#set_active_user(1) #FIXME to allow user to see doctor different department
if ids:
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_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
def onchange_date(self,context={}):

View File

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

View File

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

View File

@ -11,5 +11,16 @@ report:
- reciept:
- 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