diff --git a/netforce_clinic/actions/clinic_nurse_categ.xml b/netforce_clinic/actions/clinic_personal_categ.xml
similarity index 59%
rename from netforce_clinic/actions/clinic_nurse_categ.xml
rename to netforce_clinic/actions/clinic_personal_categ.xml
index 4528b4c..0f49c15 100644
--- a/netforce_clinic/actions/clinic_nurse_categ.xml
+++ b/netforce_clinic/actions/clinic_personal_categ.xml
@@ -1,7 +1,7 @@
- Nurse Categories
+ Personal Categories
multi_view
- clinic.nurse.categ
+ clinic.personal.categ
list,page,form
clinic_menu
diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml
index e3339a1..22dfc59 100644
--- a/netforce_clinic/layouts/clinic_cycle_item_form.xml
+++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml
@@ -9,25 +9,48 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/netforce_clinic/layouts/clinic_doctor_form.xml b/netforce_clinic/layouts/clinic_doctor_form.xml
index f84c1ef..b632921 100644
--- a/netforce_clinic/layouts/clinic_doctor_form.xml
+++ b/netforce_clinic/layouts/clinic_doctor_form.xml
@@ -15,6 +15,7 @@
+
diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml
index 077aecf..2246fdd 100644
--- a/netforce_clinic/layouts/clinic_menu.xml
+++ b/netforce_clinic/layouts/clinic_menu.xml
@@ -5,7 +5,7 @@
-
+
-
diff --git a/netforce_clinic/layouts/clinic_nurse_categ_form.xml b/netforce_clinic/layouts/clinic_personal_categ_form.xml
similarity index 65%
rename from netforce_clinic/layouts/clinic_nurse_categ_form.xml
rename to netforce_clinic/layouts/clinic_personal_categ_form.xml
index 6fc66ea..1219e0b 100644
--- a/netforce_clinic/layouts/clinic_nurse_categ_form.xml
+++ b/netforce_clinic/layouts/clinic_personal_categ_form.xml
@@ -1,6 +1,7 @@
-
diff --git a/netforce_clinic/layouts/clinic_nurse_categ_list.xml b/netforce_clinic/layouts/clinic_personal_categ_list.xml
similarity index 65%
rename from netforce_clinic/layouts/clinic_nurse_categ_list.xml
rename to netforce_clinic/layouts/clinic_personal_categ_list.xml
index 8435896..baea06c 100644
--- a/netforce_clinic/layouts/clinic_nurse_categ_list.xml
+++ b/netforce_clinic/layouts/clinic_personal_categ_list.xml
@@ -1,6 +1,7 @@
-
+
+
diff --git a/netforce_clinic/models/:w b/netforce_clinic/models/:w
deleted file mode 100644
index 778177c..0000000
--- a/netforce_clinic/models/:w
+++ /dev/null
@@ -1,53 +0,0 @@
-import time
-
-from netforce.model import Model, fields, get_model
-from netforce.access import get_active_company
-
-class CycleItem(Model):
- _name="clinic.cycle.item"
- _string="Cycle Item"
-
- def _get_x(self,ids,context):
- res={}
- for obj in self.browse(ids):
- hd_total=len([hd_case for hd_case in obj.hd_cases if hd_case.state=='completed']) # XXX
- pt=(hd_total or 0.0)
- k=(obj.var_k or 0.0)
- pt_k=pt*k
- x=(pt_k + 1275)/13.5
- res[obj.id]=x
- return res
-
- _fields={
- 'company_id': fields.Many2One("company", "Company"),
- 'cycle_id': fields.Many2One("clinic.cycle", "Cycle",search=True),
- 'date': fields.Date("Date",search=True),
- 'var_k': fields.Float("K"),
- 'var_x': fields.Float("X", function="_get_x"),
- "state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
- 'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
- 'lines': fields.One2Many('clinic.cycle.item.line', 'cycle_item_id', 'Lines'),
- }
-
- _defaults={
- 'state': 'draft',
- 'company_id': lambda *a: get_active_company(),
- 'date': lambda *a: time.strftime("%Y-%m-%d"),
- 'var_k': 450,
- }
-
- def compute(self,ids,context={}):
- for obj in self.browse(ids):
- nurer_categ_ids=[line.nurse_categ.id for line in obj.lines]
- vals={
- 'lines': [],
- }
- for nurse_categ in get_model("clinic.nurse.categ").search_browse([]):
- vals['lines'].append(('create',{
- 'nurse_categ': nurse_categ.id,
- 'formular': nurse_categ.formular or "",
- 'qty': 1,
- }))
- pass
- obj.write(vals)
-CycleItem.register()
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index 3ba6e67..437af26 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -7,7 +7,6 @@ from . import graduation
from . import morbidity
from . import nation
from . import nurse
-from . import nurse_categ
from . import address
from . import patient
from . import patient_cause_line
@@ -43,3 +42,4 @@ from . import import_data_sc
from . import translate
from . import payment
from . import account_payment
+from . import personal_categ
diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py
index e923811..885075b 100644
--- a/netforce_clinic/models/cycle_item.py
+++ b/netforce_clinic/models/cycle_item.py
@@ -19,14 +19,18 @@ class CycleItem(Model):
pt_k=pt*k
x=(pt_k + 1275)/13.5
total=0.0
- for line in obj.lines:
+ for line in obj.nurse_lines:
total+=line.amount
+ total2=0.0
+ for line in obj.doctor_lines:
+ total2+=line.amount
res[obj.id]={
'name': name,
'var_x': x,
'total_pt': hd_total,
'total_amount': hd_total*k,
'total': total,
+ 'total2': total2,
'total_balance': (hd_total*k)-total,
}
return res
@@ -42,9 +46,12 @@ class CycleItem(Model):
'total_amount': fields.Float("PT*K", function="_get_all",function_multi=True),
'total_balance': fields.Float("Total Balance", function="_get_all",function_multi=True),
'total': fields.Float("Total", function="_get_all",function_multi=True),
+ 'total2': fields.Float("Total", function="_get_all",function_multi=True),
"state": fields.Selection([("draft","Draft"),("done","Done")],"Status",required=True),
'hd_cases': fields.One2Many("clinic.hd.case","cycle_item_id", "HD Cases"),
- 'lines': fields.One2Many('clinic.cycle.item.line', 'cycle_item_id', 'Lines'),
+ 'nurse_lines': fields.One2Many('clinic.cycle.item.line', 'cycle_item_id', 'Nurse Lines',domain=[['type','=','nurse']]),
+ 'doctor_lines': fields.One2Many('clinic.cycle.item.line', 'cycle_item_id', 'Doctor Lines',domain=[['type','=','doctor']]),
+ 'var_doctor': fields.Float("K Doctor"),
}
_defaults={
@@ -52,43 +59,70 @@ class CycleItem(Model):
'company_id': lambda *a: get_active_company(),
'date': lambda *a: time.strftime("%Y-%m-%d"),
'var_k': 450,
+ 'var_doctor': 450,
}
def compute(self,ids,context={}):
for obj in self.browse(ids):
- #nurer_categ_ids=[line.nurse_categ.id for line in obj.lines]
- # XXX
- vals_dict={}
+ vals={
+ 'nurse_lines': [],
+ 'doctor_lines': [],
+ }
+ nurse_dict={}
+ doctor_dict={}
for hd_case in obj.hd_cases:
if hd_case.state=='completed':
nurse_code=hd_case.nurse_id.categ_id.code or ""
- print("nurse_code ", nurse_code)
- if not vals_dict.get(nurse_code):
- vals_dict[nurse_code]=0
- vals_dict[nurse_code]+=1
+ if not nurse_dict.get(nurse_code):
+ nurse_dict[nurse_code]=0
+ nurse_dict[nurse_code]+=1
- for line in obj.lines:
+ doctor_categ=hd_case.doctor_id.categ_id or ""
+ if not doctor_categ:
+ continue
+ doctor_name=hd_case.doctor_id.name or ""
+ key=(doctor_categ,doctor_name)
+ if not doctor_dict.get(key):
+ doctor_dict[key]=0
+ doctor_dict[key]+=1
+
+ for line in obj.nurse_lines:
+ line.delete()
+ for line in obj.doctor_lines:
line.delete()
- vals={
- 'lines': [],
- }
- print(vals_dict)
- for nurse_categ in get_model("clinic.nurse.categ").search_browse([]):
- formular=nurse_categ.formular or ""
- rate=0
- try:
- var_x="%s"%(round(obj.var_x,2))
- formulared=formular.replace("x",var_x)
- rate=eval(formulared)
- except:
- rate=0
- vals['lines'].append(('create',{
- 'nurse_categ': nurse_categ.id,
- 'formular': formular,
- 'qty': vals_dict.get(nurse_categ.code,0),
- 'rate': rate,
+ for k, v in doctor_dict.items():
+ categ=k[0]
+ name=k[1]
+ qty=v
+ vals['doctor_lines'].append(('create',{
+ 'personal_categ': categ.id,
+ 'description': name,
+ 'type': 'doctor',
+ 'formular': categ.formular,
+ 'qty': qty,
+ 'rate': obj.var_doctor or 0.0,
}))
+
+ print(nurse_dict)
+ for personal_categ in get_model("clinic.personal.categ").search_browse([]):
+ if personal_categ.type=='nurse':
+ formular=personal_categ.formular or ""
+ rate=0
+ try:
+ var_x="%s"%(round(obj.var_x,2))
+ formulared=formular.replace("x",var_x)
+ rate=eval(formulared)
+ except:
+ rate=0
+ vals['nurse_lines'].append(('create',{
+ 'personal_categ': personal_categ.id,
+ 'type': 'nurse',
+ 'formular': formular,
+ 'qty': nurse_dict.get(personal_categ.code,0),
+ 'rate': rate,
+ }))
+
obj.write(vals)
return {
@@ -107,7 +141,7 @@ class CycleItem(Model):
#qty=line.get("qty")
#rate=line.get("rate")
total=0.0
- for line in data['lines']:
+ for line in data['nurse_lines']:
line['amount']=(line['qty'] or 0) * (line['rate'] or 0.0)
total+=line['amount']
print(line)
@@ -132,16 +166,27 @@ class CycleItem(Model):
'related_id': "clinic.cycle.item,%s"%obj.id,
'direct_lines': [],
}
- for line in obj.lines:
+ for line in obj.nurse_lines:
if not line.amount:
continue
vals['direct_lines'].append(('create',{
- 'description': 'Payment; %s'%line.nurse_categ.name,
+ 'description': 'Payment; %s'%line.personal_categ.name,
'account_id': account_id,
'qty': 1,
'unit_price': line.amount,
'amount': line.amount,
}))
+ for line in obj.doctor_lines:
+ if not line.amount:
+ continue
+ vals['direct_lines'].append(('create',{
+ 'description': 'Payment; %s'%line.description,
+ 'account_id': account_id,
+ 'qty': line.qty,
+ 'unit_price': line.amount,
+ 'amount': line.amount,
+ }))
+
payment_id=get_model("account.payment").create(vals,context={"type":"in"})
get_model("account.payment").browse(payment_id).post()
obj.write({
diff --git a/netforce_clinic/models/cycle_item_line.py b/netforce_clinic/models/cycle_item_line.py
index 3069675..e53a4e2 100644
--- a/netforce_clinic/models/cycle_item_line.py
+++ b/netforce_clinic/models/cycle_item_line.py
@@ -15,8 +15,10 @@ class CycleItemLine(Model):
_fields={
'cycle_item_id': fields.Many2One("clinic.cycle.item", "Cycle Item"),
- 'nurse_categ': fields.Many2One("clinic.nurse.categ", "Nurse Category"),
+ "type": fields.Selection([("doctor","Doctor"),("nurse","Nurse")],"Personal Type",required=True),
+ 'personal_categ': fields.Many2One("clinic.personal.categ", "Nurse Category",),
'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),
diff --git a/netforce_clinic/models/doctor.py b/netforce_clinic/models/doctor.py
index d213761..3b1a488 100644
--- a/netforce_clinic/models/doctor.py
+++ b/netforce_clinic/models/doctor.py
@@ -44,6 +44,7 @@ class Doctor(Model):
"user_id": fields.Many2One("base.user","User"),
'picture': fields.File("Picture"),
'note': fields.Text("Note"),
+ 'categ_id': fields.Many2One("clinic.personal.categ", "Doctor Category", domain=[['type','=','doctor']]),
}
diff --git a/netforce_clinic/models/nurse.py b/netforce_clinic/models/nurse.py
index 11f421e..63fcd8e 100644
--- a/netforce_clinic/models/nurse.py
+++ b/netforce_clinic/models/nurse.py
@@ -44,7 +44,7 @@ class Nurse(Model):
"user_id": fields.Many2One("base.user","User"),
'picture': fields.File("Picture"),
'note': fields.Text("Note"),
- 'categ_id': fields.Many2One("clinic.nurse.categ","Category"),
+ 'categ_id': fields.Many2One("clinic.personal.categ", "Nurse Category", domain=[['type','=','nurse']]),
}
def _get_number(self,context={}):
diff --git a/netforce_clinic/models/nurse_categ.py b/netforce_clinic/models/nurse_categ.py
deleted file mode 100644
index dd60d3e..0000000
--- a/netforce_clinic/models/nurse_categ.py
+++ /dev/null
@@ -1,22 +0,0 @@
-from netforce.model import Model, fields
-from netforce.access import get_active_company
-
-class NurseCateg(Model):
- _name="clinic.nurse.categ"
- _string="Nurse Categ"
-
- _fields={
- "name": fields.Char("Name",required=True,search=True),
- "code": fields.Char("Code",required=True,search=True),
- 'formular': fields.Text("Formular"),
- 'sequence': fields.Integer("Sequence"),
- }
-
- _defaults={
- "company_id": lambda *a: get_active_company(),
- 'sequence': 0,
- }
-
- _order="sequence"
-
-NurseCateg.register()
diff --git a/netforce_clinic/models/personal_categ.py b/netforce_clinic/models/personal_categ.py
new file mode 100644
index 0000000..cc65ad5
--- /dev/null
+++ b/netforce_clinic/models/personal_categ.py
@@ -0,0 +1,43 @@
+from netforce.model import Model, fields
+from netforce.access import get_active_company
+
+class NurseCateg(Model):
+ _name="clinic.personal.categ"
+ _string="Personal Category"
+
+ _fields={
+ "name": fields.Char("Name",required=True,search=True),
+ "code": fields.Char("Code",required=True,search=True),
+ 'formular': fields.Text("Formular"),
+ 'sequence': fields.Integer("Sequence"),
+ "type": fields.Selection([("doctor","Doctor"),("nurse","Nurse")],"Personal Type",required=True),
+ }
+
+ _defaults={
+ "company_id": lambda *a: get_active_company(),
+ 'sequence': 0,
+ 'type': 'doctor',
+ }
+
+ _order="sequence"
+
+ def name_get(self,ids,context={}):
+ vals=[]
+ for obj in self.browse(ids):
+ name="%s [%s]"%(obj.name,obj.code or "")
+ vals.append((obj.id,name))
+ return vals
+
+ def name_search(self,name,domain=None,context={},**kw):
+ dom=[["name","ilike","%"+name+"%"]]
+ if domain:
+ dom=[dom,domain]
+ ids1=self.search(dom)
+ dom=[["code","ilike","%"+name+"%"]]
+ if domain:
+ dom=[dom,domain]
+ ids2=self.search(dom)
+ ids=list(set(ids1+ids2))
+ return self.name_get(ids,context=context)
+
+NurseCateg.register()