report visit
parent
14885e638e
commit
a7faddcfcd
|
@ -0,0 +1,8 @@
|
|||
<action>
|
||||
<field name="string">Report Visit</field>
|
||||
<field name="view_cls">report</field>
|
||||
<field name="model">clinic.report.visit</field>
|
||||
<field name="report_template">report_visit</field>
|
||||
<field name="report_template_xls">report_visit</field>
|
||||
<field name="menu">clinic_menu</field>
|
||||
</action>
|
|
@ -49,6 +49,7 @@
|
|||
<item string="Valcular Access" action="clinic_vascular_access"/>
|
||||
</item>
|
||||
<item string="Reports" perm="clinic_report">
|
||||
<item string="Visit Summary" action="clinic_report_visit"/>
|
||||
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
|
||||
<item string="Medical Summary" action="clinic_report_medical_summary"/>
|
||||
<item string="Recent Patient" action="clinic_report_recent_patient"/>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<form model="clinic.report.visit">
|
||||
<field name="date" span="2" mode="month" onchange="onchange_date"/>
|
||||
<field name="date_from" span="2"/>
|
||||
<field name="date_to" span="2"/>
|
||||
<field name="patient_id" span="2"/>
|
||||
<field name="doctor_id" span="2"/>
|
||||
</form>
|
|
@ -59,6 +59,7 @@ from . import schedule_copy
|
|||
from . import load_nurse
|
||||
from . import load_nurse_line
|
||||
from . import report_clinic
|
||||
from . import report_visit
|
||||
from . import report_hd_case_summary
|
||||
from . import report_medical_summary
|
||||
from . import report_recent_patient
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
import time
|
||||
from calendar import monthrange
|
||||
|
||||
from netforce.model import Model,fields,get_model
|
||||
from netforce.access import get_active_company
|
||||
|
||||
from . import utils
|
||||
|
||||
class ReportVisit(Model):
|
||||
_name="clinic.report.visit"
|
||||
_string="Report Visit"
|
||||
_transient=True
|
||||
|
||||
_fields={
|
||||
"date": fields.Date("Month"),
|
||||
"date_from": fields.Date("From", required=True),
|
||||
"date_to": fields.Date("To", required=True),
|
||||
"patient_id": fields.Many2One("clinic.patient","Patient"),
|
||||
"doctor_id": fields.Many2One("clinic.staff","Doctor",domain=[['type','=','doctor']]),
|
||||
}
|
||||
|
||||
def _get_date_from(self,context={}):
|
||||
year,month=time.strftime("%Y-%m").split("-")
|
||||
return '%s-%s-01'%(year,month)
|
||||
|
||||
def _get_date_to(self,context={}):
|
||||
year,month,day=time.strftime("%Y-%m-%d").split("-")
|
||||
weekday, total_day=monthrange(int(year), int(month))
|
||||
return "%s-%s-%s"%(year,month,total_day)
|
||||
|
||||
_defaults={
|
||||
'date': lambda *a: time.strftime("%Y-%m-%d"),
|
||||
'date_from': _get_date_from,
|
||||
'date_to': _get_date_to,
|
||||
}
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
company_id=get_active_company()
|
||||
company=get_model('company').browse(company_id)
|
||||
year, month=time.strftime("%Y-%m").split("-")
|
||||
weekday, total_day=monthrange(int(year), int(month))
|
||||
time_start='%s-%s-01'%(year,str(month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
|
||||
|
||||
defaults=context.get('defaults')
|
||||
if defaults:
|
||||
year,month,day=defaults['date'].split("-")
|
||||
weekday, total_day=monthrange(int(year), int(month))
|
||||
time_start='%s-%s-01'%(year,str(month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(month).zfill(2),total_day)
|
||||
patient_id=None
|
||||
doctor_id=None
|
||||
if ids:
|
||||
obj=self.browse(ids)[0]
|
||||
month=obj.date_from.split("-")[1]
|
||||
time_start=obj.date_from
|
||||
time_stop=obj.date_to
|
||||
patient_id=obj.patient_id.id
|
||||
doctor_id=obj.doctor_id.id
|
||||
# new patient of this month
|
||||
dom=[]
|
||||
dom.append(['visit_date','>=',time_start])
|
||||
dom.append(['visit_date','<=',time_stop])
|
||||
if patient_id:
|
||||
dom.append(['patient_id','=',patient_id])
|
||||
if doctor_id:
|
||||
dom.appen(['doctor_id','=',doctor_id])
|
||||
|
||||
records=get_model('clinic.visit').search_browse(dom)
|
||||
lines=[]
|
||||
no=1
|
||||
for record in records:
|
||||
lines.append({
|
||||
'no': no,
|
||||
'vid': record.id,
|
||||
'cid': record.cycle_id.id,
|
||||
'cname': record.cycle_id.name or "",
|
||||
'pid': record.patient_id.id or '',
|
||||
'pname': record.patient_id.name or '',
|
||||
'tname': record.patient_id.type_id.name or '',
|
||||
'tid': record.patient_id.type_id.id or '',
|
||||
'did': record.doctor_id.id,
|
||||
'dname': record.doctor_id.name or "",
|
||||
'date': record.visit_date or '',
|
||||
'note': record.note or '',
|
||||
})
|
||||
no+=1
|
||||
|
||||
month_str=utils.MONTHS['th_TH'][int(month)]
|
||||
start=int(time_start[8:10])
|
||||
stop=int(time_stop[8:10])
|
||||
diff=stop-start
|
||||
data={
|
||||
'company_name': company.name or "",
|
||||
'parent_company_name': company.parent_id.name or "",
|
||||
'lines': lines,
|
||||
'month': month_str,
|
||||
'from': time_start,
|
||||
'to': time_stop,
|
||||
'is_duration': diff+1 < total_day,
|
||||
'year': year,
|
||||
}
|
||||
return data
|
||||
|
||||
def onchange_date(self,context={}):
|
||||
data=context['data']
|
||||
date=data['date']
|
||||
year,month,day=date.split("-")
|
||||
weekday, total_day=monthrange(int(year), int(month))
|
||||
data['date_from']="%s-%s-01"%(year,month)
|
||||
data['date_to']="%s-%s-%s"%(year,month,total_day)
|
||||
return data
|
||||
|
||||
ReportVisit.register()
|
Binary file not shown.
|
@ -0,0 +1,41 @@
|
|||
<center>
|
||||
<!--
|
||||
<h2>ตารางนัดผู้ป่วย</h2>
|
||||
<h3>
|
||||
{{parent_company_name}} {{company_name}}<br/>
|
||||
</h3>
|
||||
<h4>
|
||||
{{#if has_duration}}
|
||||
ระหว่างวันที่ {{date_from}} ถึง {{date_to}}
|
||||
{{else}}
|
||||
{{date}}
|
||||
{{/if}}
|
||||
</h4>
|
||||
-->
|
||||
</center>
|
||||
<table class="table table-condensed table-striped">
|
||||
<thead>
|
||||
<th>#</th>
|
||||
<th>วันที่</th>
|
||||
<th>รอบ</th>
|
||||
<th>ผู้ป่วย</th>
|
||||
<th>สิทธ์</th>
|
||||
<th>แพทย์</th>
|
||||
<th>หมายเหตุ</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each lines }}
|
||||
<tr>
|
||||
<td>{{no}}</td>
|
||||
<td><a href="/ui#name=clinic_visit&active_id={{vid}}&mode=form">{{date}}</a></td>
|
||||
<td><a href="/ui#name=clinic_cycle&active_id={{cid}}&mode=form">{{cname}}</a></td>
|
||||
<td><a href="/ui#name=clinic_patient&active_id={{pid}}&mode=form">{{pname}}</a></td>
|
||||
<td><a href="/ui#name=clinic_patient&active_id={{tid}}&mode=form">{{tname}}</a></td>
|
||||
<td><a href="/ui#name=clinic_staff&active_id={{did}}&mode=form">{{dname}}</a></td>
|
||||
<td style="background-color:{{visit_color}}">{{note}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
</tfoot>
|
||||
</table>
|
|
@ -12,7 +12,6 @@ report:
|
|||
- doctor detail (for accounting)
|
||||
- patient visit
|
||||
|
||||
|
||||
sharing setting
|
||||
- filter by branch
|
||||
- patient -> ok
|
||||
|
|
Loading…
Reference in New Issue