diff --git a/netforce_clinic/actions/clinic_matching_payment.xml b/netforce_clinic/actions/clinic_matching_payment.xml
new file mode 100644
index 0000000..be54106
--- /dev/null
+++ b/netforce_clinic/actions/clinic_matching_payment.xml
@@ -0,0 +1,8 @@
+
+ clinic_matching_payment
+ form_view
+ clinic.matching.payment
+ clinic_matching_payment
+ account_menu
+
+
diff --git a/netforce_clinic/layouts/clinic_cycle_item_form.xml b/netforce_clinic/layouts/clinic_cycle_item_form.xml
index 2debbd9..a55db67 100644
--- a/netforce_clinic/layouts/clinic_cycle_item_form.xml
+++ b/netforce_clinic/layouts/clinic_cycle_item_form.xml
@@ -10,6 +10,7 @@
+
diff --git a/netforce_clinic/layouts/clinic_cycle_item_list.xml b/netforce_clinic/layouts/clinic_cycle_item_list.xml
index b0f1dda..9113bf8 100644
--- a/netforce_clinic/layouts/clinic_cycle_item_list.xml
+++ b/netforce_clinic/layouts/clinic_cycle_item_list.xml
@@ -1,6 +1,7 @@
+
diff --git a/netforce_clinic/layouts/clinic_matching_payment.xml b/netforce_clinic/layouts/clinic_matching_payment.xml
new file mode 100644
index 0000000..e075596
--- /dev/null
+++ b/netforce_clinic/layouts/clinic_matching_payment.xml
@@ -0,0 +1,15 @@
+
diff --git a/netforce_clinic/layouts/clinic_menu_inherit.xml b/netforce_clinic/layouts/clinic_menu_inherit.xml
index 7029e07..7284dd1 100644
--- a/netforce_clinic/layouts/clinic_menu_inherit.xml
+++ b/netforce_clinic/layouts/clinic_menu_inherit.xml
@@ -4,7 +4,8 @@
-
+
+
diff --git a/netforce_clinic/layouts/clinic_report_payment_matching.xml b/netforce_clinic/layouts/clinic_report_payment_matching.xml
index 588a06b..8880196 100644
--- a/netforce_clinic/layouts/clinic_report_payment_matching.xml
+++ b/netforce_clinic/layouts/clinic_report_payment_matching.xml
@@ -2,10 +2,11 @@
-
-
-
-
-
+
+
+
+
+
+
diff --git a/netforce_clinic/layouts/clinic_setting.xml b/netforce_clinic/layouts/clinic_setting.xml
index ed436a5..10668c0 100644
--- a/netforce_clinic/layouts/clinic_setting.xml
+++ b/netforce_clinic/layouts/clinic_setting.xml
@@ -25,7 +25,8 @@
-
+
+
diff --git a/netforce_clinic/layouts/clinic_sickbed_form.xml b/netforce_clinic/layouts/clinic_sickbed_form.xml
index 2633130..7a96c56 100644
--- a/netforce_clinic/layouts/clinic_sickbed_form.xml
+++ b/netforce_clinic/layouts/clinic_sickbed_form.xml
@@ -8,8 +8,9 @@
-
+
+
diff --git a/netforce_clinic/layouts/clinic_sickbed_list.xml b/netforce_clinic/layouts/clinic_sickbed_list.xml
index 58f968d..e8d9c05 100644
--- a/netforce_clinic/layouts/clinic_sickbed_list.xml
+++ b/netforce_clinic/layouts/clinic_sickbed_list.xml
@@ -3,6 +3,7 @@
+
diff --git a/netforce_clinic/models/__init__.py b/netforce_clinic/models/__init__.py
index db1214a..c34efbb 100644
--- a/netforce_clinic/models/__init__.py
+++ b/netforce_clinic/models/__init__.py
@@ -89,3 +89,4 @@ from . import product_categ
from . import import_uc
from . import make_apt
from . import make_apt_line
+from . import matching_payment
diff --git a/netforce_clinic/models/cycle_item.py b/netforce_clinic/models/cycle_item.py
index cee01ae..d27e2b0 100644
--- a/netforce_clinic/models/cycle_item.py
+++ b/netforce_clinic/models/cycle_item.py
@@ -39,6 +39,7 @@ class CycleItem(Model):
"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"),
}
def _get_vark(self,context={}):
@@ -50,6 +51,11 @@ class CycleItem(Model):
if b_ids:
return b_ids[0]
+ def _get_department(self,context={}):
+ dpt_ids=get_model('clinic.department').search([])
+ if dpt_ids:
+ return dpt_ids[0]
+
_defaults={
'state': 'draft',
'company_id': lambda *a: get_active_company(),
@@ -57,11 +63,12 @@ class CycleItem(Model):
'user_id': lambda *a: get_active_user(),
'var_k': _get_vark,
'branch_id': _get_branch,
+ 'department_id': _get_department,
}
_order="date desc"
_sql_constraints=[
- ("cycle_item_uniq","unique (cycle_id,date,company_id,branch_id)","Cycle item should be unique"),
+ ("cycle_item_uniq","unique (cycle_id,date,company_id,branch_id,department_id)","Cycle item should be unique"),
]
def get_cycle_daily(self,date):
diff --git a/netforce_clinic/models/hd_case.py b/netforce_clinic/models/hd_case.py
index 69bff08..66f43fc 100644
--- a/netforce_clinic/models/hd_case.py
+++ b/netforce_clinic/models/hd_case.py
@@ -507,6 +507,7 @@ class HDCase(Model):
pick_vals={
"type": "out",
+ 'journal_id': stock_journal.id,
"ref": obj.number,
"related_id": "clinic.hd.case,%s"%obj.id,
"partner_id": obj.patient_id.partner_id.id,
diff --git a/netforce_clinic/models/matching_payment.py b/netforce_clinic/models/matching_payment.py
new file mode 100644
index 0000000..d8a5c9c
--- /dev/null
+++ b/netforce_clinic/models/matching_payment.py
@@ -0,0 +1,45 @@
+from netforce.model import Model, fields, get_model
+
+class MatchingPayment(Model):
+ _name="clinic.matching.payment"
+ _transient=True
+
+ _fields={
+ 'file': fields.File("File"),
+ 'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type",required=True),
+ 'hcode_id': fields.Many2One("clinic.hospital","HCode",required=True),
+ 'expenes': fields.Many2Many("clinic.hd.case.expense","Expenses"),
+ }
+
+ def _get_ptype(self,context={}):
+ tids=get_model('clinic.patient.type').search([['default','=',True]])
+ tid=None
+ if tids:
+ tid=tids[0]
+ return tid
+
+ _defaults={
+ 'patient_type_id': _get_ptype,
+ }
+
+ def match(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ for exp in obj.expenes:
+ exp.delete()
+ exp_ids=[]
+ for exp in get_model('clinic.hd.case.expense').search_browse([]):
+ exp_ids.append(exp.id)
+ #TODO Checking
+ obj.write({
+ 'expenes': [('add',exp_ids)]
+ })
+ return {
+ 'next': {
+ 'name': 'clinic_matching_payment',
+ 'mode': 'form',
+ 'active_id': obj.id,
+ },
+ 'flash': 'Succesfully',
+ }
+
+MatchingPayment.register()
diff --git a/netforce_clinic/models/schedule.py b/netforce_clinic/models/schedule.py
index 722990c..16511c0 100644
--- a/netforce_clinic/models/schedule.py
+++ b/netforce_clinic/models/schedule.py
@@ -45,6 +45,7 @@ class Schedule(Model):
'lines': fields.One2Many("clinic.schedule.line","schedule_id","Lines"),
'company_id': fields.Many2One("company","Company"),
'branch_id': fields.Many2One("clinic.branch","Branch",required=True, search=True),
+ 'department_id': fields.Many2One("clinic.department","Department",required=True, search=True),
'state': fields.Selection([['draft','Draft'],['confirmed', 'Confirmed']],'State',search=True),
'user_id': fields.Many2One("base.user","Confirm By"),
}
@@ -71,7 +72,7 @@ class Schedule(Model):
_order="date desc"
_sql_constraints=[
- ('schedule_uniq','unique (date,company_id,branch_id)','Date should be unique'),
+ ('schedule_uniq','unique (date,company_id,branch_id,department_id)','Date should be unique'),
]
def confirm(self,ids,context={}):
@@ -132,13 +133,21 @@ class Schedule(Model):
def copy2cycle_item(self,ids,context={}):
obj=self.browse(ids)[0]
+ branch=obj.branch_id
+ department=obj.department_id
date=obj.date
items={}
cycles=set()
for line in obj.lines:
nurse=line.nurse_id
cycle=line.cycle_id
- item_objs=get_model("clinic.cycle.item").search_browse([['date','=',date],['cycle_id','=',cycle.id]])
+ dom=[
+ ['date','=',date],
+ ['cycle_id','=',cycle.id],
+ ['branch_id','=',branch.id],
+ ['department_id','=',department.id],
+ ]
+ item_objs=get_model("clinic.cycle.item").search_browse(dom)
if item_objs:
item=item_objs[0]
if item.state!='draft':
@@ -157,6 +166,8 @@ class Schedule(Model):
item_id=get_model("clinic.cycle.item").create({
'cycle_id': cycle.id,
'date': date,
+ 'branch_id': branch.id,
+ 'department_id': department.id,
})
items[item_id]=[]
items[item_id].append(('create',{
diff --git a/netforce_clinic/models/setting.py b/netforce_clinic/models/setting.py
index 6bb6c33..38561e7 100644
--- a/netforce_clinic/models/setting.py
+++ b/netforce_clinic/models/setting.py
@@ -25,6 +25,8 @@ class ClinicSetting(Model):
'auto_gen': fields.Boolean("Auto Gen"), # HD Case
'schd_from': fields.Date("From"),
'schd_to': fields.Date("To"),
+ 'department_id': fields.Many2One("clinic.department","Department"),
+ 'branch_id': fields.Many2One("clinic.branch","Branch"),
}
_defaults={
@@ -89,34 +91,18 @@ class ClinicSetting(Model):
return True
def run_script(self,ids,context={}):
- dts={}
- for pt in get_model('clinic.patient').search_browse([]):
- doctor=pt.doctor_id
- if not dts.get(doctor.id):
- dts[doctor.id]=[]
- dts[doctor.id].append(pt.id)
- x=0
- y=0
- c=1
- for doctor_id, pt_ids in dts.items():
- st=set()
- b_ids=[pt.branch_id.id for pt in get_model('clinic.patient').browse(pt_ids)]
- for b_id in b_ids:
- st.update({b_id})
- if len(st)>1:
- if doctor_id:
- doctor=get_model('clinic.staff').browse(doctor_id)
- doctor.write({
- 'branch_id': 5,
- })
- print('%s %s'%(doctor_id, st))
- # update doctor to ratchawat branch
- x+=1
- else:
- y+=1
- c+=1
- print("RD ", x)
- print("Other", y)
+ 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,
+ })
+ # create new cycle item
+ print("Done!")
def reset_last_import(self,ids,context={}):
res=get_model("clinic.report.payment.matching").search_read([],['date'],order="date desc")
diff --git a/netforce_clinic/models/sickbed.py b/netforce_clinic/models/sickbed.py
index 6dedf44..57ff2d3 100644
--- a/netforce_clinic/models/sickbed.py
+++ b/netforce_clinic/models/sickbed.py
@@ -37,6 +37,7 @@ class SickBed(Model):
'sequence': fields.Integer("Sequence"),
'note': fields.Text("Note"),
'branch_id': fields.Many2One("clinic.branch","Branch",required=True, search=True),
+ 'department_id': fields.Many2One("clinic.department","Department",required=True, search=True),
}
def _get_branch(self,context={}):
diff --git a/netforce_clinic/models/visit.py b/netforce_clinic/models/visit.py
index 0fda6ff..a63da40 100644
--- a/netforce_clinic/models/visit.py
+++ b/netforce_clinic/models/visit.py
@@ -201,6 +201,7 @@ class Visit(Model):
date=vals['time_start'][0:10]
cycle=obj.cycle_id
branch=obj.branch_id
+ department=obj.department_id
dom=[]
if date:
dom.append(['date','=',date])
@@ -208,6 +209,9 @@ class Visit(Model):
dom.append(['cycle_id','=',cycle.id])
if branch:
dom.append(['branch_id','=',branch.id])
+ if department:
+ dom.append(['department_id','=',department.id])
+
item_obj=get_model('clinic.cycle.item')
item_ids=item_obj.search(dom)
@@ -223,6 +227,7 @@ class Visit(Model):
item_vals={
'cycle_id': cycle.id,
'branch_id': branch.id,
+ 'department_id': department.id,
'date': date,
'nurses': [],
}
@@ -235,10 +240,11 @@ class Visit(Model):
item_id=item_ids[0]
item=item_obj.browse(item_id)
if item.state!='draft':
+ # reset nurse
for nurse in item.nurses:
nurse.delete()
- # get nurse from schedule
+ # copy nurse from schedule
item=item_obj.browse(item_id)
if item.state!='draft':
schedule=get_schedule(date)
diff --git a/netforce_clinic/models/visit_board.py b/netforce_clinic/models/visit_board.py
index 212c163..96ce4c7 100644
--- a/netforce_clinic/models/visit_board.py
+++ b/netforce_clinic/models/visit_board.py
@@ -77,6 +77,10 @@ class VisitBoard(Model):
'visit_id': None,
'cycle_name': '',
'cycle_color': '',
+ 'department_id': None,
+ 'department_name': None,
+ 'branch_id': None,
+ 'branch_name': None,
'patient_id': None,
'patient_name': '',
'patient_type': '',
@@ -139,6 +143,11 @@ class VisitBoard(Model):
number='*รอการยืนยัน'
cycle=visit.cycle_id
patient=visit.patient_id
+ branch=visit.branch_id
+ department=visit.department_id
+ if not branch:
+ branch=department.branch_id
+
hn_name=patient.hn_no or '-'
visit_date=visit.visit_date
@@ -156,6 +165,10 @@ class VisitBoard(Model):
'sickbed_id': sickbed_id,
'cycle_name': cycle.name,
'cycle_color': cycle.color,
+ 'department_id': department.id,
+ 'department_name': department.name or '',
+ 'branch_id': branch.id,
+ 'branch_name': branch.name or '',
'patient_name': patient.name,
'patient_id': patient.id,
'patient_type': patient.type_id.name or "",
@@ -211,9 +224,9 @@ class VisitBoard(Model):
index+=1
# footer
line=empty_line.copy()
- patient_str='>> %s'%', '.join('%s: %s'%(patient_types[k],v) for k,v in types[date].items())
- cycle_str='>> %s'%', '.join('%s: %s'%(cycle_names[k],v) for k,v in cycles[date].items())
- summary_str='>> %s'%', '.join(['รับไว้: %s'%total_wait,'จำหน่ายแล้ว: %s'%total_done, 'ยกเลิก: %s'%total_cancel])
+ patient_str='%s'%', '.join('%s: %s'%(patient_types[k],v) for k,v in types[date].items())
+ cycle_str='%s'%', '.join('%s: %s'%(cycle_names[k],v) for k,v in cycles[date].items())
+ summary_str='%s'%', '.join(['รับไว้: %s'%total_wait,'จำหน่ายแล้ว: %s'%total_done, 'ยกเลิก: %s'%total_cancel])
line['details']='ทั้งหมด %s: %s'%(total_qty,', '.join([summary_str,cycle_str,patient_str]))
line['details1']=summary_str
line['details2']=cycle_str
diff --git a/netforce_clinic/templates/visit_board.hbs b/netforce_clinic/templates/visit_board.hbs
index 0ee354e..74efa42 100644
--- a/netforce_clinic/templates/visit_board.hbs
+++ b/netforce_clinic/templates/visit_board.hbs
@@ -20,8 +20,12 @@
ใบนัดแพทย์ |
HN |
ผู้ป่วย |
+
สิทธ์ |
แพทย์ |
+ ชั้น |
เตียง |
บันทึกการรักษา |
หมายเหตุ |
@@ -30,7 +34,7 @@
{{#each lines }}
{{#if footer}}
- TOTAL |
+ สรุป |
{{details1}} |
@@ -50,8 +54,12 @@
{{number}} |
{{hn_name}} |
{{patient_name}} |
+
{{patient_type}} |
{{doctor_name}} |
+ {{department_name}} |
{{#if sickbed_id}}
{{sickbed_name}} |
{{else}}
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index 13eb149..dfcf121 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -1,7 +1,20 @@
todo:
+ - filter data
+ 1. company
+ 2. branch
+ 3. department
+ - cycle item
+ - sickedbed
+ - patient
+ - staff
+ - script
+ - after split department
+ - cycle item should be see only that department
+
- accounting
- doctor detail
- - import
+ - import match hn
+
- visit summary -> ok
- calendar
- search calendar