conv_bal
watcha.h 2014-11-21 09:39:26 +07:00
parent 97c90ac975
commit b74735980e
21 changed files with 265 additions and 84 deletions

View File

@ -16,6 +16,20 @@
</list>
</field>
</tab>
<tab string="Labor Cost">
<group form_layout="stacked">
<field name="var_k" span="3"/>
<field name="var_pt" span="3"/>
<field name="var_ptx" span="3"/>
<field name="var_x" span="3"/>
<field name="lines" nolabel="1">
<list>
<field name="level_id"/>
<field name="qty"/>
</list>
</field>
</group>
</tab>
<tab string="Other Info">
<field name="cycle_dialy_id" domain="[['date','=',date]]"/>
</tab>

View File

@ -1,5 +1,5 @@
<list model="clinic.cycle.item" colors='{"#9f9":[["state","=","done"]]}'>
<field name="name"/>
<!--<field name="name"/>-->
<field name="cycle_id"/>
<field name="date"/>
<field name="state"/>

View File

@ -31,8 +31,8 @@
<field name="age"/>
<field name="active"/>
</group>
<separator string="Address Information"/>
<field name="addresses" view="form_list"/>
<!--<separator string="Address Information"/>-->
<!--<field name="addresses" view="form_list"/>-->
</tab>
<tab string="Professional Information">
<field name="prof_license" attrs='{"invisible":[["type","in",["personal"]]]}'/>
@ -47,6 +47,7 @@
</tabs>
<related>
<field name="documents"/>
<field name="addresses"/>
<field name="cycles" nolabel="1">
<list>
<field name="cycle_id"/>

View File

@ -1,7 +1,11 @@
<form model="clinic.personal.level">
<head>
<button string="Options" dropdown="1">
<item string="Copy" method="copy"/>
</button>
</head>
<field name="name"/>
<field name="type"/>
<field name="formular"/>
<field name="sequence"/>
<field name="description"/>
</form>

View File

@ -1,7 +1,7 @@
<list model="clinic.personal.level">
<field name="name"/>
<field name="type"/>
<field name="formular"/>
<!--<field name="formular"/>-->
<field name="description"/>
<field name="sequence"/>
</list>

View File

@ -17,6 +17,7 @@
<list>
<field name="cycle_id"/>
<field name="nurse_id"/>
<field name="level_id"/>
</list>
</field>
</group>

View File

@ -1,17 +1,39 @@
<form model="clinic.setting" title="Clinic Settings">
<tabs>
<tab string="Testing">
<field name="file"/>
<newline/>
</tab>
<tab string="General">
<separator string="Labor Cost"/>
<tab string="Labor Cost">
<field name="var_k"/>
<field name="levels" nolabel="1">
<list>
<field name="level_id"/>
<field name="var_a"/>
<field name="op"/>
<field name="var_b"/>
<field name="formular"/>
</list>
<form>
<field name="level_id"/>
<field name="var_a"/>
<field name="op"/>
<field name="var_b"/>
<field name="formular"/>
</form>
</field>
<html span="5" offset="1">
<h5 style="color:#666">How labor cost affect</h5>
</html>
</tab>
<tab string="Testing">
<group form_layout="stacked">
<field name="file" span="3"/>
<newline/>
<button string="Make Visit" method="make_visit" span="2"/>
<newline/>
<button string="Make HD Case" method="make_done" span="2"/>
<newline/>
<button string="Complete HD Case" method="make_complete" span="2"/>
</group>
</tab>
</tabs>
<foot>
<button string="Make Visit" method="make_visit"/>
<button string="Make HD Case" method="make_done"/>
<button string="Complete HD Case" method="make_complete"/>
</foot>
</form>

View File

@ -1,5 +1,6 @@
from . import utils
from . import setting
from . import setting_level
from . import cause_chronic
from . import comorbidity
from . import department

View File

@ -5,7 +5,7 @@ from netforce.access import get_active_company
class CycleDialy(Model):
_name="clinic.cycle.dialy"
_string="Cycle Diay"
_string="Cycle Dialy"
_fields={
"name": fields.Char("Name"),

View File

@ -8,7 +8,7 @@ class CycleItem(Model):
_string="Cycle Item"
_name_field="name"
def _get_all(self,ids,context):
def _get_all(self,ids,context={}):
res={}
for obj in self.browse(ids):
name="%s-%s"%(obj.cycle_id.name,obj.date)
@ -17,23 +17,43 @@ class CycleItem(Model):
}
return res
def _get_pt(self,ids,context={}):
res={}
for obj in self.browse(ids):
total_case=len(obj.hd_cases)
res[obj.id]={
'var_pt': total_case,
'var_ptx': total_case*(obj.var_k or 0)
}
return res
_fields={
'name': fields.Char("Name", function="_get_all",function_multi=True),
'date': fields.Date("Date",search=True),
'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
'cycle_dialy_id': fields.Many2One("clinic.cycle.dialy", "Cycle Dialy",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'),
'sequence': fields.Char("Sequence"), # for sort item
'company_id': fields.Many2One("company", "Company"),
"state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
'var_k': fields.Float("K"),
'var_x': fields.Float("X"),
'var_pt': fields.Integer("PT", function="_get_pt",function_multi=True),
'var_ptx': fields.Float("PT x K", function="_get_pt",function_multi=True),
}
def _get_vark(self,context={}):
st=get_model("clinic.setting").browse(1)
return st.var_k or 0
_defaults={
'state': 'draft',
'company_id': lambda *a: get_active_company(),
'date': lambda *a: time.strftime("%Y-%m-%d"),
'var_k': _get_vark,
}
_order="sequence"

View File

@ -14,14 +14,11 @@ class CycleItemLine(Model):
return res
_fields={
'cycle_item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
"type": fields.Selection([("doctor","Doctor"),("nurse","Nurse")],"Personal Type",required=True),
'personal_categ': fields.Many2One("clinic.personal.categ", "Nurse Category",),
'item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
'level_id': fields.Many2One("clinic.personal.level", "Level",domain=[['type','=','nurse']]),
'formular': fields.Char("Formular", size=100),
'description': fields.Char("Description"),
'qty': fields.Integer("Qty"),
'rate': fields.Float("Rate"),
#'amount': fields.Float("Amount",function="all_amount", function_multi=True),
'amount': fields.Float("Amount"),
'company_id': fields.Many2One('company','Company'),
}

View File

@ -71,9 +71,24 @@ class GenVisit(Model):
'nurse_id': _get_nurse,
'duration': 1,
'cycle_id': _get_cycle,
'monday': True,
#'monday': True, # dynamic select weekday, use default_get
}
def default_get(self,field_names=None,context=None,**kw):
vals=super().default_get(field_names,context,**kw)
wd=datetime.now().weekday()
wds={
0: 'monday',
1: 'tuesday',
2: 'wednesday',
3: 'thursday',
4: 'friday',
5: 'sathurday',
6: 'sunday',
}
vals[wds[wd]]=True
return vals
def onchange_time(self,context={}):
data=context['data']
cycle_id=data['cycle_id']
@ -182,7 +197,7 @@ class GenVisit(Model):
dom.append(['state','=','draft'])
vids=visit_obj.search(dom)
visit_obj.delete(vids)
key='%s-%s'%(vals['cycle_id'], vals['time_start'])
key='%s/%s'%(vals['cycle_id'], vals['time_start'])
if not schedules.get(key):
schedules[key]={
'cycle_id': obj.cycle_id.id,
@ -194,19 +209,40 @@ class GenVisit(Model):
start_date=tmp
for vals in visit_vals:
vals['nurse_vals']=nurse_vals # XXX
visit_obj.create(vals)
#dom=[]
#dom.append(['time_start','>=','%s %s'%(obj.date_from[0:10],' 00:00:00')])
#dom.append(['time_stop','<=','%s %s'%(start_date.strftime(FMT_DATE)[0:10],' 23:59:59')])
#dom.append(['cycle_id','=',obj.cycle_id.id])
#schedule_obj=get_model("clinic.schedule")
#schedule_ids=schedule_obj.search(dom)
#schedule_obj.delete(schedule_ids)
#nurse_ids=[nurse['id'] for nurse in nurse_vals]
#for key, vals in schedules.items():
#vals['nurses']=[('add', nurse_ids)]
#schedule_obj.create(vals)
print("create schedule")
print("="*50)
for k, v in schedules.items():
cycle_id,time_start=k.split("/")
schedule_date=time_start[0:10]
dom=[]
dom.append(['date','=',schedule_date])
schedules=get_model("clinic.schedule").search_browse(dom)
if schedules:
schedule=schedules[0]
if schedule.state=='draft':
for line in schedule.lines:
line.delete()
else:
vals={
'date': time_start[0:10],
'time_start': time_start,
'time_stop': time_start,
}
schedule_id=get_model("clinic.schedule").create(vals)
schedule=get_model("clinic.schedule").browse(schedule_id)
lines=[]
for nv in nurse_vals:
nurse_id=nv['id']
lines.append(('create',{
'nurse_id': nurse_id,
'cycle_id': cycle_id,
}))
schedule.write({'lines': lines})
print("="*50)
return {
'next': {

View File

@ -22,7 +22,6 @@ class LoadNurse(Model):
if cycle_ids:
cycle_id=cycle_ids[0]
lines=[]
print("cycle_id ", cycle_id)
for nurse in get_model("clinic.personal").search_browse([['type','=','nurse']]):
in_cycle_id=None
if nurse.cycle_id.id:

View File

@ -1,4 +1,4 @@
from netforce.model import Model, fields
from netforce.model import Model, fields, get_model
from netforce.access import get_active_company
class PersonalLevel(Model):
@ -8,9 +8,9 @@ class PersonalLevel(Model):
_fields={
"name": fields.Char("Name",required=True,search=True),
'formular': fields.Text("Formular"),
'description': fields.Text("Description"),
'description': fields.Text("Description", search=True),
'sequence': fields.Integer("Sequence"),
"type": fields.Selection([('personal','Personal'),("doctor","Doctor"),("nurse","Nurse")],"Personal Type",required=True),
"type": fields.Selection([('personal','Personal'),("doctor","Doctor"),("nurse","Nurse")],"Personal Type",required=True, search=True),
}
_defaults={
@ -22,4 +22,21 @@ class PersonalLevel(Model):
_order="sequence"
def copy(self,ids,context={}):
obj=self.browse(ids)[0]
vals={
'name': '%s (copy)'%obj.name,
'description': obj.description,
'type': obj.type,
}
new_id=get_model("clinic.personal.level").create(vals)
return {
'next': {
'name': 'clinic_personal_level',
'mode': 'form',
'active_id': new_id,
},
'flash': 'Copy has been succcesfully',
}
PersonalLevel.register()

View File

@ -12,10 +12,12 @@ class Schedule(Model):
res={}
for obj in self.browse(ids):
st="\n" # XXX
count=0
for line in obj.lines:
nurse=line.nurse_id
st+='%s %s\n'%(nurse.name, nurse.level_id.name or "")
res[obj.id]='%s'%(st)
count+=1
res[obj.id]='%s'%(st if count else 'No nurse')
return res
def _get_item(self,ids,context={}):

View File

@ -129,6 +129,15 @@ class ScheduleCopy(Model):
'date': date,
'lines': lines,
})
else:
# copy to exist nurse
schedules=get_model("clinic.schedule").search_browse([['date','=',date]])
print("update lines ", lines)
if schedules and lines:
schd=schedules[0]
for line in schd.lines:
line.delete()
schd.write({'lines': lines})
start_date=tmp

View File

@ -4,10 +4,16 @@ class ScheduleLine(Model):
_name="clinic.schedule.line"
_string="Schedule Line"
def _get_level(self,ids,context={}):
res={}
for obj in self.browse(ids):
res[obj.id]=obj.nurse_id.level_id.id
return res
_fields={
'schedule_id': fields.Many2One("clinic.schedule","Schedule"),
'cycle_id': fields.Many2One("clinic.cycle","Cycle"),
"nurse_id": fields.Many2One("clinic.personal","Nurse",domain=[['type','=','nurse']]),
'level_id': fields.Many2One("clinic.personal.level","Level",function="_get_level"),
}
ScheduleLine.register()

View File

@ -14,6 +14,7 @@ class ClinicSetting(Model):
_fields={
"var_k": fields.Float("K"),
'file': fields.File("File"),
'levels': fields.One2Many("clinic.setting.level","setting_id","Levels"),
}
def read_excel(self,fpath=None):

View File

@ -0,0 +1,22 @@
from netforce.model import Model, fields, get_model
class SettingLevel(Model):
_name="clinic.setting.level"
_string="Setting Line"
def _get_formular(self,ids,context={}):
res={}
for obj in self.browse(ids):
res[obj.id]=''.join(['%sx'%obj.var_a or '', obj.op or '', obj.var_b or ''])
return res
_fields={
"setting_id": fields.Many2One("clinic.setting","Setting"),
"level_id": fields.Many2One("clinic.personal.level","Level",domain=[['type','=','nurse']]),
'var_a': fields.Char("Ax"),
"op": fields.Selection([["+","+"],["-","-"],["*","*"],["/","/"]],"Operation"),
'var_b': fields.Char("B"),
'formular': fields.Text("Formular",function="_get_formular"),
}
SettingLevel.register()

View File

@ -177,6 +177,64 @@ class Visit(Model):
hd_case_id=hd_case_obj.create(vals)
if context.get("called"): #XXX call outside
return hd_case_id
print("checking cycle item")
date=vals['time_start'][0:10]
cycle=obj.cycle_id
dom=[]
dom.append(['date','=',date])
dom.append(['cycle_id','=',cycle.id])
dom.append(['state','=','draft'])
item_obj=get_model('clinic.cycle.item')
item_ids=item_obj.search(dom)
def get_schedule(date):
dom=[]
dom.append(['date','=',date])
schedule=None
schedules=get_model("clinic.schedule").search_browse(dom)
if schedules:
schedule=schedules[0]
return schedule
item_vals={
'cycle_id': cycle.id,
'date': date,
'nurses': [],
}
item_id=None
if not item_ids:
item_id=item_obj.create(item_vals)
else:
# clear old nurse in cycle item
item_id=item_ids[0]
item=item_obj.browse(item_id)
for nurse in item.nurses:
nurse.delete()
item=item_obj.browse(item_id)
schedule=get_schedule(date)
if schedule:
for line in schedule.lines:
if line.cycle_id.id==cycle.id:
nurse=line.nurse_id
item_vals['nurses'].append(('create',{
'nurse_id': nurse.id,
'level_id': nurse.level_id.id,
}))
item.write(item_vals)
obj.write({
'cycle_item_id': item_id,
})
hd_case=hd_case_obj.browse(hd_case_id)
hd_case.write({
'cycle_item_id': item_id,
})
return {
'next': {
'name': 'clinic_hd_case',
@ -296,50 +354,12 @@ class Visit(Model):
}
def create(self, vals,**kw):
date=vals['time_start'][0:10]
cycle_id=vals['cycle_id']
cycle=get_model("clinic.cycle").browse(cycle_id)
dom=[]
dom.append(['date','=',date])
dom.append(['cycle_id','=',cycle_id])
item_obj=get_model('clinic.cycle.item')
item_ids=item_obj.search(dom)
item_id=None
nurse_vals=[]
if 'nurse_vals' in vals.keys():
nurse_vals=vals['nurse_vals']
del vals['nurse_vals']
if not item_ids:
item_vals={
'cycle_id': cycle_id,
'date': date,
'nurses': [],
}
for nurse_val in nurse_vals:
item_vals['nurses'].append(('create',{
'nurse_id': nurse_val['id'],
'level_id': nurse_val['level_id'],
}))
item_id=item_obj.create(item_vals)
else:
item_id=item_ids[0]
item_nurse_obj=get_model("clinic.cycle.item.nurse")
item_nurse_ids=item_nurse_obj.search([['cycle_item_id','=',item_id]])
item_nurse_obj.delete(item_nurse_ids)
for nurse_val in nurse_vals:
item_nurse_obj.create({
'cycle_item_id': item_id,
'nurse_id': nurse_val['id'],
'level_id': nurse_val['level_id'],
})
vals['cycle_item_id']=item_id
vals['sequence']='%s-%s'%(vals['time_start'][0:10],cycle.sequence) #date-sequence
vals['visit_date']=vals['time_start'][0:10]
obj_id=super().create(vals,**kw)
return obj_id
new_id=super().create(vals,**kw)
return new_id
def cancel(self,ids,context={}):
obj=self.browse(ids)[0]

View File

@ -1,5 +1,14 @@
=======
customize ui
- attribute color for field
calendar -
- show search
- change color from cycle
- filter state from attr
- can print sechedule all month
- set attribute color for field
========
cycle dialy
-list of cycle items
- report all compute all cost