auto gen visit from visit board
parent
f3bc049338
commit
2cafedd193
|
@ -13,7 +13,8 @@
|
||||||
<field name="reg_date"/>
|
<field name="reg_date"/>
|
||||||
<field name="first_name" required="1"/>
|
<field name="first_name" required="1"/>
|
||||||
<field name="last_name" required="1"/>
|
<field name="last_name" required="1"/>
|
||||||
<field name="doctor_id"/>
|
<field name="doctor_id" required="1"/>
|
||||||
|
<field name="department_id" required="1"/>
|
||||||
<field name="walkin"/>
|
<field name="walkin"/>
|
||||||
<field name="active" invisible="1"/>
|
<field name="active" invisible="1"/>
|
||||||
<tabs>
|
<tabs>
|
||||||
|
@ -79,6 +80,7 @@
|
||||||
<group span="4" columns="1">
|
<group span="4" columns="1">
|
||||||
</group>
|
</group>
|
||||||
</tab>
|
</tab>
|
||||||
|
<!--
|
||||||
<tab string="Department">
|
<tab string="Department">
|
||||||
<field name="department_id" string="Main Department"/>
|
<field name="department_id" string="Main Department"/>
|
||||||
<group span="8" columns="1">
|
<group span="8" columns="1">
|
||||||
|
@ -91,6 +93,7 @@
|
||||||
<group span="4" columns="1">
|
<group span="4" columns="1">
|
||||||
</group>
|
</group>
|
||||||
</tab>
|
</tab>
|
||||||
|
-->
|
||||||
<tab string="HD Departments">
|
<tab string="HD Departments">
|
||||||
<field name="departments" nolabel="1"/>
|
<field name="departments" nolabel="1"/>
|
||||||
<group span="8" columns="1">
|
<group span="8" columns="1">
|
||||||
|
@ -106,15 +109,23 @@
|
||||||
<tab string="Accounting">
|
<tab string="Accounting">
|
||||||
<field name="partner_id" domain='[["is_patient","=","true"]]'/>
|
<field name="partner_id" domain='[["is_patient","=","true"]]'/>
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Other">
|
<tab string="Dispose Info">
|
||||||
<group layout_form="stacked">
|
<group>
|
||||||
<field name="dispose" span="3"/>
|
<field name="dispose"/>
|
||||||
<field name="resign_date" attrs='{"required":[["dispose","=","true"]]}' span="4"/>
|
<field name="resign_date" attrs='{"required":[["dispose","=","true"]]}'/>
|
||||||
<field name="note" attrs='{"required":[["dispose","=","true"]]}' span="4"/>
|
<field name="note" attrs='{"required":[["dispose","=","true"]]}'/>
|
||||||
<field name="state" invisible="1"/>
|
<field name="state" invisible="1"/>
|
||||||
<field name="hn_no" invisible="1"/>
|
<field name="hn_no" invisible="1"/>
|
||||||
</group>
|
</group>
|
||||||
</tab>
|
</tab>
|
||||||
|
<tab string="Log">
|
||||||
|
<group>
|
||||||
|
<field name="c_time"/>
|
||||||
|
<field name="w_time"/>
|
||||||
|
<field name="c_uid"/>
|
||||||
|
<field name="w_uid"/>
|
||||||
|
</group>
|
||||||
|
</tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
<related>
|
<related>
|
||||||
<field name="addresses"/>
|
<field name="addresses"/>
|
||||||
|
|
|
@ -2,6 +2,7 @@ import time
|
||||||
|
|
||||||
from netforce.model import Model, fields, get_model
|
from netforce.model import Model, fields, get_model
|
||||||
from netforce.access import get_active_company, get_active_user, set_active_user
|
from netforce.access import get_active_company, get_active_user, set_active_user
|
||||||
|
from netforce.database import get_connection
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
|
@ -91,7 +92,24 @@ class Patient(Model):
|
||||||
set_active_user(user_id)
|
set_active_user(user_id)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def _get_log(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
db=get_connection()
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
for r in db.query("select create_time,create_uid,write_time,write_uid from clinic_patient where id = %s",obj.id):
|
||||||
|
res[obj.id]={
|
||||||
|
'c_time': r['create_time'],
|
||||||
|
'c_uid': r['create_uid'],
|
||||||
|
'w_uid': r['write_uid'],
|
||||||
|
'w_time': r['write_time'],
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
|
'c_time': fields.DateTime("Created",function="_get_log", function_multi=True),
|
||||||
|
'c_uid': fields.Many2One("base.user","Create By",function="_get_log", function_multi=True),
|
||||||
|
'w_time': fields.DateTime("Edited",function="_get_log", function_multi=True),
|
||||||
|
'w_uid': fields.Many2One("base.user","Lasted Edit",function="_get_log", function_multi=True),
|
||||||
"number": fields.Char("HN Number",required=True,search=True),
|
"number": fields.Char("HN Number",required=True,search=True),
|
||||||
"trt_no": fields.Char("TRT",search=True),
|
"trt_no": fields.Char("TRT",search=True),
|
||||||
"hn_no": fields.Char("HN",function="_get_hn_no",store=True),
|
"hn_no": fields.Char("HN",function="_get_hn_no",store=True),
|
||||||
|
|
|
@ -295,11 +295,11 @@ class ReportLaborCost(Model):
|
||||||
'option_qty2': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom5)),
|
'option_qty2': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%(dom5)),
|
||||||
})
|
})
|
||||||
for dline in dlines[1:-1]:
|
for dline in dlines[1:-1]:
|
||||||
dlines[-1]['qty']+=float(dline['qty']) or 0
|
dlines[-1]['qty']+=float((dline['qty'] or "").replace(",","")) or 0
|
||||||
dlines[-1]['qty2']+=float(dline['qty2']) or 0
|
dlines[-1]['qty2']+=float((dline['qty2'] or "").replace(",","")) or 0
|
||||||
dlines[-1]['total_qty']+=dline['total_qty'] or 0
|
dlines[-1]['total_qty']+=dline['total_qty'] or 0
|
||||||
dlines[-1]['cost']+=dline['cost'] or 0
|
dlines[-1]['cost']+=dline['cost'] or 0
|
||||||
dlines[-1]['walkin_qty']+=float(dline['qty2']) or 0
|
dlines[-1]['walkin_qty']+=float((dline['qty2'] or "").replace(",","")) or 0
|
||||||
dlines[-1]['qty']="{0:,.2f}".format(round(dlines[-1]['qty'],2)) #total
|
dlines[-1]['qty']="{0:,.2f}".format(round(dlines[-1]['qty'],2)) #total
|
||||||
dlines[-1]['qty2']="{0:,.2f}".format(round(dlines[-1]['qty2'],2)) #total
|
dlines[-1]['qty2']="{0:,.2f}".format(round(dlines[-1]['qty2'],2)) #total
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ from calendar import monthrange
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from netforce.model import Model, fields, get_model
|
from netforce.model import Model, fields, get_model
|
||||||
from netforce.access import get_active_company, get_active_user, set_active_user
|
from netforce.access import get_active_company
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
|
|
||||||
|
@ -19,6 +19,16 @@ HD_STATE={
|
||||||
"cancelled":"Cancelled"
|
"cancelled":"Cancelled"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DAYS={
|
||||||
|
'mon': 0,
|
||||||
|
'tue': 1,
|
||||||
|
'wed': 2,
|
||||||
|
'thu': 3,
|
||||||
|
'fri': 4,
|
||||||
|
'sat': 5,
|
||||||
|
'sun': 6,
|
||||||
|
}
|
||||||
|
|
||||||
class VisitBoard(Model):
|
class VisitBoard(Model):
|
||||||
_name="clinic.visit.board"
|
_name="clinic.visit.board"
|
||||||
_string="Visit Board"
|
_string="Visit Board"
|
||||||
|
@ -84,6 +94,51 @@ class VisitBoard(Model):
|
||||||
doctor_id=obj.doctor_id.id
|
doctor_id=obj.doctor_id.id
|
||||||
department_id=obj.department_id.id
|
department_id=obj.department_id.id
|
||||||
branch_id=obj.branch_id.id
|
branch_id=obj.branch_id.id
|
||||||
|
def auto_gen_visit(dom=[]):
|
||||||
|
def daterange(start_date, end_date):
|
||||||
|
for n in range(int ((end_date - start_date).days)):
|
||||||
|
yield start_date + timedelta(n)
|
||||||
|
def convert_date(date_txt):
|
||||||
|
try:
|
||||||
|
if not date_txt:
|
||||||
|
raise Exception("Date Empty")
|
||||||
|
return datetime.strptime(date_txt,"%Y-%m-%d")
|
||||||
|
except:
|
||||||
|
raise Exception("Wrong Format Date")
|
||||||
|
# IMPROVE
|
||||||
|
# check day of week of this day
|
||||||
|
for date in daterange(convert_date(date_from),convert_date(date_to)+timedelta(days=1)):
|
||||||
|
weekday=date.weekday()
|
||||||
|
date_txt=date.strftime("%Y-%m-%d")
|
||||||
|
for pt in get_model("clinic.patient").search_browse(dom):
|
||||||
|
for pc in pt.cycles:
|
||||||
|
w=DAYS.get(pc.day,0) #default monday
|
||||||
|
cycle=pc.cycle_id
|
||||||
|
department=pc.department_id
|
||||||
|
if weekday==w:
|
||||||
|
dom2=[
|
||||||
|
['visit_date','>=',date_txt],
|
||||||
|
['visit_date','<=',date_txt],
|
||||||
|
['patient_id','=',pt.id],
|
||||||
|
['cycle_id','=',cycle.id],
|
||||||
|
['department_id','=',department.id],
|
||||||
|
]
|
||||||
|
res=get_model("clinic.visit").search(dom2)
|
||||||
|
# create visit auto
|
||||||
|
if not res:
|
||||||
|
vals={
|
||||||
|
'patient_id': pt.id,
|
||||||
|
'department_id': department.id,
|
||||||
|
'cycle_id': cycle.id,
|
||||||
|
'doctor_id': pt.doctor_id.id,
|
||||||
|
'branch_id': department.branch_id.id,
|
||||||
|
'time_start': '%s %s:00'%(date_txt,cycle.time_start),
|
||||||
|
'time_stop': '%s %s:00'%(date_txt,cycle.time_stop),
|
||||||
|
'visit_date': date_txt,
|
||||||
|
'state': 'pending',
|
||||||
|
}
|
||||||
|
visit_id=get_model("clinic.visit").create(vals)
|
||||||
|
print('create new visit %s for %s'%(visit_id,pt.name))
|
||||||
time_start='%s 00:00:00'%(date_from)
|
time_start='%s 00:00:00'%(date_from)
|
||||||
time_stop='%s 23:59:59'%(date_to)
|
time_stop='%s 23:59:59'%(date_to)
|
||||||
dom=[]
|
dom=[]
|
||||||
|
@ -99,6 +154,11 @@ class VisitBoard(Model):
|
||||||
dom.append(['department_id','=',department_id])
|
dom.append(['department_id','=',department_id])
|
||||||
if branch_id:
|
if branch_id:
|
||||||
dom.append(['branch_id','=',branch_id])
|
dom.append(['branch_id','=',branch_id])
|
||||||
|
#gen visit
|
||||||
|
if department_id:
|
||||||
|
auto_gen_visit(dom=[['department_id','=',department_id]])
|
||||||
|
elif branch_id:
|
||||||
|
auto_gen_visit(dom=[['branch_id','=',branch_id]])
|
||||||
lines=[]
|
lines=[]
|
||||||
empty_line={
|
empty_line={
|
||||||
'no': '',
|
'no': '',
|
||||||
|
|
Loading…
Reference in New Issue