make appoitment

conv_bal
watcha.h 2015-02-02 13:48:25 +07:00
parent 0364dcfa13
commit e35b55736b
3 changed files with 30 additions and 3 deletions

View File

@ -4,7 +4,7 @@
<field name="date_from" span="2"/>
<field name="date_to" span="2"/>
<field name="cycle_id" span="2"/>
<field name="branch_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="lines" nolabel="1">
<list>

View File

@ -48,6 +48,28 @@ class MakeAPT(Model):
dom.append(['cycle_id','=',obj.cycle_id.id])
branch_id=obj.branch_id.id
pcs=get_model("clinic.patient.cycle").search_browse(dom)
if not pcs:
# Create patient cycle with that department
for pt in get_model("clinic.patient").search_browse([['department_id','=',obj.department_id.id]]):
for pc in pt.cycles:
vals={
'patient_id': pt.id,
'department_id': pt.department_id.id,
'cycle_id': pc.cycle_id.id,
'day': pc.day,
}
res=get_model("clinic.patient.cycle").search([[
['patient_id','=',pt.id],
['day','=',pc.day],
['cycle_id','=',pc.cycle_id.id],
['department_id','=', pt.department_id.id],
]])
if not res:
pcycle_id=get_model("clinic.patient.cycle").create(vals)
print("create ", pcycle_id)
else:
print("exist ", res)
pcs=get_model("clinic.patient.cycle").search_browse(dom)
if not pcs:
raise Exception("Please go to menu 'Patients -> Patient Cycles' and import data for %s"%(obj.department_id.name))
for pc in pcs:
@ -109,7 +131,7 @@ class MakeAPT(Model):
'mode': 'form',
'active_id': obj.id,
},
'flash': 'Reload Successfully',
'flash': 'Ready to generate',
}
def gen(self,ids,context={}):
@ -229,5 +251,10 @@ class MakeAPT(Model):
data['date_from']="%s-%s-01"%(year,month)
data['date_to']="%s-%s-%s"%(year,month,total_day)
return data
def onchange_branch(self,context={}):
data=context['data']
data['department_id']=None
return data
MakeAPT.register()

View File

@ -3,7 +3,6 @@ from netforce.model import Model, fields
class PatientCycle(Model):
_name="clinic.patient.cycle"
_string="Patient Cycle"
_key=['patient_id','cycle_id','day']
_fields={
"patient_id": fields.Many2One('clinic.patient',"Patient",required=True,on_delete="cascade",search=True),
@ -11,5 +10,6 @@ class PatientCycle(Model):
"department_id": fields.Many2One('clinic.department',"Department",search=True),
'day': fields.Selection([('mon', 'Monday'), ('tue','Tuesday'), ('wed','Wednesday'),('thu','Thursday'),('fri','Friday'),('sat','Saturday'),('sun','Sunday')], 'Day',search=True),
}
_sql_constraints=("pcycle_uniq","unique(patient_id,cycle_id,day,department_id)","patient_id,cycle_id,day,department_id should be unique"),
PatientCycle.register()