improve
parent
d2eb5f3d26
commit
bde8db41c2
|
@ -1,7 +0,0 @@
|
||||||
<action>
|
|
||||||
<field name="string">Social Security</field>
|
|
||||||
<field name="view_cls">multi_view</field>
|
|
||||||
<field name="tabs">[["All",[]],["Match",[["type","=","match"]]],["Not Match",[["type","=","not_match"]]]]</field>
|
|
||||||
<field name="model">clinic.data.sc</field>
|
|
||||||
<field name="menu">account_menu</field>
|
|
||||||
</action>
|
|
|
@ -1,7 +0,0 @@
|
||||||
<action>
|
|
||||||
<field name="string">NHSO</field>
|
|
||||||
<field name="view_cls">multi_view</field>
|
|
||||||
<field name="tabs">[["All",[]],["Success",[["type","=","success"]]],["Fail",[["type","=","fail"]]]]</field>
|
|
||||||
<field name="model">clinic.data.nhso</field>
|
|
||||||
<field name="menu">account_menu</field>
|
|
||||||
</action>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<action>
|
|
||||||
<field name="string">HD Case Daily</field>
|
|
||||||
<field name="view_cls">report</field>
|
|
||||||
<field name="model">clinic.hd.case.daily</field>
|
|
||||||
<field name="report_template">hd_case_daily</field>
|
|
||||||
<field name="report_template_xls">hd_case_daily</field>
|
|
||||||
<field name="menu">clinic_menu</field>
|
|
||||||
</action>
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<action>
|
||||||
|
<field name="string">Expenses</field>
|
||||||
|
<field name="view_cls">multi_view</field>
|
||||||
|
<field name="model">clinic.hd.case.expense</field>
|
||||||
|
<field name="menu">clinic_menu</field>
|
||||||
|
</action>
|
|
@ -2,7 +2,7 @@
|
||||||
<field name="string">Visits</field>
|
<field name="string">Visits</field>
|
||||||
<field name="view_cls">multi_view</field>
|
<field name="view_cls">multi_view</field>
|
||||||
<field name="model">clinic.visit</field>
|
<field name="model">clinic.visit</field>
|
||||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
|
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Pending",[["state","=","pending"]]],["Confirmed",[["state","=","confirmed"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
|
||||||
<field name="modes">list,form,calendar</field>
|
<field name="modes">list,form,calendar</field>
|
||||||
<field name="menu">clinic_menu</field>
|
<field name="menu">clinic_menu</field>
|
||||||
<field name="limit">25</field>
|
<field name="limit">25</field>
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<form model="clinic.hd.case.expense" attrs='{"readonly":[["state","=","approved"]]}'>
|
||||||
|
<head>
|
||||||
|
<field name="state"/>
|
||||||
|
<button string="Options" dropdown="1">
|
||||||
|
<item string="To Draft" method="to_draft" states="approved"/>
|
||||||
|
</button>
|
||||||
|
</head>
|
||||||
|
<group span="6" columns="1">
|
||||||
|
<field name="date"/>
|
||||||
|
<field name="hd_case_id"/>
|
||||||
|
<field name="payment_id"/>
|
||||||
|
<field name="invoice_id"/>
|
||||||
|
</group>
|
||||||
|
<group span="6" columns="1">
|
||||||
|
<field name="patient_id"/>
|
||||||
|
<field name="amount"/>
|
||||||
|
<field name="match"/>
|
||||||
|
</group>
|
||||||
|
<foot>
|
||||||
|
<button string="Approve" type="success" method="approve" icon="ok" states="draft"/>
|
||||||
|
</foot>
|
||||||
|
</form>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<list model="clinic.hd.case.expense" colors='{"#cfc":[["state","=","approved"]],"#dbdbdb":[["state","=","cancelled"]]}'>
|
||||||
|
<field name="date"/>
|
||||||
|
<field name="invoice_id"/>
|
||||||
|
<field name="payment_id"/>
|
||||||
|
<field name="patient_id"/>
|
||||||
|
<field name="amount"/>
|
||||||
|
<field name="match"/>
|
||||||
|
<field name="state"/>
|
||||||
|
</list>
|
|
@ -33,14 +33,13 @@
|
||||||
<field name="dialyzers" nolabel="1">
|
<field name="dialyzers" nolabel="1">
|
||||||
<list>
|
<list>
|
||||||
<field name="dialyzer_id" domain="[['patient_id','=',parent.patient_id],['state','=','active']]" onchange="onchange_dialyzer"/>
|
<field name="dialyzer_id" domain="[['patient_id','=',parent.patient_id],['state','=','active']]" onchange="onchange_dialyzer"/>
|
||||||
<field name="description"/>
|
<field name="description" readonly="1"/>
|
||||||
<field name="use_time"/>
|
<field name="use_time" readonly="1"/>
|
||||||
<field name="max_use_time"/>
|
<field name="max_use_time" readonly="1"/>
|
||||||
<field name="member_type"/>
|
<field name="member_type" readonly="1"/>
|
||||||
<field name="dialyzer_type"/>
|
<field name="dialyzer_type" readonly="1"/>
|
||||||
<field name="bid_flow_rate"/>
|
<field name="bid_flow_rate" readonly="1"/>
|
||||||
<field name="ultrafittration"/>
|
<field name="ultrafittration" readonly="1"/>
|
||||||
<field name="state"/>
|
|
||||||
</list>
|
</list>
|
||||||
</field>
|
</field>
|
||||||
</group>
|
</group>
|
||||||
|
|
|
@ -60,11 +60,12 @@
|
||||||
<item string="Valcular Access" action="clinic_vascular_access"/>
|
<item string="Valcular Access" action="clinic_vascular_access"/>
|
||||||
<item string="Clinic Settings" action="clinic_setting"/>
|
<item string="Clinic Settings" action="clinic_setting"/>
|
||||||
<divider/>
|
<divider/>
|
||||||
<header string="IMPORT"/>
|
<header string="IMPORTING"/>
|
||||||
<item string="Import Product" action="import_clinic_product"/>
|
<item string="Import Product" action="import_clinic_product"/>
|
||||||
<item string="Import Patient" action="import_clinic_patient"/>
|
<item string="Import Patient" action="import_clinic_patient"/>
|
||||||
<item string="Import Visit" action="import_clinic_visit"/>
|
<item string="Import Visit" action="import_clinic_visit"/>
|
||||||
<item string="Import HD Case" action="import_clinic_hd_case"/>
|
<item string="Import HD Case" action="import_clinic_hd_case"/>
|
||||||
<item string="Import Payment" action="import_clinic_payment"/>
|
<item string="Import Payment" action="import_clinic_payment"/>
|
||||||
|
<item string="Expenses" action="clinic_hd_case_expense"/>
|
||||||
</item>
|
</item>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<form model="clinic.setting" title="Clinic Settings">
|
<form model="clinic.setting" title="Clinic Settings">
|
||||||
<tabs>
|
<tabs>
|
||||||
|
<tab string="Visit">
|
||||||
|
<field name="find_dlz"/>
|
||||||
|
</tab>
|
||||||
<tab string="HD Case">
|
<tab string="HD Case">
|
||||||
<group form_layout="stacked">
|
<group form_layout="stacked">
|
||||||
<field name="waiting_approval" span="3"/>
|
<field name="waiting_approval" span="3"/>
|
||||||
|
|
|
@ -22,11 +22,10 @@ from . import visit
|
||||||
from . import visit_board
|
from . import visit_board
|
||||||
from . import hd_case
|
from . import hd_case
|
||||||
from . import hd_case_line
|
from . import hd_case_line
|
||||||
|
from . import hd_case_expense
|
||||||
from . import hd_case_staff
|
from . import hd_case_staff
|
||||||
from . import hd_case_gmline
|
|
||||||
from . import hd_case_discont
|
from . import hd_case_discont
|
||||||
from . import hd_case_payment
|
from . import hd_case_payment
|
||||||
from . import hd_case_daily
|
|
||||||
from . import hd_case_dialyzer
|
from . import hd_case_dialyzer
|
||||||
from . import dialyzer
|
from . import dialyzer
|
||||||
from . import cycle
|
from . import cycle
|
||||||
|
|
|
@ -91,16 +91,17 @@ class HDCase(Model):
|
||||||
"check_goverment_pay" : fields.Boolean("The Government Pay"),
|
"check_goverment_pay" : fields.Boolean("The Government Pay"),
|
||||||
"check_personal_pay" : fields.Boolean("Pay yourself"),
|
"check_personal_pay" : fields.Boolean("Pay yourself"),
|
||||||
"state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),('waiting_approval','Waiting Approval'),("completed","Completed"),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True),
|
"state": fields.Selection([("draft","Draft"),('waiting_treatment','Waiting Treatment'),("in_progress","In Progress"),('waiting_approval','Waiting Approval'),("completed","Completed"),("waiting_payment","Waiting Payment"),("discountinued","Discountinued"),("cancelled","Cancelled")],"Status",required=True),
|
||||||
"dialyzers": fields.One2Many("clinic.hd.case.dialyzer","hd_case_id","Dialyzers"),
|
|
||||||
"lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"),
|
|
||||||
"staffs": fields.One2Many("clinic.hd.case.staff","hd_case_id","Staffs"),
|
"staffs": fields.One2Many("clinic.hd.case.staff","hd_case_id","Staffs"),
|
||||||
"staff_id": fields.Many2One("clinic.hd.case.staff","Staff"), #XXX
|
"staff_id": fields.Many2One("clinic.hd.case.staff","Staff"), #XXX
|
||||||
"comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
|
"comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
|
||||||
"reconcile_id": fields.Many2One("account.reconcile","Reconcile Id",readonly=True),
|
"reconcile_id": fields.Many2One("account.reconcile","Reconcile Id",readonly=True),
|
||||||
|
"dialyzers": fields.One2Many("clinic.hd.case.dialyzer","hd_case_id","Dialyzers"),
|
||||||
|
"lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"),
|
||||||
"invoices": fields.One2Many("account.invoice","related_id","Invoices"),
|
"invoices": fields.One2Many("account.invoice","related_id","Invoices"),
|
||||||
"pickings": fields.One2Many("stock.picking","related_id","Pickings"),
|
"pickings": fields.One2Many("stock.picking","related_id","Pickings"),
|
||||||
"payments": fields.One2Many("account.payment","related_id","Payments"),
|
"payments": fields.One2Many("account.payment","related_id","Payments"),
|
||||||
"payment_lines": fields.One2Many("clinic.payment","hd_case_id","Payment Lines"),
|
"payment_lines": fields.One2Many("clinic.payment","hd_case_id","Payment Lines"),
|
||||||
|
"expenes": fields.One2Many("clinic.hd.case.expense","hd_case_id","Expenses"),
|
||||||
'visit_id': fields.Many2One("clinic.visit", "Visit"),
|
'visit_id': fields.Many2One("clinic.visit", "Visit"),
|
||||||
'duration': fields.Integer("Duration(Hours)",function="_get_duration"),
|
'duration': fields.Integer("Duration(Hours)",function="_get_duration"),
|
||||||
"total": fields.Float("Total",function="_get_total",readonly=True,function_multi=True),
|
"total": fields.Float("Total",function="_get_total",readonly=True,function_multi=True),
|
||||||
|
@ -245,6 +246,49 @@ class HDCase(Model):
|
||||||
self.update_amount(data)
|
self.update_amount(data)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def onchange_pay(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
pay_amount=data['pay_amount'] or 0
|
||||||
|
amount=data['amount'] or 0
|
||||||
|
if pay_amount > amount:
|
||||||
|
data['pay_amount']=0
|
||||||
|
return data
|
||||||
|
|
||||||
|
def onchange_type(self,context={}):
|
||||||
|
data=self.onchange_policy(context)
|
||||||
|
return data
|
||||||
|
|
||||||
|
def onchange_policy(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
inv_pol=data['invoice_policy']
|
||||||
|
total=0.0
|
||||||
|
fee=0.0
|
||||||
|
mdc=0.0
|
||||||
|
due_amt=0.0
|
||||||
|
for line in data['lines']:
|
||||||
|
amt=line['amount'] or 0.0
|
||||||
|
total+=amt
|
||||||
|
ltype=line['type']
|
||||||
|
if ltype=='fee':
|
||||||
|
fee+=amt
|
||||||
|
elif ltype=='medicine':
|
||||||
|
mdc+=amt
|
||||||
|
elif ltype=='others':
|
||||||
|
pass
|
||||||
|
if inv_pol=='fee':
|
||||||
|
due_amt=total-fee
|
||||||
|
data['invoice_option']=''
|
||||||
|
elif inv_pol=='fee_mdc':
|
||||||
|
due_amt=total-fee-mdc
|
||||||
|
data['invoice_option']='fee_mdc_split'
|
||||||
|
else:
|
||||||
|
due_amt=total
|
||||||
|
data['total']=total
|
||||||
|
data['fee_amount']=fee
|
||||||
|
data['mdc_amount']=mdc
|
||||||
|
data['amount']=due_amt
|
||||||
|
return data
|
||||||
|
|
||||||
def update_amount(self,data):
|
def update_amount(self,data):
|
||||||
total_amt=0.0
|
total_amt=0.0
|
||||||
fee_amt=0.0
|
fee_amt=0.0
|
||||||
|
@ -263,14 +307,6 @@ class HDCase(Model):
|
||||||
data['amount']=total_amt
|
data['amount']=total_amt
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def onchange_pay(self,context={}):
|
|
||||||
data=context['data']
|
|
||||||
pay_amount=data['pay_amount'] or 0
|
|
||||||
amount=data['amount'] or 0
|
|
||||||
if pay_amount > amount:
|
|
||||||
data['pay_amount']=0
|
|
||||||
return data
|
|
||||||
|
|
||||||
def make_payment(self,ids,context={}):
|
def make_payment(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
if not obj.total:
|
if not obj.total:
|
||||||
|
@ -548,11 +584,17 @@ class HDCase(Model):
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
for dlz_line in obj.dialyzers:
|
for dlz_line in obj.dialyzers:
|
||||||
dlz=dlz_line.dialyzer_id
|
dlz=dlz_line.dialyzer_id
|
||||||
#XXX
|
if dlz_line.use_time < dlz.max_use_time:
|
||||||
if dlz_line.use_time > dlz.use_time:
|
|
||||||
dlz.write({
|
dlz.write({
|
||||||
'use_time': dlz_line.use_time,
|
'use_time': dlz_line.use_time,
|
||||||
})
|
})
|
||||||
|
elif dlz_line.use_time==dlz.max_use_time:
|
||||||
|
dlz.write({
|
||||||
|
'use_time': dlz_line.use_time,
|
||||||
|
'state': 'expire',
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
raise Exception("Dialyzer is expired!")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def create_cycle_item(self,ids,context={}):
|
def create_cycle_item(self,ids,context={}):
|
||||||
|
@ -576,12 +618,40 @@ class HDCase(Model):
|
||||||
})
|
})
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def do_expense(self,ids,context={}):
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
# clear old expense
|
||||||
|
for exp in obj.expenes:
|
||||||
|
exp.delete()
|
||||||
|
|
||||||
|
exp_lines=[]
|
||||||
|
for inv in obj.invoices:
|
||||||
|
exp_lines.append(('create',{
|
||||||
|
'date': obj.date,
|
||||||
|
'patient_id': obj.patient_id.id,
|
||||||
|
'invoice_id': inv.id,
|
||||||
|
'hd_case_id': obj.id,
|
||||||
|
'amount': inv.amount_due,
|
||||||
|
}))
|
||||||
|
for pm in obj.payments:
|
||||||
|
exp_lines.append(('create',{
|
||||||
|
'date': obj.date,
|
||||||
|
'patient_id': obj.patient_id.id,
|
||||||
|
'payment_id': pm.id,
|
||||||
|
'hd_case_id': obj.id,
|
||||||
|
'amount': pm.amount_total,
|
||||||
|
}))
|
||||||
|
obj.write({
|
||||||
|
'expenes': exp_lines,
|
||||||
|
})
|
||||||
|
|
||||||
def complete(self,ids,context={}):
|
def complete(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
obj.make_invoices()
|
obj.make_invoices()
|
||||||
obj.post_invoices()
|
obj.post_invoices()
|
||||||
obj.update_usetime()
|
obj.update_usetime()
|
||||||
obj.create_cycle_item()
|
obj.create_cycle_item()
|
||||||
|
obj.do_expense()
|
||||||
vals={
|
vals={
|
||||||
"state":"completed",
|
"state":"completed",
|
||||||
}
|
}
|
||||||
|
@ -590,7 +660,6 @@ class HDCase(Model):
|
||||||
timenow=time.strftime("%H:%M:%S")
|
timenow=time.strftime("%H:%M:%S")
|
||||||
date=obj.date
|
date=obj.date
|
||||||
vals['time_stop']='%s %s'%(date,timenow)
|
vals['time_stop']='%s %s'%(date,timenow)
|
||||||
|
|
||||||
st=get_model("clinic.setting").browse(1)
|
st=get_model("clinic.setting").browse(1)
|
||||||
if st.waiting_approval:
|
if st.waiting_approval:
|
||||||
vals['state']='waiting_approval'
|
vals['state']='waiting_approval'
|
||||||
|
@ -645,6 +714,9 @@ class HDCase(Model):
|
||||||
for pm_line in obj.payment_lines:
|
for pm_line in obj.payment_lines:
|
||||||
pm_line.delete()
|
pm_line.delete()
|
||||||
|
|
||||||
|
for exp in obj.expenes:
|
||||||
|
exp.delete()
|
||||||
|
|
||||||
state=context.get("state","in_progress") #force state
|
state=context.get("state","in_progress") #force state
|
||||||
obj.write({
|
obj.write({
|
||||||
'state': state,
|
'state': state,
|
||||||
|
@ -851,41 +923,6 @@ class HDCase(Model):
|
||||||
vals=self.get_invoice_policy(vals,patient_id)
|
vals=self.get_invoice_policy(vals,patient_id)
|
||||||
super().write(ids,vals,**kw)
|
super().write(ids,vals,**kw)
|
||||||
|
|
||||||
def onchange_type(self,context={}):
|
|
||||||
data=self.onchange_policy(context)
|
|
||||||
return data
|
|
||||||
|
|
||||||
def onchange_policy(self,context={}):
|
|
||||||
data=context['data']
|
|
||||||
inv_pol=data['invoice_policy']
|
|
||||||
total=0.0
|
|
||||||
fee=0.0
|
|
||||||
mdc=0.0
|
|
||||||
due_amt=0.0
|
|
||||||
for line in data['lines']:
|
|
||||||
amt=line['amount'] or 0.0
|
|
||||||
total+=amt
|
|
||||||
ltype=line['type']
|
|
||||||
if ltype=='fee':
|
|
||||||
fee+=amt
|
|
||||||
elif ltype=='medicine':
|
|
||||||
mdc+=amt
|
|
||||||
elif ltype=='others':
|
|
||||||
pass
|
|
||||||
if inv_pol=='fee':
|
|
||||||
due_amt=total-fee
|
|
||||||
data['invoice_option']=''
|
|
||||||
elif inv_pol=='fee_mdc':
|
|
||||||
due_amt=total-fee-mdc
|
|
||||||
data['invoice_option']='fee_mdc_split'
|
|
||||||
else:
|
|
||||||
due_amt=total
|
|
||||||
data['total']=total
|
|
||||||
data['fee_amount']=fee
|
|
||||||
data['mdc_amount']=mdc
|
|
||||||
data['amount']=due_amt
|
|
||||||
return data
|
|
||||||
|
|
||||||
def approve(self,ids,context={}):
|
def approve(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
obj.write({
|
obj.write({
|
||||||
|
|
|
@ -1,90 +0,0 @@
|
||||||
import time
|
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
from netforce.model import Model, fields, get_model
|
|
||||||
from netforce.access import get_active_company
|
|
||||||
|
|
||||||
from . import utils
|
|
||||||
|
|
||||||
class HDCaseDialy(Model):
|
|
||||||
_name="clinic.hd.case.daily"
|
|
||||||
_string="HD Case Daily"
|
|
||||||
_transient=True
|
|
||||||
|
|
||||||
_fields={
|
|
||||||
"date": fields.Date("Date", required=True),
|
|
||||||
}
|
|
||||||
|
|
||||||
_defaults={
|
|
||||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
|
||||||
}
|
|
||||||
|
|
||||||
def get_report_data(self,ids,context={}):
|
|
||||||
company_id=get_active_company()
|
|
||||||
company=get_model("company").browse(company_id)
|
|
||||||
|
|
||||||
date=datetime.now().strftime("%Y-%m-%d")
|
|
||||||
if ids:
|
|
||||||
obj=self.browse(ids)[0]
|
|
||||||
date=obj.date
|
|
||||||
month=int(date[5:7])
|
|
||||||
day=date[8:10]
|
|
||||||
year=date[0:4]
|
|
||||||
month_str=utils.MONTHS['th_TH'][month]
|
|
||||||
dom=[]
|
|
||||||
dom.append(['time_start','>=','%s 00:00:00'%date])
|
|
||||||
dom.append(['time_stop','<=','%s 23:59:59'%date])
|
|
||||||
lines=[]
|
|
||||||
|
|
||||||
for obj in get_model("clinic.hd.case").search_browse(dom):
|
|
||||||
patient_type=obj.patient_id.type_id.name or ""
|
|
||||||
dlz_number=""
|
|
||||||
dlz_id=None
|
|
||||||
for line in obj.dialyzers:
|
|
||||||
dlz=line.dialyzer_id
|
|
||||||
dlz_id=dlz.id
|
|
||||||
dlz_number=dlz.number
|
|
||||||
cycle=obj.cycle_id
|
|
||||||
line={
|
|
||||||
'cycle_name': cycle.name,
|
|
||||||
'cycle_sequence': cycle.sequence,
|
|
||||||
'cycle_color': cycle.color or "",
|
|
||||||
'hd_case_number': obj.number,
|
|
||||||
'patient_name': obj.patient_id.name,
|
|
||||||
'patient_type': patient_type,
|
|
||||||
'doctor_name': obj.doctor_id.name,
|
|
||||||
'doctor_id': obj.doctor_id.id,
|
|
||||||
'fee_amount': obj.fee_amount,
|
|
||||||
'hd_case_id': obj.id,
|
|
||||||
'dlz_number': dlz_number,
|
|
||||||
'dlz_id': dlz_id,
|
|
||||||
'success_color': obj.state=='completed' and '#99ff99' or '',
|
|
||||||
'note': obj.note or "",
|
|
||||||
'last': False,
|
|
||||||
}
|
|
||||||
lines.append(line)
|
|
||||||
|
|
||||||
year=int(year)+543
|
|
||||||
date_str='%s %s %s'%(day,month_str,year)
|
|
||||||
|
|
||||||
no=1
|
|
||||||
slines=[]
|
|
||||||
for line in sorted(lines,key=lambda x: (x['cycle_sequence'],x['hd_case_number'])):
|
|
||||||
line['no']=no
|
|
||||||
slines.append(line)
|
|
||||||
no+=1
|
|
||||||
|
|
||||||
# find all nurse for each cycle
|
|
||||||
items=get_model("clinic.cycle.item").search_browse([['date','=',date]])
|
|
||||||
for item in sorted(items,key=lambda x: x.cycle_id.sequence):
|
|
||||||
pass
|
|
||||||
|
|
||||||
data={
|
|
||||||
'lines': slines,
|
|
||||||
'date': date_str,
|
|
||||||
'company_name': company.name,
|
|
||||||
'company_parent_name': company.parent_id.name,
|
|
||||||
}
|
|
||||||
return data
|
|
||||||
|
|
||||||
HDCaseDialy.register()
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
import time
|
||||||
|
|
||||||
|
from netforce.model import Model, fields
|
||||||
|
|
||||||
|
class HDCaseExpense(Model):
|
||||||
|
_name="clinic.hd.case.expense"
|
||||||
|
_string="Expense"
|
||||||
|
_name_field="date"
|
||||||
|
_fields={
|
||||||
|
'date': fields.Date("Date"),
|
||||||
|
'patient_id': fields.Many2One("clinic.patient","Patient"),
|
||||||
|
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case"),
|
||||||
|
'invoice_id': fields.Many2One("account.invoice","Invoice"),
|
||||||
|
'payment_id': fields.Many2One("account.payment","Payment"),
|
||||||
|
'amount': fields.Float("Amount"),
|
||||||
|
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
|
||||||
|
'match': fields.Boolean("Match"),
|
||||||
|
}
|
||||||
|
|
||||||
|
_defaults={
|
||||||
|
'state': 'draft',
|
||||||
|
'date': time.strftime("%Y-%m-%d"),
|
||||||
|
'match': False,
|
||||||
|
}
|
||||||
|
|
||||||
|
_order="date desc"
|
||||||
|
|
||||||
|
def approve(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
obj.write({
|
||||||
|
'state': 'approved',
|
||||||
|
})
|
||||||
|
|
||||||
|
def to_draft(self,ids,context={}):
|
||||||
|
obj=self.browse(ids)[0]
|
||||||
|
obj.write({
|
||||||
|
'state': 'draft',
|
||||||
|
})
|
||||||
|
|
||||||
|
HDCaseExpense.register()
|
|
@ -1,16 +0,0 @@
|
||||||
from netforce.model import Model, fields
|
|
||||||
|
|
||||||
class HDCaseGMline(Model):
|
|
||||||
_name="clinic.hd.case.gm.line"
|
|
||||||
_fields={
|
|
||||||
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
|
|
||||||
"product_id": fields.Many2One("product","Product",search=True),
|
|
||||||
"description": fields.Char("Description",search=True),
|
|
||||||
"qty":fields.Integer("QTY"),
|
|
||||||
"uom_id": fields.Many2One("uom","UOM",required=True,search=True),
|
|
||||||
"price":fields.Float("Price"),
|
|
||||||
"amount":fields.Float("Amount"),
|
|
||||||
}
|
|
||||||
|
|
||||||
HDCaseGMline.register()
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ class HDCasePayment(Model):
|
||||||
if st.waiting_approval:
|
if st.waiting_approval:
|
||||||
vals['state']='waiting_approval'
|
vals['state']='waiting_approval'
|
||||||
hd_case.write(vals)
|
hd_case.write(vals)
|
||||||
|
hd_case.do_expense()
|
||||||
obj.write({
|
obj.write({
|
||||||
'pay_amount': hd_case.amount,
|
'pay_amount': hd_case.amount,
|
||||||
})
|
})
|
||||||
|
@ -83,6 +84,7 @@ class HDCasePayment(Model):
|
||||||
}
|
}
|
||||||
if st.waiting_approval:
|
if st.waiting_approval:
|
||||||
vals['state']='waiting_approval'
|
vals['state']='waiting_approval'
|
||||||
|
hd_case.do_expense()
|
||||||
hd_case.write(vals)
|
hd_case.write(vals)
|
||||||
return {
|
return {
|
||||||
'next': {
|
'next': {
|
||||||
|
|
|
@ -16,9 +16,10 @@ class ClinicSetting(Model):
|
||||||
'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'),
|
||||||
'period_id': fields.Many2One("clinic.period","Period"),
|
'period_id': fields.Many2One("clinic.period","Period"),
|
||||||
'waiting_approval': fields.Boolean("Waiting Approval"),
|
'waiting_approval': fields.Boolean("Waiting Approval"), # HD Case
|
||||||
'real_time': fields.Boolean("Real Time"),
|
'real_time': fields.Boolean("Real Time"), # HD Case
|
||||||
'patient_type_id': fields.Many2One("clinic.patient.type","Default Type"),
|
'patient_type_id': fields.Many2One("clinic.patient.type","Default Type"), # Import payment
|
||||||
|
'find_dlz': fields.Boolean("Find Dialyzer After Confirm Visit"), # Visit
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Visit(Model):
|
||||||
'hd_cases': fields.One2Many('clinic.hd.case','visit_id',"HD Cases",readonly=True),
|
'hd_cases': fields.One2Many('clinic.hd.case','visit_id',"HD Cases",readonly=True),
|
||||||
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
|
||||||
'cycle_color': fields.Char('Color',function="_get_color"),
|
'cycle_color': fields.Char('Color',function="_get_color"),
|
||||||
"state": fields.Selection([["draft","Draft"],["confirmed","Confirmed"],["cancelled","Cancelled"]],"Status",required=True),
|
"state": fields.Selection([["draft","Draft"],['pending','Pending'],["confirmed","Confirmed"],["cancelled","Cancelled"]],"Status",required=True),
|
||||||
"comments": fields.One2Many("message","related_id","Comments"),
|
"comments": fields.One2Many("message","related_id","Comments"),
|
||||||
'visit_date': fields.Date('Visit Date'),
|
'visit_date': fields.Date('Visit Date'),
|
||||||
'print_date': fields.Date('Print Date',function="_get_print_date"),
|
'print_date': fields.Date('Print Date',function="_get_print_date"),
|
||||||
|
@ -97,6 +97,51 @@ class Visit(Model):
|
||||||
|
|
||||||
_order="sequence"
|
_order="sequence"
|
||||||
|
|
||||||
|
def new_dlz(self,patient_id):
|
||||||
|
if not patient_id:
|
||||||
|
raise Exception("No Patient to creat Dialyzer")
|
||||||
|
dlz_vals=get_model("clinic.dialyzer").default_get()
|
||||||
|
dlz_vals['product_id']=dlz_vals['product_id'][0]
|
||||||
|
dlz_vals['company_id']=dlz_vals['company_id'][0]
|
||||||
|
dlz_vals['patient_id']=patient_id
|
||||||
|
dlz_id=get_model('clinic.dialyzer').create(dlz_vals)
|
||||||
|
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
|
||||||
|
dialyzer.confirm()
|
||||||
|
return dlz_id
|
||||||
|
|
||||||
|
def get_dlz(self,visit_id):
|
||||||
|
obj=self.browse(visit_id)
|
||||||
|
patient=obj.patient_id
|
||||||
|
dialyzers=get_model("clinic.dialyzer").search_browse([['patient_id','=',patient.id],['state','=','active']])
|
||||||
|
if not dialyzers:
|
||||||
|
dlz_id=self.new_dlz(patient.id)
|
||||||
|
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
|
||||||
|
else:
|
||||||
|
dialyzer=dialyzers[-1]
|
||||||
|
use_time=dialyzer.use_time or 0
|
||||||
|
max_time=dialyzer.max_use_time or 0
|
||||||
|
if use_time > max_time:
|
||||||
|
dialyzer.write({
|
||||||
|
'state': 'expire',
|
||||||
|
})
|
||||||
|
# get new dialyzer
|
||||||
|
dlz_id=self.new_dlz(patient.id)
|
||||||
|
dialyzer=get_model("clinic.dialyzer").browse(dlz_id)
|
||||||
|
#raise Exception("%s is expired"%dialyzer.number)
|
||||||
|
use_time+=1
|
||||||
|
vals={
|
||||||
|
"description": dialyzer.description or dialyzer.product_id.name or "",
|
||||||
|
"use_time": use_time,
|
||||||
|
"max_use_time": dialyzer.max_use_time,
|
||||||
|
"member_type": dialyzer.member_type,
|
||||||
|
"dialyzer_type": dialyzer.dialyzer_type,
|
||||||
|
"bid_flow_rate": dialyzer.bid_flow_rate,
|
||||||
|
"ultrafittration": dialyzer.ultrafittration,
|
||||||
|
"state": dialyzer.state,
|
||||||
|
'dialyzer_id': dialyzer.id,
|
||||||
|
}
|
||||||
|
return vals
|
||||||
|
|
||||||
def confirm(self,ids,context={}):
|
def confirm(self,ids,context={}):
|
||||||
obj=self.browse(ids)[0]
|
obj=self.browse(ids)[0]
|
||||||
number=obj.number
|
number=obj.number
|
||||||
|
@ -126,6 +171,11 @@ class Visit(Model):
|
||||||
'state': 'waiting_treatment',
|
'state': 'waiting_treatment',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
st=get_model("clinic.setting").browse(1)
|
||||||
|
if st.find_dlz:
|
||||||
|
dialyzer=self.get_dlz(obj.id)
|
||||||
|
vals['dialyzers'].append(('create',dialyzer))
|
||||||
|
|
||||||
# use exist hd_case (in case set to draft)
|
# use exist hd_case (in case set to draft)
|
||||||
hd_case_id=None
|
hd_case_id=None
|
||||||
if obj.hd_cases:
|
if obj.hd_cases:
|
||||||
|
@ -242,10 +292,12 @@ class Visit(Model):
|
||||||
'doctor_id': obj.doctor_id.id,
|
'doctor_id': obj.doctor_id.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,
|
||||||
'cycle': obj.cycle,
|
'cycle_id': obj.cycle_id.id,
|
||||||
|
'time_start': obj.time_start,
|
||||||
|
'time_stop': obj.time_stop,
|
||||||
|
'visit_date': obj.visit_date,
|
||||||
}
|
}
|
||||||
new_id=self.create(vals,context=context)
|
new_id=self.create(vals,context=context)
|
||||||
new_obj=self.browse(new_id)
|
|
||||||
return {
|
return {
|
||||||
'next':{
|
'next':{
|
||||||
'name': 'clinic_visit',
|
'name': 'clinic_visit',
|
||||||
|
@ -253,7 +305,7 @@ class Visit(Model):
|
||||||
'active_id': new_id,
|
'active_id': new_id,
|
||||||
},
|
},
|
||||||
|
|
||||||
'flash': 'Visit %s is copy to %s'%(obj.number,new_obj.number),
|
'flash': 'Visit %s successfully'%(obj.number),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue