visit board

conv_bal
watcha.h@almacom.co.th 2014-12-20 16:48:29 +07:00
parent 97cea74246
commit fd6fe56294
8 changed files with 97 additions and 30 deletions

View File

@ -1,7 +1,7 @@
<board>
<hpanel>
<widget action="clinic_visit_widget" string="Current Visit" span="12"/>
<widget action="clinic_recent_patient_widget" string="Recent Patient"/>
<widget action="clinic_cycle_widget" string="Average Cycle"/>
<!--<widget action="clinic_recent_patient_widget" string="Recent Patient"/>-->
<!--<widget action="clinic_cycle_widget" string="Average Cycle"/>-->
</hpanel>
</board>

View File

@ -36,7 +36,7 @@
<item string="Visits">
<item string="Visits" action="clinic_visit"/>
<item string="Visit Board" action="clinic_visit_board"/>
<item string="Generate Visit" action="clinic_gen_visit_form"/>
<!--<item string="Generate Visit" action="clinic_gen_visit_form"/>-->
</item>
<item string="HD Cases">
<item string="HD Cases" action="clinic_hd_case"/>

View File

@ -3,4 +3,10 @@
<field name="date_from" span="2"/>
<field name="date_to" span="2"/>
<field name="patient_id" span="2"/>
<group span="2" columns="1">
<button string="Make an appointment" method="make_visit" span="2" icon="calendar" type="success" size="small"/>
</group>
<group span="2" columns="1">
<button string="Visit Planning" action="clinic_gen_visit_form" span="2" icon="arrow-right" type="default" size="small"/>
</group>
</form>

View File

@ -13,8 +13,9 @@
<group span="6" columns="1">
<field name="number"/>
<field name="time_start" onchange="onchange_datefrom"/>
<field name="department_id"/>
<field name="cycle_id" onchange="onchange_cycle" required="1"/>
<field name="sickbed_id" domain="[['available','=',true]]" attrs='{"required":[["state","=","pending"]]}'/>
<field name="department_id"/>
</group>
<group span="6" columns="1">
<field name="patient_id" onchange="onchange_patient"/>

View File

@ -28,6 +28,7 @@ class Visit(Model):
_fields={
"number": fields.Char("Number",required=True,search=True),
'sickbed_id': fields.Many2One("clinic.sickbed","Sickbed"),
"time_start": fields.DateTime("Start Time",required=True),
"time_stop": fields.DateTime("End Time",required=True),
"patient_id": fields.Many2One("clinic.patient","Patient",required=True,search=True),
@ -159,6 +160,7 @@ class Visit(Model):
'patient_id': obj.patient_id.id,
'nurse_id': obj.nurse_id.id,
'department_id': obj.department_id.id,
'sickbed_id': obj.sickbed_id.id,
'time_start': obj.time_start,
'time_stop': obj.time_stop,
'cycle_id' : obj.cycle_id.id,

View File

@ -8,7 +8,17 @@ from netforce.access import get_active_company
from . import utils
DRT=5
DRT=0
HD_STATE={
"draft":"Draft",
'waiting_treatment':'Waiting Treatment',
"in_progress":"In Progress",
"completed":"Finish Treatment",
'paid':'Paid',
"waiting_payment":"Waiting Payment",
"discountinued":"Discountinued",
"cancelled":"Cancelled"
}
class VisitBoard(Model):
_name="clinic.visit.board"
@ -60,6 +70,7 @@ class VisitBoard(Model):
'patient_id': None,
'patient_name': '',
'patient_type': '',
'patient_type_id': None,
'doctor_name': '',
'doctor_id': None,
'hd_case_number': '',
@ -67,7 +78,9 @@ class VisitBoard(Model):
'success_color': '',
'date':'',
'title': True,
'footer': False,
'details':'',
'hd_case_state': '',
}
patient_types={t['id']:t['name'] for t in get_model("clinic.patient.type").search_read([[]],['name'])}
@ -76,29 +89,38 @@ class VisitBoard(Model):
for visit in get_model("clinic.visit").search_browse(dom):
hd_case_id=None
hd_case_number=''
hd_case_state=''
visit_color=''
if visit.hd_cases:
hd_case=visit.hd_cases[0]
hd_case_id=hd_case.id,
hd_case_number=hd_case.number,
if hd_case.number=='/':
hd_case_number='*รอการรรักษา'
else:
hd_case_number=hd_case.number
hd_case_state=hd_case.state
if hd_case_state=='completed':
visit_color='#99ff99'
number=visit.number
if number=='/':
number='รอการรรักษา'
number='*รอการยืนยัน'
cycle=visit.cycle_id
patient=visit.patient_id
visit_date=visit.visit_date
visit_color=''
if visit.state=='confirmed':
visit_color='#99ff99'
elif visit.state=='cancelled':
visit_color='#D84B4B',
#if visit.state=='confirmed':
#visit_color='#99ff99'
#elif visit.state=='cancelled':
#visit_color='#D84B4B',
line={
'number': number,
'visit_id': visit.id,
'sickbed_name': visit.sickbed_id.name or "",
'cycle_name': cycle.name,
'cycle_color': cycle.color,
'patient_name': patient.name,
'patient_id': patient.id,
'patient_type': patient.type_id.name or "",
'patient_type_id': patient.type_id.id or None,
'doctor_name': visit.doctor_id.name,
'doctor_id': visit.doctor_id.id,
'hd_case_number': hd_case_number,
@ -106,8 +128,11 @@ class VisitBoard(Model):
'visit_color': visit_color,
'date': visit_date,
'title': False,
'footer': False,
'details':'',
'no': no,
'note': visit.note,
'hd_case_state':HD_STATE.get(hd_case_state,''),
}
lines.append(line)
no+=1
@ -119,17 +144,30 @@ class VisitBoard(Model):
dates=[]
index=0
total_qty=0
count=0
for line in lines:
date=line['date']
if not date:
continue
if date not in dates:
line=empty_line.copy()
count=0
total_qty=0
line=empty_line.copy()
for qty in types[date].values():
total_qty+=qty
line['cycle_name']=utils.date2thai(date,format='%(Td)s %(d)s %(Tm)s',lang="th_TH2"),
line['details']='รวม %s: %s'%(total_qty,', '.join('%s %s'%(patient_types[k],v) for k,v in types[date].items()))
lines.insert(index,line)
dates.append(date)
if count==total_qty:
index+=1
# footer
line=empty_line.copy()
line['details']='รวม %s: %s'%(total_qty,', '.join('%s %s'%(patient_types[k],v) for k,v in types[date].items()))
line['footer']=True
line['title']=False
lines.insert(index,line)
count+=1
index+=1
has_duration=False
@ -155,5 +193,13 @@ class VisitBoard(Model):
data['date_from']="%s-%s-01"%(year,month)
data['date_to']="%s-%s-%s"%(year,month,total_day)
return data
def make_visit(self,ids,context={}):
return {
'next': {
'name': 'clinic_visit',
'mode': 'form',
}
}
VisitBoard.register()

View File

@ -1,4 +1,5 @@
<center>
<!--
<h2>ตารางเวร</h2>
<h3>
{{parent_company_name}}&nbsp;{{company_name}}<br/>
@ -10,6 +11,7 @@
{{date}}
{{/if}}
</h4>
-->
</center>
<table class="table table-condensed table-striped">
<thead>

View File

@ -1,4 +1,5 @@
<center>
<!--
<h2>ตารางนัดผู้ป่วย</h2>
<h3>
{{parent_company_name}}&nbsp;{{company_name}}<br/>
@ -10,6 +11,7 @@
{{date}}
{{/if}}
</h4>
-->
</center>
<table class="table table-condensed table-striped">
<thead>
@ -19,26 +21,34 @@
<th>ผู้ป่วย</th>
<th>สิทธ์</th>
<th>แพทย์</th>
<th>HD Case</th>
<th>เตียง</th>
<th>บันทึกการรักษา</th>
<th>หมายเหตุ</th>
</thead>
<tbody>
{{#each lines }}
<tr style="background-color:{{visit_color}}">
{{#if title}}
<td style="background-color:#ddddff"><b>{{cycle_name}}</b></td>
<td colspan="8" style="text-align:right; background-color:#ddddff"><b>{{details}}</b></td>
{{else}}
<td style="background-color:{{cycle_color}}">{{cycle_name}}</td>
<td style="background-color:{{visit_color}}">{{no}}</td>
<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}}"><a href="/ui#name=clinic_patient&active_id={{patient_id}}&mode=form">{{patient_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_hd_case&active_id={{hd_case_id}}&mode=form">{{hd_case_number}}</a></td>
<td style="background-color:{{visit_color}}">{{note}}</td>
{{/if}}
</tr>
{{#if footer}}
<tr>
<td colspan="9" style="text-align:right; background-color:#b9b9b7"><b>{{details}}</b></td>
</tr>
{{else}}
<tr style="background-color:{{visit_color}}">
{{#if title}}
<td style="background-color:#ddddff"><b>{{cycle_name}}</b></td>
<td style="background-color:#ddddff" colspan="9"></td>
{{else}}
<td style="background-color:{{cycle_color}}">{{cycle_name}}</td>
<td style="background-color:{{visit_color}}">{{no}}</td>
<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}}"><a href="/ui#name=clinic_patient&active_id={{patient_id}}&mode=form">{{patient_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}}">{{sickbed_name}}</td>
<td style="background-color:{{visit_color}}"><a href="/ui#name=clinic_hd_case&active_id={{hd_case_id}}&mode=form">{{hd_case_number}}</a></td>
<td style="background-color:{{visit_color}}">{{note}}</td>
{{/if}}
</tr>
{{/if}}
{{/each}}
</tbody>
<tfoot>