conv_bal
watcha.h 2014-11-02 00:30:48 +07:00
parent 14ae8fb35f
commit 16fdf098e0
14 changed files with 64 additions and 19 deletions

View File

@ -3,5 +3,6 @@
<field name="view_cls">multi_view</field>
<field name="model">clinic.cycle.item</field>
<field name="modes">list,form</field>
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Done",[["state","=","done"]]]]</field>
<field name="menu">clinic_menu</field>
</action>

View File

@ -0,0 +1,7 @@
<action>
<field name="view_cls">list_view</field>
<field name="model">clinic.visit</field>
<field name="domain">[["state","not in",["confirmed"]]]</field>
<field name="view_xml">clinic_visit_widget</field>
<field name="limit">10</field>
</action>

View File

@ -1,11 +1,11 @@
<board>
<!--<hpanel>-->
<!--<widget action="clinic_visit_cal_widget" string="Visits Calendar" span="12"/>-->
<!--</hpanel>-->
<vpanel>
<widget action="clinic_cycle_widget" string="Average Cycle" span="12"/>
<widget action="clinic_visit_widget" string="Current Visit" span="12"/>
</vpanel>
<vpanel>
<widget action="clinic_recent_patient_widget" string="Recent Patient" span="12"/>
</vpanel>
<vpanel>
<widget action="clinic_cycle_widget" string="Average Cycle" span="12"/>
</vpanel>
</board>

View File

@ -2,8 +2,9 @@
<group form_layout="stacked">
<field name="date_from" onchange="onchange_time" span="3"/>
<field name="date_to" onchange="onchange_dateto" span="3"/>
<field name="duration" span="3"/>
<!--<field name="duration" span="3"/>-->
<field name="cycle_id" onchange="onchange_time" span="3"/>
<field name="patient_categ_id" span="3"/>
<field name="doctor_id" span="3"/>
<field name="department_id" span="3"/>
<field name="patient_type" span="3"/>

View File

@ -6,5 +6,6 @@
<field name="hn"/>
<field name="name"/>
<field name="reg_date"/>
<field name="categ_id"/>
<field name="type"/>
</list>

View File

@ -27,7 +27,8 @@
</tabs>
<foot>
<button string="Confirm" type="success" method="confirm" states="draft" />
<button string="To Draft" type="default" icon="refresh" method="to_draft" states="confirmed" />
<button string="Cancel" type="danger" method="cancel" states="draft" />
<button string="To Draft" type="default" icon="repeat" method="to_draft" states="confirmed,cancelled" />
</foot>
<related>
<field name="hd_cases" readonly="1"/>

View File

@ -1,4 +1,4 @@
<list model="clinic.visit">
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]],"#bcbbb9":[["state","=","cancelled"]]}'>
<search>
<field name="number"/>
<field name="time_start"/>
@ -6,7 +6,6 @@
<field name="cycle_id"/>
<field name="patient_id"/>
<field name="doctor_id"/>
<field name="nurse_id"/>
</search>
<field name="number"/>
<field name="time_start"/>
@ -14,6 +13,5 @@
<field name="cycle_id"/>
<field name="patient_id"/>
<field name="doctor_id"/>
<field name="nurse_id"/>
<field name="state"/>
</list>

View File

@ -0,0 +1,7 @@
<list model="clinic.visit" colors='{"#cfc":[["state","=","confirmed"]]}'>
<field name="cycle_id"/>
<field name="visit_date"/>
<field name="patient_id"/>
<field name="doctor_id"/>
<field name="state"/>
</list>

View File

@ -33,4 +33,6 @@ class CycleItem(Model):
'date': lambda *a: time.strftime("%Y-%m-%d"),
}
_order="date asc"
CycleItem.register()

View File

@ -37,6 +37,7 @@ class GenVisit(Model):
'department_id': fields.Many2One("clinic.department","Department"),
'duration': fields.Integer("Duration (hrs)", function="_get_duration"),
"patient_type": fields.Selection([("mg","Medical Government"),("sc","Social Security"),("nhso","NHSO (30฿)"),("personal","Personal"),("others","Others")],"Patient Type"),
'patient_categ_id': fields.Many2One("clinic.patient.categ", "Patient Category"),
'nurse_categ_id': fields.Many2One("clinic.personal.categ", "Nurse Category", domain=[['type','=','nurse']]),
}
@ -116,6 +117,12 @@ class GenVisit(Model):
patients=[p.patient_id.id for p in obj.patient_lines if p.patient_id]
if not patients and obj.patient_type:
patients=get_model("clinic.patient").search([['type','=',obj.patient_type]])
if not patients:
raise Exception("No patient for type %s"%obj.patient_type)
elif not patients and obj.patient_categ_id:
patients=get_model("clinic.patient").search([['categ_id','=',obj.patient_categ_id.id]])
if not patients:
raise Exception("No patient for category %s"%obj.patient_categ_id.name)
elif patients:
# continue to generate with condition
pass
@ -132,11 +139,11 @@ class GenVisit(Model):
while wd != weekday-1:
start_date+=timedelta(days=1)
wd=start_date.weekday()
#XXX should gen only in scope
if start_date.strftime(FMT_DATE) > date_to.strftime(FMT_DATE):
continue
count=0
tmp=start_date
while count < day_total:
tmp=start_date+timedelta(days=count)
ttime_start="%s %s" % (tmp.strftime(FMT_DATE),date_from.strftime(FMT_DATETIME)[11:])
@ -144,7 +151,6 @@ class GenVisit(Model):
vals={
'patient_id': patient_id,
'doctor_id': obj.doctor_id.id,
'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id,
'cycle_id': obj.cycle_id.id,
'time_start': ttime_start,
@ -225,6 +231,8 @@ class GenVisit(Model):
patients=[p.patient_id.id for p in obj.patient_lines if p.patient_id]
if not patients and obj.patient_type:
patients=get_model("clinic.patient").search([['type','=',obj.patient_type]])
elif not patients and obj.patient_categ_id:
patients=get_model("clinic.patient").search([['categ_id','=',obj.patient_categ_id.id]])
elif patients:
# continue to create with critiria
pass
@ -263,6 +271,7 @@ class GenVisit(Model):
if start_date.strftime(FMT_DATE) > date_to.strftime(FMT_DATE):
continue
count=0
tmp=start_date
while count < day_total:
tmp=start_date+timedelta(days=count)
time_start="%s 00:00:00" % (tmp.strftime(FMT_DATE))

View File

@ -235,7 +235,7 @@ class Patient(Model):
def name_get(self,ids,context={}):
vals=[]
for obj in self.browse(ids):
name="%s [%s] %s"%(obj.name,obj.number,obj.hn or "")
name="%s %s %s"%(obj.number,obj.name, obj.hn)
vals.append((obj.id,name))
return vals

View File

@ -10,7 +10,7 @@ class Schedule(Model):
res={}
for obj in self.browse(ids):
total_nurse=len(obj.nurses)
res[obj.id]='Cycle: %s, Nurse: %s'%(obj.cycle_id.name or "", total_nurse)
res[obj.id]='%s, Nurse: %s'%(obj.cycle_id.name or "", total_nurse)
return res
_fields={
@ -26,7 +26,7 @@ class Schedule(Model):
_defaults={
"company_id": lambda *a: get_active_company(),
}
def confirm(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({

View File

@ -24,7 +24,7 @@ class Visit(Model):
for obj in self.browse(ids):
res[obj.id]=datetime.now().strftime("%Y-%m-%d %H:%M:%S")
return res
_fields={
"number": fields.Char("Number",required=True,search=True),
"time_start": fields.DateTime("Time Start",required=True),
@ -42,6 +42,7 @@ class Visit(Model):
'visit_date': fields.Date('Visit Date',function="_get_visit_date"),
'print_date': fields.Date('Print Date',function="_get_print_date"),
'cycle_item_id': fields.Many2One("clinic.cycle.item","Cycle Item"), # on_delete="cascade" -> rm visit from cycle item
'sequence': fields.Char("Sequence"),
}
def _get_number(self,context={}):
@ -83,13 +84,13 @@ class Visit(Model):
_defaults={
"state": "draft",
#'time_start': _get_time_start,
#'time_stop': _get_time_stop,
'time_start': _get_time_start,
'time_stop': _get_time_stop,
"number": "/",
"company_id": lambda *a: get_active_company(),
'nurse_id': _get_nurse,
}
_order="id desc"
_order="sequence"
def confirm(self,ids,context={}):
obj=self.browse(ids[0])
@ -299,9 +300,23 @@ class Visit(Model):
})
else:
item_id=item_ids[0]
print("item_id ",item_id)
vals['cycle_item_id']=item_id
vals['sequence']='%s-%s'%(vals['time_start'][0:10],cycle_id)
obj_id=super().create(vals,**kw)
return obj_id
def cancel(self,ids,context={}):
obj=self.browse(ids)[0]
obj.write({
'state': 'cancelled',
})
return {
'next': {
'name': 'clinic_visit',
'mode': 'form',
'active_id': obj.id,
},
'flash': 'Visit\'s %s has been cancelled'%obj.patient_id.name
}
Visit.register()

View File

@ -1,3 +1,5 @@
dashboard
: hd summary report -> click and go direct
cycle item:
cycle_id
list's nurse
@ -11,6 +13,7 @@ formalar
order
- visit
- date, cycle (1, 2, 3), state
- by datenow, cycle sequence, state
- solution: maybe make some dashboard to that
- like a table treatment in 1 day