make apt
parent
db29c0cc2c
commit
14885e638e
|
@ -17,7 +17,7 @@
|
|||
</list>
|
||||
</field>
|
||||
<foot replace="1">
|
||||
<button string="Load Data" method="load" icon="repeat" type="success"/>
|
||||
<button string="Generate" method="gen" icon="arrow-right" type="primary"/>
|
||||
<button string="Load Data" method="load" icon="repeat" type="primary"/>
|
||||
<button string="Generate" method="gen" icon="arrow-right" type="success"/>
|
||||
</foot>
|
||||
</form>
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
<item string="Visits" action="clinic_visit"/>
|
||||
<item string="Visit Board" action="clinic_visit_board"/>
|
||||
<divider/>
|
||||
<item string="New Visit" action="clinic_visit" action_options="mode=form"/>
|
||||
<item string="Make An Appoitment" action="clinic_make_apt"/>
|
||||
</item>
|
||||
<item string="HD Cases" perm="clinic_hdcase">
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
<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="patient_id" span="2"/>
|
||||
<group span="1" columns="1">
|
||||
<button string="New Visit" method="make_visit" span="1" icon="plus" type="success" size="small"/>
|
||||
</group>
|
||||
<group span="2" columns="1">
|
||||
<field name="doctor_id" span="2"/>
|
||||
<!--<group span="1" columns="1">-->
|
||||
<!--<button string="New Visit" method="make_visit" span="1" icon="plus" type="success" size="small"/>-->
|
||||
<!--</group>-->
|
||||
<!--<group span="2" columns="1">-->
|
||||
<!--<button string="Make An Appointment" action="clinic_gen_visit_form" span="1" icon="calendar" type="default" size="small"/>-->
|
||||
<!--<button string="Calendar" offset="10" icon="calendar" size="small"/>-->
|
||||
</group>
|
||||
<!--</group>-->
|
||||
</form>
|
||||
|
|
|
@ -20,10 +20,19 @@ class MakeAPT(Model):
|
|||
"lines": fields.One2Many("clinic.make.apt.line","apt_id","Lines"),
|
||||
}
|
||||
|
||||
def _get_date_from(self,context={}):
|
||||
year,month,day=time.strftime(FMT_DATE).split("-")
|
||||
return "%s-%s-%s"%(year,month,"01")
|
||||
|
||||
def _get_date_to(self,context={}):
|
||||
year,month,day=time.strftime(FMT_DATE).split("-")
|
||||
weekday, total_day=monthrange(int(year), int(month))
|
||||
return "%s-%s-%s"%(year,month,("%s"%total_day).zfill(2))
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'date_from': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'date_to': lambda *a: (datetime.now()+timedelta(days=DRT)).strftime("%Y-%m-%d"),
|
||||
'date_from': _get_date_from,
|
||||
'date_to': _get_date_to,
|
||||
}
|
||||
|
||||
def load(self,ids,context={}):
|
||||
|
@ -65,6 +74,9 @@ class MakeAPT(Model):
|
|||
pt_id, dpt_id=k
|
||||
if pt_id:
|
||||
vals['patient_id']=pt_id
|
||||
if not dpt_id:
|
||||
pt=get_model("clinic.patient").browse(pt_id)
|
||||
dpt_id=pt.department_id.id
|
||||
if dpt_id:
|
||||
vals['department_id']=dpt_id
|
||||
lines.append(('create',vals))
|
||||
|
@ -108,8 +120,8 @@ class MakeAPT(Model):
|
|||
days.append([2,cycle,dpt])
|
||||
|
||||
if line.wed_cycle_id:
|
||||
days.append([3,cycle,dpt])
|
||||
cycle=line.wed_cycle_id
|
||||
days.append([3,cycle,dpt])
|
||||
|
||||
if line.thu_cycle_id:
|
||||
cycle=line.thu_cycle_id
|
||||
|
@ -175,19 +187,23 @@ class MakeAPT(Model):
|
|||
staff_ids=get_model("clinic.staff").search([['type','=','type'],['user_id','=',user_id]])
|
||||
confirm_id=None
|
||||
|
||||
flash='Generate Visit Successfully'
|
||||
if staff_ids:
|
||||
confirm_id=staff_ids[0]
|
||||
count=0
|
||||
for vals in visit_vals:
|
||||
vals['nurse_id']=confirm_id
|
||||
visit_obj.create(vals)
|
||||
|
||||
count+=1
|
||||
if count:
|
||||
flash="Visit is generated succesfully %s items."%count
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_make_apt',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': 'Generate Visit Successfully',
|
||||
'flash': flash,
|
||||
}
|
||||
|
||||
def onchange_date(self,context={}):
|
||||
|
|
|
@ -8,7 +8,7 @@ class MakeAPTLine(Model):
|
|||
'apt_id': fields.Many2One("clinic.make.apt","APT", required=True,on_delete="cascade"),
|
||||
'patient_id': fields.Many2One("clinic.patient","Patient"),
|
||||
'mon_cycle_id': fields.Many2One("clinic.cycle","Monday"),
|
||||
'tue_cycle_id': fields.Many2One("clinic.cycle","Tueday"),
|
||||
'tue_cycle_id': fields.Many2One("clinic.cycle","Tuesday"),
|
||||
'wed_cycle_id': fields.Many2One("clinic.cycle","Wedsday"),
|
||||
'thu_cycle_id': fields.Many2One("clinic.cycle","Thursday"),
|
||||
'fri_cycle_id': fields.Many2One("clinic.cycle","Friday"),
|
||||
|
|
|
@ -30,6 +30,8 @@ class VisitBoard(Model):
|
|||
"date_from": fields.Date("From", required=True),
|
||||
"date_to": fields.Date("To", required=True),
|
||||
'patient_id': fields.Many2One("clinic.patient","Patient"),
|
||||
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
|
||||
'doctor_id': fields.Many2One("clinic.staff","Doctor",domain=[["type","=","doctor"]]),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
|
@ -45,11 +47,15 @@ class VisitBoard(Model):
|
|||
date_from=datetime.now().strftime("%Y-%m-%d")
|
||||
date_to=(datetime.now()+timedelta(days=DRT)).strftime("%Y-%m-%d")
|
||||
patient_id=None
|
||||
cycle_id=None
|
||||
doctor_id=None
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
date_from=obj.date_from
|
||||
date_to=obj.date_to
|
||||
patient_id=obj.patient_id.id
|
||||
cycle_id=obj.cycle_id.id
|
||||
doctor_id=obj.doctor_id.id
|
||||
|
||||
time_start='%s 00:00:00'%(date_from)
|
||||
time_stop='%s 23:59:59'%(date_to)
|
||||
|
@ -59,6 +65,10 @@ class VisitBoard(Model):
|
|||
dom.append(['time_stop','<=','%s'%time_stop])
|
||||
if patient_id:
|
||||
dom.append(['patient_id','=',patient_id])
|
||||
if cycle_id:
|
||||
dom.append(['cycle_id','=',cycle_id])
|
||||
if doctor_id:
|
||||
dom.append(['doctor_id','=',doctor_id])
|
||||
|
||||
lines=[]
|
||||
empty_line={
|
||||
|
@ -217,8 +227,6 @@ class VisitBoard(Model):
|
|||
has_duration=False
|
||||
if date_from != date_to:
|
||||
has_duration=True
|
||||
import pprint
|
||||
pprint.pprint(lines)
|
||||
data={
|
||||
'lines': lines,
|
||||
'date': utils.date2thai(date_from,format='ประจำวัน%(Td)s ที่ %(d)s %(Tm)s %(BY)s'),
|
||||
|
@ -239,13 +247,5 @@ class VisitBoard(Model):
|
|||
data['date_from']="%s-%s-01"%(year,month)
|
||||
data['date_to']="%s-%s-%s"%(year,month,total_day)
|
||||
return data
|
||||
|
||||
def make_visit(self,ids,context={}):
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_visit',
|
||||
'mode': 'form',
|
||||
}
|
||||
}
|
||||
|
||||
VisitBoard.register()
|
||||
|
|
Loading…
Reference in New Issue