improvement

conv_bal
watcha.h@almacom.co.th 2015-06-03 11:39:08 +07:00
parent 157454f03b
commit 1a61b83116
8 changed files with 13 additions and 45 deletions

View File

@ -85,20 +85,6 @@
<field name="cstate"/> <field name="cstate"/>
</form> </form>
</field> </field>
<!--<field name="patients">-->
<field name="patients" attrs='{"readonly":1,"invisible":[["type","in",["nurse","staff"]]]}'>
<list>
<field name="reg_date"/>
<field name="hn_no"/>
<field name="trt_no"/>
<field name="card_no"/>
<field name="name"/>
<field name="type_id"/>
<field name="department_id"/>
<field name="walkin"/>
<field name="dispose"/>
</list>
</field>
<field name="comments"/> <field name="comments"/>
</related> </related>
</form> </form>

View File

@ -1,4 +1,5 @@
from netforce.model import Model, fields from netforce.model import Model, fields
from netforce.access import get_active_user, set_active_user
class CycleItemLine(Model): class CycleItemLine(Model):
_name="clinic.cycle.item.line" _name="clinic.cycle.item.line"
@ -6,6 +7,8 @@ class CycleItemLine(Model):
def _get_all(self,ids,context={}): def _get_all(self,ids,context={}):
res={} res={}
user_id=get_active_user()
set_active_user(1)
for obj in self.browse(ids): for obj in self.browse(ids):
citem=obj.cycle_item_id citem=obj.cycle_item_id
pt_total=len([hdcase for hdcase in citem.hd_cases if hdcase.state in ('waiting_payment','paid')]) pt_total=len([hdcase for hdcase in citem.hd_cases if hdcase.state in ('waiting_payment','paid')])
@ -13,6 +16,7 @@ class CycleItemLine(Model):
'cstate': citem.state, 'cstate': citem.state,
'pt_total': pt_total, 'pt_total': pt_total,
} }
set_active_user(user_id)
return res return res
_fields={ _fields={

View File

@ -1458,8 +1458,6 @@ class HDCase(Model):
vals=self.get_hct(vals,patient_id) vals=self.get_hct(vals,patient_id)
new_id=super().create(vals,**kw) new_id=super().create(vals,**kw)
self.function_store([new_id]) self.function_store([new_id])
#obj=self.browse(new_id)
#self.check_hct(obj)
return new_id return new_id
def check_hct(self,obj): def check_hct(self,obj):

View File

@ -410,7 +410,6 @@ class LaborCost(Model):
doctor_lines.append(('create',line)) doctor_lines.append(('create',line))
else: else:
nurse_lines.append(('create',line)) nurse_lines.append(('create',line))
obj.write({ obj.write({
'doctor_lines': doctor_lines, 'doctor_lines': doctor_lines,
'nurse_lines': nurse_lines, 'nurse_lines': nurse_lines,

View File

@ -31,7 +31,7 @@ class LaborCostLine(Model):
_fields={ _fields={
"labor_cost_id": fields.Many2One("clinic.labor.cost","Labor Cost",required=True,on_delete="cascade"), "labor_cost_id": fields.Many2One("clinic.labor.cost","Labor Cost",required=True,on_delete="cascade"),
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Staff Type",required=True,search=True,function="_get_store",function_multi=True), "type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Staff Type",required=True,search=True,function="_get_store",function_multi=True,store=True),
'staff_id': fields.Many2One("clinic.staff", "Staff",search=True), 'staff_id': fields.Many2One("clinic.staff", "Staff",search=True),
'level_id': fields.Many2One("clinic.staff.level", "Level",search=True), 'level_id': fields.Many2One("clinic.staff.level", "Level",search=True),
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True), 'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),

View File

@ -175,7 +175,7 @@ class Patient(Model):
"vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."), "vascular_acc": fields.Many2One("clinic.vascular.access","Vascular Ac."),
'state': fields.Selection([['admit','Admit'],['dispose','Dispose']],'State'), 'state': fields.Selection([['admit','Admit'],['dispose','Dispose']],'State'),
'walkin': fields.Selection([['yes','Yes'],['no','No']],"Walkin"), 'walkin': fields.Selection([['yes','Yes'],['no','No']],"Walkin"),
'department_names': fields.Text("Departments",function="_get_department_names"), #'department_names': fields.Text("Departments",function="_get_department_names"),
'location': fields.Char("Location"), #to filter 'location': fields.Char("Location"), #to filter
} }

View File

@ -99,8 +99,12 @@ class Staff(Model):
def _get_location(self,ids,context={}): def _get_location(self,ids,context={}):
res={} res={}
user_id=get_active_user()
set_active_user(1)
for obj in self.browse(ids): for obj in self.browse(ids):
res[obj.id]=",".join([d.code for d in obj.departments]) st_codes=set([d.code for d in obj.departments])
res[obj.id]=",".join([dcode for dcode in sorted(st_codes)])
set_active_user(user_id)
return res return res
def _get_department_names(self,ids,context={}): def _get_department_names(self,ids,context={}):
@ -108,26 +112,11 @@ class Staff(Model):
user_id=get_active_user() user_id=get_active_user()
set_active_user(1) set_active_user(1)
for obj in self.browse(ids): for obj in self.browse(ids):
res[obj.id]=','.join([dpt.name for dpt in obj.departments]) dpt_st=set([dpt.name for dpt in obj.departments])
res[obj.id]=','.join([dpt_name for dpt_name in sorted(dpt_st)])
set_active_user(user_id) set_active_user(user_id)
return res return res
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
pt_ids=[]
if obj.type=='doctor':
pt_ids=get_model("clinic.patient").search([['doctor_id','=',obj.id]])
elif obj.type=='nurse':
p=set()
for cline in obj.cycle_item_lines:
citem=cline.cycle_item_id
for hdcase in citem.hd_cases:
p.update({hdcase.patient_id.id})
pt_ids=list(p)
res[obj.id]=pt_ids
return res
_fields={ _fields={
'employee_id': fields.Many2One("hr.employee","Employee"), 'employee_id': fields.Many2One("hr.employee","Employee"),
"number": fields.Char("Number",required=True,search=True), "number": fields.Char("Number",required=True,search=True),
@ -154,8 +143,6 @@ class Staff(Model):
"prof_license_expiry" : fields.Date("Expired License"), "prof_license_expiry" : fields.Date("Expired License"),
"birthday": fields.Date("BirthDay",search=True), "birthday": fields.Date("BirthDay",search=True),
"department_id": fields.Many2One("clinic.department", "Department",search=True), "department_id": fields.Many2One("clinic.department", "Department",search=True),
#"patients": fields.One2Many("clinic.patient","doctor_id","Patients"),
"patients": fields.Many2Many("clinic.patient","Patients",function="_get_all"),
"addresses": fields.One2Many("address","staff_id","Addresses"), "addresses": fields.One2Many("address","staff_id","Addresses"),
"comments": fields.One2Many("message","related_id","Comments"), "comments": fields.One2Many("message","related_id","Comments"),
"nurse_visits": fields.One2Many("clinic.visit","nurse_id","Visits"), "nurse_visits": fields.One2Many("clinic.visit","nurse_id","Visits"),

View File

@ -75,12 +75,6 @@
<div> <div>
<a href="#name=clinic_visit_board">{{t "Visit Board"}}</a> <a href="#name=clinic_visit_board">{{t "Visit Board"}}</a>
</div> </div>
<div>
<a href="#name=clinic_visit&mode=form">{{t "New Visit"}}</a>
</div>
<div>
<a href="#name=clinic_make_apt">{{t "Make An Appointment"}}</a>
</div>
</div> </div>
<div class="nf-board-title"> <div class="nf-board-title">
<h3>{{t "HD Cases"}}</h3> <h3>{{t "HD Cases"}}</h3>