auto remove visit(pending) and remove the rest visit before make apt
parent
c1bb614d1e
commit
d68842e5a5
|
@ -8,11 +8,10 @@
|
|||
<field name="number"/>
|
||||
<field name="type" required="1"/>
|
||||
<field name="name"/>
|
||||
<field name="name_eng"/>
|
||||
<field name="nick_name"/>
|
||||
<field name="partner_id" domain='[["is_staff","=","true"]]'/>
|
||||
<field name="branch_id" required="1"/>
|
||||
<field name="nick_name"/>
|
||||
<field name="department_id" domain='[["branch_id","=",branch_id]]' required="1"/>
|
||||
<field name="name_eng"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
|
@ -46,6 +45,9 @@
|
|||
<field name="ot_per_cycle"/>
|
||||
<!--<field name="check_max_cycle"/>-->
|
||||
</tab>
|
||||
<tab string="Accounting">
|
||||
<field name="partner_id" domain='[["is_staff","=","true"]]'/>
|
||||
</tab>
|
||||
<tab string="Note">
|
||||
<field name="note" nolabel="1"/>
|
||||
</tab>
|
||||
|
|
|
@ -146,6 +146,8 @@ class MakeAPT(Model):
|
|||
|
||||
for line in obj.lines:
|
||||
patient=line.patient_id
|
||||
if not patient:
|
||||
continue
|
||||
dpt=line.department_id or patient.department_id
|
||||
days=[]
|
||||
if line.mon_cycle_id:
|
||||
|
@ -176,6 +178,15 @@ class MakeAPT(Model):
|
|||
cycle=line.sun_cycle_id
|
||||
days.append([7,cycle,dpt])
|
||||
|
||||
# remove the rest
|
||||
dom=[]
|
||||
dom.append(['visit_date','>=', obj.date_from])
|
||||
dom.append(['visit_date','<=', (datetime.strptime(obj.date_to,FMT_DATE)+timedelta(days=14)).strftime(FMT_DATE)])
|
||||
dom.append(['patient_id', '=', patient.id])
|
||||
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:
|
||||
|
@ -207,19 +218,17 @@ class MakeAPT(Model):
|
|||
'visit_date': visit_date,
|
||||
'state': 'pending',
|
||||
}
|
||||
visit_vals.append(vals)
|
||||
count+=7
|
||||
|
||||
dom=[]
|
||||
dom.append(['time_start','>=','%s %s'%(tmp.strftime(FMT_DATE)[0:10],' 00:00:00')])
|
||||
dom.append(['time_stop','<=','%s %s'%(tmp.strftime(FMT_DATE)[0:10],' 23:59:59')])
|
||||
dom.append(['patient_id', '=', patient.id])
|
||||
dom.append(['cycle_id', '=', cycle.id])
|
||||
dom.append(['state','=','pending'])
|
||||
dom.append(['state','in',['confirmed']])
|
||||
vids=visit_obj.search(dom)
|
||||
visit_obj.delete(vids)
|
||||
if not vids:
|
||||
visit_vals.append(vals)
|
||||
count+=7
|
||||
start_date=tmp
|
||||
|
||||
user_id=get_active_user()
|
||||
staff_ids=get_model("clinic.staff").search([['type','=','type'],['user_id','=',user_id]])
|
||||
confirm_id=None
|
||||
|
|
|
@ -68,7 +68,7 @@ class Patient(Model):
|
|||
"weight": fields.Float("Weight (kg.)"),
|
||||
"height": fields.Float("Height (cm.)"),
|
||||
"card_type": fields.Selection([("identification","Identification"),("passport","Passport")],"Card Type"),
|
||||
'card_no' : fields.Char("ID Card"),
|
||||
'card_no' : fields.Char("Card ID"),
|
||||
'card_exp' : fields.Date("Card Exp."),
|
||||
"app_no": fields.Char("Application No."),
|
||||
"salary": fields.Selection([["20000","5,001-20,000"],["50000","20,001-50,000"],["100000","50,001-100,000"],["100001","100,000+"]], "Salary"),
|
||||
|
@ -213,6 +213,7 @@ class Patient(Model):
|
|||
if 'active' in vals.keys():
|
||||
if not vals['active']:
|
||||
vals['resign_date']=time.strftime("%Y-%m-%d")
|
||||
vals['rm_remain_visit']=True
|
||||
|
||||
for obj in self.browse(ids):
|
||||
if 'doctor_id' in vals.keys():
|
||||
|
@ -221,8 +222,6 @@ class Patient(Model):
|
|||
'doctor_id': vals['doctor_id'],
|
||||
})
|
||||
print("update doctor %s to patient %s"%(vals['doctor_id'], obj.name))
|
||||
#if not obj.addresses:
|
||||
#raise Exception("Address not found - %s!"%obj.name)
|
||||
partner_id=obj.partner_id
|
||||
if not partner_id:
|
||||
for partner in get_model("partner").search_browse([['name', '=', obj.name]]):
|
||||
|
@ -237,7 +236,6 @@ class Patient(Model):
|
|||
'is_patient': True,
|
||||
})
|
||||
vals['partner_id']=partner_id
|
||||
|
||||
if not isinstance(partner_id,int):
|
||||
partner_id=partner_id.id
|
||||
if obj.addresses:
|
||||
|
@ -256,8 +254,8 @@ class Patient(Model):
|
|||
})
|
||||
del vals['addresses']
|
||||
print("create address for %s"%obj.name, ' ', addr_vals)
|
||||
if obj.rm_remain_visit:
|
||||
visit_ids=get_model('clinic.visit').search([['patient_id','=',obj.id],['state','=','draft']])
|
||||
if obj.rm_remain_visit or vals.get('rm_remain_visit'):
|
||||
visit_ids=get_model('clinic.visit').search([['patient_id','=',obj.id],['state','in',('draft','pending')]])
|
||||
get_model('clinic.visit').delete(visit_ids)
|
||||
print('remove visit auto %s'%visit_ids)
|
||||
self.function_store(ids)
|
||||
|
|
Loading…
Reference in New Issue