conv_bal
watcha.h 2014-10-05 12:47:19 +07:00
parent 53670f8f8d
commit 5fb4bef0b9
10 changed files with 83 additions and 42 deletions

View File

@ -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"]]],["In Progress",[["state","=","in_progress"]]],["Completed",[["state","=","completed"]]],["Incomplete",[["state","=","fail"]]],["Cancelled",[["state","=","cancelled"]]]]</field>
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["In Progress",[["state","=","in_progress"]]],["Completed",[["state","=","completed"]]],["Uncompleted",[["state","=","uncompleted"]]]]</field>
<field name="modes">list,form</field>
<field name="menu">clinic_menu</field>
</action>

View File

@ -1,4 +1,4 @@
<form model="clinic.hd.case" attrs='{"readonly":[["state","in",["cancelled","validated"]]]}' show_company="1">
<form model="clinic.hd.case" attrs='{"readonly":[["state","in",["uncompleted","completed"]]]}' show_company="1">
<head>
<field name="state"/>
<button string="Options" dropdown="1">
@ -7,16 +7,17 @@
</head>
<group span="6" columns="1">
<field name="number"/>
<field name="date_start"/>
<field name="date"/>
<field name="time_start"/>
<field name="total_time"/>
<field name="department_id"/>
<field name="visit_id"/>
</group>
<group span="6" columns="1">
<field name="patient_id" onchange="onchange_patient"/>
<field name="date_stop"/>
<field name="doctor_id"/>
<field name="time_stop"/>
<field name="nurse_id"/>
<field name="department_id"/>
</group>
<tabs>
<tab string="Dialyzer">
@ -34,7 +35,7 @@
</list>
</field>
</tab>
<tab string="Healthy Notes">
<tab string="Notes">
<field name="wh_start"/>
<field name="wh_stop"/>
<field name="bp_start"/>
@ -48,7 +49,7 @@
<field name="paid" readonly="1"/>
</tab>
</tabs>
<separator string="Others Payment"/>
<separator string="Other Expenses"/>
<field name="lines" count="4" nolabel="1">
<list>
<field name="product_id" onchange="onchange_product"/>
@ -73,7 +74,7 @@
<foot>
<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"/>
<button string="Discontinue" type="danger" method="discontinue" states="in_progress"/>
</foot>
<related>
<field name="invoices" click_action="view_invoice"/>

View File

@ -1,7 +1,7 @@
<list model="clinic.hd.case">
<field name="number"/>
<field name="date_start"/>
<field name="date_stop"/>
<field name="time_start"/>
<field name="time_stop"/>
<field name="patient_id"/>
<field name="doctor_id"/>
<field name="nurse_id"/>

View File

@ -18,6 +18,9 @@
</item>
<item string="Visits" action="clinic_visit"/>
<item string="Treatments" action="clinic_hd_case"/>
<item string="Planings">
<item string="Visit" action="clinic_visit"/>
</item>
<item string="Reports">
<item string="Report1" action="report1"/>
</item>

View File

@ -1,4 +1,5 @@
<calendar model="clinic.visit" states='waiting_treatment' date_field="visit_date" colors='{"#090":[["cycle","=",1]],"#2400ff":[["cycle","=",2]],"#ebff00":[["cycle","=",3]],"#f20000":[["cycle","=",4]]}'>
<!--<calendar model="clinic.visit" states='waiting_treatment' date_field="visit_date" colors='{"#090":[["cycle","=",1]],"#2400ff":[["cycle","=",2]],"#ebff00":[["cycle","=",3]],"#f20000":[["cycle","=",4]]}'>-->
<calendar model="clinic.visit" states='waiting_treatment' start_field="time_start" end_field="time_stop" colors='{"#090":[["cycle","=",1]],"#2400ff":[["cycle","=",2]],"#ebff00":[["cycle","=",3]],"#f20000":[["cycle","=",4]]}'>
<field name="patient_id"/>
<field name="cycle"/>
<field name="number"/>

View File

@ -1,4 +1,4 @@
<form model="clinic.visit" attrs='{"readonly":[["state","in",["cancelled","confirmed"]]]}' show_company="1">
<form model="clinic.visit" attrs='{"readonly":[["state","in",["treatment"]]]}' show_company="1">
<head>
<field name="state"/>
<button string="Print" icon="print" action="print_visit"/>
@ -7,12 +7,11 @@
</button>
</head>
<tabs>
<tab string="Visit">
<tab string="General">
<group span="6" columns="1">
<field name="number"/>
<field name="visit_date"/>
<field name="cycle"/>
<field name="time_use"/>
</group>
<group span="6" columns="1">
<field name="patient_id" onchange="onchange_patient"/>
@ -21,6 +20,12 @@
<field name="department_id"/>
</group>
</tab>
<tab string="Planing">
<field name="time_start"/>
<field name="time_stop"/>
<field name="time_use" onchange="onchange_timeuse"/>
<separator string="Apply to"/>
</tab>
</tabs>
<group attrs='{"invisible": [["state","not in",["waiting_treatment"]]]}'>
<separator string="Select Dialyzer -> Click Do Treatment"/>
@ -41,8 +46,8 @@
<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" />
<button string="Re Visit" type="default" method="reopen" states="cancelled" />
<button string="Cancel Visit" type="danger" method="cancel" states="waiting_treatment" confirm="Are you sure to cancel HD case?"/>
<button string="Dicard" type="warning" icon="trash" method="discard" states="waiting_treatment" confirm="Are you sure to cancel HD case?"/>
<button string="Re Visit" type="default" attrs='{"invisible":[["state","=","treatment"]]}' icon="repeat" method="reopen" states="cancelled" />
</foot>
<related>
<field name="comments"/>

View File

@ -17,7 +17,7 @@ class HDcase(Model):
res={}
fmt="%Y-%m-%d %H:%M:%S"
for obj in self.browse(ids):
diff=datetime.strptime(obj.date_stop,fmt)-datetime.strptime(obj.date_start,fmt)
diff=datetime.strptime(obj.time_stop,fmt)-datetime.strptime(obj.time_start,fmt)
total_time=round(diff.seconds/3600,2)
res[obj.id]=total_time
return res
@ -27,8 +27,6 @@ class HDcase(Model):
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
"doctor_id": fields.Many2One("clinic.doctor","Doctor", required=True,search=True),
"nurse_id": fields.Many2One("clinic.nurse","Nurse", required=True,search=True),
"date_start": fields.DateTime("Time start",required=True,search=True),
"date_stop": fields.DateTime("Time stop",required=True,search=True),
"department_id": fields.Many2One("clinic.department", "Department",search=True),
"wh_start": fields.Float("Wt.Kg start"),
"wh_stop": fields.Float("Wt.Kg stop"),
@ -37,7 +35,7 @@ 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"),("in_progress","In Progress"),("completed","Completed"),("cancelled","Cancelled"),("incomplete","Incomplete")],"Status",required=True),
"state": fields.Selection([("draft","Draft"),("in_progress","In Progress"),("completed","Completed"),("discountinued","Discountinued"),("uncompleted","Uncompleted")],"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"),
@ -54,6 +52,9 @@ class HDcase(Model):
"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"),
"time_start": fields.DateTime("Time start",required=True,search=True),
"time_stop": fields.DateTime("Time stop",required=True,search=True),
"date": fields.Date("Date Treatment",required=True),
}
def _get_number(self,context={}):
@ -80,14 +81,15 @@ class HDcase(Model):
_defaults={
"state": "draft",
"date_start": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
"date_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
"date": lambda *a: time.strftime("%Y-%m-%d"),
"time_start": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
"time_stop": lambda *a: time.strftime("%Y-%m-%d %H:%M:%S"),
'nurse_id': _get_nurse,
"number": _get_number,
"company_id": lambda *a: get_active_company(),
"fee": 1500,
}
_order="date_start desc,number desc"
_order="date desc,number desc"
def onchange_dialyzer(self,context={}):
data=context["data"]
@ -111,6 +113,7 @@ class HDcase(Model):
data=context['data']
patient_id=data['patient_id']
hd_cases=self.search_browse([['patient_id','=',patient_id]])
# TODO reset dialyzer
if hd_cases:
hd_case=hd_cases[-1]
data['doctor_id']=hd_case.doctor_id.id
@ -151,10 +154,6 @@ class HDcase(Model):
data['total']=total
return data
def cancelled(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({"state":"cancelled"})
def make_invoices(self,ids,context={}):
setting=get_model("settings").browse(1)
currency_id=setting.currency_id.id
@ -296,9 +295,10 @@ class HDcase(Model):
obj=self.browse(ids)[0]
obj.write({"state":"in_progress"})
def reject(self,ids,context={}):
def discontinue(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({"state":"cancelled"})
# TODO pop to note
obj.write({"state":"uncompleted"})
def complete(self,ids,context={}):
obj=self.browse(ids)[0]

View File

@ -91,12 +91,17 @@ class Patient(Model):
if not res:
return num
get_model("sequence").increment_number(seq_id,context=context)
def _get_cause_line(self,context={}):
cause_ids=get_model("clinic.cause.chronic").search([])
return cause_ids
_defaults={
"type": "mg",
"reg_date": lambda *a: time.strftime("%Y-%m-%d"),
"number": _get_number,
"company_id": lambda *a: get_active_company(),
#'cause_lines': _get_cause_line,
}
_order="date desc,number desc"

View File

@ -24,20 +24,23 @@ class Visit(Model):
res[obj.id]=late
return res
_fields={
"number": fields.Char("Number",required=True,search=True),
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
"doctor_id": fields.Many2One("clinic.doctor","Doctor",search=True),
"nurse_id": fields.Many2One("clinic.nurse","Nurse",search=True),
"visit_date": fields.Date("Visit Date",required=True,search=True),
"department_id": fields.Many2One("clinic.department", "Department",search=True),
"cycle": fields.Selection([("1","One"),("2","Two"),("3","Tree"),("4","Four")],"Cycle",required=True),
"state": fields.Selection([("draft","Draft"),("waiting_treatment","Waiting Treatment"),('treatment','Treatment'),("cancelled","Cancelled")],"Status",required=True),
"comments": fields.One2Many("message","related_id","Comments"),
"company_id": fields.Many2One("company","Company"),
'time_use': fields.Integer("Time Use(hrs)"),
'time_use': fields.Integer("Fix Hr"),
'late_visit': fields.Integer("Late Vist",function="_get_visit_late"),
"dialyzers": fields.One2Many("clinic.dialyzer.line","visit_id","Dialyzers"),
"visit_date": fields.Date("Visit Date",required=True,search=True),
"time_start": fields.DateTime("Time Start"),
"time_stop": fields.DateTime("Time Stop"),
}
def _get_number(self,context={}):
@ -62,10 +65,23 @@ class Visit(Model):
return nurse_ids[0]
return None
def _get_time_start(self,context={}):
now=datetime.datetime.now()
starttime=now.strftime("%Y-%m-%d %H:%M:%S")
return starttime
def _get_time_stop(self,context={}):
hr=datetime.timedelta(seconds=3600)
now=datetime.datetime.now()
stoptime=(now+hr).strftime("%Y-%m-%d %H:%M:%S")
return stoptime
_defaults={
"state": "draft",
"cycle": "1",
'visit_date': time.strftime("%Y-%m-%d"),
'visit_date': lambda *a: time.strftime("%Y-%m-%d"),
'time_start': _get_time_start,
'time_stop': _get_time_stop,
"number": "/",
"company_id": lambda *a: get_active_company(),
'nurse_id': _get_nurse,
@ -90,7 +106,6 @@ class Visit(Model):
def do_treatment(self,ids,context={}):
hd_case_obj=get_model("clinic.hd.case")
dt=datetime.datetime
timenow=dt.now().strftime("%H:%M:%S")
datenow=dt.now().strftime("%Y-%m-%d")
obj=self.browse(ids)[0]
@ -99,21 +114,17 @@ class Visit(Model):
raise Exception("Today is not treament date!")
if not obj.dialyzers:
raise Exception("Please select dialyzer!")
if len(obj.dialyzers)>1:
raise Exception("Can select only 1 dialyzer!")
fmt_date="%Y-%m-%d %H:%M:%S"
date_from=dt.strptime("%s %s"%(obj.visit_date,timenow),fmt_date)
seconds=(obj.time_use or 1)*3600
date_to=date_from+datetime.timedelta(seconds=seconds)
date_to=date_to.strftime(fmt_date)
date_from=date_from.strftime(fmt_date)
include_fee=obj.patient_id.type in ('mg','sc','nhso') and True or False
vals={
'patient_id': obj.patient_id.id,
'doctor_id': obj.doctor_id.id,
'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id,
'date_start': date_from,
'date_stop': date_to,
'time_start': obj.time_start,
'time_stop': obj.time_stop,
'visit_id': obj.id,
'fee': include_fee and 1500.00 or 0.0,
'fee_type': obj.patient_id.type,
@ -162,7 +173,7 @@ class Visit(Model):
'flash': 'Visit %s has been confirmed'%obj.number,
}
def cancel(self,ids,context={}):
def discard(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({"state":"cancelled"})
@ -260,5 +271,16 @@ class Visit(Model):
line["ultrafittration"]=dialyzer.ultrafittration
line["state"]=dialyzer.state
return data
def onchange_timeuse(self,context={}):
data=context["data"]
time_start=data['time_start']
fmt_date="%Y-%m-%d %H:%M:%S"
time_start=datetime.datetime.strptime(time_start,fmt_date)
time_use=data['time_use']
seconds=(time_use or 1)*3600
time_stop=time_start+datetime.timedelta(seconds=seconds)
data['time_stop']=time_stop.strftime(fmt_date)
return data
Visit.register()

View File

@ -10,7 +10,9 @@
- patient
- new
- load default data
- one2many
- visit
-> split date and time
-> state
- draft
- confirmed
@ -24,6 +26,8 @@
- print visit -> ok
- treament
-
- visit planing
- print invoice
- time start/stop
- only time