report summary

conv_bal
watcha.h 2014-11-04 23:10:23 +07:00
parent c196d8878e
commit b892f55408
6 changed files with 129 additions and 109 deletions

View File

@ -39,12 +39,9 @@
<header string="REPORTS"/> <header string="REPORTS"/>
<item string="HD Summary" action="clinic_report_hd_case_summary"/> <item string="HD Summary" action="clinic_report_hd_case_summary"/>
<item string="HD Detail" action="clinic_report_hd_case_detail"/> <item string="HD Detail" action="clinic_report_hd_case_detail"/>
<header string="REPORT SETTINGS"/>
<item string="Topics" action="clinic_translate"/>
</item> </item>
<item string="Reports"> <item string="Reports">
<item string="Medical Summary" action="clinic_report_hd_case_medical"/> <item string="Medical Summary" action="clinic_report_hd_case_medical"/>
<item string="Payment Summary" action="clinic_report_hd_case_payment"/>"
</item> </item>
<item string="Settings"> <item string="Settings">
<item string="Departments" action="clinic_department"/> <item string="Departments" action="clinic_department"/>

View File

@ -34,8 +34,6 @@ from . import gen_visit_line
from . import report_clinic from . import report_clinic
from . import report_hd_case_detail from . import report_hd_case_detail
from . import report_hd_case_summary from . import report_hd_case_summary
from . import report_hd_case_medical
from . import report_hd_case_payment
from . import fin_setting from . import fin_setting
from . import import_data_mg from . import import_data_mg
from . import import_data_nhso from . import import_data_nhso

View File

@ -3,6 +3,7 @@ import time
from datetime import datetime from datetime import datetime
from calendar import monthrange from calendar import monthrange
from netforce.model import Model, fields, get_model from netforce.model import Model, fields, get_model
from netforce.database import get_connection
from . import utils from . import utils
@ -20,6 +21,7 @@ class ReportHDCaseSummary(Model):
} }
def get_report_data(self,ids,context={}): def get_report_data(self,ids,context={}):
db=get_connection()
for item in get_model("company").search_browse([]): for item in get_model("company").search_browse([]):
company_name=item.name company_name=item.name
@ -27,99 +29,118 @@ class ReportHDCaseSummary(Model):
if ids: if ids:
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
date=obj.date date=obj.date
year=int(date[0:4])
prev_year=year
next_year=year
crr_month=int(date[5:7]) crr_month=int(date[5:7])
prev_month=crr_month-1 prev_month=crr_month-1
next_month=crr_month+1 next_month=crr_month+1
if crr_month==1: if crr_month==1:
prev_month=12 prev_month=12
prev_year-=1
if crr_month==12: if crr_month==12:
next_month=1 next_month=1
next_year+=1
year=int(date[0:4])
month_str=utils.MONTHS['th_TH'][crr_month] month_str=utils.MONTHS['th_TH'][crr_month]
next_month_str=utils.MONTHS['th_TH'][next_month] next_month_str=utils.MONTHS['th_TH'][next_month]
prev_month_str=utils.MONTHS['th_TH'][prev_month] prev_month_str=utils.MONTHS['th_TH'][prev_month]
dom=[] # number of hd case of this month
weekday, prev_total_day=monthrange(year, prev_month)
prev_time_start='2014-%s-01 00:00:00'%(str(prev_month).zfill(2))
prev_time_stop='2014-%s-%s 23:59:59'%(str(prev_month).zfill(2),prev_total_day)
dom.append(['time_start','>=', prev_time_start])
dom.append(['time_stop','<=',prev_time_stop])
prev_total=len(get_model("clinic.hd.case").search(dom))
dom=[] dom=[]
weekday, crr_total_day=monthrange(year, crr_month) weekday, crr_total_day=monthrange(year, crr_month)
crr_time_start='2014-%s-01 00:00:00'%(str(crr_month).zfill(2)) time_start='%s-%s-01 00:00:00'%(year,str(crr_month).zfill(2))
crr_time_stop='2014-%s-%s 23:59:59'%(str(crr_month).zfill(2),crr_total_day) time_stop='%s-%s-%s 23:59:59'%(year,str(crr_month).zfill(2),crr_total_day)
dom.append(['time_start','>=', crr_time_start]) dom.append(['time_start','>=', time_start])
dom.append(['time_stop','<=',crr_time_stop]) dom.append(['time_stop','<=',time_stop])
dom.append(['state','=','completed'])
crr_total=len(get_model("clinic.hd.case").search(dom)) crr_total=len(get_model("clinic.hd.case").search(dom))
items={}
dom=[] items['topic1']={
weekday, next_total_day=monthrange(year, next_month)
next_time_start='2014-%s-01 00:00:00'%(str(next_month).zfill(2))
next_time_stop='2014-%s-%s 23:59:59'%(str(next_month).zfill(2),next_total_day)
dom.append(['time_start','>=', next_time_start])
dom.append(['time_stop','<=',next_time_stop])
next_total=len(get_model("clinic.hd.case").search(dom))
items={
'topic1': {
'month': month_str, 'month': month_str,
'amount': crr_total, 'amount': crr_total,
'date_from': crr_time_start[0:10], 'date_from': time_start[0:10],
'date_to': crr_time_stop[0:10], 'date_to': time_stop[0:10],
}, 'link': True,
'topic2': }
{
# number patient from previous month
dom=[]
weekday, prev_total_day=monthrange(prev_year, prev_month)
#time_start='%s-%s-01'%(prev_year,str(prev_month).zfill(2))
time_stop='%s-%s-%s'%(prev_year,str(prev_month).zfill(2),prev_total_day)
#dom.append(['reg_date','>=', time_start])
dom.append(['reg_date','<=',time_stop])
npatient=len(get_model("clinic.patient").search(dom))
items['topic2']={
'month': prev_month_str, 'month': prev_month_str,
'amount': prev_total, 'amount': npatient or 0.0,
'date_from': prev_time_start[0:10],
'date_to': prev_time_stop[0:10],
},
'topic3':
{
'month': month_str,
'amount': next_total,
'date_from': next_time_start[0:10],
'date_to': next_time_stop[0:10],
},
'topic4':
{
'month': month_str,
'amount': 'N/A',
'date_from': '', 'date_from': '',
'date_to': '', 'date_to': '',
}, 'link': False,
'topic5': }
{
# new patient of this month
dom=[]
weekday, crr_total_day=monthrange(prev_year, crr_month)
time_start='%s-%s-01 00:00:00'%(year,str(crr_month).zfill(2))
time_stop='%s-%s-%s 23:59:59'%(year,str(crr_month).zfill(2),crr_total_day)
new_patients=db.query("select id, name, note from clinic_patient where active=true and create_time >=%s and create_time <=%s",time_start,time_stop)
items['topic3']={
'month': month_str,
'amount': len(new_patients) or 0.0,
'date_from': '',
'date_to': '',
'link': False,
}
# number for patient who resign for this month
time_start='%s-%s-01 00:00:00'%(year,str(crr_month).zfill(2))
time_stop='%s-%s-%s 23:59:59'%(year,str(crr_month).zfill(2),crr_total_day)
resign_patients=db.query("select id, name, note from clinic_patient where active=false and write_time >=%s and write_time <=%s",time_start,time_stop)
items['topic4']={
'month': month_str,
'amount': len(resign_patients) or 0.0,
'date_from': '',
'date_to': '',
'link': False,
}
# all patient who are in hospital now
dom=[]
weekday, crr_total_day=monthrange(year, crr_month)
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
npatients=db.query("select id, name, note from clinic_patient where active=true and reg_date <=%s",time_stop)
items['topic5']={
'month': next_month_str, 'month': next_month_str,
'amount': 'N/A', 'amount': len(npatients),
'date_from': '', 'date_from': '',
'date_to': '', 'date_to': '',
}, 'link': False,
'topic6': }
{
npatients=get_model("clinic.patient").search([['type','=','sc']])
items['topic6']={
'month': '', 'month': '',
'amount': '', 'amount': len(npatients),
'date_from': '', 'date_from': '',
'date_to': '', 'date_to': '',
}, 'link': False,
'topic7': }
{ npatients=get_model("clinic.patient").search([['type','=','nhso']])
items['topic7']={
'month':'', 'month':'',
'amount': '', 'amount': len(npatients),
'date_from': '', 'date_from': '',
'date_to': '', 'date_to': '',
}, 'link': False,
'topic8': }
{ npatients=get_model("clinic.patient").search([['type','in',['personal','others']]])
items['topic8']={
'month': '', 'month': '',
'amount': '', 'amount': len(npatients),
'date_from': '', 'date_from': '',
'date_to': '', 'date_to': '',
}, 'link': False,
} }
lines=[] lines=[]
@ -134,28 +155,32 @@ class ReportHDCaseSummary(Model):
lines.append(line) lines.append(line)
index+=1 index+=1
new_pt_lines=[] new_patient_lines=[]
for i in range(3): index=1
new_pt_lines.append({ for new_patient in new_patients:
'no': i+1, new_patient_lines.append({
'name': 'xxxxx', 'no': index,
'note': '', 'name': new_patient['name'] or "",
'note': new_patient['note'] or "",
}) })
index+=1
resign_pt_lines=[] resign_patient_lines=[]
for i in range(5): index=1
resign_pt_lines.append({ for resign_patient in resign_patients:
'no': i+1, resign_patient_lines.append({
'name': 'xxxxx', 'no': index,
'note': '', 'name': resign_patient['name'],
'note': resign_patient['note'],
}) })
index+=1
data={ data={
'month': month_str, 'month': month_str,
'year': year, 'year': year,
'lines': lines, 'lines': lines,
'new_pt_lines': new_pt_lines, 'new_patient_lines': new_patient_lines,
'resign_pt_lines': resign_pt_lines, 'resign_patient_lines': resign_patient_lines,
'company_name': company_name, 'company_name': company_name,
} }
return data return data

View File

@ -5,6 +5,15 @@ DAYS={ 'th_TH': ['จันทร์', 'อังคาร', 'พุธ', 'พ
MONTHS={ 'th_TH': [None, 'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'] MONTHS={ 'th_TH': [None, 'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม']
, 'en_US': [None, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] , 'en_US': [None, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
} }
PATIENT_TYPE={
"mg":"Medical Government",
"sc":"ปกส.",
"nhso":"สปกส.",
"personal": "จ่ายเอง",
"others": "อื่นๆ",
}
TOPICS={ TOPICS={
'topic1': {'name': 'จำนวนครั้งการทำ Hemodialysis', 'unit': 'ครั้ง'}, 'topic1': {'name': 'จำนวนครั้งการทำ Hemodialysis', 'unit': 'ครั้ง'},
'topic2': {'name': 'จำนวนผู้ป่วยยกมาจากเดือน', 'unit': 'คน'}, 'topic2': {'name': 'จำนวนผู้ป่วยยกมาจากเดือน', 'unit': 'คน'},

View File

@ -1,11 +1,11 @@
<center> <center>
<h2>Detail of the Hemodialysis</h2> <h2>รายละเอียดการทำ Hemodialysis</h2>
<h3>[{{company_name}}]</h3> <h3>ศูนย์ไตเทียมราชวัตร {{company_name}}</h3>
<h4> <h4>
{{#if same_date}} {{#if same_date}}
As at {{fmt_date date_from}} ณ วันที่ {{fmt_date date_from}}
{{else}} {{else}}
From {{fmt_date date_from}} to {{fmt_date date_to}} ตั้งแต่ {{fmt_date date_from}} ถึง {{fmt_date date_to}}
{{/if}} {{/if}}
</h4> </h4>
</center> </center>
@ -13,28 +13,25 @@
<thead class="scroll-header"> <thead class="scroll-header">
<tr> <tr>
<th> <th>
Cycle รอบ
</th> </th>
<th> <th>
Patient ผู้ป่วย
</th> </th>
<th> <th>
Patient Type ประเภท
</th> </th>
<th> <th>
HD Fee ค่าธรรมเนียม
</th> </th>
<th> <th>
RC.No HD.No
</th> </th>
<th> <th>
Dialyzer Dialyzer
</th> </th>
<th> <th>
Doctor หมอ
</th>
<th>
Nurse
</th> </th>
</tr> </tr>
</thead> </thead>
@ -49,7 +46,7 @@
{{/if}} {{/if}}
<tr class="{{color}}"> <tr class="{{color}}">
{{#if no_patient}} {{#if no_patient}}
<td><b>TOTAL</b></td> <td><b>ทั้งหมด</b></td>
<td>{{no_patient}}</td> <td>{{no_patient}}</td>
{{else}} {{else}}
<td></td> <td></td>
@ -64,13 +61,11 @@
<td><a style="text-decoration: underline" href="ui#name=clinic_hd_case&mode=page&active_id={{hd_case_id}}">{{rc_no}}</a></td> <td><a style="text-decoration: underline" href="ui#name=clinic_hd_case&mode=page&active_id={{hd_case_id}}">{{rc_no}}</a></td>
<td><a style="text-decoration: underline" href="ui#name=clinic_dialyzer&mode=page&active_id={{dialyzer_number}}">{{dialyzer_number}}</a></td> <td><a style="text-decoration: underline" href="ui#name=clinic_dialyzer&mode=page&active_id={{dialyzer_number}}">{{dialyzer_number}}</a></td>
<td><a style="text-decoration: underline" href="ui#name=clinic_doctor&mode=page&active_id={{doctor_id}}">{{doctor_name}}</a></td> <td><a style="text-decoration: underline" href="ui#name=clinic_doctor&mode=page&active_id={{doctor_id}}">{{doctor_name}}</a></td>
<td><a style="text-decoration: underline" href="ui#name=clinic_nurse&mode=page&active_id={{nurse_id}}">{{nurse_name}}</a></td>
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>
<tfoot> <tfoot>
<tr style="font-weight:bold"> <tr style="font-weight:bold">
</tr> </tr>
</tfoot> </tfoot>
</table> </table>

View File

@ -23,7 +23,11 @@
<td>{{topic}}</td> <td>{{topic}}</td>
<td>{{month}}</td> <td>{{month}}</td>
<td>เท่ากับ</td> <td>เท่ากับ</td>
{{#if link}}
<td><a style="text-decoration: underline" href="ui#name=clinic_report_hd_case_detail&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}" >{{amount}}</a></td> <td><a style="text-decoration: underline" href="ui#name=clinic_report_hd_case_detail&defaults.date_from={{date_from}}&defaults.date_to={{date_to}}" >{{amount}}</a></td>
{{else}}
<td>{{amount}}</td>
{{/if}}
<td>{{unit}}</td> <td>{{unit}}</td>
</tr> </tr>
{{/each}} {{/each}}
@ -35,15 +39,11 @@
<table class="table"> <table class="table">
<thead> <thead>
<th><h4>รายชื่อผู้ป่วยรับใหม่</h4></th> <th><h4>รายชื่อผู้ป่วยรับใหม่</h4></th>
<th></th>
<th></th>
</thead> </thead>
<tbody> <tbody>
{{#each new_pt_lines}} {{#each new_patient_lines}}
<tr> <tr>
<td>{{no}}</td> <td>{{no}}. {{name}} {{note}}</td>
<td>{{name}}</td>
<td>{{note}}</td>
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>
@ -77,15 +77,11 @@
<table class="table"> <table class="table">
<thead> <thead>
<th><h4>รายชื่อผู้ป่วยจำหน่าย<h4></th> <th><h4>รายชื่อผู้ป่วยจำหน่าย<h4></th>
<th></th>
<th></th>
</thead> </thead>
<tbody> <tbody>
{{#each resign_pt_lines}} {{#each resign_patient_lines}}
<tr> <tr>
<td>{{no}}</td> <td>{{no}}. {{name}} {{note}}</td>
<td>{{name}}</td>
<td>{{note}}</td>
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>