report summary filter by company

conv_bal
watcha.h 2014-11-05 13:17:32 +07:00
parent f30b84c6b7
commit 436dc8f5db
3 changed files with 12 additions and 14 deletions

View File

@ -35,15 +35,11 @@
<item string="Visit Dialy" action="clinic_visit_dialy"/>
<item string="Generate Visit" action="clinic_gen_visit_form"/>
</item>
<item string="HD Cases">
<item string="HD Cases" action="clinic_hd_case"/>
<divider/>
<header string="REPORTS"/>
<item string="HD Cases" action="clinic_hd_case"/>
<item string="Reports">
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
<item string="HD Case Detail" action="clinic_report_hd_case_detail"/>
</item>
<item string="Reports">
<item string="TODO" action="clinic_report_hd_case_medical"/>
<item string="Report Patient" action="clinic_report_new_patient"/>
</item>
<item string="Settings">
<item string="Departments" action="clinic_department"/>

View File

@ -4,6 +4,7 @@ from datetime import datetime
from calendar import monthrange
from netforce.model import Model, fields, get_model
from netforce.database import get_connection
from netforce.access import get_active_company
from . import utils
@ -22,8 +23,8 @@ class ReportHDCaseSummary(Model):
def get_report_data(self,ids,context={}):
db=get_connection()
for item in get_model("company").search_browse([]):
company_name=item.name
company_id=get_active_company()
company=get_model("company").browse(company_id)
date=datetime.now().strftime("%Y-%m-%d")
if ids:
@ -85,7 +86,7 @@ class ReportHDCaseSummary(Model):
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)
new_patients=db.query("select id, name, note from clinic_patient where active=true and create_time >=%s and create_time <=%s and company_id=%s",time_start,time_stop,company_id)
items['topic3']={
'month': month_str,
'amount': len(new_patients) or 0.0,
@ -97,7 +98,7 @@ class ReportHDCaseSummary(Model):
# 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)
resign_patients=db.query("select id, name, note from clinic_patient where active=false and write_time >=%s and write_time <=%s and company_id=%s",time_start,time_stop,company_id)
items['topic4']={
'month': month_str,
'amount': len(resign_patients) or 0.0,
@ -109,7 +110,7 @@ class ReportHDCaseSummary(Model):
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)
npatients=db.query("select id, name, note from clinic_patient where active=true and reg_date <=%s and company_id=%s",time_stop,company_id)
items['topic5']={
'month': next_month_str,
'amount': len(npatients),
@ -181,7 +182,8 @@ class ReportHDCaseSummary(Model):
'lines': lines,
'new_patient_lines': new_patient_lines,
'resign_patient_lines': resign_patient_lines,
'company_name': company_name,
'company_name': company.name or "",
'parent_company_name': company.parent_id.name or "",
}
return data

View File

@ -3,7 +3,7 @@
ใบสรุปการทำ Hemodialysis
</h2>
<h3>
ศูนย์ไตเทียมราชวัตร {{company_name}}<br/>
{{parent_company_name}}&nbsp;{{company_name}}<br/>
</h3>
<h4>
ประจำเดือน {{month}} {{year}}