report cycle item
parent
3d17dbcd72
commit
0c0c79a00b
|
@ -0,0 +1,8 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">Report Cycle Item</field>
|
||||||
|
<field name="view_cls">report</field>
|
||||||
|
<field name="model">clinic.report.cycle.item</field>
|
||||||
|
<field name="report_template">report_cycle_item</field>
|
||||||
|
<field name="report_template_xls">report_cycle_item</field>
|
||||||
|
<field name="menu">clinic_menu</field>
|
||||||
|
</action>
|
|
@ -0,0 +1 @@
|
||||||
|
dom=[['patient_id.field_bool','=',True]] => not working
|
|
@ -26,7 +26,7 @@
|
||||||
</field>
|
</field>
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Validation">
|
<tab string="Validation">
|
||||||
<field name="user_id" span="3"/>
|
<field name="user_id" span="4"/>
|
||||||
<button string="Validate" perm="clinic_cycle_item_validate" type="success" method="validate" icon="ok" size="small" states="draft" />
|
<button string="Validate" perm="clinic_cycle_item_validate" type="success" method="validate" icon="ok" size="small" states="draft" />
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
</group>
|
</group>
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<p></p>
|
<p></p>
|
||||||
<b>Note: </b> HD Case State Accepted: <b style="color:green">'Finish Treatment', 'Waiting Payment', 'Paid'.</b></div>
|
<b>Note: </b>State Accept: <b style="color:green">'Finish Treatment', 'Waiting Payment', 'Paid'.</b></div>
|
||||||
</template>
|
</template>
|
||||||
</group>
|
</group>
|
||||||
</tab>
|
</tab>
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
</head>
|
</head>
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="department_id"/>
|
|
||||||
<field name="branch_id"/>
|
<field name="branch_id"/>
|
||||||
|
<field name="department_id"/>
|
||||||
<field name="nurse_total"/>
|
<field name="nurse_total"/>
|
||||||
<field name="user_id"/>
|
<field name="user_id"/>
|
||||||
<field name="date_validate"/>
|
<field name="date_validate"/>
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
<item string="Sickbed" action="clinic_sickbed"/>
|
<item string="Sickbed" action="clinic_sickbed"/>
|
||||||
</item>
|
</item>
|
||||||
<item string="Reporting" perm="clinic_report">
|
<item string="Reporting" perm="clinic_report">
|
||||||
<!--<item string="Visit Summary" action="clinic_report_visit"/>-->
|
<item string="Cycle Item Summary" action="clinic_report_cycle_item"/>
|
||||||
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
||||||
<item string="Medical Summary" action="clinic_report_medical_summary"/>
|
<item string="Medical Summary" action="clinic_report_medical_summary"/>
|
||||||
<item string="Recent Patient" action="clinic_report_recent_patient"/>
|
<item string="Recent Patient" action="clinic_report_recent_patient"/>
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<field name="categ_id"/>
|
<field name="categ_id"/>
|
||||||
<field name="branch_id" required="1"/>
|
<field name="branch_id" required="1"/>
|
||||||
<field name="department_id" required="1" domain='[["branch_id","=",branch_id]]'/>
|
<field name="department_id" required="1" domain='[["branch_id","=",branch_id]]'/>
|
||||||
<field name="is_walkin"/>
|
<field name="walkin"/>
|
||||||
<field name="active" invisible="1"/>
|
<field name="active" invisible="1"/>
|
||||||
<tabs>
|
<tabs>
|
||||||
<tab string="General">
|
<tab string="General">
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<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_to" span="2"/>
|
||||||
|
<field name="cycle_id" span="2"/>
|
||||||
|
<field name="branch_id" span="2"/>
|
||||||
|
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
|
||||||
|
<group span="6" columns="1">
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<p></p>
|
||||||
|
<b>Note: </b>Cycle Item State Should Be <b style="color:green">'Validated'</b>.
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</group>
|
||||||
|
<group span="6" columns="1">
|
||||||
|
</group>
|
||||||
|
</form>
|
|
@ -64,6 +64,7 @@ from . import load_nurse
|
||||||
from . import load_nurse_line
|
from . import load_nurse_line
|
||||||
from . import report_clinic
|
from . import report_clinic
|
||||||
from . import report_visit
|
from . import report_visit
|
||||||
|
from . import report_cycle_item
|
||||||
from . import report_hd_case_summary
|
from . import report_hd_case_summary
|
||||||
from . import report_hd_case_detail
|
from . import report_hd_case_detail
|
||||||
from . import report_medical_summary
|
from . import report_medical_summary
|
||||||
|
|
|
@ -98,7 +98,10 @@ class CycleItem(Model):
|
||||||
def validate(self,ids,context={}):
|
def validate(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
for hdcase in obj.hd_cases:
|
for hdcase in obj.hd_cases:
|
||||||
if hdcase.state not in ('completed','waiting_payment','paid'):
|
state=hdcase.state
|
||||||
|
if state=='cancelled':
|
||||||
|
continue
|
||||||
|
if state not in ('completed','waiting_payment','paid'):
|
||||||
raise Exception('Invalidate cycle item %s: HD Case %s is not completed' % (obj.name, hdcase.patient_id.name))
|
raise Exception('Invalidate cycle item %s: HD Case %s is not completed' % (obj.name, hdcase.patient_id.name))
|
||||||
for obj_id in ids:
|
for obj_id in ids:
|
||||||
lcost_ids=get_model("clinic.labor.cost").search([['cycle_item_id','=',obj_id]])
|
lcost_ids=get_model("clinic.labor.cost").search([['cycle_item_id','=',obj_id]])
|
||||||
|
@ -148,7 +151,7 @@ class CycleItem(Model):
|
||||||
nurse_id=line['nurse_id']
|
nurse_id=line['nurse_id']
|
||||||
nurse=get_model('clinic.staff').browse(nurse_id)
|
nurse=get_model('clinic.staff').browse(nurse_id)
|
||||||
line['level_id']=nurse.level_id.id
|
line['level_id']=nurse.level_id.id
|
||||||
line['categ_id']=nurse.categ_id #XXX
|
line['categ_id']=nurse.categ_id.id
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def view_schedule(self,ids,context={}):
|
def view_schedule(self,ids,context={}):
|
||||||
|
|
|
@ -132,7 +132,7 @@ class Patient(Model):
|
||||||
'cycles': fields.One2Many("clinic.patient.cycle","patient_id", "Cycles"),
|
'cycles': fields.One2Many("clinic.patient.cycle","patient_id", "Cycles"),
|
||||||
"vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."),
|
"vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."),
|
||||||
'state': fields.Selection([['admit','Admit'],['dispose','Dispose']],'State'),
|
'state': fields.Selection([['admit','Admit'],['dispose','Dispose']],'State'),
|
||||||
'is_walkin': fields.Boolean("Walk In"),
|
'walkin': fields.Selection([['yes','Yes'],['no','No']],"Walk In"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_number(self,context={}):
|
def _get_number(self,context={}):
|
||||||
|
@ -180,6 +180,7 @@ class Patient(Model):
|
||||||
'type_id': _get_type,
|
'type_id': _get_type,
|
||||||
"active" : True,
|
"active" : True,
|
||||||
'state': 'admit',
|
'state': 'admit',
|
||||||
|
'walkin': 'no',
|
||||||
}
|
}
|
||||||
|
|
||||||
_sql_constraints=("clinic_patient_key_uniq","unique(name_check,branch_id)","name should be unique"),
|
_sql_constraints=("clinic_patient_key_uniq","unique(name_check,branch_id)","name should be unique"),
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
import time
|
||||||
|
|
||||||
|
from netforce.model import Model,fields,get_model
|
||||||
|
from netforce.access import get_active_company
|
||||||
|
|
||||||
|
from . import utils
|
||||||
|
|
||||||
|
class ReportCycleItem(Model):
|
||||||
|
_name="clinic.report.cycle.item"
|
||||||
|
_string="Report Cycle Item"
|
||||||
|
_transient=True
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
"date": fields.Date("Month"),
|
||||||
|
"date_from": fields.Date("From", required=True),
|
||||||
|
"date_to": fields.Date("To", required=True),
|
||||||
|
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
||||||
|
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||||
|
'department_id': fields.Many2One("clinic.department","Department"),
|
||||||
|
}
|
||||||
|
|
||||||
|
def default_get(self,field_names=None,context={},**kw):
|
||||||
|
defaults=context.get("defaults",{})
|
||||||
|
date=defaults.get('date',time.strftime("%Y-%m-%d"))
|
||||||
|
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))
|
||||||
|
res={
|
||||||
|
'date': date,
|
||||||
|
'date_from': date_from,
|
||||||
|
'date_to': date_to,
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
|
def get_report_data(self,ids,context={}):
|
||||||
|
company_id=get_active_company()
|
||||||
|
company=get_model('company').browse(company_id)
|
||||||
|
defaults=self.default_get(context=context)
|
||||||
|
date_from=defaults.get("date_from")
|
||||||
|
date_to=defaults.get("date_to")
|
||||||
|
month=date_from.split("-")[1]
|
||||||
|
branch_id=None
|
||||||
|
department_id=None
|
||||||
|
cycle_id=None
|
||||||
|
if ids:
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
month=obj.date_from.split("-")[1]
|
||||||
|
date_from=obj.date_from
|
||||||
|
date_to=obj.date_to
|
||||||
|
branch_id=obj.branch_id.id
|
||||||
|
department_id=obj.department_id.id
|
||||||
|
cycle_id=obj.cycle_id.id
|
||||||
|
# new patient of this month
|
||||||
|
dom=[]
|
||||||
|
dom.append(['date','>=',date_from])
|
||||||
|
dom.append(['date','<=',date_to])
|
||||||
|
dom.append(['state','=','validated'])
|
||||||
|
if cycle_id:
|
||||||
|
dom.append(['cycle_id','=',cycle_id])
|
||||||
|
if branch_id:
|
||||||
|
dom.append(['branch_id','=',branch_id])
|
||||||
|
if department_id:
|
||||||
|
dom.append(['department_id','=',department_id])
|
||||||
|
no=1
|
||||||
|
lines=[]
|
||||||
|
for citem in get_model('clinic.cycle.item').search_browse(dom):
|
||||||
|
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
|
||||||
|
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,
|
||||||
|
'cname': cycle.name or '',
|
||||||
|
'cid': 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:
|
||||||
|
department=get_model("clinic.department").browse(department_id)
|
||||||
|
company_name+=" ("+department.name+")"
|
||||||
|
elif branch_id:
|
||||||
|
branch=get_model("clinic.branch").browse(branch_id)
|
||||||
|
company_name+=" ("+branch.name+")"
|
||||||
|
data={
|
||||||
|
'company_name': company_name or "",
|
||||||
|
'lines': lines,
|
||||||
|
'month': month_str,
|
||||||
|
'date_from': date_from,
|
||||||
|
'date_to': date_to,
|
||||||
|
}
|
||||||
|
return data
|
||||||
|
|
||||||
|
def onchange_date(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
date=data['date']
|
||||||
|
year,month,day=date.split("-")
|
||||||
|
weekday, total_day=monthrange(int(year), int(month))
|
||||||
|
data['date_from']="%s-%s-01"%(year,month)
|
||||||
|
data['date_to']="%s-%s-%s"%(year,month,total_day)
|
||||||
|
return data
|
||||||
|
|
||||||
|
ReportCycleItem.register()
|
|
@ -87,11 +87,11 @@ class ReportHDCaseSummary(Model):
|
||||||
dom.append(["time_start",">=",time_start])
|
dom.append(["time_start",">=",time_start])
|
||||||
dom.append(["time_stop","<=",time_stop])
|
dom.append(["time_stop","<=",time_stop])
|
||||||
dom.append(["state","in",["completed","waiting_payment","paid"]])
|
dom.append(["state","in",["completed","waiting_payment","paid"]])
|
||||||
|
dom.append(['patient_id.walkin','=','no'])
|
||||||
if branch_id:
|
if branch_id:
|
||||||
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])
|
||||||
print('>> dom ', dom)
|
|
||||||
crr_total=len(get_model("clinic.hd.case").search(dom))
|
crr_total=len(get_model("clinic.hd.case").search(dom))
|
||||||
items={}
|
items={}
|
||||||
items['topic%s'%count]={
|
items['topic%s'%count]={
|
||||||
|
|
|
@ -136,34 +136,12 @@ class ClinicSetting(Model):
|
||||||
if user_id !=1:
|
if user_id !=1:
|
||||||
print("Only admin!!")
|
print("Only admin!!")
|
||||||
return
|
return
|
||||||
#obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
#obj.update_staff_department()
|
#obj.update_staff_department()
|
||||||
#obj.remove_rotation()
|
#obj.remove_rotation()
|
||||||
#obj.update_staff_level()
|
obj.update_staff_level()
|
||||||
#obj.update_cycle_item_level()
|
#obj.update_cycle_item_level()
|
||||||
for st in get_model("clinic.staff").search_browse([]):
|
|
||||||
st.write({
|
|
||||||
'note': ' ',
|
|
||||||
})
|
|
||||||
print("Done!")
|
print("Done!")
|
||||||
return
|
|
||||||
|
|
||||||
lines=[]
|
|
||||||
for pt in get_model("clinic.patient").search_browse([['state','=','admit']]):
|
|
||||||
partner_id=None
|
|
||||||
if pt.partner_id:
|
|
||||||
partner_id=pt.partner_id.id
|
|
||||||
vals={
|
|
||||||
'patient_id': pt.id,
|
|
||||||
'partner_id': partner_id,
|
|
||||||
'type_id': pt.type_id.id,
|
|
||||||
}
|
|
||||||
lines.append(('create',vals))
|
|
||||||
obj=self.browse(ids)[0]
|
|
||||||
obj.write({
|
|
||||||
'account_patients': lines,
|
|
||||||
})
|
|
||||||
return
|
|
||||||
|
|
||||||
def update_staff_department(self,ids,context={}):
|
def update_staff_department(self,ids,context={}):
|
||||||
user_id=get_active_user()
|
user_id=get_active_user()
|
||||||
|
@ -198,17 +176,6 @@ class ClinicSetting(Model):
|
||||||
if user_id !=1:
|
if user_id !=1:
|
||||||
print("Only admin!!")
|
print("Only admin!!")
|
||||||
return
|
return
|
||||||
for citem in get_model("clinic.cycle.item").search_browse([]):
|
|
||||||
for line in citem.lines:
|
|
||||||
nurse=line.nurse_id
|
|
||||||
categ_id=nurse.categ_id.id
|
|
||||||
level_id=nurse.level_id
|
|
||||||
line.write({
|
|
||||||
'categ_id': categ_id,
|
|
||||||
'level_id': level_id,
|
|
||||||
})
|
|
||||||
print("Done!")
|
|
||||||
return
|
|
||||||
# run below before above!
|
# run below before above!
|
||||||
import csv
|
import csv
|
||||||
f=open("/tmp/update_rotation.csv","r")
|
f=open("/tmp/update_rotation.csv","r")
|
||||||
|
@ -236,8 +203,21 @@ class ClinicSetting(Model):
|
||||||
'level_id': level_id,
|
'level_id': level_id,
|
||||||
'categ_id': categ_id,
|
'categ_id': categ_id,
|
||||||
})
|
})
|
||||||
#print(line)
|
|
||||||
|
|
||||||
|
#force update level, category store
|
||||||
|
for staff in get_model("clinic.staff").search_browse([]):
|
||||||
|
staff.write({
|
||||||
|
'note': ' ',
|
||||||
|
})
|
||||||
|
for citem in get_model("clinic.cycle.item").search_browse([]):
|
||||||
|
for line in citem.lines:
|
||||||
|
nurse=line.nurse_id
|
||||||
|
categ_id=nurse.categ_id
|
||||||
|
level_id=nurse.level_id
|
||||||
|
line.write({
|
||||||
|
'categ_id': categ_id.id,
|
||||||
|
'level_id': level_id.id,
|
||||||
|
})
|
||||||
print("Done!")
|
print("Done!")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,41 @@
|
||||||
|
<center>
|
||||||
|
<h2>สรุปรอบการรักษา</h2>
|
||||||
|
<h3>
|
||||||
|
{{company_name}}<br/>
|
||||||
|
</h3>
|
||||||
|
<h4>
|
||||||
|
ระหว่างวันที่ {{date_from}} ถึง {{date_to}}
|
||||||
|
</h4>
|
||||||
|
</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>EPO</th>
|
||||||
|
<th>HCT</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_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>{{epo}}</td>
|
||||||
|
<td>{{hct}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
|
@ -17,8 +17,17 @@ todo:
|
||||||
- sickbed
|
- sickbed
|
||||||
- staff
|
- staff
|
||||||
- staff rotation : only manager nurse
|
- staff rotation : only manager nurse
|
||||||
|
- reports
|
||||||
|
- P Moo cycle item
|
||||||
|
- P อ้วน
|
||||||
|
- patient
|
||||||
|
- update
|
||||||
|
- new feature
|
||||||
|
- slit invoice (fee & another)
|
||||||
|
- schedule job
|
||||||
|
- create visit next month
|
||||||
- run script
|
- run script
|
||||||
- update level's nurse
|
- update level's nurse -> ok
|
||||||
- report k. boy (sub detail) -> ok
|
- report k. boy (sub detail) -> ok
|
||||||
- ** update accounting
|
- ** update accounting
|
||||||
- link ref -> ok
|
- link ref -> ok
|
||||||
|
|
Loading…
Reference in New Issue