remove visit if dispose
parent
556262f9cc
commit
dad6af8a8e
|
@ -46,7 +46,7 @@
|
||||||
<item string="Sickbed" action="clinic_sickbed"/>
|
<item string="Sickbed" action="clinic_sickbed"/>
|
||||||
</item>
|
</item>
|
||||||
<item string="Reporting" perm="clinic_report">
|
<item string="Reporting" perm="clinic_report">
|
||||||
<item string="Visit Summary" action="clinic_report_visit"/>
|
<!--<item string="Visit Summary" action="clinic_report_visit"/>-->
|
||||||
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
||||||
<item string="Medical Summary" action="clinic_report_medical_summary"/>
|
<item string="Medical Summary" action="clinic_report_medical_summary"/>
|
||||||
<item string="Recent Patient" action="clinic_report_recent_patient"/>
|
<item string="Recent Patient" action="clinic_report_recent_patient"/>
|
||||||
|
|
|
@ -17,6 +17,6 @@
|
||||||
<field name="note"/>
|
<field name="note"/>
|
||||||
<field name="company_id" invisible="1"/>
|
<field name="company_id" invisible="1"/>
|
||||||
<foot>
|
<foot>
|
||||||
<button string="Approve" method="approve" type="success"/>
|
<button string="Approve" method="approve" states="draft" type="success"/>
|
||||||
</foot>
|
</foot>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -250,8 +250,10 @@ class Patient(Model):
|
||||||
vals['state']='dispose'
|
vals['state']='dispose'
|
||||||
if not vals.get("resign_date"):
|
if not vals.get("resign_date"):
|
||||||
vals['resign_date']=time.strftime("%Y-%m-%d")
|
vals['resign_date']=time.strftime("%Y-%m-%d")
|
||||||
|
vals['rm_remain_visit']=True
|
||||||
else:
|
else:
|
||||||
vals['state']='admit'
|
vals['state']='admit'
|
||||||
|
vals['rm_remain_visit']=False
|
||||||
if 'card_no' in vals.keys():
|
if 'card_no' in vals.keys():
|
||||||
self.check_idcard(vals['card_no'])
|
self.check_idcard(vals['card_no'])
|
||||||
ctx={}
|
ctx={}
|
||||||
|
|
|
@ -105,35 +105,49 @@ class ClinicSetting(Model):
|
||||||
schd.confirm()
|
schd.confirm()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def remove_rotation(self,ids,context={}):
|
||||||
|
staffs={}
|
||||||
|
for rt in get_model("clinic.staff.rotation").search_browse([]):
|
||||||
|
staff=rt.staff_id
|
||||||
|
if staff.name not in staffs:
|
||||||
|
staffs[staff.name]=[rt.id]
|
||||||
|
else:
|
||||||
|
staffs[staff.name].append(rt.id)
|
||||||
|
for st_name, vals in staffs.items():
|
||||||
|
for rt_id in vals:
|
||||||
|
rt=get_model("clinic.staff.rotation").browse(rt_id)
|
||||||
|
if not rt.level_id:
|
||||||
|
rt.delete()
|
||||||
|
print("Done!")
|
||||||
|
return
|
||||||
|
|
||||||
def run_script(self,ids,context={}):
|
def run_script(self,ids,context={}):
|
||||||
user_id=get_active_user()
|
user_id=get_active_user()
|
||||||
if user_id !=1:
|
if user_id !=1:
|
||||||
print("Only admin!!")
|
print("Only admin!!")
|
||||||
return
|
return
|
||||||
for cpt in get_model("clinic.patient.cycle").search_browse([]):
|
lines=[]
|
||||||
patient=cpt.patient_id
|
for rt in get_model("clinic.staff.rotation").search_browse([]):
|
||||||
if patient.state!='admit':
|
staff=rt.staff_id
|
||||||
print(patient.name)
|
if staff.type!='nurse':
|
||||||
cpt.delete()
|
continue
|
||||||
print("Done!")
|
level_name=''
|
||||||
return
|
if staff.level_id:
|
||||||
|
level_name=staff.level_id.name
|
||||||
for pt in get_model("clinic.patient").search_browse([]):
|
lines.append({
|
||||||
pt.write({
|
'id': rt.id,
|
||||||
'state': 'admit',
|
'name': staff.name,
|
||||||
|
'level': level_name,
|
||||||
|
'categ': staff.categ_id.name or "",
|
||||||
})
|
})
|
||||||
|
st="Database ID,Staff,Level,Category\n"
|
||||||
|
for line in sorted(lines,key=lambda x: x['name']):
|
||||||
|
st+="%s,%s,%s,%s\n"%(line['id'],line['name'],line['level'],line['categ'])
|
||||||
|
f=open("/tmp/rotation.csv","w")
|
||||||
|
f.write(st)
|
||||||
|
f.close()
|
||||||
print("Done!")
|
print("Done!")
|
||||||
return
|
return
|
||||||
for citem in get_model("clinic.cycle.item").search_browse([]):
|
|
||||||
for line in citem.lines:
|
|
||||||
nurse=line.nurse_id
|
|
||||||
level=nurse.level_id
|
|
||||||
if not line.level_id:
|
|
||||||
if level:
|
|
||||||
line.write({
|
|
||||||
'level_id': level.id
|
|
||||||
})
|
|
||||||
print("Done!")
|
|
||||||
|
|
||||||
def update_departments(self,ids,context={}):
|
def update_departments(self,ids,context={}):
|
||||||
user_id=get_active_user()
|
user_id=get_active_user()
|
||||||
|
|
|
@ -20,15 +20,6 @@ class Staff(Model):
|
||||||
res[obj.id]=age
|
res[obj.id]=age
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_level(self,ids,context={}):
|
|
||||||
res={}
|
|
||||||
for obj in self.browse(ids):
|
|
||||||
level_id=None
|
|
||||||
for rotate in obj.rotations:
|
|
||||||
level_id=rotate.level_id.id
|
|
||||||
res[obj.id]=level_id
|
|
||||||
return res
|
|
||||||
|
|
||||||
def _get_cycle(self,ids,context={}):
|
def _get_cycle(self,ids,context={}):
|
||||||
res={}
|
res={}
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
|
@ -39,20 +30,24 @@ class Staff(Model):
|
||||||
res[obj.id]=cycle_id
|
res[obj.id]=cycle_id
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _get_base(self,ids,context={}):
|
def _get_rotation(self,ids,context={}):
|
||||||
res={}
|
res={}
|
||||||
for obj in self.browse(ids):
|
for obj in self.browse(ids):
|
||||||
wage=0
|
wage=0
|
||||||
max_cycle=0
|
max_cycle=0
|
||||||
ot_per_cycle=0
|
ot_per_cycle=0
|
||||||
|
level_id=None
|
||||||
for rotate in obj.rotations:
|
for rotate in obj.rotations:
|
||||||
wage=rotate.wage
|
if rotate.state=='approved':
|
||||||
max_cycle=rotate.max_cycle
|
level_id=rotate.level_id.id
|
||||||
ot_per_cycle=rotate.ot_per_cycle or 0
|
wage=rotate.wage
|
||||||
|
max_cycle=rotate.max_cycle
|
||||||
|
ot_per_cycle=rotate.ot_per_cycle or 0
|
||||||
res[obj.id]={
|
res[obj.id]={
|
||||||
'wage': wage,
|
'wage': wage,
|
||||||
'max_cycle': max_cycle,
|
'max_cycle': max_cycle,
|
||||||
'ot_per_cycle': ot_per_cycle,
|
'ot_per_cycle': ot_per_cycle,
|
||||||
|
'level_id': level_id,
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
@ -132,12 +127,12 @@ class Staff(Model):
|
||||||
'image': fields.File("Image"),
|
'image': fields.File("Image"),
|
||||||
'note': fields.Text("Note"),
|
'note': fields.Text("Note"),
|
||||||
'categ_id': fields.Many2One("clinic.staff.categ", "Category",search=True),
|
'categ_id': fields.Many2One("clinic.staff.categ", "Category",search=True),
|
||||||
'level_id': fields.Many2One("clinic.staff.level", "Level", function="_get_level"),
|
'level_id': fields.Many2One("clinic.staff.level", "Level", function="_get_rotation",function_multi=True),
|
||||||
'active': fields.Boolean("Active"),
|
'active': fields.Boolean("Active"),
|
||||||
'date': fields.Date("Register Date"),
|
'date': fields.Date("Register Date"),
|
||||||
'wage': fields.Float("Wage", function="_get_base",function_multi=True),
|
'wage': fields.Float("Wage", function="_get_rotation",function_multi=True),
|
||||||
'max_cycle': fields.Integer("Max Cycle", function="_get_base",function_multi=True),
|
'max_cycle': fields.Integer("Max Cycle", function="_get_rotation",function_multi=True),
|
||||||
'ot_per_cycle': fields.Integer("OT Per Cycle", function="_get_base",function_multi=True),
|
'ot_per_cycle': fields.Integer("OT Per Cycle", function="_get_rotation",function_multi=True),
|
||||||
'check_max_cycle': fields.Boolean("Check Max Cycle"),
|
'check_max_cycle': fields.Boolean("Check Max Cycle"),
|
||||||
'hire_date': fields.Date("Hire Date"),
|
'hire_date': fields.Date("Hire Date"),
|
||||||
'resign_date': fields.Date("Resign Date"),
|
'resign_date': fields.Date("Resign Date"),
|
||||||
|
|
|
@ -8,6 +8,15 @@ class StaffRotation(Model):
|
||||||
_string="Staff Rotation"
|
_string="Staff Rotation"
|
||||||
_multi_company=True
|
_multi_company=True
|
||||||
|
|
||||||
|
def _get_all(self,ids,context={}):
|
||||||
|
res={}
|
||||||
|
for obj in self.browse(ids):
|
||||||
|
staff=obj.staff_id
|
||||||
|
res[obj.id]={
|
||||||
|
'staff_name': staff.name or "",
|
||||||
|
}
|
||||||
|
return res
|
||||||
|
|
||||||
_fields={
|
_fields={
|
||||||
"type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type",search=True),
|
"type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type",search=True),
|
||||||
"staff_id": fields.Many2One("clinic.staff","Staff", search=True),
|
"staff_id": fields.Many2One("clinic.staff","Staff", search=True),
|
||||||
|
@ -21,6 +30,7 @@ class StaffRotation(Model):
|
||||||
"note": fields.Text("Note"),
|
"note": fields.Text("Note"),
|
||||||
'company_id': fields.Many2One("company","Company"),
|
'company_id': fields.Many2One("company","Company"),
|
||||||
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
|
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
|
||||||
|
'staff_name': fields.Char("Staff Name", function="_get_all",function_multi=True,store=True), #XXX
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults={
|
_defaults={
|
||||||
|
@ -42,4 +52,13 @@ class StaffRotation(Model):
|
||||||
'state': 'approved',
|
'state': 'approved',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def create(self,vals,**kw):
|
||||||
|
id=super().create(vals,**kw)
|
||||||
|
self.function_store([id])
|
||||||
|
return id
|
||||||
|
|
||||||
|
def write(self,ids,vals,**kw):
|
||||||
|
super().write(ids,vals,**kw)
|
||||||
|
self.function_store(ids)
|
||||||
|
|
||||||
StaffRotation.register()
|
StaffRotation.register()
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
todo:
|
todo:
|
||||||
- report k. boy (sub detail)
|
- report k. boy (sub detail) -> ok
|
||||||
- change by department
|
- staff rotation
|
||||||
|
- update level for staff
|
||||||
|
- add script to
|
||||||
|
- multi department access
|
||||||
|
- merge staff same name but different department
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
- compute labor cost
|
- compute labor cost
|
||||||
|
|
Loading…
Reference in New Issue