planing visit

conv_bal
watcha.h 2014-10-05 15:29:21 +07:00
parent 5fb4bef0b9
commit 12a365c2d6
10 changed files with 212 additions and 26 deletions

View File

@ -2,7 +2,7 @@
<head> <head>
<field name="state"/> <field name="state"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="Journal Report" method="journal_report"/> <item string="New Visit" method="new_visit"/>
</button> </button>
</head> </head>
<group span="6" columns="1"> <group span="6" columns="1">
@ -35,6 +35,17 @@
</list> </list>
</field> </field>
</tab> </tab>
<tab string="New Visit">
<separator string="Click Options-> New Visit"/>
<field name="planes" nolabel="1" domain="[['state','=','open']]">
<list>
<field name="date" onchange="onchange_dateplane"/>
<field name="time_start"/>
<field name="time_stop"/>
<field name="state"/>
</list>
</field>
</tab>
<tab string="Notes"> <tab string="Notes">
<field name="wh_start"/> <field name="wh_start"/>
<field name="wh_stop"/> <field name="wh_stop"/>
@ -50,7 +61,7 @@
</tab> </tab>
</tabs> </tabs>
<separator string="Other Expenses"/> <separator string="Other Expenses"/>
<field name="lines" count="4" nolabel="1"> <field name="lines" count="3" nolabel="1">
<list> <list>
<field name="product_id" onchange="onchange_product"/> <field name="product_id" onchange="onchange_product"/>
<field name="description"/> <field name="description"/>

View File

@ -1,4 +1,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' date_field="date_visit" 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]]}'> <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="patient_id"/>
<field name="cycle"/> <field name="cycle"/>

View File

@ -10,21 +10,29 @@
<tab string="General"> <tab string="General">
<group span="6" columns="1"> <group span="6" columns="1">
<field name="number"/> <field name="number"/>
<field name="visit_date"/> <field name="date_visit" onchange="onchange_date_visit"/>
<field name="cycle"/> <field name="cycle"/>
</group> </group>
<group span="6" columns="1"> <group span="6" columns="1">
<field name="patient_id" onchange="onchange_patient"/> <field name="patient_id" onchange="onchange_patient"/>
<field name="doctor_id"/> <field name="doctor_id" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
<field name="nurse_id"/> <field name="nurse_id" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
<field name="department_id"/> <field name="department_id"/>
</group> </group>
</tab> </tab>
<tab string="Planing"> <tab string="Planing">
<field name="time_start" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
<field name="time_stop" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
<field name="time_use" onchange="onchange_timeuse"/>
<separator string="Next Visit"/>
<field name="planes" nolabel="1">
<list>
<field name="date" onchange="onchange_dateplane"/>
<field name="time_start"/> <field name="time_start"/>
<field name="time_stop"/> <field name="time_stop"/>
<field name="time_use" onchange="onchange_timeuse"/> <field name="state"/>
<separator string="Apply to"/> </list>
</field>
</tab> </tab>
</tabs> </tabs>
<group attrs='{"invisible": [["state","not in",["waiting_treatment"]]]}'> <group attrs='{"invisible": [["state","not in",["waiting_treatment"]]]}'>

View File

@ -1,7 +1,7 @@
<list model="clinic.visit" colors='{"#EF4D4D":[["late_visit","=",1]]}'> <list model="clinic.visit" colors='{"#EF4D4D":[["late_visit","=",1]]}'>
<field name="late_visit" invisible="1"/> <field name="late_visit" invisible="1"/>
<field name="number"/> <field name="number"/>
<field name="visit_date"/> <field name="date_visit"/>
<field name="cycle"/> <field name="cycle"/>
<field name="patient_id"/> <field name="patient_id"/>
<field name="doctor_id"/> <field name="doctor_id"/>

View File

@ -8,7 +8,6 @@ from . import doctor
from . import nurse from . import nurse
from . import visit from . import visit
from . import hd_case from . import hd_case
#from . import hd_case_dialyzer
from . import hd_case_line from . import hd_case_line
from . import dialyzer from . import dialyzer
from . import dialyzer_line from . import dialyzer_line
@ -24,3 +23,4 @@ from . import input_line
from . import file_sheet from . import file_sheet
from . import payment from . import payment
from . import import_payment from . import import_payment
from . import visit_plan

View File

@ -1,5 +1,5 @@
import time import time
from datetime import datetime from datetime import datetime, timedelta
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
from netforce.utils import get_data_path from netforce.utils import get_data_path
@ -55,6 +55,7 @@ class HDcase(Model):
"time_start": fields.DateTime("Time start",required=True,search=True), "time_start": fields.DateTime("Time start",required=True,search=True),
"time_stop": fields.DateTime("Time stop",required=True,search=True), "time_stop": fields.DateTime("Time stop",required=True,search=True),
"date": fields.Date("Date Treatment",required=True), "date": fields.Date("Date Treatment",required=True),
'planes': fields.One2Many("clinic.visit.plane","hd_case_id","Planning"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -163,7 +164,7 @@ class HDcase(Model):
if not uom: if not uom:
raise Exception("Unit not found in uom") raise Exception("Unit not found in uom")
obj=self.browse(ids[0]) obj=self.browse(ids[0])
due_date=obj.date_start[0:10] due_date=obj.date[0:10]
# XXX # XXX
context['type']='out' context['type']='out'
context['inv_type']='invoice' context['inv_type']='invoice'
@ -369,4 +370,104 @@ class HDcase(Model):
data['fee']=0.0 data['fee']=0.0
return data return data
def new_visit(self,ids,context={}):
obj=self.browse(ids[0])
skip_plan_id=0
for plane in obj.planes:
if plane.state=='close':
continue
break
# XXX
if not plane or plane.state=='close':
raise Exception("No Planing")
print("found plane ",plane)
vals={
'date_visit': plane.date,
'time_start': plane.time_start,
'time_stop': plane.time_stop,
'patient_id': obj.patient_id.id,
'doctor_id': obj.doctor_id.id,
'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id,
'planes': [],
'dialyzers': [],
#'state': 'waiting_treatment',
'state': 'draft', # XXX need to gen new doc
}
plane.write({
'state': 'close',
})
visit_id=get_model("clinic.visit").create(vals)
visit=get_model('clinic.visit').browse(visit_id)
skip_plan_id=plane.id
# copy remaining plane to new visit
new_planes=[]
for pl in obj.planes:
# XXX
if skip_plan_id==pl.id:
continue
if pl.state=='close':
continue
print("pl state ", pl.state)
line={
'date': pl.date,
'time_start': pl.time_start,
'time_stop': pl.time_stop,
'visit_id': visit_id,
}
new_planes.append(('create',line))
new_dialyzers=[]
for dlz in obj.dialyzers:
if dlz.use_time > dlz.dialyzer_id.max_use_time:
continue
use_time=(dlz.use_time or 0)+1
line={
"visit_id": visit_id,
"dialyzer_id": dlz.dialyzer_id.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,
}
new_dialyzers.append(('create',line))
vals={
'planes': new_planes,
'dialyzers': new_dialyzers,
}
visit.write(vals)
return {
'next': {
'name': "clinic_visit",
'mode': 'form',
'active_id': visit_id,
},
'flash': "New visit is created",
}
def onchange_dateplane(self,context={}):
data=context["data"]
path=context["path"]
line=get_data_path(data,path,parent=True)
start_date=line.get("date")
if not start_date:
return {}
timenow=time.strftime("%H:%M:%S")
timevisit=timenow
# XXX
timevisit=data['time_start'][11:20]
fmt_date="%Y-%m-%d %H:%M:%S"
fix_hrs=data['total_time'] or 0 # XXX
time_start=datetime.strptime("%s %s"%(start_date,timevisit),fmt_date)
seconds=fix_hrs*3600
time_stop=time_start+timedelta(seconds=seconds)
line['time_start']=time_start.strftime(fmt_date)
line['time_stop']=time_stop.strftime(fmt_date)
if not line.get('state'):
line['state']='open'
return data
HDcase.register() HDcase.register()

View File

@ -19,7 +19,7 @@ class Visit(Model):
datenow=time.strftime("%Y-%m-%d") datenow=time.strftime("%Y-%m-%d")
for obj in self.browse(ids): for obj in self.browse(ids):
late=0 late=0
if datenow > obj.visit_date and obj.state=='waiting_treatment': if datenow > obj.date_visit and obj.state=='waiting_treatment':
late=1 late=1
res[obj.id]=late res[obj.id]=late
return res return res
@ -35,12 +35,13 @@ class Visit(Model):
"state": fields.Selection([("draft","Draft"),("waiting_treatment","Waiting Treatment"),('treatment','Treatment'),("cancelled","Cancelled")],"Status",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"), "comments": fields.One2Many("message","related_id","Comments"),
"company_id": fields.Many2One("company","Company"), "company_id": fields.Many2One("company","Company"),
'time_use': fields.Integer("Fix Hr"), 'time_use': fields.Integer("Fix Hour"),
'late_visit': fields.Integer("Late Vist",function="_get_visit_late"), 'late_visit': fields.Integer("Late Vist",function="_get_visit_late"),
"dialyzers": fields.One2Many("clinic.dialyzer.line","visit_id","Dialyzers"), "dialyzers": fields.One2Many("clinic.dialyzer.line","visit_id","Dialyzers"),
"visit_date": fields.Date("Visit Date",required=True,search=True), "date_visit": fields.Date("Visit Date",required=True,search=True),
"time_start": fields.DateTime("Time Start"), "time_start": fields.DateTime("Time Start"),
"time_stop": fields.DateTime("Time Stop"), "time_stop": fields.DateTime("Time Stop"),
'planes': fields.One2Many("clinic.visit.plane","visit_id","Planning"),
} }
def _get_number(self,context={}): def _get_number(self,context={}):
@ -79,7 +80,7 @@ class Visit(Model):
_defaults={ _defaults={
"state": "draft", "state": "draft",
"cycle": "1", "cycle": "1",
'visit_date': lambda *a: time.strftime("%Y-%m-%d"), 'date_visit': lambda *a: time.strftime("%Y-%m-%d"),
'time_start': _get_time_start, 'time_start': _get_time_start,
'time_stop': _get_time_stop, 'time_stop': _get_time_stop,
"number": "/", "number": "/",
@ -110,7 +111,7 @@ class Visit(Model):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
# cannot treatment if current date is not same visit date # cannot treatment if current date is not same visit date
if obj.visit_date!=datenow: if obj.date_visit!=datenow:
raise Exception("Today is not treament date!") raise Exception("Today is not treament date!")
if not obj.dialyzers: if not obj.dialyzers:
raise Exception("Please select dialyzer!") raise Exception("Please select dialyzer!")
@ -163,6 +164,11 @@ class Visit(Model):
dlz.write({ dlz.write({
'hd_case_id': hd_case_id, 'hd_case_id': hd_case_id,
}) })
for plan in obj.planes:
plan.write({
'hd_case_id': hd_case_id,
})
obj.write({"state":"treatment"}) obj.write({"state":"treatment"})
return { return {
'next': { 'next': {
@ -186,7 +192,7 @@ class Visit(Model):
patient_id=data['patient_id'] patient_id=data['patient_id']
visits=self.search_browse([['patient_id','=',patient_id]],order="number desc") visits=self.search_browse([['patient_id','=',patient_id]],order="number desc")
if visits: if visits:
#print([(v.id, v.visit_date,v.cycle) for v in visits]) #print([(v.id, v.date_visit,v.cycle) for v in visits])
visit=visits[0] visit=visits[0]
data['doctor_id']=visit.doctor_id.id data['doctor_id']=visit.doctor_id.id
data['department_id']=visit.department_id.id data['department_id']=visit.department_id.id
@ -242,7 +248,7 @@ class Visit(Model):
cycle_list={'1': 'One','2': 'Two','3': 'Tree','4': 'Four'} cycle_list={'1': 'One','2': 'Two','3': 'Tree','4': 'Four'}
data={ data={
'number': obj.number, 'number': obj.number,
'visit_date': obj.visit_date, 'date_visit': obj.date_visit,
'department_name': obj.department_id.name or "", 'department_name': obj.department_id.name or "",
'patient_name': obj.patient_id.name or "", 'patient_name': obj.patient_id.name or "",
'doctor_name': obj.doctor_id.name or "", 'doctor_name': obj.doctor_id.name or "",
@ -283,4 +289,39 @@ class Visit(Model):
data['time_stop']=time_stop.strftime(fmt_date) data['time_stop']=time_stop.strftime(fmt_date)
return data return data
def onchange_date_visit(self,context={}):
data=context["data"]
timenow=time.strftime("%Y-%m-%d")
date_visit=data['date_visit']
fmt_date="%Y-%m-%d %H:%M:%S"
time_start=datetime.datetime.strptime("%s %s"%(date_visit,timenow),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
def onchange_dateplane(self,context={}):
data=context["data"]
path=context["path"]
line=get_data_path(data,path,parent=True)
start_date=line.get("date")
if not start_date:
return {}
timenow=time.strftime("%H:%M:%S")
timevisit=timenow
# XXX
timevisit=data['time_start'][11:20]
fmt_date="%Y-%m-%d %H:%M:%S"
fix_hrs=data['time_use'] or 0
time_start=datetime.datetime.strptime("%s %s"%(start_date,timevisit),fmt_date)
seconds=fix_hrs*3600
time_stop=time_start+datetime.timedelta(seconds=seconds)
line['time_start']=time_start.strftime(fmt_date)
line['time_stop']=time_stop.strftime(fmt_date)
if not line.get('state'):
line['state']='open'
return data
Visit.register() Visit.register()

View File

@ -0,0 +1,22 @@
from netforce.model import Model, fields
class VisitPlane(Model):
_name="clinic.visit.plane"
_string="Visit Plan"
_fieldname="visit_id"
_fields={
'visit_id': fields.Many2One("clinic.visit","Visit"),
'hd_case_id': fields.Many2One("clinic.hd.case","HD Case"),
"date": fields.Date("Date"),
"time_start": fields.DateTime("Time Start"),
"time_stop": fields.DateTime("Time Stop"),
"state": fields.Selection([("open","Open"),("close","Close")],"Status"),
'active': fields.Boolean("Active"), # to hide
}
_defaults={
'state': 'open',
'active': True,
}
VisitPlane.register()

Binary file not shown.

View File

@ -12,7 +12,7 @@
- load default data - load default data
- one2many - one2many
- visit - visit
-> split date and time -> split date and time ->ok
-> state -> state
- draft - draft
- confirmed - confirmed
@ -26,17 +26,20 @@
- print visit -> ok - print visit -> ok
- treament - treament
-
- visit planing - visit planing
- find visit of patient which state is close
- print invoice - print invoice
- time start/stop - pay for normal person
-> how ???
- make payment
- time start/stop -> ok
- only time - only time
- date treament - date treament ->ok
- color (check state) - color (check state)
- if fail -> red - if fail -> red
- cancelled - cancelled
- make next appointment - make next appointment -> ok
- make payment
- state - state
- ready to treatment - ready to treatment
- paid -> no because not realte to accounting - paid -> no because not realte to accounting