conv_bal
watcha.h 2014-10-14 10:57:20 +07:00
parent e1240368c0
commit 1db2481ca7
17 changed files with 286 additions and 236 deletions

View File

@ -0,0 +1,7 @@
<action>
<field name="string">Cycles</field>
<field name="view_cls">multi_view</field>
<field name="model">clinic.cycle</field>
<field name="modes">list,form</field>
<field name="menu">clinic_menu</field>
</action>

View File

@ -0,0 +1,4 @@
<form model="clinic.cycle">
<field name="name"/>
<field name="duration"/>
</form>

View File

@ -0,0 +1,4 @@
<list model="clinic.cycle">
<field name="name"/>
<field name="duration"/>
</list>

View File

@ -2,25 +2,33 @@
<head>
<field name="state"/>
<button string="Options" dropdown="1">
<item string="New Visit" method="new_visit"/>
<!--<item string="New Visit" method="new_visit"/>-->
<item string="TODO" method="todo"/>
</button>
</head>
<group span="6" columns="1">
<field name="number"/>
<field name="date"/>
<field name="time_start"/>
<field name="total_time"/>
<field name="visit_id"/>
<field name="doctor_id"/>
<field name="nurse_id"/>
<field name="cycle_id"/>
</group>
<group span="6" columns="1">
<field name="patient_id" onchange="onchange_patient"/>
<field name="doctor_id"/>
<field name="time_stop"/>
<field name="nurse_id"/>
<field name="duration"/>
<field name="department_id"/>
<field name="visit_id"/>
</group>
<tabs>
<tab string="Dialyzer">
<tab string="General">
<field name="wh_start"/>
<field name="wh_stop"/>
<field name="bp_start"/>
<field name="per_bp_start"/>
<field name="bp_stop"/>
<field name="per_bp_stop"/>
<field name="hct"/>
<field name="dialyzers" nolabel="1">
<list>
<field name="dialyzer_id" domain="[['patient_id','=',parent.patient_id]]" onchange="onchange_dialyzer"/>
@ -35,32 +43,7 @@
</list>
</field>
</tab>
<tab string="Notes">
<field name="wh_start"/>
<field name="wh_stop"/>
<field name="bp_start"/>
<field name="per_bp_start"/>
<field name="bp_stop"/>
<field name="per_bp_stop"/>
<field name="hct"/>
</tab>
<tab string="Next 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="Others">
<field name="note"/>
<field name="paid" readonly="1"/>
</tab>
</tabs>
<separator string="Other Expenses"/>
<tab string="Other Expenses">
<field name="lines" count="3" nolabel="1">
<list>
<field name="product_id" onchange="onchange_product"/>
@ -71,17 +54,41 @@
<field name="amount"/>
</list>
</field>
<group span="4" columns="1">
<field name="fee"/>
<!--<field name="fee_type" onchange="onchange_fee_type"/>-->
<field name="fee_partner_id" domain="[['type','=','org']]" attrs='{"required":[["fee","!=",0]]}'/>
</group>
<group span="4" columns="1">
<group span="8" columns="1">
</group>
<group span="4" columns="1">
<field name="total"/>
<field name="amount"/>
</group>
</tab>
<tab string="Government Pays">
<field name="gm_lines" count="3" nolabel="1">
<list>
<field name="product_id" onchange="onchange_gmproduct"/>
<field name="description"/>
<field name="qty" onchange="onchange_gmline"/>
<field name="uom_id"/>
<field name="price" onchange="onchange_gmline"/>
<field name="amount"/>
</list>
</field>
<group span="8" columns="1">
<group span="6" columns="1">
<!--<field name="fee_partner_id"/>-->
<field name="fee_partner_id" domain="[['type','=','org']]" attrs='{"required":[["fee_amount","!=",0]]}'/>
</group>
<group span="2" columns="1">
</group>
</group>
<group span="4" columns="1">
<field name="fee_total"/>
<field name="fee_amount"/>
</group>
</tab>
<tab string="Notes">
<field name="note" nolabel="1"/>
</tab>
</tabs>
<foot>
<button string="Confirm" type="success" method="confirm" states="draft"/>
<button string="Complete" type="success" method="complete" states="in_progress"/>

View File

@ -2,6 +2,7 @@
<field name="number"/>
<field name="time_start"/>
<field name="time_stop"/>
<field name="cycle_id"/>
<field name="patient_id"/>
<field name="doctor_id"/>
<field name="nurse_id"/>

View File

@ -19,9 +19,6 @@
</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="TODO" action="todo"/>
</item>
@ -30,6 +27,7 @@
</item>
<item string="Settings">
<item string="Departments" action="clinic_department"/>
<item string="Cycle" action="clinic_cycle"/>
<item string="Clinic Settings" action="clinic_setting"/>
</item>
</menu>

View File

@ -1,5 +1,5 @@
<!--<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' date_field="date_visit" start_field="time_start" end_field="time_stop" colors='{"#090":[["cycle","=",1]],"#2400ff":[["cycle","=",2]],"orange":[["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]],"orange":[["cycle","=",3]],"#f20000":[["cycle","=",4]]}'>
<field name="patient_id"/>
<field name="cycle"/>
<field name="number"/>

View File

@ -5,53 +5,25 @@
<button string="Options" dropdown="1">
<item string="Copy" method="copy"/>
<item string="Create Dialyzer" method="create_dialyzer"/>
<item string="Generate Cycle" method="generate_cycle"/>
</button>
</head>
<tabs>
<tab string="General">
<group span="6" columns="1">
<field name="number"/>
<field name="date_visit" onchange="onchange_date_visit"/>
<field name="cycle"/>
<field name="time_start" onchange="onchange_time" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
<field name="department_id"/>
<field name="cycle_id" onchange="onchange_time" required="1"/>
</group>
<group span="6" columns="1">
<field name="patient_id" onchange="onchange_patient"/>
<field name="doctor_id" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
<field name="nurse_id" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
<field name="department_id"/>
</group>
</tab>
<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_stop"/>
<field name="state"/>
</list>
</field>
<field name="doctor_id"/>
<field name="nurse_id" attrs='{"required":[["state","=","waiting_treatment"]]}'/>
</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" />

View File

@ -1,10 +1,18 @@
<list model="clinic.visit" colors='{"#EF4D4D":[["late_visit","=",1]]}'>
<field name="late_visit" invisible="1"/>
<list model="clinic.visit">
<search>
<field name="number"/>
<field name="date_visit"/>
<field name="cycle"/>
<field name="cycle_id"/>
<field name="date"/>
<field name="patient_id"/>
<field name="doctor_id"/>
<field name="nurse_id"/>
</search>
<field name="number"/>
<field name="time_start"/>
<field name="time_stop"/>
<field name="patient_id"/>
<field name="doctor_id"/>
<field name="nurse_id"/>
<field name="cycle_id"/>
<field name="state"/>
</list>

View File

@ -16,11 +16,14 @@ from . import department
from . import doctor
from . import nurse
from . import visit
from . import visit_line
from . import visit_plan
from . import hd_case
from . import hd_case_line
from . import hd_case_gmline
from . import hd_case_discont
from . import dialyzer
from . import dialyzer_line
from . import import_payment
from . import file_sheet
from . import cycle

View File

@ -0,0 +1,37 @@
from datetime import datetime, timedelta
from netforce.model import Model, fields
FMT_DATE="%Y-%m-%d %H:%M:%S"
class Cycle(Model):
_name="clinic.cycle"
_string="Cycle"
_fields={
"name": fields.Char("Name",required=True,search=True),
#"time_start": fields.DateTime("Time Start"),
#"time_stop": fields.DateTime("Time Stop"),
'duration': fields.Integer("Duration (hrs)"),
}
def _get_time_stop(self,context):
time_stop=datetime.now()+timedelta(seconds=3600)
return time_stop.strftime(FMT_DATE)
_defaults={
#'time_start': lambda *a: datetime.now().strftime(FMT_DATE),
#'time_stop': _get_time_stop,
'duration': 1,
}
def onchange_duration(self,context={}):
data=context['data']
duration=data['duration']
seconds=duration*3600
time_start=data['time_start']
data['time_stop']=(datetime.strptime(time_start,FMT_DATE)+timedelta(seconds=seconds)).strftime(FMT_DATE)
return data
Cycle.register()

View File

@ -24,8 +24,11 @@ class HDcase(Model):
_fields={
"number": fields.Char("Number",required=True,search=True),
"time_start": fields.DateTime("Time start",required=True,search=True),
"time_stop": fields.DateTime("Time stop",required=True,search=True),
"date": fields.Date("Time stop",required=True,search=True),
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
"doctor_id": fields.Many2One("clinic.doctor","Doctor", required=True,search=True),
"doctor_id": fields.Many2One("clinic.doctor","Doctor", required=False,search=True),
"nurse_id": fields.Many2One("clinic.nurse","Nurse", required=True,search=True),
"department_id": fields.Many2One("clinic.department", "Department",search=True),
"wh_start": fields.Float("Wt.Kg start"),
@ -38,9 +41,9 @@ class HDcase(Model):
"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"),
"gm_lines": fields.One2Many("clinic.hd.case.gm.line","hd_case_id","GM Lines"),
"comments": fields.One2Many("message","related_id","Comments"),
"company_id": fields.Many2One("company","Company"),
"fee": fields.Float("HD Fee"),
"amount": fields.Float("Due Amount",function="get_total",readonly=True,function_multi=True),
"total": fields.Float("Total",function="get_total",readonly=True,function_multi=True),
"reconcile_id": fields.Many2One("account.reconcile","Reconcile Id",readonly=True),
@ -48,15 +51,13 @@ class HDcase(Model):
"pickings": fields.One2Many("stock.picking","related_id","Pickings"),
"payments": fields.One2Many("account.payment","related_id","Payments"),
'visit_id': fields.Many2One("clinic.visit", "Visit"),
'total_time': fields.Integer("Total Time(Hrs)",function="get_hrs"),
'duration': fields.Integer("Duration (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","Contact Fee"),
'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),
'planes': fields.One2Many("clinic.visit.plane","hd_case_id","Planning"),
"fee_amount": fields.Float("Due Amount",function="get_gmtotal",readonly=True,function_multi=True),
"fee_total": fields.Float("Total",function="get_gmtotal",readonly=True,function_multi=True),
'note': fields.Text("Note"),
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
}
def _get_number(self,context={}):
@ -90,6 +91,7 @@ class HDcase(Model):
"number": _get_number,
"company_id": lambda *a: get_active_company(),
"fee": 1500,
'cycle': '1',
}
_order="date desc,number desc"
@ -156,6 +158,37 @@ class HDcase(Model):
data['total']=total
return data
def onchange_gmproduct(self,context={}):
data=context['data']
path=context["path"]
line=get_data_path(data,path,parent=True)
product_id=line.get('product_id')
if not product_id:
return
prod=get_model("product").browse(product_id)
line['uom_id']=prod.uom_id.id
line['description']=prod.name
line['qty']=1
line['price']=prod.sale_price or 0.0
line['amount']=prod.sale_price or 0.0
data=self.onchange_gmline(context)
return data
def onchange_gmline(self,context={}):
data=context['data']
total=0.0
for line in data['gm_lines']:
price=line.get('price') or 0
qty=line.get('qty') or 0
amt=qty * price
product_id=line.get("product_id")
if product_id:
line['amount']=amt
total+=amt
data['fee_total']=total
data['fee_amount']=total
return data
def make_invoices(self,ids,context={}):
setting=get_model("settings").browse(1)
currency_id=setting.currency_id.id
@ -313,11 +346,12 @@ class HDcase(Model):
def complete(self,ids,context={}):
obj=self.browse(ids)[0]
if not obj.dialyzers:
raise Exception("Please enter dialyzer!")
obj.make_invoices()
obj.post_invoices()
obj.write({
"state":"completed",
#'paid': True,
})
return {
'next': {
@ -357,6 +391,22 @@ class HDcase(Model):
}
return vals
def get_gmtotal(self,ids,context={}):
vals={}
for obj in self.browse(ids):
total=0
amt=0
fee=obj.fee or 0
for line in obj.gm_lines:
total+=line.amount or 0
fee=0 # XXX
amt=total+fee
vals[obj.id]={
"fee_total": total,
"fee_amount": amt,
}
return vals
def view_hdcase(self,ids,context={}):
return {
'name': 'clinic_hd_case',

View File

@ -0,0 +1,16 @@
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()

View File

@ -183,14 +183,6 @@ class Patient(Model):
get_model("partner").delete(partner_ids)
super().delete(ids)
def _delete(self,ids,context={}):
partner_ids=[]
for obj in self.browse(ids):
if obj.type not in ("mg","nhso","sc"):
partner_ids.append(obj.partner_id.id)
get_model("partner").delete(partner_ids)
super().delete(ids)
def write(self,ids,vals,**kw):
for obj in self.browse(ids):
partner_id=obj.partner_id
@ -208,4 +200,8 @@ class Patient(Model):
vals['partner_id']=partner_id
super().write(ids,vals,**kw)
def generate_visit(self,ids,context={}):
obj=self.browse(ids)[0]
pass
Patient.register()

View File

@ -1,9 +1,11 @@
import time
import datetime
from datetime import datetime, timedelta
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
#from netforce.utils import get_data_path
FMT_DATE="%Y-%m-%d %H:%M:%S"
class Visit(Model):
_name="clinic.visit"
@ -14,35 +16,30 @@ 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
if datenow > obj.date_visit and obj.state=='waiting_treatment':
if datenow > (obj.date_visit or '') and obj.state=='waiting_treatment':
late=1
res[obj.id]=late
return res
_fields={
"number": fields.Char("Number",required=True,search=True),
"date": fields.Date("Date Visit"),
"time_start": fields.DateTime("Time Start"),
"time_stop": fields.DateTime("Time Stop"),
"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),
"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("Fix Hour"),
'late_visit': fields.Integer("Late Vist",function="_get_visit_late"),
"dialyzers": fields.One2Many("clinic.dialyzer.line","visit_id","Dialyzers"),
"date_visit": fields.Date("Visit Date",required=True,search=True),
"time_start": fields.DateTime("Time Start"),
"time_stop": fields.DateTime("Time Stop"),
'planes': fields.One2Many("clinic.visit.plane","visit_id","Planning"),
'late_visit': fields.Integer("Late Vist",function="_get_visit_late", store=True),
'hd_cases': fields.One2Many('clinic.hd.case','visit_id',"HD Cases",readonly=True),
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
"state": fields.Selection([("draft","Draft"),("waiting_treatment","Waiting Treatment"),('treatment','Treatment'),("cancelled","Cancelled")],"Status",required=True),
"comments": fields.One2Many("message","related_id","Comments"),
}
def _get_number(self,context={}):
@ -68,25 +65,25 @@ class Visit(Model):
return None
def _get_time_start(self,context={}):
now=datetime.datetime.now()
now=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()
hr=timedelta(seconds=3600)
now=datetime.now()
stoptime=(now+hr).strftime("%Y-%m-%d %H:%M:%S")
return stoptime
_defaults={
"state": "draft",
"cycle": "1",
'date_visit': lambda *a: time.strftime("%Y-%m-%d"),
'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,
'cycle': '1',
'time_use': 1,
}
_order="id desc"
@ -107,19 +104,15 @@ class Visit(Model):
def do_treatment(self,ids,context={}):
hd_case_obj=get_model("clinic.hd.case")
dt=datetime.datetime
dt=datetime
datenow=dt.now().strftime("%Y-%m-%d")
obj=self.browse(ids)[0]
date_visit=obj.time_start[0:10]
# cannot treatment if current date is not same visit date
if obj.date_visit!=datenow:
if date_visit!=datenow:
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!")
include_fee=obj.patient_id.type in ('mg','sc','nhso') and True or False
#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,
@ -128,7 +121,8 @@ class Visit(Model):
'time_start': obj.time_start,
'time_stop': obj.time_stop,
'visit_id': obj.id,
'fee': include_fee and 1500.00 or 0.0,
'cycle_id': obj.cycle_id.id,
#'fee': include_fee and 1500.00 or 0.0,
'fee_type': obj.patient_id.type,
'lines':[],
'dialyzers': [],
@ -155,21 +149,7 @@ class Visit(Model):
vals['fee_partner_id']=partner_id
break
# find dialyser
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,
})
for plan in obj.planes:
plan.write({
'hd_case_id': hd_case_id,
})
obj.write({"state":"treatment"})
return {
'next': {
@ -193,14 +173,9 @@ class Visit(Model):
patient_id=data['patient_id']
visits=self.search_browse([['patient_id','=',patient_id]],order="number desc")
if visits:
#print([(v.id, v.date_visit,v.cycle) for v in visits])
visit=visits[0]
data['doctor_id']=visit.doctor_id.id
data['department_id']=visit.department_id.id
cycle=int(visit.cycle)+1
data['cycle']=str(cycle)
if cycle>4:
data['cycle']='1'
else:
data['doctor_id']=None
data['department_id']=None
@ -213,15 +188,8 @@ class Visit(Model):
'doctor_id': obj.doctor_id.id,
'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id,
'cycle': obj.cycle,
}
# XXX update cycle
visits=self.search_browse([['patient_id','=',obj.patient_id.id]],order="number desc")
if visits:
visit=visits[0] # order desc already
cycle=int(visit.cycle)+1
vals['cycle']=str(cycle)
if cycle>4:
vals['cycle']='1'
new_id=self.create(vals,context=context)
new_obj=self.browse(new_id)
return {
@ -246,7 +214,6 @@ class Visit(Model):
return {}
ref_id=int(ref_id)
obj=self.browse(ref_id)
cycle_list={'1': 'One','2': 'Two','3': 'Tree','4': 'Four'}
data={
'number': obj.number,
'date_visit': obj.date_visit,
@ -254,80 +221,22 @@ class Visit(Model):
'patient_name': obj.patient_id.name or "",
'doctor_name': obj.doctor_id.name or "",
'nurse_name': obj.nurse_id.name or "",
'cycle': cycle_list.get(obj.cycle,""),
'print_date': time.strftime("%d/%m/%Y"),
}
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
def onchange_timeuse(self,context={}):
data=context["data"]
def onchange_time(self,context={}):
data=context['data']
cycle_id=data['cycle_id']
duration=1
if cycle_id:
cycle=get_model('clinic.cycle').browse(cycle_id)
duration=cycle.duration or 0
seconds=duration*3600
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)
data['time_stop']=(datetime.strptime(time_start,FMT_DATE)+timedelta(seconds=seconds)).strftime(FMT_DATE)
return data
def onchange_date_visit(self,context={}):
data=context["data"]
timenow=time.strftime("%H:%M:%S")
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)
print("time_start ", time_start)
time_use=data['time_use']
seconds=(time_use or 1)*3600
time_stop=time_start+datetime.timedelta(seconds=seconds)
data['time_start']=time_start.strftime(fmt_date)
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]
if not timevisit:
timevisit=timenow
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
def create_dialyzer(self,ids,context={}):
return {

View File

@ -0,0 +1,15 @@
from netforce.model import Model, fields, get_model
class VisitLine(Model):
_name="clinic.visit.line"
_string="Visit Line"
_fields={
'visit_id': fields.Many2One("clinic.visit","Visit"),
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
'time_start': fields.DateTime("Time Start"),
'time_stop': fields.DateTime("Time Stop"),
"state": fields.Selection([("pending","Pending"),("completed","Completed")],"Status"),
}
VisitLine.register()

View File

@ -1,7 +1,30 @@
=====
select diaylizer at treatment page
=====
step:
nurse
1. go to visit calendar
- auto gen visit
2. go to visit
- confirm
- copy data to hd case
- patient
- doctor
- department
- nurse
- other ...
- auto generate cycle (4 cycle)
3. go to hd case
- select dialyzer
- if not we can no do treament
===== todo
monday:
- A, B, C, D
tueday:
######
- import payment
- visit planing
######
========
Account Receivable -> invoice
find account id