[fix] report hd case

conv_bal
watcha.h 2014-12-02 19:54:10 +07:00
parent 57950fbf4f
commit c6e5111a2d
5 changed files with 50 additions and 55 deletions

View File

@ -4,7 +4,13 @@
<item string="New Contact" method="new_contact"/>
</button>
</head>
<field name="name"/>
<field name="code"/>
<field name="contact_id"/>
<tabs>
<tab string="General">
<field name="name"/>
<field name="code"/>
<field name="contact_id"/>
</tab>
<tab string="Other">
</tab>
</tabs>
</form>

View File

@ -43,6 +43,7 @@ class ReportDiscontinuePatient(Model):
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)
if ids:

View File

@ -33,6 +33,7 @@ class ReportHDCaseSummary(Model):
prev_year=year
next_year=year
crr_month=int(date[5:7])
print('crr_month ', crr_month)
prev_month=crr_month-1
next_month=crr_month+1
if crr_month==1:
@ -54,7 +55,7 @@ class ReportHDCaseSummary(Model):
def replace_quote(dom=""):
return dom.replace("'","\"")
count=1
# number of hd case of this month
dom=[]
weekday, crr_total_day=monthrange(year, crr_month)
@ -65,12 +66,13 @@ class ReportHDCaseSummary(Model):
dom.append(["state","=","completed"])
crr_total=len(get_model("clinic.hd.case").search(dom))
items={}
items['topic1']={
items['topic%s'%count]={
'month': month_str,
'qty': crr_total or 0,
'action': 'clinic_hd_case',
'action_options': 'mode=list&search_domain=%s&tab_no=4'%replace_quote('%s'%dom),
}
count+=1
# number of patient from previous
dom=[]
@ -79,12 +81,13 @@ class ReportHDCaseSummary(Model):
dom.append(['reg_date','<=',time_stop])
npatient=len(get_model("clinic.patient").search(dom))
dom=replace_quote('%s'%dom)
items['topic2']={
items['topic%s'%count]={
'month': prev_month_str,
'qty': npatient or 0,
'action': 'clinic_patient',
'action_options': 'mode=list&search_domain=%s'%dom,
}
count+=1
# new patient of this month
dom=[]
@ -95,12 +98,13 @@ class ReportHDCaseSummary(Model):
dom.append(['reg_date','<=',time_stop])
new_patients=get_model('clinic.patient').search_browse(dom)
dom=replace_quote('%s'%dom)
items['topic3']={
items['topic%s'%count]={
'month': month_str,
'qty': len(new_patients) or 0,
'action': 'clinic_patient',
'action_options': 'mode=list&search_domain=%s'%dom,
}
count+=1
# number for patient who resign for this month
dom=[]
@ -112,12 +116,13 @@ class ReportHDCaseSummary(Model):
resign_patients=get_model('clinic.patient').search_browse(dom)
del dom[-1]
dom=replace_quote('%s'%dom)
items['topic4']={
items['topic%s'%count]={
'month': month_str,
'qty': len(resign_patients) or 0,
'action': 'clinic_patient',
'action_options': 'mode=list&search_domain=%s&tab_no=1'%dom,
}
count+=1
# all patient who are in hospital on select month
dom=[]
@ -126,60 +131,40 @@ class ReportHDCaseSummary(Model):
dom.append(['reg_date','<=',time_stop])
total_patient=get_model('clinic.patient').search_browse(dom)
dom=replace_quote('%s'%dom)
items['topic5']={
items['topic%s'%count]={
'month': next_month_str,
'qty': len(total_patient) or 0,
'action': 'clinic_patient',
'action_options': 'mode=list&search_domain=%s'%dom,
}
count+=1
# 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': '',
'qty': len(npatients),
'action': 'clinic_patient',
'action_options': 'mode=list&search_domain=%s&tab_no=2'%dom,
}
topics=utils.TOPICS
for ptype in get_model("clinic.patient.type").search_read([[]],['name']):
tkey='topic%s'%count
topics.update({
tkey:{
'name': ptype['name'],
'unit': 'คน',
}
})
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)
print(time_start, ' ', time_stop, crr_total_day, crr_month,)
dom.append(['reg_date','>=',time_start])
dom.append(['reg_date','<=',time_stop])
dom.append(['type_id','=',ptype['id']])
npatients=get_model("clinic.patient").search(dom)
dom=replace_quote('%s'%dom)
items[tkey]={
'month': '',
'qty': len(npatients),
'action': 'clinic_patient',
'action_options': 'mode=list&search_domain=%s&tab_no=2'%dom,
}
count+=1
# all patient who are uc 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','=','uc'])
npatients=get_model("clinic.patient").search(dom)
dom=replace_quote('%s'%dom)
items['topic7']={
'month':'',
'qty': len(npatients),
'action': 'clinic_patient',
'action_options': 'mode=list&search_domain=%s&tab_no=3'%dom,
}
# 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','=','others'])
npatients=get_model("clinic.patient").search(dom)
dom=replace_quote('%s'%dom)
items['topic8']={
'month': '',
'qty': len(npatients),
'action': 'clinic_patient',
'action_options': 'mode=list&search_domain=%s&tab_no=4'%dom,
}
lines=[]
index=1
for item in items:

View File

@ -40,6 +40,7 @@ class ReportMedicalSummary(Model):
defaults=context.get('defaults')
if defaults:
year,month,total_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)

View File

@ -43,6 +43,8 @@ class ReportRecentPatient(Model):
defaults=context.get('defaults')
if defaults:
year,month,day=defaults['date'].split("-")
# XXX
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)
if ids: