multi dpt
parent
df6c188c32
commit
e177f2744f
|
@ -0,0 +1,8 @@
|
|||
<record model="action">
|
||||
<field name="name">clinic_matching_payment</field>
|
||||
<field name="view">form_view</field>
|
||||
<field name="model">clinic.matching.payment</field>
|
||||
<field name="view_xml">clinic_matching_payment</field>
|
||||
<field name="menu">account_menu</field>
|
||||
</record>
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
<group from_layout="stacked">
|
||||
<field name="cycle_id" span="3" required="1"/>
|
||||
<field name="date" span="3" required="1"/>
|
||||
<field name="department_id" span="3" required="1"/>
|
||||
<field name="branch_id" span="3" required="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
</group>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<list model="clinic.cycle.item" colors='{"#9f9":[["state","=","validated"]]}'>
|
||||
<field name="cycle_id"/>
|
||||
<field name="date"/>
|
||||
<field name="department_id"/>
|
||||
<field name="branch_id"/>
|
||||
<field name="state"/>
|
||||
</list>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<form model="clinic.matching.payment" title="Matching Payment">
|
||||
<separator string="1. Click Match > 2. Review Items > 3. Import Payment"/>
|
||||
<group form_layout="stacked">
|
||||
<field name="file" span="3"/>
|
||||
<field name="patient_type_id" span="3"/>
|
||||
<field name="hcode_id" span="3"/>
|
||||
</group>
|
||||
<foot replace="1">
|
||||
<button string="Match" method="match" icon="ok" type="success"/>
|
||||
<button string="Import Payment" method="pay" icon="arrow-right" type="default"/>
|
||||
</foot>
|
||||
<related>
|
||||
<field name="expenes"/>
|
||||
</related>
|
||||
</form>
|
|
@ -4,7 +4,8 @@
|
|||
<item string="Labor Cost" action="clinic_labor_cost"/>
|
||||
<item string="Labor Cost Items" action="clinic_labor_cost_item"/>
|
||||
<item string="Labor Cost Entries" action="clinic_labor_cost_entry"/>
|
||||
<item string="Matching Invoices" action="clinic_report_payment_matching"/>
|
||||
<!--<item string="Matching Invoices" action="clinic_report_payment_matching"/>-->
|
||||
<item string="Matching Payment" action="clinic_matching_payment"/>
|
||||
<item string="HD Case Expenses" action="clinic_hd_case_expense"/>
|
||||
<divider/>
|
||||
<header string="REPORTS"/>
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
<field name="file" span="4" required="1"/>
|
||||
<field name="type_id" onchange="onchange_type" span="3"/>
|
||||
<field name="hcode_id" span="3" attrs='{"invisible":[["show_hcode","=",0]]}'/>
|
||||
<newline/>
|
||||
<group span="6" columns="1">
|
||||
<button string='Match' span="2" type="success" size="small" icon="ok" method="match_invoice"/>
|
||||
<button string='Make A Payment' method="make_payment" span="2" type="default" size="small" icon="arrow-right"/>
|
||||
</group>
|
||||
<field name="show_hcode" invisible="1" span="3"/>
|
||||
<group span="6" columns="1">
|
||||
<button string='Match' type="success" icon="ok" method="match_invoice"/>
|
||||
<button string='Make A Payment' method="make_payment" type="default" icon="arrow-right"/>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
</group>
|
||||
</form>
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
</field>
|
||||
</group>
|
||||
</tab>
|
||||
<tab string="Testing">
|
||||
<tab string="Development">
|
||||
<!--<field name='branch_id'/>-->
|
||||
<button string="Click Me" type="default" method="run_script" perm="clinic_setting_test"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
<field name="name"/>
|
||||
<field name="available"/>
|
||||
<field name="sequence"/>
|
||||
<field name="branch_id" invisible="1"/>
|
||||
<field name="department_id"/>
|
||||
<field name="note"/>
|
||||
<field name="branch_id" invisible="1"/>
|
||||
<field name="company_id" invisible="1"/>
|
||||
<related>
|
||||
<field name="hd_cases"/>
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<field name="date"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="image" preview="1"/>
|
||||
<field name="department_id"/>
|
||||
<field name="branch_id"/>
|
||||
<field name="note"/>
|
||||
<field name="state"/>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
|
@ -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',{
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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={}):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -20,8 +20,12 @@
|
|||
<th>ใบนัดแพทย์</th>
|
||||
<th>HN</th>
|
||||
<th>ผู้ป่วย</th>
|
||||
<!--
|
||||
<th>สาขา</th>
|
||||
-->
|
||||
<th>สิทธ์</th>
|
||||
<th>แพทย์</th>
|
||||
<th>ชั้น</th>
|
||||
<th>เตียง</th>
|
||||
<th>บันทึกการรักษา</th>
|
||||
<th>หมายเหตุ</th>
|
||||
|
@ -30,7 +34,7 @@
|
|||
{{#each lines }}
|
||||
{{#if footer}}
|
||||
<tr>
|
||||
<td rowspan="3" align="middle" style="vertical-align:middle; background-color:#4183c4;color:white"><span><b>TOTAL</b></span></td>
|
||||
<td rowspan="3" align="middle" style="vertical-align:middle; background-color:#4183c4;color:white"><span><b>สรุป</b></span></td>
|
||||
<td colspan="10" style="text-align:right; background-color:#dbdbdb"><b>{{details1}}</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -50,8 +54,12 @@
|
|||
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_visit&active_id={{visit_id}}&mode=form">{{number}}</a></td>
|
||||
<td style="background-color:{{visit_color}}">{{hn_name}}</td>
|
||||
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_patient&active_id={{patient_id}}&mode=form">{{patient_name}}</a></td>
|
||||
<!--
|
||||
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_branch&active_id={{branch_id}}&mode=form">{{branch_name}}</a></td>
|
||||
-->
|
||||
<td style="background-color:{{visit_color}}">{{patient_type}}</td>
|
||||
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_staff&active_id={{doctor_id}}&mode=form">{{doctor_name}}</a></td>
|
||||
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_department&active_id={{department_id}}&mode=form">{{department_name}}</a></td>
|
||||
{{#if sickbed_id}}
|
||||
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_sickbed&active_id={{sickbed_id}}&mode=form">{{sickbed_name}}</a></td>
|
||||
{{else}}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue