treatment
parent
a27ef19307
commit
53670f8f8d
|
@ -2,7 +2,7 @@
|
|||
<field name="string">Treatments</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.hd.case</field>
|
||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]],["Approved",[["state","=","approved"]]],["Paid",[["state","=","paid"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
|
||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["In Progress",[["state","=","in_progress"]]],["Completed",[["state","=","completed"]]],["Incomplete",[["state","=","fail"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
|
||||
<field name="modes">list,form</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
||||
|
|
|
@ -22,17 +22,19 @@
|
|||
<tab string="Dialyzer">
|
||||
<field name="dialyzers" nolabel="1">
|
||||
<list>
|
||||
<field name="dialyzer_id"/>
|
||||
<field name="dialyzer_id" domain="[['patient_id','=',parent.patient_id]]" onchange="onchange_dialyzer"/>
|
||||
<field name="description"/>
|
||||
<field name="use_time"/>
|
||||
<field name="max_use_time"/>
|
||||
<field name="member_type"/>
|
||||
<field name="dialyzer_type"/>
|
||||
<field name="bid_flow_rate"/>
|
||||
<field name="ultrafittration"/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
</field>
|
||||
</tab>
|
||||
<tab string="Healthy History">
|
||||
<tab string="Healthy Notes">
|
||||
<field name="wh_start"/>
|
||||
<field name="wh_stop"/>
|
||||
<field name="bp_start"/>
|
||||
|
@ -41,6 +43,10 @@
|
|||
<field name="per_bp_stop"/>
|
||||
<field name="hct"/>
|
||||
</tab>
|
||||
<tab string="Others">
|
||||
<separator string="Accounting"/>
|
||||
<field name="paid" readonly="1"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
<separator string="Others Payment"/>
|
||||
<field name="lines" count="4" nolabel="1">
|
||||
|
@ -65,10 +71,9 @@
|
|||
<field name="amount"/>
|
||||
</group>
|
||||
<foot>
|
||||
<button string="Confirm" type="success" method="confirm" states="draft" />
|
||||
<button string="Validate" type="success" method="approve" states="confirmed"/>
|
||||
<!--<button string="Validate" type="success" method="validate" states="confirmed" />-->
|
||||
<button string="Pay" type="success" method="paid" states="approved" />
|
||||
<button string="Confirm" type="success" method="confirm" states="draft"/>
|
||||
<button string="Complete" type="success" method="complete" states="in_progress"/>
|
||||
<button string="Reject" type="danger" method="reject" states="in_progress"/>
|
||||
</foot>
|
||||
<related>
|
||||
<field name="invoices" click_action="view_invoice"/>
|
||||
|
|
|
@ -8,18 +8,21 @@
|
|||
<field name="mg_file"/>
|
||||
<group span="6">
|
||||
<field name="mg_payment_id" readonly="1"/>
|
||||
<button string="Post" type="success" method="post_mg"/>
|
||||
<button string="Undo" type="danger" method="undo_mg" attrs='{"invisible":[["state","in",["success"]]]}'/>
|
||||
</group>
|
||||
<separator string="Social Security"/>
|
||||
<field name="sc_file"/>
|
||||
<group span="6">
|
||||
<field name="sc_payment_id" readonly="1"/>
|
||||
<button string="Post" type="success" method="post_sc"/>
|
||||
<button string="Undo" type="danger" method="undo_sc" attrs='{"invisible":[["state","in",["success"]]]}'/>
|
||||
</group>
|
||||
<separator string="NHSO (30฿)"/>
|
||||
<field name="nhso_file"/>
|
||||
<group span="6">
|
||||
<field name="nhso_payment_id" readonly="1"/>
|
||||
<button string="Post" type="success" method="post_nhso"/>
|
||||
<button string="Undo" type="danger" method="undo_nhso" attrs='{"invisible":[["state","in",["success"]]]}'/>
|
||||
</group>
|
||||
<foot>
|
||||
|
|
|
@ -15,13 +15,29 @@
|
|||
<field name="time_use"/>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
<field name="department_id"/>
|
||||
<field name="patient_id" onchange="onchange_patient"/>
|
||||
<field name="doctor_id"/>
|
||||
<field name="nurse_id"/>
|
||||
<field name="department_id"/>
|
||||
</group>
|
||||
</tab>
|
||||
</tabs>
|
||||
<group attrs='{"invisible": [["state","not in",["waiting_treatment"]]]}'>
|
||||
<separator string="Select Dialyzer -> Click Do Treatment"/>
|
||||
<field name="dialyzers" nolabel="1" count="3">
|
||||
<list>
|
||||
<field name="dialyzer_id" domain="[['state','=','active'],['patient_id','=',parent.patient_id]]" onchange="onchange_dialyzer"/>
|
||||
<field name="description"/>
|
||||
<field name="use_time"/>
|
||||
<field name="max_use_time"/>
|
||||
<field name="member_type"/>
|
||||
<field name="dialyzer_type"/>
|
||||
<field name="bid_flow_rate"/>
|
||||
<field name="ultrafittration"/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
</field>
|
||||
</group>
|
||||
<foot>
|
||||
<button string="Confirm" type="success" method="confirm" states="draft" />
|
||||
<button string="Do Treatment" type="success" method="do_treatment" icon="arrow-right" states="waiting_treatment" />
|
||||
|
|
|
@ -8,9 +8,10 @@ from . import doctor
|
|||
from . import nurse
|
||||
from . import visit
|
||||
from . import hd_case
|
||||
from . import hd_case_dialyzer
|
||||
#from . import hd_case_dialyzer
|
||||
from . import hd_case_line
|
||||
from . import dialyzer
|
||||
from . import dialyzer_line
|
||||
from . import department
|
||||
from . import education
|
||||
from . import setting
|
||||
|
|
|
@ -16,7 +16,6 @@ class Dialyzer(Model):
|
|||
"use_time": fields.Integer("Use Time"),
|
||||
"max_use_time": fields.Integer("Max Use Time"),
|
||||
"exp_date": fields.Date("Expiry Date",search=True),
|
||||
"patient_id": fields.Many2One("clinic.patient","Patient"),
|
||||
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
|
||||
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
|
||||
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)",search=True),
|
||||
|
@ -26,6 +25,9 @@ class Dialyzer(Model):
|
|||
"company_id": fields.Many2One("company","Company"),
|
||||
'product_id': fields.Many2One("product", "Product",required=True),
|
||||
"pickings": fields.One2Many("stock.picking","related_id","Pickings"),
|
||||
"patient_id": fields.Many2One("clinic.patient","Patient"),
|
||||
"visit_id": fields.Many2One("clinic.visit","Visit"),
|
||||
"hd_case_id": fields.Many2One("clinic.hd.case","HD Case"),
|
||||
}
|
||||
|
||||
def _get_number(self,context={}):
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
from netforce.model import Model, fields
|
||||
|
||||
class DialyzerLine(Model):
|
||||
_name="clinic.dialyzer.line"
|
||||
_fields={
|
||||
"hd_case_id": fields.Many2One("clinic.hd.case","HdCase",on_delete="cascade"),
|
||||
"visit_id": fields.Many2One("clinic.visit","Visit",on_delete="cascade"),
|
||||
"dialyzer_id": fields.Many2One("clinic.dialyzer","Dialzer",search=True),
|
||||
"description": fields.Char("Description",search=True),
|
||||
"use_time":fields.Integer("Use time"),
|
||||
"max_use_time":fields.Integer("Max use time"),
|
||||
"member_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Member Type"),
|
||||
"dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Member Type"),
|
||||
"bid_flow_rate": fields.Integer("Bid Flow Rate (ml/min)"),
|
||||
"ultrafittration": fields.Float("Ultrafittration Kg."),
|
||||
"state":fields.Selection([("draft","New"),("active","Active"),("drop","Drop")],"Status"),
|
||||
}
|
||||
|
||||
DialyzerLine.register()
|
||||
|
|
@ -37,8 +37,8 @@ class HDcase(Model):
|
|||
"bp_stop": fields.Integer("BP mmHG stop"),
|
||||
"per_bp_stop": fields.Integer("/Per stop"),
|
||||
"hct": fields.Integer("HCT %"),
|
||||
"state": fields.Selection([("draft","Draft"),("confirmed","Confirmed"),("approved","Approved"),("cancelled","Cancelled"),("paid","Paid")],"Status",required=True),
|
||||
"dialyzers": fields.One2Many("clinic.hd.case.dialyzer","hd_case_id","Dializers"),
|
||||
"state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("cancelled","Cancelled"),("incomplete","Incomplete")],"Status",required=True),
|
||||
"dialyzers": fields.One2Many("clinic.dialyzer.line","hd_case_id","Dializers"),
|
||||
"lines": fields.One2Many("clinic.hd.case.line","hd_case_id","Lines"),
|
||||
"comments": fields.One2Many("message","related_id","Comments"),
|
||||
"company_id": fields.Many2One("company","Company"),
|
||||
|
@ -53,6 +53,7 @@ class HDcase(Model):
|
|||
'total_time': fields.Integer("Total Time(Hrs)",function="get_hrs"),
|
||||
"fee_type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Fee Type"),
|
||||
'fee_partner_id': fields.Many2One("partner","Fee Contact"),
|
||||
'paid': fields.Boolean("Paid"),
|
||||
}
|
||||
|
||||
def _get_number(self,context={}):
|
||||
|
@ -92,11 +93,11 @@ class HDcase(Model):
|
|||
data=context["data"]
|
||||
path=context["path"]
|
||||
line=get_data_path(data,path,parent=True)
|
||||
dialyzer_id=line.get("dialzer_id")
|
||||
dialyzer_id=line.get("dialyzer_id")
|
||||
if not dialyzer_id:
|
||||
return {}
|
||||
dialyzer=get_model("clinic.dialyzer").browse(dialyzer_id)
|
||||
line["detail"]=dialyzer.detail
|
||||
line["description"]=dialyzer.description or ""
|
||||
line["use_time"]=dialyzer.use_time
|
||||
line["max_use_time"]=dialyzer.max_use_time
|
||||
line["member_type"]=dialyzer.member_type
|
||||
|
@ -167,7 +168,7 @@ class HDcase(Model):
|
|||
# XXX
|
||||
context['type']='out'
|
||||
context['inv_type']='invoice'
|
||||
if obj.lines:
|
||||
if obj.lines and obj.total:
|
||||
# XXX need to split function prepare invoice
|
||||
vals={
|
||||
"type": "out",
|
||||
|
@ -293,112 +294,29 @@ class HDcase(Model):
|
|||
|
||||
def confirm(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({"state":"confirmed"})
|
||||
obj.write({"state":"in_progress"})
|
||||
|
||||
def paid(self,ids,context={}):
|
||||
def reject(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({"state":"paid"})
|
||||
obj.write({"state":"cancelled"})
|
||||
|
||||
def approve(self,ids,context={}):
|
||||
def complete(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.make_invoices()
|
||||
obj.post_invoices()
|
||||
obj.write({"state":"approved"})
|
||||
obj.write({
|
||||
"state":"completed",
|
||||
'paid': True,
|
||||
})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_hd_case',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': '%s has been approved'%obj.number,
|
||||
'flash': '%s is completed'%obj.number,
|
||||
}
|
||||
|
||||
def approved(self,ids,context={}):
|
||||
for obj in self.browse(ids):
|
||||
user_id=get_active_user()
|
||||
try:
|
||||
set_active_user(1)
|
||||
settings=get_model("clinic.setting").browse(1)
|
||||
reconcile_id=get_model("account.reconcile").create({})
|
||||
if obj.patient_id.type == 'mg':
|
||||
vals={
|
||||
"narration": obj.number,
|
||||
"lines": [
|
||||
("create",{
|
||||
"description": obj.number,
|
||||
"account_id": settings.ar_mg_id.id,
|
||||
"debit": obj.amount,
|
||||
"credit": 0,
|
||||
"partner_id": settings.mg_partner_id.id,
|
||||
"due_date": obj.date,
|
||||
"reconcile_id":reconcile_id,
|
||||
}),
|
||||
("create",{
|
||||
"description": obj.number,
|
||||
"account_id": settings.ap_mg_id.id,
|
||||
"debit": 0,
|
||||
"credit": obj.amount,
|
||||
}),
|
||||
],
|
||||
"state": "posted",
|
||||
"date_posted": obj.date,
|
||||
"date": obj.date,
|
||||
}
|
||||
get_model("account.move").create(vals)
|
||||
elif obj.patient_id.type == 'sc':
|
||||
vals={
|
||||
"narration": obj.number,
|
||||
"lines": [
|
||||
("create",{
|
||||
"description": obj.number,
|
||||
"account_id": settings.ar_sc_id.id,
|
||||
"debit": obj.amount,
|
||||
"credit": 0,
|
||||
"partner_id": settings.sc_partner_id.id,
|
||||
"due_date": obj.date,
|
||||
"reconcile_id":reconcile_id,
|
||||
}),
|
||||
("create",{
|
||||
"description": obj.number,
|
||||
"account_id": settings.ap_sc_id.id,
|
||||
"debit": 0,
|
||||
"credit": obj.amount,
|
||||
}),
|
||||
],
|
||||
"state": "posted",
|
||||
"date_posted": obj.date,
|
||||
"date": obj.date,
|
||||
}
|
||||
get_model("account.move").create(vals)
|
||||
elif obj.patient_id.type == 'nhso':
|
||||
vals={
|
||||
"narration": obj.number,
|
||||
"lines": [
|
||||
("create",{
|
||||
"description": obj.number,
|
||||
"account_id": settings.ar_nhso_id.id,
|
||||
"debit": obj.amount,
|
||||
"credit": 0,
|
||||
"partner_id": settings.nhso_partner_id.id,
|
||||
"due_date": obj.date,
|
||||
"reconcile_id":reconcile_id,
|
||||
}),
|
||||
("create",{
|
||||
"description": obj.number,
|
||||
"account_id": settings.ap_nhso_id.id,
|
||||
"debit": 0,
|
||||
"credit": obj.amount,
|
||||
}),
|
||||
],
|
||||
"state": "posted",
|
||||
"date_posted": obj.date,
|
||||
"date": obj.date,
|
||||
}
|
||||
get_model("account.move").create(vals)
|
||||
finally:
|
||||
set_active_user(user_id)
|
||||
obj.write({"state":"approved","reconcile_id":reconcile_id})
|
||||
|
||||
def journal_report(self,ids,context={}):
|
||||
obj=self.browse(ids[0])
|
||||
move_id = get_model("account.move").search([["narration","=",obj.number]])
|
||||
|
|
|
@ -3,6 +3,7 @@ import datetime
|
|||
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company, get_active_user, set_active_user
|
||||
from netforce.utils import get_data_path
|
||||
|
||||
class Visit(Model):
|
||||
_name="clinic.visit"
|
||||
|
@ -13,6 +14,8 @@ class Visit(Model):
|
|||
|
||||
def _get_visit_late(self,ids,context={}):
|
||||
res={}
|
||||
#oneday=datetime.timedelta(days=1)
|
||||
#yesterday=datetime.datetime.now()-oneday
|
||||
datenow=time.strftime("%Y-%m-%d")
|
||||
for obj in self.browse(ids):
|
||||
late=0
|
||||
|
@ -34,6 +37,7 @@ class Visit(Model):
|
|||
"company_id": fields.Many2One("company","Company"),
|
||||
'time_use': fields.Integer("Time Use(hrs)"),
|
||||
'late_visit': fields.Integer("Late Vist",function="_get_visit_late"),
|
||||
"dialyzers": fields.One2Many("clinic.dialyzer.line","visit_id","Dialyzers"),
|
||||
}
|
||||
|
||||
def _get_number(self,context={}):
|
||||
|
@ -93,6 +97,8 @@ class Visit(Model):
|
|||
# cannot treatment if current date is not same visit date
|
||||
if obj.visit_date!=datenow:
|
||||
raise Exception("Today is not treament date!")
|
||||
if not obj.dialyzers:
|
||||
raise Exception("Please select dialyzer!")
|
||||
|
||||
fmt_date="%Y-%m-%d %H:%M:%S"
|
||||
date_from=dt.strptime("%s %s"%(obj.visit_date,timenow),fmt_date)
|
||||
|
@ -113,6 +119,7 @@ class Visit(Model):
|
|||
'fee_type': obj.patient_id.type,
|
||||
'lines':[],
|
||||
'dialyzers': [],
|
||||
'state': 'in_progress',
|
||||
}
|
||||
|
||||
patient_type={
|
||||
|
@ -136,31 +143,15 @@ class Visit(Model):
|
|||
break
|
||||
|
||||
# find dialyser
|
||||
for dlz in get_model("clinic.dialyzer").search_browse([['patient_id','=',obj.patient_id.id],['state','=','active']],order="id desc"):
|
||||
use_time=dlz.use_time or 0
|
||||
use_time+=1
|
||||
# XXX update dialyzer
|
||||
dlz.write({
|
||||
'use_time': use_time,
|
||||
})
|
||||
if use_time > dlz.max_use_time:
|
||||
dlz.write({
|
||||
"state": "expire",
|
||||
})
|
||||
continue
|
||||
vals['dialyzers'].append(('create',{
|
||||
"dialyzer_id": dlz.id,
|
||||
"description": dlz.description,
|
||||
"use_time": use_time,
|
||||
"max_use_time": dlz.max_use_time,
|
||||
"member_type": dlz.member_type,
|
||||
"dialyzer_type": dlz.dialyzer_type,
|
||||
"bid_flow_rate": dlz.bid_flow_rate,
|
||||
"ultrafittration": dlz.ultrafittration,
|
||||
}))
|
||||
if not vals['dialyzers']:
|
||||
if not obj.dialyzers:
|
||||
raise Exception("%s don't have dialyzer for treatment yet" % obj.patient_id.name)
|
||||
hd_case_id=hd_case_obj.create(vals)
|
||||
for dlz in obj.dialyzers:
|
||||
# TODO check max time and expire day also
|
||||
dlz.dialyzer_id.write({'use_time': dlz.use_time}) # count use time
|
||||
dlz.write({
|
||||
'hd_case_id': hd_case_id,
|
||||
})
|
||||
obj.write({"state":"treatment"})
|
||||
return {
|
||||
'next': {
|
||||
|
@ -250,4 +241,24 @@ class Visit(Model):
|
|||
}
|
||||
return data
|
||||
|
||||
def onchange_dialyzer(self,context={}):
|
||||
data=context["data"]
|
||||
path=context["path"]
|
||||
line=get_data_path(data,path,parent=True)
|
||||
dialyzer_id=line.get("dialyzer_id")
|
||||
if not dialyzer_id:
|
||||
return {}
|
||||
dialyzer=get_model("clinic.dialyzer").browse(dialyzer_id)
|
||||
use_time=dialyzer.use_time or 0
|
||||
use_time+=1
|
||||
line["description"]=dialyzer.description or ""
|
||||
line["use_time"]=use_time
|
||||
line["max_use_time"]=dialyzer.max_use_time
|
||||
line["member_type"]=dialyzer.member_type
|
||||
line["dialyzer_type"]=dialyzer.dialyzer_type
|
||||
line["bid_flow_rate"]=dialyzer.bid_flow_rate
|
||||
line["ultrafittration"]=dialyzer.ultrafittration
|
||||
line["state"]=dialyzer.state
|
||||
return data
|
||||
|
||||
Visit.register()
|
||||
|
|
|
@ -14,19 +14,17 @@
|
|||
-> state
|
||||
- draft
|
||||
- confirmed
|
||||
- should dialyzer before treament
|
||||
- buttons
|
||||
- should select dialyzer before treament
|
||||
- buttons -> ok
|
||||
- confirm
|
||||
- state : draft -> waiting treatment
|
||||
- do treatment
|
||||
- state : waiting treatment ->
|
||||
- cancel visit
|
||||
- print visit
|
||||
- plaining visit
|
||||
- day [monday, tueday, wedsday, thursday, friday]
|
||||
- time
|
||||
- cancel visit -> ok
|
||||
- print visit -> ok
|
||||
|
||||
- treament
|
||||
- print invoice
|
||||
- time start/stop
|
||||
- only time
|
||||
- date treament
|
||||
|
@ -36,12 +34,24 @@
|
|||
- make next appointment
|
||||
- make payment
|
||||
- state
|
||||
- draft
|
||||
- confirm
|
||||
- ready to treatment
|
||||
- paid -> no because not realte to accounting
|
||||
- many2one for dializer
|
||||
- list show percent of progress bar
|
||||
- plaining visit !!!
|
||||
- select next day to visit
|
||||
- copy data to visit
|
||||
- after click complete
|
||||
- day [monday, tueday, wedsday, thursday, friday]
|
||||
- time
|
||||
- dialyzer
|
||||
|
||||
- import payment
|
||||
- import
|
||||
- create payment with invoice that found
|
||||
- post
|
||||
- undo
|
||||
=======
|
||||
|
||||
sequence (support multi company) -> ok
|
||||
- visit
|
||||
- hd case
|
||||
|
|
Loading…
Reference in New Issue