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_from" span="2"/>
<field name="date_to" span="2"/>
<field name="cycle_id" span="2"/>
<field name="branch_id" span="2" onchange="onchange_branch"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
<!--<field name="cycle_id" span="2"/>-->
<field name="branch_id" span="3" onchange="onchange_branch"/>
<field name="department_id" domain='[["branch_id","=",branch_id]]' span="3"/>
<field name="lines" nolabel="1">
<list>
<field name="patient_id" onchange="onchange_patient"/>

View File

@ -2,6 +2,7 @@
<tabs>
<tab string="Visit">
<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 string="HD Case">
<group form_layout="stacked">

View File

@ -147,12 +147,18 @@ class MakeAPT(Model):
visit_vals=[]
date_from=datetime.strptime(obj.date_from,FMT_DATE)
date_to=datetime.strptime(obj.date_to,FMT_DATE)
old_pids=[]
for line in obj.lines:
patient=line.patient_id
if not patient:
continue
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=[]
if line.mon_cycle_id:
cycle=line.mon_cycle_id
@ -181,7 +187,6 @@ class MakeAPT(Model):
if line.sun_cycle_id:
cycle=line.sun_cycle_id
days.append([7,cycle,dpt])
# remove the rest
dom=[]
dom.append(['visit_date','>=', obj.date_from])
@ -190,7 +195,6 @@ class MakeAPT(Model):
dom.append(['state','=','pending'])
vids=visit_obj.search(dom)
visit_obj.delete(vids)
ntoday=1
day_total=(date_to-date_from).days+ntoday
for weekday, cycle, department in days:
@ -231,7 +235,7 @@ class MakeAPT(Model):
vids=visit_obj.search(dom)
if not vids:
visit_vals.append(vals)
count+=7 #XXX
count+=7 #XXX recheck
start_date=tmp
user_id=get_active_user()
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.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
class ClinicSetting(Model):
@ -126,19 +126,37 @@ class ClinicSetting(Model):
if user_id !=1:
print("Only admin!!")
return
pids=get_model("clinic.patient").search([['state','=','dispose']])
count=0
for visit in get_model("clinic.visit").search_browse([['patient_id','in',pids]]):
if visit.state=='confirmed':
continue
visit.to_draft()
hdcase=visit.hd_case_id
if hdcase:
hdcase.to_draft()
hdcase.delete()
visit.delete()
count+=1
print("count ", count)
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)
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!")
return