labor cost and search patient type
parent
9abb3c8e0e
commit
d3a5cb86e2
|
@ -0,0 +1,8 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">Report Staff</field>
|
||||||
|
<field name="view_cls">multi_view</field>
|
||||||
|
<field name="model">clinic.report.staff</field>
|
||||||
|
<field name="modes">list,form</field>
|
||||||
|
<field name="menu">account_menu</field>
|
||||||
|
<field name="limit">25</field>
|
||||||
|
</action>
|
|
@ -22,7 +22,16 @@
|
||||||
<separator string="Doctor"/>
|
<separator string="Doctor"/>
|
||||||
<field name="cost_per_case"/>
|
<field name="cost_per_case"/>
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Importing">
|
<tab string="Products">
|
||||||
|
<field name="account_products" nolabel="1">
|
||||||
|
<list>
|
||||||
|
<field name="product_id"/>
|
||||||
|
<field name="ar_debit_id"/>
|
||||||
|
<field name="ar_credit_id"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</tab>
|
||||||
|
<tab string="Matching Payment">
|
||||||
<field name="patient_type_id"/>
|
<field name="patient_type_id"/>
|
||||||
<field name="imp_patient_type_id"/>
|
<field name="imp_patient_type_id"/>
|
||||||
</tab>
|
</tab>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<field name="date"/>
|
<field name="date"/>
|
||||||
<field name="cycle_id"/>
|
<field name="cycle_id"/>
|
||||||
<field name="patient_id"/>
|
<field name="patient_id"/>
|
||||||
|
<field name="patient_type_id"/>
|
||||||
<field name="department_id"/>
|
<field name="department_id"/>
|
||||||
<field name="branch_id"/>
|
<field name="branch_id"/>
|
||||||
</search>
|
</search>
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
<field name="qty" onchange="onchange_line"/>
|
<field name="qty" onchange="onchange_line"/>
|
||||||
<field name="rate" onchange="onchange_line"/>
|
<field name="rate" onchange="onchange_line"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
|
<field name="report_staff_id"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
<field name="dcost" string="Total" span="3" offset="9"/>
|
<field name="dcost" string="Total" span="3" offset="9"/>
|
||||||
|
@ -37,6 +38,7 @@
|
||||||
<field name="qty" string="PT" onchange="onchange_line"/>
|
<field name="qty" string="PT" onchange="onchange_line"/>
|
||||||
<field name="rate" onchange="onchange_line"/>
|
<field name="rate" onchange="onchange_line"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
|
<field name="report_staff_id"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
<field name="ncost" string="Total" span="3" offset="9"/>
|
<field name="ncost" string="Total" span="3" offset="9"/>
|
||||||
|
|
|
@ -47,8 +47,8 @@
|
||||||
<field name="description"/>
|
<field name="description"/>
|
||||||
<field name="level_id"/>
|
<field name="level_id"/>
|
||||||
<field name="state"/>
|
<field name="state"/>
|
||||||
<field name="qty" onchange="onchange_cost_line"/>
|
<!--<field name="qty" onchange="onchange_cost_line"/>-->
|
||||||
<field name="rate" onchange="onchange_cost_line"/>
|
<!--<field name="rate" onchange="onchange_cost_line"/>-->
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
<item string="HD Case Expenses" action="clinic_hd_case_expense"/>
|
<item string="HD Case Expenses" action="clinic_hd_case_expense"/>
|
||||||
<divider/>
|
<divider/>
|
||||||
<header string="REPORTS"/>
|
<header string="REPORTS"/>
|
||||||
|
<item string="Staff" action="clinic_report_staff"/>
|
||||||
<item string="Staff Fee" action="clinic_report_staff_fee"/>
|
<item string="Staff Fee" action="clinic_report_staff_fee"/>
|
||||||
<item string="Staff Fee Detail" action="clinic_report_staff_fee_detail"/>
|
<item string="Staff Fee Detail" action="clinic_report_staff_fee_detail"/>
|
||||||
<item string="Staff Fee Summary" action="clinic_report_staff_fee_sum"/>
|
<item string="Staff Fee Summary" action="clinic_report_staff_fee_sum"/>
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<form model="clinic.report.staff">
|
||||||
|
<head>
|
||||||
|
<button string="Print" icon="print"/>
|
||||||
|
<button string="Options" dropdown="1">
|
||||||
|
<item string="TODO"/>
|
||||||
|
</button>
|
||||||
|
</head>
|
||||||
|
<group form_layout="stacked">
|
||||||
|
<field name="date_from" span="3"/>
|
||||||
|
<field name="date_to" span="3"/>
|
||||||
|
<field name="staff_id" span="3"/>
|
||||||
|
</group>
|
||||||
|
<field name="lines" nolabel="1">
|
||||||
|
<list>
|
||||||
|
<field name="hd_case_id"/>
|
||||||
|
</list>
|
||||||
|
</field>
|
||||||
|
</form>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<list model="clinic.report.staff">
|
||||||
|
<field name="date_from"/>
|
||||||
|
<field name="date_to"/>
|
||||||
|
<field name="staff_id"/>
|
||||||
|
<field name="hdcase_total"/>
|
||||||
|
</list>
|
|
@ -1,6 +1,7 @@
|
||||||
from . import utils
|
from . import utils
|
||||||
from . import setting
|
from . import setting
|
||||||
from . import fin_setting
|
from . import fin_setting
|
||||||
|
from . import setting_account_product
|
||||||
from . import setting_product
|
from . import setting_product
|
||||||
from . import setting_level
|
from . import setting_level
|
||||||
from . import setting_policy
|
from . import setting_policy
|
||||||
|
@ -62,6 +63,8 @@ from . import report_hd_case_summary
|
||||||
from . import report_medical_summary
|
from . import report_medical_summary
|
||||||
from . import report_recent_patient
|
from . import report_recent_patient
|
||||||
from . import report_discontinue_patient
|
from . import report_discontinue_patient
|
||||||
|
from . import report_staff
|
||||||
|
from . import report_staff_line
|
||||||
from . import report_staff_fee
|
from . import report_staff_fee
|
||||||
from . import report_staff_fee_detail
|
from . import report_staff_fee_detail
|
||||||
from . import report_staff_fee_sum
|
from . import report_staff_fee_sum
|
||||||
|
|
|
@ -78,7 +78,7 @@ class HDCase(Model):
|
||||||
"time_stop": fields.DateTime("Finish Time",required=True),
|
"time_stop": fields.DateTime("Finish Time",required=True),
|
||||||
"date": fields.Date("Date",required=True,search=True),
|
"date": fields.Date("Date",required=True,search=True),
|
||||||
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
|
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
|
||||||
"patient_type_id": fields.Many2One("clinic.patient.type", "Type",function="_get_patient_type"),
|
"patient_type_id": fields.Many2One("clinic.patient.type", "Type"),
|
||||||
"nurse_id": fields.Many2One("clinic.staff","Approve By", domain=[['type','=','nurse']]),
|
"nurse_id": fields.Many2One("clinic.staff","Approve By", domain=[['type','=','nurse']]),
|
||||||
"department_id": fields.Many2One("clinic.department", "Department",search=True),
|
"department_id": fields.Many2One("clinic.department", "Department",search=True),
|
||||||
"wt_start": fields.Float("Start Wt (kg.)"),
|
"wt_start": fields.Float("Start Wt (kg.)"),
|
||||||
|
@ -983,8 +983,8 @@ class HDCase(Model):
|
||||||
vals['lines']=[]
|
vals['lines']=[]
|
||||||
for st_prod in st.products:
|
for st_prod in st.products:
|
||||||
if patient.type_id.id==st_prod.patient_type_id.id:
|
if patient.type_id.id==st_prod.patient_type_id.id:
|
||||||
price=st_prod.price
|
price=st_prod.price or 0
|
||||||
qty=st_prod.qty
|
qty=st_prod.qty or 0
|
||||||
amt=st_prod.amount
|
amt=st_prod.amount
|
||||||
categ=st_prod.product_categ_id
|
categ=st_prod.product_categ_id
|
||||||
account_id=st_prod.ar_credit_id.id
|
account_id=st_prod.ar_credit_id.id
|
||||||
|
|
|
@ -394,12 +394,20 @@ class LaborCost(Model):
|
||||||
def update_amt(self,context):
|
def update_amt(self,context):
|
||||||
total=0.0
|
total=0.0
|
||||||
data=context['data']
|
data=context['data']
|
||||||
for line in data['lines']:
|
for line in data['doctor_lines']:
|
||||||
qty=line['qty'] or 0
|
qty=line['qty'] or 0
|
||||||
rate=line['rate'] or 0.0
|
rate=line['rate'] or 0.0
|
||||||
amt=qty*rate
|
amt=qty*rate
|
||||||
total+=amt
|
total+=amt
|
||||||
data['total_cost']=total
|
data['total_dcost']=total
|
||||||
|
for line in data['nurse_lines']:
|
||||||
|
#qty=line['qty'] or 0
|
||||||
|
#rate=line['rate'] or 0.0
|
||||||
|
#amt=qty*rate
|
||||||
|
amt=line['amount'] or 0.0
|
||||||
|
total+=amt
|
||||||
|
data['total_ncost']=total
|
||||||
|
data['total']=total
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def create(self,vals,**kw):
|
def create(self,vals,**kw):
|
||||||
|
|
|
@ -101,18 +101,28 @@ class LaborCostEntry(Model):
|
||||||
amt=line.amount
|
amt=line.amount
|
||||||
state=line.state or staff.state
|
state=line.state or staff.state
|
||||||
dpt=staff.department_id
|
dpt=staff.department_id
|
||||||
|
citem=line.labor_cost_id.cycle_item_id
|
||||||
if not dpt:
|
if not dpt:
|
||||||
dpt=line.labor_cost_id.cycle_item_id.department_id
|
dpt=citem.department_id
|
||||||
if not staffs.get(staff.id):
|
if not staffs.get(staff.id):
|
||||||
staffs[staff.id]={
|
staffs[staff.id]={
|
||||||
|
'staff_type': staff.type,
|
||||||
'department_id': dpt.id,
|
'department_id': dpt.id,
|
||||||
'qty': 0,
|
'qty': 0,
|
||||||
'amt': 0,
|
'amt': 0,
|
||||||
'rate': 0, # XXX for special nurse
|
'rate': 0, # XXX for special nurse
|
||||||
'state': state,
|
'state': state,
|
||||||
|
'report_staff_id': get_model("clinic.report.staff").create({
|
||||||
|
'date_from': obj.date_from,
|
||||||
|
'date_to': obj.date_to,
|
||||||
|
'staff_id': staff.id,
|
||||||
|
}),
|
||||||
|
'items': set(),
|
||||||
}
|
}
|
||||||
|
# create staff report
|
||||||
staffs[staff.id]['qty']+=qty
|
staffs[staff.id]['qty']+=qty
|
||||||
staffs[staff.id]['amt']+=amt
|
staffs[staff.id]['amt']+=amt
|
||||||
|
staffs[staff.id]['items'].update({citem.id})
|
||||||
|
|
||||||
lines=[]
|
lines=[]
|
||||||
timenow=time.strftime("%Y-%m-%d")
|
timenow=time.strftime("%Y-%m-%d")
|
||||||
|
@ -120,6 +130,29 @@ class LaborCostEntry(Model):
|
||||||
qty=vals['qty'] or 0
|
qty=vals['qty'] or 0
|
||||||
amt=vals['amt'] or 0.0
|
amt=vals['amt'] or 0.0
|
||||||
state=vals['state']
|
state=vals['state']
|
||||||
|
report_staff_id=vals['report_staff_id']
|
||||||
|
report_staff=get_model("clinic.report.staff").browse(report_staff_id)
|
||||||
|
# find hd case for each staff
|
||||||
|
hids=set()
|
||||||
|
for item in get_model("clinic.cycle.item").browse(vals['items']):
|
||||||
|
if vals['staff_type']=='nurse':
|
||||||
|
for hd_case in item.hd_cases:
|
||||||
|
hids.update({hd_case.id})
|
||||||
|
else:
|
||||||
|
for hd_case in item.hd_cases:
|
||||||
|
doctor_id=hd_case.doctor_id.id
|
||||||
|
if staff_id==doctor_id:
|
||||||
|
hids.update({hd_case.id})
|
||||||
|
rlines=[]
|
||||||
|
for hid in list(hids):
|
||||||
|
rlines.append(('create',{
|
||||||
|
'hd_case_id': hid,
|
||||||
|
}))
|
||||||
|
report_staff.write({
|
||||||
|
'lines': rlines,
|
||||||
|
})
|
||||||
|
#####
|
||||||
|
|
||||||
rate=0.0
|
rate=0.0
|
||||||
if qty:
|
if qty:
|
||||||
rate=amt/qty # average
|
rate=amt/qty # average
|
||||||
|
@ -131,6 +164,7 @@ class LaborCostEntry(Model):
|
||||||
'rate': rate,
|
'rate': rate,
|
||||||
'state': state,
|
'state': state,
|
||||||
'department_id': vals['department_id'],
|
'department_id': vals['department_id'],
|
||||||
|
'report_staff_id': report_staff.id,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
for line in obj.lines:
|
for line in obj.lines:
|
||||||
|
|
|
@ -19,6 +19,7 @@ class LaborCostEntryLine(Model):
|
||||||
'department_id': fields.Many2One("clinic.department","Department"),
|
'department_id': fields.Many2One("clinic.department","Department"),
|
||||||
"type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type"),
|
"type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type"),
|
||||||
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
|
"state": fields.Selection([["part_time","Part Time"],["full_time","Full Time"]],"Working Status",search=True),
|
||||||
|
'report_staff_id': fields.Many2One("clinic.report.staff","#"),
|
||||||
}
|
}
|
||||||
|
|
||||||
_order="type"
|
_order="type"
|
||||||
|
@ -34,4 +35,11 @@ class LaborCostEntryLine(Model):
|
||||||
new_id=super().create(vals,**kw)
|
new_id=super().create(vals,**kw)
|
||||||
return new_id
|
return new_id
|
||||||
|
|
||||||
|
def delete(self,ids):
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
report=obj.report_staff_id
|
||||||
|
if report:
|
||||||
|
report.delete()
|
||||||
|
super().delete(ids)
|
||||||
|
|
||||||
LaborCostEntryLine.register()
|
LaborCostEntryLine.register()
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
from netforce.model import Model, fields
|
||||||
|
|
||||||
|
class ReportStaff(Model):
|
||||||
|
_name='clinic.report.staff'
|
||||||
|
_string="Report Staff"
|
||||||
|
|
||||||
|
def _get_store(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
total=len(obj.lines)
|
||||||
|
res[obj.id]={
|
||||||
|
'name': total,
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
|
def _get_all(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
total=len(obj.lines)
|
||||||
|
res[obj.id]={
|
||||||
|
'hdcase_total': total,
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
'staff_id': fields.Many2One("clinic.staff",'Staff'),
|
||||||
|
'name': fields.Char("Name", function="_get_store",function_multi=True,store=True),
|
||||||
|
'date_from': fields.Date("From"),
|
||||||
|
'date_to': fields.Date("To"),
|
||||||
|
'hdcase_total': fields.Char("Total", function="_get_all",function_multi=True),
|
||||||
|
'lines': fields.One2Many("clinic.report.staff.line","report_staff_id","Lines"),
|
||||||
|
}
|
||||||
|
|
||||||
|
def create(self,vals,**kw):
|
||||||
|
id=super().create(vals,**kw)
|
||||||
|
self.function_store([id])
|
||||||
|
return id
|
||||||
|
|
||||||
|
def write(self,ids,vals,**kw):
|
||||||
|
super().write(ids,vals,**kw)
|
||||||
|
self.function_store(ids)
|
||||||
|
|
||||||
|
ReportStaff.register()
|
|
@ -0,0 +1,11 @@
|
||||||
|
from netforce.model import Model, fields
|
||||||
|
|
||||||
|
class ReportStaffLine(Model):
|
||||||
|
_name='clinic.report.staff.line'
|
||||||
|
_string="Report Staff Line"
|
||||||
|
_fields={
|
||||||
|
'report_staff_id': fields.Many2One("clinic.report.staff","Report Staff", required=True, on_delete="cascade"),
|
||||||
|
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case"),
|
||||||
|
}
|
||||||
|
|
||||||
|
ReportStaffLine.register()
|
|
@ -12,6 +12,7 @@ class ClinicSetting(Model):
|
||||||
'file': fields.File("File"),
|
'file': fields.File("File"),
|
||||||
'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"),
|
'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"),
|
||||||
'products': fields.One2Many("clinic.setting.product","setting_id","Products"),
|
'products': fields.One2Many("clinic.setting.product","setting_id","Products"),
|
||||||
|
'account_products': fields.One2Many("clinic.setting.account.product","setting_id","Account Products"),
|
||||||
'invoice_policies': fields.One2Many("clinic.setting.policy","setting_id","Invoice Policies"),
|
'invoice_policies': fields.One2Many("clinic.setting.policy","setting_id","Invoice Policies"),
|
||||||
'cost_per_case': fields.Float("Cost Per Case"),
|
'cost_per_case': fields.Float("Cost Per Case"),
|
||||||
'company_id': fields.Many2One("company", 'Company'),
|
'company_id': fields.Many2One("company", 'Company'),
|
||||||
|
@ -101,23 +102,13 @@ class ClinicSetting(Model):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def run_script(self,ids,context={}):
|
def run_script(self,ids,context={}):
|
||||||
for hdcase in get_model("clinic.hd.case").search_browse([]):
|
count=1
|
||||||
mt=hdcase.membrane_type
|
for hd_case in get_model("clinic.hd.case").search_browse([]):
|
||||||
for dlz in hdcase.dialyzers:
|
hd_case.write({
|
||||||
dlz2=dlz.dialyzer_id
|
'patient_type_id': hd_case.patient_id.type_id.id,
|
||||||
dlz2.write({
|
})
|
||||||
'membrane_type': mt,
|
print(count, " update ", hd_case.patient_id.type_id.id)
|
||||||
})
|
count+=1
|
||||||
for pt in get_model("clinic.patient").search_browse([]):
|
|
||||||
count=0
|
|
||||||
for hdcase in pt.hd_cases:
|
|
||||||
if count > 1:
|
|
||||||
break
|
|
||||||
if hdcase.vascular_acc:
|
|
||||||
pt.write({
|
|
||||||
'vascular_acc': hdcase.vascular_acc.id,
|
|
||||||
})
|
|
||||||
count+=1
|
|
||||||
print("Done! ")
|
print("Done! ")
|
||||||
|
|
||||||
def reset_last_import(self,ids,context={}):
|
def reset_last_import(self,ids,context={}):
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
from netforce.model import Model, fields
|
||||||
|
from netforce.access import get_active_company
|
||||||
|
|
||||||
|
class SettingAccountProduct(Model):
|
||||||
|
_name="clinic.setting.account.product"
|
||||||
|
_string="Setting Account Product"
|
||||||
|
_multi_company=True
|
||||||
|
|
||||||
|
_fields={
|
||||||
|
"setting_id": fields.Many2One("clinic.setting","Setting",required=True,on_delete="cascade"),
|
||||||
|
"product_id": fields.Many2One("product","Product"),
|
||||||
|
"ar_credit_id": fields.Many2One("account.account","AR Credit",multi_company=True),
|
||||||
|
"ar_debit_id": fields.Many2One("account.account","AR Debit",multi_company=True),
|
||||||
|
'company_id': fields.Many2One("company","Company"),
|
||||||
|
}
|
||||||
|
|
||||||
|
_defaults={
|
||||||
|
"company_id": lambda *a: get_active_company(),
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingAccountProduct.register()
|
|
@ -161,6 +161,7 @@ class Visit(Model):
|
||||||
hd_case_obj=get_model("clinic.hd.case")
|
hd_case_obj=get_model("clinic.hd.case")
|
||||||
vals={
|
vals={
|
||||||
'patient_id': obj.patient_id.id,
|
'patient_id': obj.patient_id.id,
|
||||||
|
'patient_type_id': obj.patient_id.type_id.id,
|
||||||
'vascular_acc': obj.patient_id.vascular_acc.id,
|
'vascular_acc': obj.patient_id.vascular_acc.id,
|
||||||
'nurse_id': obj.nurse_id.id,
|
'nurse_id': obj.nurse_id.id,
|
||||||
'department_id': obj.department_id.id,
|
'department_id': obj.department_id.id,
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
todo:
|
todo:
|
||||||
- accounting
|
- accounting
|
||||||
|
- labor cost
|
||||||
|
- report ***
|
||||||
- invoice line -> account -> credit
|
- invoice line -> account -> credit
|
||||||
- debit from hd case setting
|
- debit from hd case setting
|
||||||
- if user select product by them self
|
- if user select product by them self
|
||||||
|
|
Loading…
Reference in New Issue