improvement

conv_bal
watcha.h 2015-03-03 13:08:38 +07:00
parent 98ec00abb5
commit 45b5e932fa
4 changed files with 44 additions and 21 deletions

View File

@ -3,9 +3,9 @@
<field name="date" span="2" mode="month" onchange="onchange_date"/> <field name="date" span="2" mode="month" onchange="onchange_date"/>
<field name="date_from" span="2"/> <field name="date_from" span="2"/>
<field name="date_to" span="2"/> <field name="date_to" span="2"/>
<field name="cycle_id" span="2"/> <!--<field name="cycle_id" span="2"/>-->
<field name="branch_id" span="2" onchange="onchange_branch"/> <field name="branch_id" span="3" onchange="onchange_branch"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/> <field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
<field name="lines" nolabel="1"> <field name="lines" nolabel="1">
<list> <list>
<field name="patient_id" onchange="onchange_patient"/> <field name="patient_id" onchange="onchange_patient"/>

View File

@ -2,6 +2,7 @@
<tabs> <tabs>
<tab string="Visit"> <tab string="Visit">
<field name="find_dlz"/> <field name="find_dlz"/>
<button string="Remove Duplicate Visit" type="default" icon="arrow-right" method="remove_douplicate_visit" perm="clinic_setting_rm_dbl_visit"/>
</tab> </tab>
<tab string="HD Case"> <tab string="HD Case">
<group form_layout="stacked"> <group form_layout="stacked">

View File

@ -147,12 +147,18 @@ class MakeAPT(Model):
visit_vals=[] visit_vals=[]
date_from=datetime.strptime(obj.date_from,FMT_DATE) date_from=datetime.strptime(obj.date_from,FMT_DATE)
date_to=datetime.strptime(obj.date_to,FMT_DATE) date_to=datetime.strptime(obj.date_to,FMT_DATE)
old_pids=[]
for line in obj.lines: for line in obj.lines:
patient=line.patient_id patient=line.patient_id
if not patient: if not patient:
continue continue
dpt=line.department_id or patient.department_id dpt=line.department_id or patient.department_id
# skip already gen
if patient.id in old_pids:
print("skip patient ", patient.id, old_pids)
continue
old_pids.append(patient.id)
days=[] days=[]
if line.mon_cycle_id: if line.mon_cycle_id:
cycle=line.mon_cycle_id cycle=line.mon_cycle_id
@ -181,7 +187,6 @@ class MakeAPT(Model):
if line.sun_cycle_id: if line.sun_cycle_id:
cycle=line.sun_cycle_id cycle=line.sun_cycle_id
days.append([7,cycle,dpt]) days.append([7,cycle,dpt])
# remove the rest # remove the rest
dom=[] dom=[]
dom.append(['visit_date','>=', obj.date_from]) dom.append(['visit_date','>=', obj.date_from])
@ -190,7 +195,6 @@ class MakeAPT(Model):
dom.append(['state','=','pending']) dom.append(['state','=','pending'])
vids=visit_obj.search(dom) vids=visit_obj.search(dom)
visit_obj.delete(vids) visit_obj.delete(vids)
ntoday=1 ntoday=1
day_total=(date_to-date_from).days+ntoday day_total=(date_to-date_from).days+ntoday
for weekday, cycle, department in days: for weekday, cycle, department in days:
@ -231,7 +235,7 @@ class MakeAPT(Model):
vids=visit_obj.search(dom) vids=visit_obj.search(dom)
if not vids: if not vids:
visit_vals.append(vals) visit_vals.append(vals)
count+=7 #XXX count+=7 #XXX recheck
start_date=tmp start_date=tmp
user_id=get_active_user() user_id=get_active_user()
staff_ids=get_model("clinic.staff").search([['type','=','type'],['user_id','=',user_id]]) staff_ids=get_model("clinic.staff").search([['type','=','type'],['user_id','=',user_id]])

View File

@ -1,6 +1,6 @@
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
from netforce.utils import get_file_path, get_data_path from netforce.utils import get_file_path, get_data_path
from netforce.access import get_active_company, get_active_user from netforce.access import get_active_company, get_active_user, set_active_user
from netforce.database import get_connection from netforce.database import get_connection
class ClinicSetting(Model): class ClinicSetting(Model):
@ -126,19 +126,37 @@ class ClinicSetting(Model):
if user_id !=1: if user_id !=1:
print("Only admin!!") print("Only admin!!")
return return
pids=get_model("clinic.patient").search([['state','=','dispose']]) for pt in get_model("clinic.patient").search_browse([]):
count=0 dates=[]
for visit in get_model("clinic.visit").search_browse([['patient_id','in',pids]]): print("="*50)
if visit.state=='confirmed': for visit in pt.visits:
continue if visit.state=='confirmed':
visit.to_draft() continue
hdcase=visit.hd_case_id if visit.visit_date in dates:
if hdcase: print(pt.name, ' delete ', visit.visit_date)
hdcase.to_draft() visit.to_draft()
hdcase.delete() visit.delete()
visit.delete() dates.append(visit.visit_date)
count+=1 print("="*50)
print("count ", count) print("Done!")
return
def remove_douplicate_visit(self,ids,context={}):
user_id=get_active_user()
set_active_user(1)
for pt in get_model("clinic.patient").search_browse([]):
dates=[]
print("="*50)
for visit in pt.visits:
if visit.state=='confirmed':
continue
if visit.visit_date in dates:
print(pt.name, ' delete ', visit.visit_date)
visit.to_draft()
visit.delete()
dates.append(visit.visit_date)
print("="*50)
set_active_user(user_id)
print("Done!") print("Done!")
return return