report hd summary
parent
0613851962
commit
c933fb1280
|
@ -1,5 +1,5 @@
|
|||
<action>
|
||||
<field name="string">HD Report Summary</field>
|
||||
<field name="string">HD Case Report Summary</field>
|
||||
<field name="view_cls">report</field>
|
||||
<field name="model">clinic.report.hd.case.summary</field>
|
||||
<field name="report_template">report_hd_case_summary</field>
|
||||
|
|
|
@ -4,4 +4,5 @@
|
|||
<field name="time_stop"/>
|
||||
<field name="patient_id"/>
|
||||
<field name="cycle_id"/>
|
||||
<field name="state"/>
|
||||
</search>
|
||||
|
|
|
@ -88,6 +88,7 @@
|
|||
<tab string="Note">
|
||||
<field name="note" nolabel="1"/>
|
||||
<field name="active"/>
|
||||
<field name="resign_date" readonly="1"/>
|
||||
</tab>
|
||||
</tabs>
|
||||
<related>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<field name="hn"/>
|
||||
<field name="name"/>
|
||||
<field name="reg_date"/>
|
||||
<field name="resign_date"/>
|
||||
<field name="categ_id"/>
|
||||
<field name="type"/>
|
||||
</list>
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
<form model="clinic.report.medical.summary">
|
||||
<group>
|
||||
<field name="date" span="3"/>
|
||||
</group>
|
||||
<field name="date" mode="month" span="3"/>
|
||||
</form>
|
||||
|
|
|
@ -76,11 +76,12 @@ class Patient(Model):
|
|||
"hd_cases": fields.One2Many("clinic.hd.case","patient_id","HD Cases"),
|
||||
"partner_id": fields.Many2One("partner","Contact"),
|
||||
"dialyzers": fields.One2Many("clinic.dialyzer","patient_id","Dialyzers"),
|
||||
"active":fields.Boolean("Mark as discountinue"),
|
||||
"active":fields.Boolean("Uncheck as discountinue", search=True),
|
||||
'note': fields.Text("Note"),
|
||||
'categ_id': fields.Many2One("clinic.patient.categ","Category"),
|
||||
'doctor_id': fields.Many2One("clinic.personal","Doctor",domain=[['type','=','doctor']]),
|
||||
"documents": fields.One2Many("document","related_id","Documents"),
|
||||
'resign_date': fields.Date("Resign Date"),
|
||||
}
|
||||
|
||||
def _get_number(self,context={}):
|
||||
|
@ -197,6 +198,9 @@ class Patient(Model):
|
|||
super().delete(ids)
|
||||
|
||||
def write(self,ids,vals,**kw):
|
||||
if 'active' in vals.keys():
|
||||
if not vals['active']:
|
||||
vals['resign_date']=time.strftime("%Y-%m-%d")
|
||||
for obj in self.browse(ids):
|
||||
partner_id=obj.partner_id
|
||||
if not partner_id:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import time
|
||||
import urllib.parse as urllib
|
||||
|
||||
from datetime import datetime
|
||||
from calendar import monthrange
|
||||
|
@ -47,103 +48,140 @@ class ReportHDCaseSummary(Model):
|
|||
next_month_str=utils.MONTHS['th_TH'][next_month]
|
||||
prev_month_str=utils.MONTHS['th_TH'][prev_month]
|
||||
|
||||
def encode_url(dom):
|
||||
dom='%s'%dom
|
||||
dom=urllib.quote(dom.encode('utf-8'))
|
||||
return dom
|
||||
|
||||
def replace_quote(dom=""):
|
||||
return dom.replace("'","\"")
|
||||
|
||||
|
||||
# number of hd case of this month
|
||||
dom=[]
|
||||
weekday, crr_total_day=monthrange(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)
|
||||
dom.append(['time_start','>=', time_start])
|
||||
dom.append(['time_stop','<=',time_stop])
|
||||
dom.append(['state','=','completed'])
|
||||
dom.append(["time_start",">=",time_start])
|
||||
dom.append(["time_stop","<=",time_stop])
|
||||
dom.append(["state","=","completed"])
|
||||
crr_total=len(get_model("clinic.hd.case").search(dom))
|
||||
items={}
|
||||
items['topic1']={
|
||||
'month': month_str,
|
||||
'amount': crr_total,
|
||||
'date_from': time_start[0:10],
|
||||
'date_to': time_stop[0:10],
|
||||
'link': True,
|
||||
'qty': crr_total or 0,
|
||||
'action': 'clinic_hd_case',
|
||||
'action_options': 'mode=list&search_domain=%s'%replace_quote('%s'%dom),
|
||||
}
|
||||
|
||||
# number patient from previous month
|
||||
# number of patient from previous
|
||||
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))
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic2']={
|
||||
'month': prev_month_str,
|
||||
'amount': npatient or 0.0,
|
||||
'date_from': '',
|
||||
'date_to': '',
|
||||
'link': False,
|
||||
'qty': npatient or 0,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
}
|
||||
|
||||
# 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 and company_id=%s",time_start,time_stop,company_id)
|
||||
time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
dom.append(['reg_date','>=',time_start])
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
new_patients=get_model('clinic.patient').search_browse(dom)
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic3']={
|
||||
'month': month_str,
|
||||
'amount': len(new_patients) or 0.0,
|
||||
'date_from': '',
|
||||
'date_to': '',
|
||||
'link': False,
|
||||
'qty': len(new_patients) or 0,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
}
|
||||
|
||||
# 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 and company_id=%s",time_start,time_stop,company_id)
|
||||
dom=[]
|
||||
time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
dom.append(['resign_date','>=',time_start])
|
||||
dom.append(['resign_date','<=',time_stop])
|
||||
dom.append(['active','=',False])
|
||||
resign_patients=get_model('clinic.patient').search_browse(dom)
|
||||
del dom[-1]
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic4']={
|
||||
'month': month_str,
|
||||
'amount': len(resign_patients) or 0.0,
|
||||
'date_from': '',
|
||||
'date_to': '',
|
||||
'link': False,
|
||||
'qty': len(resign_patients) or 0,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s&tab_no=1'%dom,
|
||||
}
|
||||
# all patient who are in hospital now
|
||||
|
||||
# all patient who are in hospital on select month
|
||||
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 and company_id=%s",time_stop,company_id)
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
total_patient=get_model('clinic.patient').search_browse(dom)
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic5']={
|
||||
'month': next_month_str,
|
||||
'amount': len(npatients),
|
||||
'date_from': '',
|
||||
'date_to': '',
|
||||
'link': False,
|
||||
'qty': len(total_patient) or 0,
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s'%dom,
|
||||
}
|
||||
|
||||
npatients=get_model("clinic.patient").search([['type','=','sc']])
|
||||
# all patient who are sc in hospital on select month
|
||||
dom=[]
|
||||
time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
dom.append(['reg_date','>=',time_start])
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
dom.append(['type','=','sc'])
|
||||
npatients=get_model("clinic.patient").search(dom)
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic6']={
|
||||
'month': '',
|
||||
'amount': len(npatients),
|
||||
'date_from': '',
|
||||
'date_to': '',
|
||||
'link': False,
|
||||
'qty': len(npatients),
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s&tab_no=2'%dom,
|
||||
}
|
||||
npatients=get_model("clinic.patient").search([['type','=','nhso']])
|
||||
|
||||
# all patient who are nhso in hospital on select month
|
||||
dom=[]
|
||||
time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
dom.append(['reg_date','>=',time_start])
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
dom.append(['type','=','nhso'])
|
||||
npatients=get_model("clinic.patient").search(dom)
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic7']={
|
||||
'month':'',
|
||||
'amount': len(npatients),
|
||||
'date_from': '',
|
||||
'date_to': '',
|
||||
'link': False,
|
||||
'qty': len(npatients),
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s&tab_no=3'%dom,
|
||||
}
|
||||
npatients=get_model("clinic.patient").search([['type','in',['personal','others']]])
|
||||
|
||||
# all patient who are other in hospital on select month
|
||||
dom=[]
|
||||
time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
|
||||
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
|
||||
dom.append(['reg_date','>=',time_start])
|
||||
dom.append(['reg_date','<=',time_stop])
|
||||
dom.append(['type','=','personal'])
|
||||
npatients=get_model("clinic.patient").search(dom)
|
||||
dom=replace_quote('%s'%dom)
|
||||
items['topic8']={
|
||||
'month': '',
|
||||
'amount': len(npatients),
|
||||
'date_from': '',
|
||||
'date_to': '',
|
||||
'link': False,
|
||||
'qty': len(npatients),
|
||||
'action': 'clinic_patient',
|
||||
'action_options': 'mode=list&search_domain=%s&tab_no=4'%dom,
|
||||
}
|
||||
|
||||
lines=[]
|
||||
index=1
|
||||
for item in items:
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
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 ReportMedicalSummary(Model):
|
||||
_name="clinic.report.medical.summary"
|
||||
|
@ -17,7 +19,29 @@ class ReportMedicalSummary(Model):
|
|||
}
|
||||
|
||||
def get_report_data(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
date=time.strftime("%Y-%m-%d")
|
||||
defaults=context.get('defaults')
|
||||
if defaults:
|
||||
date=defaults['date']
|
||||
year=int(date[0:4])
|
||||
month=int(date[5:7])
|
||||
weekday, total_day=monthrange(year, month)
|
||||
|
||||
dom=[]
|
||||
dom.append([['state','=','completed']])
|
||||
dom.append([['time_start','>=','%s-%s-01 00:00:00'%(year,month)]])
|
||||
dom.append([['time_stop','<=','%s-%s-%s 23:59:59'%(year,month,total_day)]])
|
||||
print("dom ", dom)
|
||||
|
||||
products=[]
|
||||
for hd_case in get_model('clinic.hd.case').search_browse(dom):
|
||||
print("="*30)
|
||||
for line in hd_case.lines:
|
||||
prod=line.product_id
|
||||
if line.type=='fee':
|
||||
continue
|
||||
if prod.type=='service':
|
||||
continue
|
||||
|
||||
company_id=get_active_company()
|
||||
company=get_model('company').browse(company_id)
|
||||
|
|
|
@ -23,10 +23,14 @@
|
|||
<td>{{topic}}</td>
|
||||
<td>{{month}}</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>
|
||||
{{#if qty}}
|
||||
<td>
|
||||
{{view "link" string=qty action=action action_options=action_options}}
|
||||
</td>
|
||||
{{else}}
|
||||
<td>{{amount}}</td>
|
||||
<td>
|
||||
0
|
||||
</td>
|
||||
{{/if}}
|
||||
<td>{{unit}}</td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue