prepare cycle item for spliting department
parent
1ad905ead9
commit
c166295720
|
@ -1,8 +0,0 @@
|
|||
<action>
|
||||
<field name="string">Cycle Daily</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.cycle.daily</field>
|
||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Confirmed",[["state","=","confirmed"]]]]</field>
|
||||
<field name="modes">list,form</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
|
@ -1,8 +0,0 @@
|
|||
<action>
|
||||
<field name="string">Cycle Monthly</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="model">clinic.cycle.monthly</field>
|
||||
<field name="tabs">[["All",[]],["Draft",[["state","=","draft"]]],["Approved",[["state","=","approved"]]]]</field>
|
||||
<field name="modes">list,form</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
|
@ -1,53 +0,0 @@
|
|||
<form model="clinic.cycle.daily" attrs='{"readonly":[["state","in",["confirmed"]]]}' show_company="1">
|
||||
<head>
|
||||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="To Draft" method="to_draft" states="confirmed"/>
|
||||
<item string="Recheck Item" method="recheck_item" states="draft"/>
|
||||
<item string="View Cycle Monthly" method="view_cycle_monthly" states="confirmed"/>
|
||||
</button>
|
||||
</head>
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
<field name="date"/>
|
||||
<field name="lines" nolabel="1">
|
||||
<list>
|
||||
<field name="cycle_id"/>
|
||||
<field name="staff_id"/>
|
||||
<field name="level_id"/>
|
||||
<field name="type"/>
|
||||
<field name="qty" onchange="onchange_line"/>
|
||||
<field name="rate" onchange="onchange_line"/>
|
||||
<field name="amount"/>
|
||||
</list>
|
||||
<form>
|
||||
<field name="cycle_id"/>
|
||||
<field name="staff_id"/>
|
||||
<field name="level_id"/>
|
||||
<field name="type"/>
|
||||
<field name="qty"/>
|
||||
<field name="rate"/>
|
||||
<field name="amount"/>
|
||||
</form>
|
||||
</field>
|
||||
<group span="12">
|
||||
<field name="total" span="2" offset="10"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Confirmation">
|
||||
<field name="user_id"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
<foot>
|
||||
<button string="Confirm" type="success" method="confirm" icon="ok" states="draft" />
|
||||
</foot>
|
||||
<related>
|
||||
<field name="cycle_items">
|
||||
<list colors='{"#cfc":[["state","=","done"]]}'>
|
||||
<field name="cycle_id"/>
|
||||
<field name="date"/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
</field>
|
||||
</related>
|
||||
</form>
|
|
@ -1,4 +0,0 @@
|
|||
<list model="clinic.cycle.daily" colors='{"#cfc":[["state","=","confirmed"]],"#dbdbdb":[["state","=","cancelled"]]}'>
|
||||
<field name="name"/>
|
||||
<field name="state"/>
|
||||
</list>
|
|
@ -16,7 +16,7 @@
|
|||
</group>
|
||||
<tabs>
|
||||
<tab string="Nurses">
|
||||
<field name="nurses" nolabel="1">
|
||||
<field name="lines" nolabel="1">
|
||||
<list>
|
||||
<field name="nurse_id" domain="[['type','=','nurse']]" onchange="onchange_nurse"/>
|
||||
<field name="level_id"/>
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
<form model="clinic.cycle.monthly" attrs='{"readonly":[["state","in",["approved"]]]}' show_company="1">
|
||||
<head>
|
||||
<field name="state"/>
|
||||
<button string="Options" dropdown="1">
|
||||
<item string="To Draft" method="to_draft" states="approved"/>
|
||||
</button>
|
||||
</head>
|
||||
<tabs>
|
||||
<tab string="General">
|
||||
<field name="name"/>
|
||||
<field name="lines" nolabel="1">
|
||||
<list>
|
||||
<field name="staff_id"/>
|
||||
<field name="level_id"/>
|
||||
<field name="type"/>
|
||||
<field name="amount" onchange="onchange_line"/>
|
||||
</list>
|
||||
<form>
|
||||
<field name="staff_id"/>
|
||||
<field name="level_id"/>
|
||||
<field name="type"/>
|
||||
<field name="amount"/>
|
||||
</form>
|
||||
</field>
|
||||
<group span="12">
|
||||
<field name="total" span="2" offset="10"/>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Approval">
|
||||
<field name="user_id"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
<foot>
|
||||
<button string="Approve" type="success" method="approve" icon="ok" states="draft" />
|
||||
</foot>
|
||||
<related>
|
||||
<field name="cycle_dailies">
|
||||
<list colors='{"#cfc":[["state","=","confirmed"]]}'>
|
||||
<field name="name"/>
|
||||
<field name="date"/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
</field>
|
||||
</related>
|
||||
</form>
|
|
@ -1,4 +0,0 @@
|
|||
<list model="clinic.cycle.monthly">
|
||||
<field name="name"/>
|
||||
<field name="state"/>
|
||||
</list>
|
|
@ -3,5 +3,7 @@
|
|||
<button string="Print"/>
|
||||
</head>
|
||||
<field name="name"/>
|
||||
<field name="branch_id"/>
|
||||
<field name="department_id"/>
|
||||
<field name="state"/>
|
||||
</calendar>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from . import utils
|
||||
from . import setting
|
||||
from . import fin_setting
|
||||
from . import setting_product
|
||||
from . import setting_level
|
||||
from . import setting_policy
|
||||
|
@ -33,17 +34,10 @@ from . import hd_case_dialyzer
|
|||
from . import dialyzer
|
||||
from . import cycle
|
||||
from . import cycle_item
|
||||
from . import cycle_item_nurse
|
||||
from . import cycle_item_other
|
||||
from . import cycle_item_line
|
||||
from . import cycle_daily
|
||||
from . import cycle_daily_line
|
||||
from . import cycle_monthly
|
||||
from . import cycle_monthly_line
|
||||
from . import gen_visit
|
||||
from . import gen_visit_line
|
||||
from . import gen_visit_time
|
||||
from . import fin_setting
|
||||
from . import payment
|
||||
from . import account_payment
|
||||
from . import account_invoice
|
||||
|
@ -76,6 +70,7 @@ from . import import_product
|
|||
from . import import_patient
|
||||
from . import import_visit
|
||||
from . import import_hd_case
|
||||
from . import import_uc
|
||||
from . import vascular_access
|
||||
from . import hospital
|
||||
from . import labor_cost
|
||||
|
@ -86,7 +81,6 @@ from . import labor_cost_entry
|
|||
from . import labor_cost_entry_line
|
||||
from . import sickbed
|
||||
from . import product_categ
|
||||
from . import import_uc
|
||||
from . import make_apt
|
||||
from . import make_apt_line
|
||||
from . import matching_payment
|
||||
|
|
|
@ -1,194 +0,0 @@
|
|||
import time
|
||||
|
||||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company, get_active_user
|
||||
from netforce.utils import get_data_path
|
||||
|
||||
class CycleDaily(Model):
|
||||
_name="clinic.cycle.daily"
|
||||
_string="Cycle Daily"
|
||||
|
||||
def _get_all(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
total=0.0
|
||||
for line in obj.lines:
|
||||
total+=(line.amount or 0)
|
||||
res[obj.id]={
|
||||
'total': total,
|
||||
}
|
||||
return res
|
||||
|
||||
_fields={
|
||||
"name": fields.Char("Name"),
|
||||
'date': fields.Date("Date", required=True, search=True),
|
||||
'cycle_items': fields.One2Many("clinic.cycle.item","cycle_daily_id", "Cycle Items"),
|
||||
'cycle_monthly_id': fields.Many2One("clinic.cycle.monthly","Monthly"),
|
||||
'lines': fields.One2Many("clinic.cycle.daily.line","cycle_daily_id", "Lines"),
|
||||
"state": fields.Selection([("draft","Draft"),('confirmed','Confirmed')],"Status",required=True),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
'total': fields.Float("Total",function="_get_all", function_multi=True),
|
||||
'user_id': fields.Many2One("base.user","User"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'company_id': lambda *a: get_active_company(),
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'name': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'user_id': lambda *a: get_active_user(),
|
||||
'state': 'draft',
|
||||
}
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
date=vals.get('date','')
|
||||
if date:
|
||||
vals['name']=date
|
||||
super().write(ids,vals,**kw)
|
||||
|
||||
def confirm(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
'state': 'confirmed',
|
||||
})
|
||||
all_vals={}
|
||||
for line in obj.lines:
|
||||
staff=line.staff_id
|
||||
level=line.level_id
|
||||
amt=line.amount or 0.0
|
||||
qty=line.qty or 0
|
||||
if not all_vals.get(staff.id):
|
||||
all_vals[staff.id]={
|
||||
'level_id': level.id,
|
||||
'type': line.type,
|
||||
'qty': 0,
|
||||
'amount': 0,
|
||||
}
|
||||
all_vals[staff.id]['amount']+=amt
|
||||
all_vals[staff.id]['qty']+=qty
|
||||
lines=[]
|
||||
for staff_id, vals in all_vals.items():
|
||||
vals.update({'staff_id': staff_id})
|
||||
lines.append(('create',vals))
|
||||
|
||||
mname=obj.date[0:7].replace("-","/")
|
||||
mobj=get_model("clinic.cycle.monthly")
|
||||
res=mobj.search_browse([['name','=',mname]])
|
||||
mid=None
|
||||
monthly=None
|
||||
if res:
|
||||
mid=res[0]['id']
|
||||
monthly=mobj.browse(mid)
|
||||
# find other cycle daily and summary salary of staff
|
||||
for daily in monthly.cycle_dailies:
|
||||
# don't include amount the same date
|
||||
if daily.date==obj.date:
|
||||
continue
|
||||
for line in daily.lines:
|
||||
amt=line.amount or 0.0
|
||||
qty=line.qty or 0
|
||||
staff=line.staff_id
|
||||
vals=all_vals.get(staff.id,None)
|
||||
if vals:
|
||||
vals['amount']+=amt
|
||||
|
||||
lines=[]
|
||||
for staff_id, vals in all_vals.items():
|
||||
vals.update({'staff_id': staff_id})
|
||||
lines.append(('create',vals))
|
||||
|
||||
# update staff amount
|
||||
staff_ids=all_vals.keys()
|
||||
for line in monthly.lines:
|
||||
staff=line.staff_id
|
||||
if staff.id in staff_ids:
|
||||
line.delete()
|
||||
|
||||
monthly.write({
|
||||
'lines': lines,
|
||||
})
|
||||
else:
|
||||
mid=mobj.create({
|
||||
'name': mname,
|
||||
'lines': lines,
|
||||
})
|
||||
monthly=mobj.browse(mid)
|
||||
if not monthly:
|
||||
return
|
||||
|
||||
obj.write({
|
||||
'cycle_monthly_id': mid,
|
||||
})
|
||||
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_cycle_monthly',
|
||||
'mode': 'form',
|
||||
'active_id': monthly.id,
|
||||
},
|
||||
'flash':'Cycle %s has been confirmed and %s has been updated'%(obj.name,monthly.name)
|
||||
}
|
||||
|
||||
def recheck_item(self,ids,context={}):
|
||||
# copy cost of nurse and doctor from cycle item
|
||||
obj=self.browse(ids)[0]
|
||||
lines=[]
|
||||
ctx=context.copy()
|
||||
context['called']=True
|
||||
# sorted by sequence of cycle
|
||||
for cycle_item in sorted(obj.cycle_items, key=lambda x: x.cycle_id.sequence):
|
||||
lines+=cycle_item.validate(context=context)
|
||||
obj.write({
|
||||
'lines': lines,
|
||||
})
|
||||
context=ctx
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_cycle_daily',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash':'Recheck successfully',
|
||||
}
|
||||
|
||||
def to_draft(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
# remove journal entry
|
||||
obj.write({
|
||||
'state': 'draft',
|
||||
})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_cycle_daily',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash':'Draft!',
|
||||
}
|
||||
|
||||
def onchange_line(self,context={}):
|
||||
data=context['data']
|
||||
path=context['path']
|
||||
line=get_data_path(data,path,parent=True)
|
||||
qty=line['qty']
|
||||
rate=line['rate']
|
||||
line['amount']=qty*rate
|
||||
total=0.0
|
||||
for line in data['lines']:
|
||||
qty=line['qty']
|
||||
rate=line['rate']
|
||||
total+=qty*rate
|
||||
data['total']=total
|
||||
return data
|
||||
|
||||
def view_cycle_monthly(self,ids,context):
|
||||
obj=self.browse(ids)[0]
|
||||
monthly=obj.cycle_monthly_id
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_monthly',
|
||||
'mode': 'form',
|
||||
'active_id': monthly.id,
|
||||
},
|
||||
}
|
||||
|
||||
CycleDaily.register()
|
|
@ -1,26 +0,0 @@
|
|||
from netforce.model import Model, fields
|
||||
from netforce.access import get_active_company
|
||||
|
||||
class CycleDailyLine(Model):
|
||||
_name="clinic.cycle.daily.line"
|
||||
_string="Cycle Daily Line"
|
||||
|
||||
_fields={
|
||||
"cycle_daily_id": fields.Many2One("clinic.cycle.daily","Cycle Daily"),
|
||||
'cycle_id': fields.Many2One("clinic.cycle", "Cycle"),
|
||||
'staff_id': fields.Many2One("clinic.staff", "Staff"),
|
||||
'level_id': fields.Many2One("clinic.staff.level", "Level"),
|
||||
'qty': fields.Integer("Qty"),
|
||||
'rate': fields.Float("Rate"),
|
||||
'amount': fields.Float("Amount"),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Type",required=True),
|
||||
'date': fields.Date("Date"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'company_id': lambda *a: get_active_company(),
|
||||
}
|
||||
|
||||
|
||||
CycleDailyLine.register()
|
|
@ -28,24 +28,18 @@ class CycleItem(Model):
|
|||
'name': fields.Char("Name",function="_get_all",function_multi=True,store=True),
|
||||
'date': fields.Date("Date",search=True),
|
||||
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
|
||||
'lines': fields.One2Many("clinic.cycle.item.line","item_id", "Lines"),
|
||||
'visits': fields.One2Many("clinic.visit","cycle_item_id", "Visits"),
|
||||
'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
|
||||
'nurses': fields.One2Many("clinic.cycle.item.nurse",'cycle_item_id','Nurses'),
|
||||
'nurse_id': fields.Many2One("clinic.staff","Nurse",domain=[['type','=','nurse']]),
|
||||
'lines': fields.One2Many("clinic.cycle.item.line",'cycle_item_id','Nurses'),
|
||||
'sequence': fields.Char("Sequence",function="_get_all",function_multi=True,store=True),
|
||||
"state": fields.Selection([("draft","Draft"),("validated","Validated")],"Status",required=True),
|
||||
'user_id': fields.Many2One("base.user","Validator"),
|
||||
"comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
|
||||
'company_id': fields.Many2One("company", "Company"),
|
||||
'branch_id': fields.Many2One("clinic.branch", "Branch"),
|
||||
'department_id': fields.Many2One("clinic.department", "Department"),
|
||||
"comments": fields.One2Many("message","related_id","Comments"), "company_id": fields.Many2One("company","Company"),
|
||||
"state": fields.Selection([("draft","Draft"),("validated","Validated")],"Status",required=True),
|
||||
}
|
||||
|
||||
def _get_vark(self,context={}):
|
||||
st=get_model("clinic.setting").browse(1)
|
||||
return st.var_k or 0
|
||||
|
||||
def _get_branch(self,context={}):
|
||||
b_ids=get_model('clinic.branch').search([])
|
||||
if b_ids:
|
||||
|
@ -58,10 +52,9 @@ class CycleItem(Model):
|
|||
|
||||
_defaults={
|
||||
'state': 'draft',
|
||||
'company_id': lambda *a: get_active_company(),
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'user_id': lambda *a: get_active_user(),
|
||||
'var_k': _get_vark,
|
||||
'company_id': lambda *a: get_active_company(),
|
||||
'branch_id': _get_branch,
|
||||
'department_id': _get_department,
|
||||
}
|
||||
|
@ -70,25 +63,8 @@ class CycleItem(Model):
|
|||
_sql_constraints=[
|
||||
("cycle_item_uniq","unique (cycle_id,date,company_id,branch_id,department_id)","Cycle item should be unique"),
|
||||
]
|
||||
|
||||
def get_cycle_daily(self,date):
|
||||
dom=[]
|
||||
print("get ", date)
|
||||
dom.append(['date','=',date])
|
||||
cd_ids=get_model('clinic.cycle.daily').search(dom)
|
||||
cd_id=None
|
||||
if cd_ids:
|
||||
cd_id=cd_ids[0]
|
||||
else:
|
||||
cd_id=get_model('clinic.cycle.daily').create({
|
||||
'date':date,
|
||||
'name':date,
|
||||
})
|
||||
return cd_id
|
||||
|
||||
|
||||
def create(self, vals,**kw):
|
||||
print('kw ', kw)
|
||||
new_id=super().create(vals,**kw)
|
||||
self.function_store([new_id])
|
||||
return new_id
|
||||
|
@ -144,27 +120,40 @@ class CycleItem(Model):
|
|||
|
||||
def view_schedule(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
company=obj.company_id
|
||||
branch=obj.branch_id
|
||||
department=obj.department_id
|
||||
cycle=obj.cycle_id
|
||||
date=obj.date
|
||||
schd_ids=get_model('clinic.schedule').search([['date','=',date]])
|
||||
dom=[
|
||||
['date','=',date],
|
||||
['company_id','=',company.id],
|
||||
['branch_id','=',branch.id],
|
||||
['department_id','=',department.id],
|
||||
]
|
||||
schd_ids=get_model('clinic.schedule').search(dom)
|
||||
schedule_id=None
|
||||
if schd_ids:
|
||||
schedule_id=schd_ids[0]
|
||||
if not schedule_id:
|
||||
lines=[]
|
||||
for lnurse in obj.nurses:
|
||||
nurse=lnurse.nurse_id
|
||||
for line in obj.lines:
|
||||
nurse=line.nurse_id
|
||||
level=nurse.level_id
|
||||
lines.append(('create',{
|
||||
'cycle_id': obj.cycle_id.id,
|
||||
'cycle_id': cycle.id,
|
||||
'cycle_item_id': obj.id,
|
||||
'nurse_id': nurse.id,
|
||||
'level_id': level.id ,
|
||||
'note': '',
|
||||
}))
|
||||
schedule_id=get_model('clinic.schedule').create({
|
||||
'branch_id': branch.id,
|
||||
'department_id': department.id,
|
||||
'company_id': company.id,
|
||||
'date': date,
|
||||
'time_start': '%s 08:00:00'%date, #XXX
|
||||
'time_stop': '%s 21:00:00'%date, #XXX
|
||||
'time_start': '%s %s'%(date,cycle.time_start),
|
||||
'time_stop': '%s %s'%(date,cycle.time_stop),
|
||||
'lines': lines,
|
||||
})
|
||||
return {
|
||||
|
@ -174,18 +163,6 @@ class CycleItem(Model):
|
|||
'active_id': schedule_id,
|
||||
},
|
||||
}
|
||||
|
||||
def view_cycle_daily(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
if not obj.cycle_daily_id:
|
||||
raise Exception("Please validate cycle item")
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_cycle_daily',
|
||||
'mode': 'form',
|
||||
'active_id': obj.cycle_daily_id.id,
|
||||
}
|
||||
}
|
||||
|
||||
def load_nurse_from_schedule(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
|
|
|
@ -1,34 +1,13 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company
|
||||
from netforce.model import Model, fields
|
||||
|
||||
class CycleItemLine(Model):
|
||||
_name="clinic.cycle.item.line"
|
||||
_string="Cycle Item Line"
|
||||
_string="Cycle Item Nurse"
|
||||
|
||||
def all_amount(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
res[obj.id]={
|
||||
'amount': (obj.qty or 0)*(obj.rate or 0.0),
|
||||
}
|
||||
return res
|
||||
|
||||
_fields={
|
||||
'item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
|
||||
'level_id': fields.Many2One("clinic.staff.level", "Level",domain=[['type','=','nurse']]),
|
||||
'qty': fields.Integer("Qty"),
|
||||
'var_a': fields.Float("A"),
|
||||
'var_b': fields.Float("B"),
|
||||
'formular_org': fields.Char("FML1 (Setting)", size=100),
|
||||
'formular': fields.Char("FML2", size=100),
|
||||
'rate': fields.Float("Rate"),
|
||||
'amount': fields.Float("Result",scale=2),
|
||||
'company_id': fields.Many2One('company','Company'),
|
||||
"state": fields.Selection([["fail","Fail"],["success","Success"]],"Status",),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
|
||||
'level_id': fields.Many2One("clinic.staff.level", "Level",),
|
||||
'nurse_id': fields.Many2One("clinic.staff",'Nurse',domain=[['type','=','nurse']]),
|
||||
}
|
||||
|
||||
CycleItemLine.register()
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company
|
||||
|
||||
class CycleItemNurse(Model):
|
||||
_name="clinic.cycle.item.nurse"
|
||||
_string="Cycle Item Nurse"
|
||||
|
||||
_fields={
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
|
||||
'level_id': fields.Many2One("clinic.staff.level", "Level",),
|
||||
'nurse_id': fields.Many2One("clinic.staff",'Nurse',domain=[['type','=','nurse']]),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
}
|
||||
|
||||
CycleItemNurse.register()
|
|
@ -1,18 +0,0 @@
|
|||
from netforce.model import Model, fields, get_model
|
||||
from netforce.access import get_active_company
|
||||
|
||||
class CycleItemOther(Model):
|
||||
_name="clinic.cycle.item.other"
|
||||
_string="Cycle Item Other"
|
||||
|
||||
_fields={
|
||||
'cycle_item_id': fields.Many2One("clinic.cycle.item", "Cycle Item",required=True),
|
||||
'level_id': fields.Many2One("clinic.staff.level", "Level",),
|
||||
'staff_id': fields.Many2One("clinic.staff",'Staff'),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
"company_id": lambda *a: get_active_company(),
|
||||
}
|
||||
|
||||
CycleItemOther.register()
|
|
@ -1,109 +0,0 @@
|
|||
import time
|
||||
|
||||
from netforce.model import Model, fields
|
||||
from netforce.access import get_active_company, get_active_user
|
||||
from netforce.utils import get_data_path
|
||||
|
||||
class CycleMonthly(Model):
|
||||
_name="clinic.cycle.monthly"
|
||||
_string="Cycle Monthly"
|
||||
|
||||
def _get_all(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
total=0.0
|
||||
for line in obj.lines:
|
||||
total+=(line.amount or 0)
|
||||
res[obj.id]={
|
||||
'total': total,
|
||||
}
|
||||
return res
|
||||
|
||||
_fields={
|
||||
"name": fields.Char("Name"),
|
||||
'cycle_dailies': fields.One2Many("clinic.cycle.daily","cycle_monthly_id", "Cycle Dialy"),
|
||||
'lines': fields.One2Many("clinic.cycle.monthly.line","cycle_monthly_id", "Lines"),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
'total': fields.Float("Total",function="_get_all", function_multi=True),
|
||||
'user_id': fields.Many2One("base.user","User"),
|
||||
"state": fields.Selection([("draft","Draft"),('approved','Approved')],"Status",required=True),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'company_id': lambda *a: get_active_company(),
|
||||
'name': lambda *a: time.strftime("%Y/%m"),
|
||||
'user_id': lambda *a: get_active_user(),
|
||||
'state': 'draft',
|
||||
}
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
date=vals.get('month','')
|
||||
if date:
|
||||
vals['name']=date
|
||||
super().write(ids,vals,**kw)
|
||||
|
||||
def approve(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
'state': 'approved',
|
||||
})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_cycle_monthly',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash':'Approved',
|
||||
}
|
||||
|
||||
def recheck_daily(self,ids,context={}):
|
||||
# copy cost of nurse and doctor from cycle item
|
||||
obj=self.browse(ids)[0]
|
||||
lines=[]
|
||||
ctx=context.copy()
|
||||
context['called']=True
|
||||
for cycle_daily in obj.dailies:
|
||||
lines+=cycle_daily.confirm(context=context)
|
||||
obj.write({
|
||||
'lines': lines,
|
||||
})
|
||||
context=ctx
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_cycle_monthly',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash':'Recheck successfully',
|
||||
}
|
||||
|
||||
def onchange_line(self,context={}):
|
||||
data=context['data']
|
||||
path=context['path']
|
||||
line=get_data_path(data,path,parent=True)
|
||||
qty=line['qty']
|
||||
rate=line['rate']
|
||||
line['amount']=qty*rate
|
||||
total=0.0
|
||||
for line in data['lines']:
|
||||
qty=line['qty']
|
||||
rate=line['rate']
|
||||
total+=qty*rate
|
||||
data['total']=total
|
||||
return data
|
||||
|
||||
def to_draft(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
obj.write({
|
||||
'state': 'draft',
|
||||
})
|
||||
return {
|
||||
'next': {
|
||||
'name': 'clinic_cycle_monthly',
|
||||
'mode': 'form',
|
||||
'active_id': obj.id,
|
||||
},
|
||||
'flash': '%s has been set to draft'%obj.name
|
||||
}
|
||||
|
||||
CycleMonthly.register()
|
|
@ -1,36 +0,0 @@
|
|||
import time
|
||||
|
||||
from netforce.model import Model, fields
|
||||
from netforce.access import get_active_company
|
||||
|
||||
class CycleMonthlyLine(Model):
|
||||
_name="clinic.cycle.monthly.line"
|
||||
_string="Cycle Monthly Line"
|
||||
|
||||
def _get_max_cycle(self,ids,context={}):
|
||||
res={}
|
||||
for obj in self.browse(ids):
|
||||
staff=obj.staff_id
|
||||
res[obj.id]=staff.max_cycle
|
||||
return res
|
||||
|
||||
_fields={
|
||||
"cycle_monthly_id": fields.Many2One("clinic.cycle.monthly","Cycle Monthly"),
|
||||
'staff_id': fields.Many2One("clinic.staff", "Staff"),
|
||||
'level_id': fields.Many2One("clinic.staff.level", "Level"),
|
||||
'date': fields.Date("Date"),
|
||||
'qty': fields.Integer("Qty"),
|
||||
'rate': fields.Float("Rate"),
|
||||
'amount': fields.Float("Amount"),
|
||||
'company_id': fields.Many2One("company","Company"),
|
||||
"type": fields.Selection([('staff','Staff'),("doctor","Doctor"),('nurse','Nurse')],"Type",required=True),
|
||||
'max_cycle': fields.Float('Max Cycle',function="_get_max_cycle"),
|
||||
}
|
||||
|
||||
_defaults={
|
||||
'company_id': lambda *a: get_active_company(),
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
}
|
||||
|
||||
|
||||
CycleMonthlyLine.register()
|
|
@ -179,12 +179,12 @@ class Schedule(Model):
|
|||
})
|
||||
cycles.update({cycle.name})
|
||||
|
||||
for item_id, nurses in items.items():
|
||||
for item_id, lines in items.items():
|
||||
item=get_model("clinic.cycle.item").browse(item_id)
|
||||
for nurse in item.nurses:
|
||||
nurse.delete()
|
||||
for line in item.lines:
|
||||
line.delete()
|
||||
item.write({
|
||||
'nurses': nurses,
|
||||
'lines': lines,
|
||||
})
|
||||
|
||||
cycles=list(reversed(list(cycles)))
|
||||
|
|
|
@ -93,15 +93,29 @@ class ClinicSetting(Model):
|
|||
def run_script(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
#sickbed: update department
|
||||
for sb in get_model('clinic.sickbed').search_browse([]):
|
||||
hdcs=sorted(sb.hd_cases, key=lambda a: a.id)
|
||||
if hdcs:
|
||||
hdc=hdcs[0]
|
||||
#patient=hdc.patient_id
|
||||
sb.write({
|
||||
'department_id': hdc.department_id.id,
|
||||
})
|
||||
#for sb in get_model('clinic.sickbed').search_browse([]):
|
||||
#hdcs=sorted(sb.hd_cases, key=lambda a: a.id)
|
||||
#if hdcs:
|
||||
#hdc=hdcs[0]
|
||||
##patient=hdc.patient_id
|
||||
#sb.write({
|
||||
#'department_id': hdc.department_id.id,
|
||||
#})
|
||||
# create new cycle item
|
||||
# TODO
|
||||
# copy old schedule
|
||||
# copy old nurse to schedule
|
||||
# delete old cycle item
|
||||
# confirm schedule
|
||||
# set visit & hd case to cycle item
|
||||
old_schd=[]
|
||||
for schd in get_model("clinic.schedule").search_browse([]):
|
||||
if schd.lines:
|
||||
print("x")
|
||||
pass
|
||||
for citem in get_model("clinic.cycle.item").search_browse([]):
|
||||
if citem.lines:
|
||||
print("y")
|
||||
print("Done!")
|
||||
|
||||
def reset_last_import(self,ids,context={}):
|
||||
|
|
|
@ -62,7 +62,7 @@ class Staff(Model):
|
|||
if obj.type=='doctor':
|
||||
hids=get_model("clinic.hd.case.staff").search([['staff_id','=',obj.id]])
|
||||
elif obj.type=='nurse':
|
||||
item_ids=[item['cycle_item_id'][0] for item in get_model("clinic.cycle.item.nurse").search_read([['nurse_id','=',obj.id]],['cycle_item_id'])]
|
||||
item_ids=[item['cycle_item_id'][0] for item in get_model("clinic.cycle.item.line").search_read([['nurse_id','=',obj.id]],['cycle_item_id'])]
|
||||
for item in get_model("clinic.cycle.item").browse(item_ids):
|
||||
for hdcase in item.hd_cases:
|
||||
hids.append(hdcase.id)
|
||||
|
@ -115,7 +115,7 @@ class Staff(Model):
|
|||
'cycle_id': fields.Many2One('clinic.cycle','Last Cycle',function="_get_cycle"),
|
||||
"hd_case_staffs": fields.One2Many("clinic.hd.case.staff","staff_id","HD Cases"),
|
||||
"hd_cases": fields.Many2Many("clinic.hd.case","HD Cases",function="_get_hdcase"), # not need to use (it's slow to load)
|
||||
"cycle_item_nurses": fields.One2Many("clinic.cycle.item.nurse","nurse_id","Cycle Items"),
|
||||
"cycle_item_nurses": fields.One2Many("clinic.cycle.item.line","nurse_id","Cycle Items"),
|
||||
'branch_id': fields.Many2One("clinic.branch","Branch", search=True),
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
todo:
|
||||
- XXXX
|
||||
- make a script to generate cycle item
|
||||
- accounting
|
||||
|
||||
- filter data
|
||||
1. company
|
||||
2. branch
|
||||
|
@ -10,18 +14,18 @@ todo:
|
|||
- script
|
||||
- after split department
|
||||
- cycle item should be see only that department
|
||||
|
||||
- accounting
|
||||
- doctor detail
|
||||
- import match hn
|
||||
|
||||
- visit summary -> ok
|
||||
|
||||
- calendar
|
||||
- search calendar
|
||||
- remove
|
||||
- multi company
|
||||
- running number for each branch
|
||||
|
||||
- make an appoitment
|
||||
-
|
||||
=======
|
||||
generate visit ใหม่ -> ok
|
||||
popup select dyalyzer -> ok
|
||||
|
|
Loading…
Reference in New Issue