conv_bal
chayut.s 2014-10-27 09:38:52 +07:00
parent 3215e9b638
commit 96ca8834a3
3 changed files with 359 additions and 1 deletions

View File

@ -30,7 +30,7 @@ from . import gen_visit
from . import gen_visit_line from . import gen_visit_line
from . import report_hd_detail from . import report_hd_detail
from . import report_hd_summary from . import report_hd_summary
from . import report_hd_madical from . import report_hd_medical
from . import input_data from . import input_data
from . import fin_setting from . import fin_setting
from . import import_data_mg from . import import_data_mg
@ -39,3 +39,4 @@ from . import import_data_sc
from . import translate from . import translate
from . import payment from . import payment
from . import account_payment from . import account_payment
from . import report_hd_payment

View File

@ -0,0 +1,183 @@
import time
from datetime import datetime
from calendar import monthrange
from netforce.model import Model,fields,get_model
class ReportHDMedical(Model):
_name="clinic.report.hd.medical"
_string="Hemodialysis Report Medical Summary"
_transient=True
_fields={
"date": fields.Date("Month", required=True),
}
_defaults={
'date': lambda *a: time.strftime("%Y-%m-%d"),
}
def get_report_data(self,ids,context={}):
for item in get_model("company").search_browse([]):
company_name=item.name
date=datetime.now().strftime("%Y-%m-%d")
#datemonth=datetime.now().strftime("%m")
if ids:
obj=self.browse(ids)[0]
date=obj.date
year=int(date[0:4])
month=int(date[5:7])
month_str=datetime.strptime(date,'%Y-%m-%d').strftime("%B")
#dom=[]
#dom.append(['fee_type','=','mg'])
weekday, total_day=monthrange(year, month)
time_start='2014-%s-01 00:00:00'%(month)
time_stop='2014-%s-%s 23:59:59'%(month,total_day)
dom=[]
dom.append(['state','=','completed'])
dom.append(['time_start','>=',time_start])
dom.append(['time_stop','<=',time_stop])
for product in get_model("clinic.hd.case.gm.line").search_browse([]):
product_id=product.product_id.Product_id
#product_total=len(product_id)
#print(product_id)
if product_id:
product_name=product.description or ""
#product_id=product.product_id.id or ""
lines=[
{
'product_id' : 'MD-XXXX',
'madical' : product_name,
'mg': '',
'uc': '437',
'sc': '',
'buy' : '4',
'total' : '441',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'H2',
'mg': '',
'uc': '',
'sc': '',
'buy' : '',
'total' : '',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'Epr4',
'mg': '',
'uc': '216',
'sc': '',
'buy' : '',
'total' : '216',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'Epr2',
'mg': '437',
'uc': '',
'sc': '',
'buy' : '',
'total' : '',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'Epk4',
'mg': '437',
'uc': '70',
'sc': '',
'buy' : '',
'total' : '70',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'Epk2',
'mg': '437',
'uc': '',
'sc': '',
'buy' : '',
'total' : '',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'Epg4',
'mg': '437',
'uc': '98',
'sc': '',
'buy' : '',
'total' : '98',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'Epg2',
'mg': '437',
'uc': '',
'sc': '',
'buy' : '',
'total' : '',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'Rng4',
'mg': '437',
'uc': '34',
'sc': '',
'buy' : '9',
'total' : '43',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'Rng2',
'mg': '437',
'uc': '',
'sc': '',
'buy' : '',
'total' : '',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'Epi4',
'mg': '437',
'uc': '264',
'sc': '',
'buy' : '9',
'total' : '43',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'Epi2',
'mg': '437',
'uc': '',
'sc': '',
'buy' : '',
'total' : '',
},
{
'product_id' : 'MD-XXXX',
'madical' : 'Vnf',
'mg': '437',
'uc': '',
'sc': '',
'buy' : '',
'total' : '',
},
]
data={
'month': month_str,
'year': year,
'lines': lines,
'company_name': company_name,
}
return data
ReportHDMedical.register()

View File

@ -0,0 +1,174 @@
import time
from netforce.model import Model, fields, get_model
class ReportHDPayment(Model):
_name="clinic.report.hd.payment"
_string="Hemodialysis Report Payment"
_transient=True
_fields={
"patient_id" : fields.Many2One("clinic.patient","Patient"),
"doctor_id" : fields.Many2One("clinic.doctor","Doctor"),
"nurse_id" : fields.Many2One("clinic.nurse","Nurse"),
"date_from": fields.Date("From"),
"date_to": fields.Date("To"),
"cycle_id": fields.Many2One("clinic.cycle","Cycle"),
"type": fields.Selection([("mg","Medical Goverment"),("sc","Social Security"),("nhso","NHSO (30B)"),("personal","Personal"),("other","Other")],"Type"),
}
_defaults={
'date_from': lambda *a: time.strftime("%Y-%m-%d"),
'date_to': lambda *a: time.strftime("%Y-%m-%d"),
}
_order="cycle_id desc"
def get_report_data(self,ids,context={}):
# company_id=get_active_company
# comp=get_model("company").browse(company_id)
# context=> dict
# inside context => keys => defaults => type => dict
# dict => key: value => '', 1, [], {}
# context['default'] => defaults(dict) => key => inside key => value => '2014-10-22'
for item in get_model("company").search_browse([]):
company_name=item.name
date_from=time.strftime("%Y-%m-%d")
date_to=time.strftime("%Y-%m-%d")
defaults=context.get("defaults")
if defaults:
if defaults.get("date_from"):
date_from=defaults['date_from']
if defaults.get("date_to"):
date_to=defaults['date_to']
PATIENT_TYPE={
"mg":"Medical Government",
"sc":"Social Security",
"nhso":"NHSO (30฿)",
"personal": "Personal",
"others": "Others",
}
dom=[]
dom.append(['state','=','completed'])
if ids:
obj=self.browse(ids)[0]
if obj.date_from:
date_from=obj.date_from
if obj.date_to:
date_to=obj.date_to
if obj.cycle_id:
dom.append([
'cycle_id','=',obj.cycle_id.id,
])
if obj.patient_id:
dom.append([
'patient_id','=',obj.patient_id.id,
])
if obj.nurse_id:
dom.append([
'nurse_id','=',obj.nurse_id.id,
])
if obj.doctor_id:
dom.append([
'doctor_id','=',obj.doctor_id.id,
])
if obj.type_id:
dom.append([
'type','=',obj.type_id.id,
])
dom.append(['time_start', ">=", date_from+" 00:00:00"])
dom.append(['time_stop',"<=", date_to+" 23:59:59"])
lines=[]
cycles=[]
index=0
no_patient=0
for hd_case in get_model("clinic.hd.case").search_browse(dom,order="cycle_id.sequence"):
#print('='*50)
#for line in hd_case.line:
# dialyzer_id=line.dialyzer_id
# if dialyzer_id:
# dialyzer_number=line.number or ""
# print(dialyzer_number)
#print('='*50)
patient_type=hd_case.patient_id.type
patient_type=PATIENT_TYPE.get(patient_type)
#dialyzer=get_model("clinic.dialyzer").search_browse([])
cycle_name=hd_case.cycle_id.name or ""
show_cycle=False
if not cycle_name in cycles:
cycles.append(cycle_name)
show_cycle=True
vals={
'color': 'success',
'show_cycle': False,
'cycle' : "",
'patient': "",
'no_patient': no_patient,
'patient_type' : "",
'doctor' : "",
'total' : "",
'rc_no' : "",
'dialyzer_name' : "",
'nurse' : "",
}
lines.append(vals)
no_patient=1
else:
no_patient+=1
index+=1
vals={
'show_cycle': show_cycle,
'cycle' : cycle_name,
'patient_id': hd_case.patient_id.id,
'patient_name': hd_case.patient_id.name,
'patient_type' : patient_type,
'no_patient': 0,
'doctor_id': hd_case.doctor_id.id,
'doctor_name' : hd_case.doctor_id.name,
'total' : hd_case.total,
'hd_case_id' : hd_case.id,
'rc_no' : hd_case.number,
'dialyzer_number' : 'DZ-XXXX',
'nurse_id': hd_case.nurse_id.id,
'nurse_name' : hd_case.nurse_id.name,
}
lines.append(vals)
# XXX
if lines:
vals={
'color': 'success',
'show_cycle': False,
'cycle' : "",
'patient': "",
'no_patient': no_patient,
'patient_type' : "",
'doctor' : "",
'total' : "",
'rc_no' : "",
'dialyzer_name' : "",
'nurse' : "",
}
lines.append(vals)
#XXX
del lines[0]
data={
'lines': lines,
'same_date': date_from==date_to,
'date_from': date_from,
'date_to': date_to,
'company_name': company_name,
}
return data
ReportHDPayment.register()