improve
parent
22f8dbda52
commit
e9253f1712
|
@ -2,5 +2,6 @@
|
|||
<field name="string">New Dialyzer</field>
|
||||
<field name="view_cls">form_popup</field>
|
||||
<field name="model">clinic.hd.case.popup.dlz</field>
|
||||
<field name="width">800</field>
|
||||
<field name="target">_popup</field>
|
||||
</action>
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
|
||||
class HDCasePopupDlz(Model):
|
||||
_name="clinic.hd.case.popup.dlz"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
|
||||
'product_id': fields.Many2One("product", "Product",required=True),
|
||||
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
|
||||
"max_use_time": fields.Integer("Max Use Time"),
|
||||
"exp_date": fields.Date("Expiry Date"),
|
||||
"note": fields.Text("Note"),
|
||||
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
|
||||
}
|
||||
|
||||
def __get_hd_case_id(self,context={}):
|
||||
hd_case_id=context.get("refer_id")
|
||||
print("clinic.hd.case.popup.dlz default")
|
||||
if not hd_case_id:
|
||||
return None
|
||||
return int(hd_case_id)
|
||||
|
||||
def default_get(self,field_names=None,context={},**kw):
|
||||
defaults=context.get("defaults",{})
|
||||
hdcase_id=defaults.get('hd_case_id')
|
||||
dialyzer_type=defaults.get('dialyzer_type')
|
||||
if not hdcase_id:
|
||||
hdcase_id=context.get("refer_id")
|
||||
if hdcase_id:
|
||||
hdcase=get_model('clinic.hd.case').browse(hdcase_id)
|
||||
dom=[]
|
||||
for dlz in get_model('clinic.dialyzer').search_browse(dom):
|
||||
dialyzer_type=dlz.dialyzer_type or "low"
|
||||
pass
|
||||
res={
|
||||
'hd_case_id': hdcase_id,
|
||||
'dialyzer_type': 'low',
|
||||
'max_use_time': 10,
|
||||
}
|
||||
print('res', res)
|
||||
return res
|
||||
|
||||
def new_dlz(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
hd_case=obj.hd_case_id
|
||||
res={}
|
||||
if hd_case:
|
||||
context['is_wiz']=True
|
||||
context['pop_id']=obj.id
|
||||
res=hd_case.new_dialyzer(context=context)
|
||||
print('res ', res)
|
||||
return res
|
||||
|
||||
def onchange_product(self,context={}):
|
||||
data=context['data']
|
||||
hdcase_id=data['hd_case_id']
|
||||
patient=None
|
||||
if hdcase_id:
|
||||
hdcase=get_model('clinic.hd.case').browse(hdcase_id)
|
||||
patient=hdcase.patient_id
|
||||
product_id=data['product_id']
|
||||
data['membrane_type']=None
|
||||
data['dialyzer_type']=None
|
||||
data['max_use_time']=10
|
||||
dom=[]
|
||||
if patient:
|
||||
dom.append(['patient_id','=',patient.id])
|
||||
for dlz in get_model("clinic.dialyzer").search_browse(dom):
|
||||
prod=dlz.product_id
|
||||
if prod.id==product_id:
|
||||
data['membrane_type']=dlz.membrane_type
|
||||
data['dialyzer_type']=dlz.dialyzer_type or "low"
|
||||
data['max_use_time']=dlz.max_use_time or 10
|
||||
break
|
||||
return data
|
||||
|
||||
HDCasePopupDlz.register()
|
|
@ -133,3 +133,6 @@ from . import report_shop
|
|||
from . import account_tax_component
|
||||
from . import report_thai_wht_certif
|
||||
from . import num2word
|
||||
from . import province
|
||||
#from . import district
|
||||
#from . import subdistrict
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
from netforce.model import Model, fields
|
||||
|
||||
class District(Model):
|
||||
_inherit="district"
|
||||
|
||||
def _get_sort_name(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
sname=''
|
||||
if obj.name:
|
||||
sname=obj.name[0:1]
|
||||
res[obj.id]=sname
|
||||
return res
|
||||
|
||||
_fields={
|
||||
"name": fields.Char("Name",required=True,search=True,translate=True),
|
||||
"sort_name": fields.Char("Sort Name",function="_get_sort_name",store=True),
|
||||
}
|
||||
_order="sort_name asc"
|
||||
|
||||
District.register()
|
|
@ -868,8 +868,8 @@ class HDCase(Model):
|
|||
for obj in self.browse(ids):
|
||||
is_decrease=context.get('is_decrease')
|
||||
for dlz_line in obj.dialyzers:
|
||||
membrane_type=dlz_line.membrane_type or ''
|
||||
dialyzer_type=dlz_line.dialyzer_type or ''
|
||||
membrane_type=dlz_line.membrane_type or 'unsub'
|
||||
dialyzer_type=dlz_line.dialyzer_type or 'low'
|
||||
use_time=dlz_line.use_time or 0
|
||||
max_use_time=dlz_line.max_use_time or 0
|
||||
desc=dlz_line.description or ''
|
||||
|
|
|
@ -14,18 +14,40 @@ class HDCasePopupDlz(Model):
|
|||
"membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
|
||||
}
|
||||
|
||||
def _get_hd_case_id(self,context={}):
|
||||
def __get_hd_case_id(self,context={}):
|
||||
hd_case_id=context.get("refer_id")
|
||||
print("clinic.hd.case.popup.dlz default")
|
||||
if not hd_case_id:
|
||||
return None
|
||||
return int(hd_case_id)
|
||||
|
||||
_defaults={
|
||||
'hd_case_id': _get_hd_case_id,
|
||||
'dialyzer_type': 'low',
|
||||
'max_use_time': 10,
|
||||
}
|
||||
|
||||
def default_get(self,field_names=None,context={},**kw):
|
||||
defaults=context.get("defaults",{})
|
||||
hdcase_id=defaults.get('hd_case_id')
|
||||
dialyzer_type=defaults.get('dialyzer_type', "low")
|
||||
membrane_type=defaults.get('membrane_type', "unsub")
|
||||
product_id=defaults.get('product_id', None)
|
||||
max_use_time=defaults.get('max_use_time', 10)
|
||||
if not hdcase_id:
|
||||
hdcase_id=context.get("refer_id")
|
||||
if hdcase_id:
|
||||
hdcase_id=int(hdcase_id)
|
||||
hdcase=get_model('clinic.hd.case').browse(hdcase_id)
|
||||
for line in hdcase.dialyzers:
|
||||
dlz=line.dialyzer_id
|
||||
product_id=dlz.product_id.id
|
||||
dialyzer_type=dlz.dialyzer_type or "low"
|
||||
membrane_type=dlz.membrane_type or "unsub"
|
||||
max_use_time=dlz.max_use_time or 10
|
||||
res={
|
||||
'hd_case_id': hdcase_id,
|
||||
'dialyzer_type': dialyzer_type,
|
||||
'membrane_type': membrane_type,
|
||||
'max_use_time': max_use_time,
|
||||
'product_id': product_id,
|
||||
}
|
||||
print('res', res)
|
||||
return res
|
||||
|
||||
def new_dlz(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
|
@ -40,17 +62,37 @@ class HDCasePopupDlz(Model):
|
|||
|
||||
def onchange_product(self,context={}):
|
||||
data=context['data']
|
||||
hdcase_id=data['hd_case_id']
|
||||
patient=None
|
||||
if hdcase_id:
|
||||
hdcase=get_model('clinic.hd.case').browse(hdcase_id)
|
||||
patient=hdcase.patient_id
|
||||
product_id=data['product_id']
|
||||
data['membrane_type']=None
|
||||
data['dialyzer_type']=None
|
||||
#data['max_use_time']=None
|
||||
for dlz in get_model("clinic.dialyzer").search_browse([]):
|
||||
data['max_use_time']=10
|
||||
dom=[]
|
||||
if patient:
|
||||
dom.append(['patient_id','=',patient.id])
|
||||
count=0
|
||||
for dlz in get_model("clinic.dialyzer").search_browse(dom):
|
||||
prod=dlz.product_id
|
||||
if prod.id==product_id:
|
||||
count+=1
|
||||
data['membrane_type']=dlz.membrane_type
|
||||
data['dialyzer_type']=dlz.dialyzer_type or "low"
|
||||
data['max_use_time']=dlz.max_use_time or 0
|
||||
data['max_use_time']=dlz.max_use_time or 10
|
||||
break
|
||||
# search from another patient
|
||||
if not count:
|
||||
dom=[]
|
||||
for dlz in get_model("clinic.dialyzer").search_browse(dom):
|
||||
prod=dlz.product_id
|
||||
if prod.id==product_id:
|
||||
data['membrane_type']=dlz.membrane_type
|
||||
data['dialyzer_type']=dlz.dialyzer_type or "low"
|
||||
data['max_use_time']=dlz.max_use_time or 10
|
||||
break
|
||||
return data
|
||||
|
||||
HDCasePopupDlz.register()
|
||||
|
|
|
@ -328,6 +328,24 @@ class Patient(Model):
|
|||
super().delete(ids)
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
if 'cycles' in vals.keys():
|
||||
index=0
|
||||
for cvals in vals['cycles']:
|
||||
mode=cvals[0]
|
||||
if mode=='delete':
|
||||
continue
|
||||
elif mode=='create':
|
||||
cycle_vals=cvals[1]
|
||||
elif mode=='write':
|
||||
continue
|
||||
cycle_vals=cvals[2]
|
||||
cdom=[]
|
||||
for f, v in cycle_vals.items():
|
||||
cdom.append([f,'=',v])
|
||||
print('cdom ', cdom)
|
||||
for c in get_model('clinic.patient.cycle').search_browse(cdom):
|
||||
c.delete()
|
||||
index+=1
|
||||
if 'type_id' in vals.keys():
|
||||
#update patient in hd case which state is condition below
|
||||
for obj in self.browse(ids):
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
from netforce.model import Model, fields
|
||||
|
||||
class Province(Model):
|
||||
_inherit="province"
|
||||
def _get_sort_name(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
sname=''
|
||||
if obj.name:
|
||||
sname=obj.name[0:1]
|
||||
res[obj.id]=sname
|
||||
return res
|
||||
|
||||
_fields={
|
||||
"name": fields.Char("Name",required=True,search=True,translate=True),
|
||||
"sort_name": fields.Char("Sort Name",function="_get_sort_name",store=True),
|
||||
}
|
||||
_order="sort_name asc"
|
||||
|
||||
Province.register()
|
|
@ -97,7 +97,10 @@ class ReportCycleItem(Model):
|
|||
cycles[cycle.id]=[]
|
||||
for line in citem.lines:
|
||||
nurse=line.nurse_id
|
||||
cycles[cycle.id].append(nurse.name)
|
||||
cycles[cycle.id].append({
|
||||
'name': nurse.name,
|
||||
'first_name': nurse.first_name or "",
|
||||
})
|
||||
for hdcase in citem.hd_cases:
|
||||
patient=hdcase.patient_id
|
||||
vascular=patient.vascular_acc
|
||||
|
@ -116,11 +119,14 @@ class ReportCycleItem(Model):
|
|||
dlz_use="%sทิ้ง"%dlz_use
|
||||
dlz_drop=True
|
||||
cancel=False
|
||||
row_color=''
|
||||
if hdcase.state=='cancelled':
|
||||
cancel=True
|
||||
row_color='#b6b6b6'
|
||||
lines.append({
|
||||
'dlz_drop': dlz_drop,
|
||||
'cancel': cancel,
|
||||
'row_color': row_color,
|
||||
'pname': patient.name or '',
|
||||
'pid': patient.id or '',
|
||||
'hn': patient.hn_no,
|
||||
|
@ -154,13 +160,38 @@ class ReportCycleItem(Model):
|
|||
elif branch_id:
|
||||
branch=get_model("clinic.branch").browse(branch_id)
|
||||
company_name+=" ("+branch.name+")"
|
||||
no=1
|
||||
nlines=[]
|
||||
index=0
|
||||
old=[]
|
||||
total_fee=0
|
||||
total_mdc=0
|
||||
dates={}
|
||||
no=0
|
||||
count=0
|
||||
sub_fee=0
|
||||
sub_mdc=0
|
||||
pt=0
|
||||
for line in sorted(lines,key=lambda x:(x['date'],x['cseq'])):
|
||||
pt+=1
|
||||
date=line['date'] or ''
|
||||
key='%s-%s'%(date,line['cseq'])
|
||||
if key not in dates.keys():
|
||||
no=1
|
||||
count=0
|
||||
sub_fee=0
|
||||
sub_mdc=0
|
||||
for x in lines:
|
||||
if x['cseq']==line['cseq'] and x['date']==date:
|
||||
sub_fee+=x['fee'] or 0
|
||||
sub_mdc+=x['mdc'] or 0
|
||||
count+=1
|
||||
line['date_txt']=line['date']
|
||||
line['cseq_txt']=line['cseq']
|
||||
dates[key]=0
|
||||
else:
|
||||
no+=1
|
||||
dates[key]+=1
|
||||
line['no']=no
|
||||
total_fee+=line.get("fee",0)
|
||||
total_mdc+=line.get("mdc",0)
|
||||
cid=line['cid']
|
||||
|
@ -172,10 +203,17 @@ class ReportCycleItem(Model):
|
|||
cres=cycles[cid]
|
||||
line['nurse']=''
|
||||
if index < len(cres):
|
||||
line['nurse']=cres[index]
|
||||
line['no']=no
|
||||
line['nurse']=cres[index]['name']
|
||||
line['nfirst_name']=cres[index]['first_name']
|
||||
nlines.append(line)
|
||||
no+=1
|
||||
if no==count:
|
||||
nlines.append({
|
||||
'sub': 'show',
|
||||
'row_color': '#dfdfdf',
|
||||
'no': count,
|
||||
'fee': sub_fee,
|
||||
'mdc': sub_mdc,
|
||||
})
|
||||
vscl_lines=[]
|
||||
for k,v in vasculars.items():
|
||||
vscl_lines.append({
|
||||
|
@ -198,6 +236,7 @@ class ReportCycleItem(Model):
|
|||
'month': month_str,
|
||||
'date_from': date_from,
|
||||
'date_to': date_to,
|
||||
'total_pt': pt,
|
||||
'total_fee': total_fee,
|
||||
'total_mdc': total_mdc,
|
||||
'total_pt': total_pt,
|
||||
|
|
|
@ -161,15 +161,21 @@ class ClinicSetting(Model):
|
|||
if user_id !=1:
|
||||
print("Only admin!!")
|
||||
return
|
||||
for sline in get_model("clinic.hd.case.staff").search_browse([]):
|
||||
hdcase=sline.hd_case_id
|
||||
sline.write({
|
||||
'date': hdcase.date,
|
||||
for pv in get_model("province").search_browse([]):
|
||||
name=(pv.name or "")[0:1]
|
||||
pv.write({
|
||||
'sort_name': name,
|
||||
})
|
||||
print('update ', sline.id, hdcase.date)
|
||||
#obj=self.browse(ids)[0]
|
||||
#obj.del_duplicate_staff()
|
||||
#obj.merge_staff()
|
||||
#for dt in get_model("district").search_browse([]):
|
||||
#name=(dt.name or "")[0:1]
|
||||
#dt.write({
|
||||
#'sort_name': name,
|
||||
#})
|
||||
#for sdt in get_model("subdistrict").search_browse([]):
|
||||
#name=(sdt.name or "")[0:1]
|
||||
#sdt.write({
|
||||
#'sort_name': name,
|
||||
#})
|
||||
print("Done!")
|
||||
|
||||
def merge_staff(self,ids,context={}):
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
from netforce.model import Model, fields
|
||||
|
||||
class SubDistrict(Model):
|
||||
_inherit="subdistrict"
|
||||
|
||||
def _get_sort_name(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
sname=''
|
||||
if obj.name:
|
||||
sname=obj.name[0:1]
|
||||
res[obj.id]=sname
|
||||
return res
|
||||
|
||||
_fields={
|
||||
"name": fields.Char("Name",required=True,search=True,translate=True),
|
||||
"sort_name": fields.Char("Sort Name",function="_get_sort_name",store=True),
|
||||
}
|
||||
_order="sort_name asc"
|
||||
|
||||
SubDistrict.register()
|
Binary file not shown.
Binary file not shown.
|
@ -4,16 +4,16 @@
|
|||
ระหว่างวันที่ {{date_from}} ถึง {{date_to}}
|
||||
</h4>
|
||||
</center>
|
||||
<table class="table table-condensed table-striped">
|
||||
<table class="table table-condensed table-striped" style="margin-bottom:0px;">
|
||||
<thead>
|
||||
<th>#</th>
|
||||
<th>วันที่</th>
|
||||
<th>รอบ</th>
|
||||
<th>No</th>
|
||||
<th>ชื่อ-สกุล</th>
|
||||
<th>แพทย์</th>
|
||||
<th>สิทธ์</th>
|
||||
<th style="text-align:right">จ.น.เงิน</th>
|
||||
<th>ยาฉีด</th>
|
||||
<th style="text-align:right">ยาฉีด</th>
|
||||
<th>DZ</th>
|
||||
<th>N/U</th>
|
||||
<th>พยาบาล</th>
|
||||
|
@ -22,39 +22,70 @@
|
|||
<tbody>
|
||||
{{#each lines }}
|
||||
{{#if cancel}}
|
||||
<tr style="background-color:#b6b6b6;">
|
||||
<tr class="active">
|
||||
{{else}}
|
||||
<tr>
|
||||
{{/if}}
|
||||
<td>{{no}}</td>
|
||||
<td><a href="/ui#name=clinic_hd_case&active_id={{hdcase_id}}&mode=form">{{date}}</a></td>
|
||||
<td>{{cname}}</td>
|
||||
{{#ifeq sub "show"}}
|
||||
<tr class="info" style="font-weight:bold;">
|
||||
{{/ifeq}}
|
||||
{{#if cseq_txt}}
|
||||
<th>{{date_txt}}</th>
|
||||
<th>{{cseq_txt}}</th>
|
||||
<td style="text-align:center">{{no}}</td>
|
||||
<td><a href="/ui#name=clinic_patient&active_id={{pid}}&mode=form">{{pname}}</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 style="text-align:right">{{fee}}</td>
|
||||
<td style="text-align:right">{{mdc}}</td>
|
||||
<td style="text-align:right">{{currency fee zero=""}}</td>
|
||||
<td style="text-align:right">{{currency mdc zero=""}}</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>
|
||||
<td><a href="/ui#name=clinic_cycle_item&active_id={{ctid}}&mode=form">{{nfirst_name}}</a></td>
|
||||
{{else}}
|
||||
{{#ifeq sub "show"}}
|
||||
<td>รวม</td>
|
||||
{{else}}
|
||||
<td></td>
|
||||
{{/ifeq}}
|
||||
<td></td>
|
||||
<td style="text-align:center">{{no}}</td>
|
||||
<td><a href="/ui#name=clinic_patient&active_id={{pid}}&mode=form">{{pname}}</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 style="text-align:right">{{currency fee zero=""}}</td>
|
||||
<td style="text-align:right">{{currency mdc}}</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">{{nfirst_name}}</a></td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th style="text-align:right">{{currency total_fee zero=""}}</th>
|
||||
<th style="text-align:right">{{currency total_mdc}}</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th class="active">รวมทั้งหมด</th>
|
||||
<th class="active"></th>
|
||||
<th class="active">{{total_pt}}</th>
|
||||
<th class="active"></th>
|
||||
<th class="active"></th>
|
||||
<th class="active"></th>
|
||||
<th class="active" style="text-align:right">{{currency total_fee zero=""}}</th>
|
||||
<th class="active" style="text-align:right">{{currency total_mdc}}</th>
|
||||
<th class="active"></th>
|
||||
<th class="active"></th>
|
||||
<th class="active"></th>
|
||||
</tfoot>
|
||||
</table>
|
||||
<table class="table table-condensed table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
{{#each vscl_lines}}
|
||||
<th style="text-align:right;">{{description}} = </th>
|
||||
<th style="text-align:left">{{qty}}</th>
|
||||
{{/each}}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!--
|
||||
<table class="table table-condensed table-striped">
|
||||
<tr>
|
||||
<td colspan="5" style="width:50%">
|
||||
|
@ -93,3 +124,4 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
-->
|
||||
|
|
Loading…
Reference in New Issue