remove visit if dispose

conv_bal
watcha.h 2015-03-03 09:32:45 +07:00
parent 556262f9cc
commit dad6af8a8e
7 changed files with 77 additions and 43 deletions

View File

@ -46,7 +46,7 @@
<item string="Sickbed" action="clinic_sickbed"/>
</item>
<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="Medical Summary" action="clinic_report_medical_summary"/>
<item string="Recent Patient" action="clinic_report_recent_patient"/>

View File

@ -17,6 +17,6 @@
<field name="note"/>
<field name="company_id" invisible="1"/>
<foot>
<button string="Approve" method="approve" type="success"/>
<button string="Approve" method="approve" states="draft" type="success"/>
</foot>
</form>

View File

@ -250,8 +250,10 @@ class Patient(Model):
vals['state']='dispose'
if not vals.get("resign_date"):
vals['resign_date']=time.strftime("%Y-%m-%d")
vals['rm_remain_visit']=True
else:
vals['state']='admit'
vals['rm_remain_visit']=False
if 'card_no' in vals.keys():
self.check_idcard(vals['card_no'])
ctx={}

View File

@ -105,36 +105,50 @@ class ClinicSetting(Model):
schd.confirm()
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={}):
user_id=get_active_user()
if user_id !=1:
print("Only admin!!")
return
for cpt in get_model("clinic.patient.cycle").search_browse([]):
patient=cpt.patient_id
if patient.state!='admit':
print(patient.name)
cpt.delete()
lines=[]
for rt in get_model("clinic.staff.rotation").search_browse([]):
staff=rt.staff_id
if staff.type!='nurse':
continue
level_name=''
if staff.level_id:
level_name=staff.level_id.name
lines.append({
'id': rt.id,
'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!")
return
for pt in get_model("clinic.patient").search_browse([]):
pt.write({
'state': 'admit',
})
print("Done!")
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={}):
user_id=get_active_user()
if user_id !=1:

View File

@ -20,15 +20,6 @@ class Staff(Model):
res[obj.id]=age
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={}):
res={}
for obj in self.browse(ids):
@ -39,20 +30,24 @@ class Staff(Model):
res[obj.id]=cycle_id
return res
def _get_base(self,ids,context={}):
def _get_rotation(self,ids,context={}):
res={}
for obj in self.browse(ids):
wage=0
max_cycle=0
ot_per_cycle=0
level_id=None
for rotate in obj.rotations:
wage=rotate.wage
max_cycle=rotate.max_cycle
ot_per_cycle=rotate.ot_per_cycle or 0
if rotate.state=='approved':
level_id=rotate.level_id.id
wage=rotate.wage
max_cycle=rotate.max_cycle
ot_per_cycle=rotate.ot_per_cycle or 0
res[obj.id]={
'wage': wage,
'max_cycle': max_cycle,
'ot_per_cycle': ot_per_cycle,
'level_id': level_id,
}
return res
@ -132,12 +127,12 @@ class Staff(Model):
'image': fields.File("Image"),
'note': fields.Text("Note"),
'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"),
'date': fields.Date("Register Date"),
'wage': fields.Float("Wage", function="_get_base",function_multi=True),
'max_cycle': fields.Integer("Max Cycle", function="_get_base",function_multi=True),
'ot_per_cycle': fields.Integer("OT Per Cycle", function="_get_base",function_multi=True),
'wage': fields.Float("Wage", function="_get_rotation",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_rotation",function_multi=True),
'check_max_cycle': fields.Boolean("Check Max Cycle"),
'hire_date': fields.Date("Hire Date"),
'resign_date': fields.Date("Resign Date"),

View File

@ -8,6 +8,15 @@ class StaffRotation(Model):
_string="Staff Rotation"
_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={
"type": fields.Selection([['staff','Staff'],["doctor","Doctor"],["nurse","Nurse"]],"Type",search=True),
"staff_id": fields.Many2One("clinic.staff","Staff", search=True),
@ -21,6 +30,7 @@ class StaffRotation(Model):
"note": fields.Text("Note"),
'company_id': fields.Many2One("company","Company"),
'state': fields.Selection([['draft','Draft'],['approved','Approved']],'State'),
'staff_name': fields.Char("Staff Name", function="_get_all",function_multi=True,store=True), #XXX
}
_defaults={
@ -41,5 +51,14 @@ class StaffRotation(Model):
obj.write({
'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()

View File

@ -1,6 +1,10 @@
todo:
- report k. boy (sub detail)
- change by department
- report k. boy (sub detail) -> ok
- staff rotation
- update level for staff
- add script to
- multi department access
- merge staff same name but different department
===============================
- compute labor cost