conv_bal
watcha.h 2015-03-17 19:18:05 +07:00
parent c48ad556bc
commit fd33b9b1d0
5 changed files with 26 additions and 12 deletions

View File

@ -3,8 +3,6 @@
<field name="type_id"/> <field name="type_id"/>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<!--<item string="Generate Visit" action="clinic_gen_visit"/>--> <!--<item string="Generate Visit" action="clinic_gen_visit"/>-->
<!--<item string="New Dialyzer" method="new_dialyzer"/>-->
<item string="New Address" method="simple_address" perm="clinic_simple_address"/>
</button> </button>
</head> </head>
<field name="number"/> <field name="number"/>

View File

@ -4,6 +4,8 @@ class Address(Model):
_inherit="address" _inherit="address"
_fields={ _fields={
'fax': fields.Char("Fax"), 'fax': fields.Char("Fax"),
'patient_id': fields.Many2One("clinic.patient", "Patient"),
"staff_id": fields.Many2One("clinic.staff","Staff"),
} }
Address.register() Address.register()

View File

@ -142,12 +142,12 @@ class Patient(Model):
"partner_id": fields.Many2One("partner","Contact"), "partner_id": fields.Many2One("partner","Contact"),
"dialyzers": fields.One2Many("clinic.dialyzer","patient_id","Dialyzers"), "dialyzers": fields.One2Many("clinic.dialyzer","patient_id","Dialyzers"),
"active":fields.Boolean("Active"), "active":fields.Boolean("Active"),
"dispose":fields.Boolean("Dispose"), "dispose":fields.Boolean("Dispose",search=True),
'note': fields.Text("Note"), 'note': fields.Text("Note"),
'categ_id': fields.Many2One("clinic.patient.categ","Category"), 'categ_id': fields.Many2One("clinic.patient.categ","Category"),
'doctor_id': fields.Many2One("clinic.staff","Doctor",domain=[['type','=','doctor']]), 'doctor_id': fields.Many2One("clinic.staff","Doctor",domain=[['type','=','doctor']]),
"documents": fields.One2Many("document","related_id","Documents"), "documents": fields.One2Many("document","related_id","Documents"),
'resign_date': fields.Date("Dispose Date"), 'resign_date': fields.Date("Dispose Date", search=True),
'rm_remain_visit': fields.Boolean("Auto Remove Remaining Visit"), 'rm_remain_visit': fields.Boolean("Auto Remove Remaining Visit"),
'department_id': fields.Many2One("clinic.department","Department",search=True), 'department_id': fields.Many2One("clinic.department","Department",search=True),
'cycle_id': fields.Many2One("clinic.cycle","Last Cycle",function="_get_last_cycle"), 'cycle_id': fields.Many2One("clinic.cycle","Last Cycle",function="_get_last_cycle"),
@ -223,7 +223,7 @@ class Patient(Model):
if res.get("department_ids"): if res.get("department_ids"):
dpt_ids=res['department_ids'] dpt_ids=res['department_ids']
else: else:
dpt_ids=res['department_id'] dpt_ids=[res['department_id']]
dpts=get_model("clinic.department").browse(dpt_ids) dpts=get_model("clinic.department").browse(dpt_ids)
code=','.join([dpt.code for dpt in dpts]) code=','.join([dpt.code for dpt in dpts])
return code return code
@ -249,6 +249,7 @@ class Patient(Model):
'departments': _get_departments, 'departments': _get_departments,
'location': _get_default_location, 'location': _get_default_location,
'nation_id': _get_nation, 'nation_id': _get_nation,
'dispose': False,
} }
_sql_constraints=("clinic_patient_key_uniq","unique(name_check,branch_id)","name should be unique"), _sql_constraints=("clinic_patient_key_uniq","unique(name_check,branch_id)","name should be unique"),

View File

@ -99,6 +99,8 @@ class ReportHDCaseSummary(Model):
return dom return dom
def replace_quote(dom=""): def replace_quote(dom=""):
dom=dom.replace("False","false") #XXX
dom=dom.replace("True","true") #XXX
return dom.replace("'","\"") return dom.replace("'","\"")
count=1 count=1
@ -127,6 +129,8 @@ class ReportHDCaseSummary(Model):
weekday, prev_total_day=monthrange(prev_year, prev_month) weekday, prev_total_day=monthrange(prev_year, prev_month)
time_stop='%s-%s-%s'%(prev_year,str(prev_month).zfill(2),prev_total_day) time_stop='%s-%s-%s'%(prev_year,str(prev_month).zfill(2),prev_total_day)
dom.append(['reg_date','<=',time_stop]) dom.append(['reg_date','<=',time_stop])
dom.append(['walkin','=',"no"])
dom.append(['dispose','=',False])
if branch_id: if branch_id:
dom.append(['branch_id','=',branch_id]) dom.append(['branch_id','=',branch_id])
if department_id: if department_id:
@ -148,6 +152,8 @@ class ReportHDCaseSummary(Model):
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day) 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_start])
dom.append(['reg_date','<=',time_stop]) dom.append(['reg_date','<=',time_stop])
dom.append(['walkin','=',"no"])
dom.append(['dispose','=',False])
if branch_id: if branch_id:
dom.append(['branch_id','=',branch_id]) dom.append(['branch_id','=',branch_id])
if department_id: if department_id:
@ -168,6 +174,8 @@ class ReportHDCaseSummary(Model):
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day) 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_start])
dom.append(['resign_date','<=',time_stop]) dom.append(['resign_date','<=',time_stop])
dom.append(['walkin','=',"no"])
dom.append(['dispose','=',True])
if branch_id: if branch_id:
dom.append(['branch_id','=',branch_id]) dom.append(['branch_id','=',branch_id])
if department_id: if department_id:
@ -177,14 +185,12 @@ class ReportHDCaseSummary(Model):
for pt in get_model('clinic.patient').search_browse(dom): for pt in get_model('clinic.patient').search_browse(dom):
resign_patients_qty+=1 resign_patients_qty+=1
resign_patients.append(pt.name) resign_patients.append(pt.name)
del dom[-1]
dom=replace_quote('%s'%dom) dom=replace_quote('%s'%dom)
items['topic%s'%count]={ items['topic%s'%count]={
'month': month_str, 'month': month_str,
'qty': resign_patients_qty, 'qty': resign_patients_qty,
'action': 'clinic_patient', 'action': 'clinic_patient',
'action_options': 'mode=list&search_domain=%s&tab_no=2'%dom, 'action_options': 'mode=list&search_domain=%s&tab_no=3'%dom,
} }
count+=1 count+=1
# all patient who are in hospital on select month # all patient who are in hospital on select month
@ -196,6 +202,8 @@ class ReportHDCaseSummary(Model):
dom.append(['branch_id','=',branch_id]) dom.append(['branch_id','=',branch_id])
if department_id: if department_id:
dom.append(['department_id','=',department_id]) dom.append(['department_id','=',department_id])
dom.append(['walkin','=',"no"])
dom.append(['dispose','=',False])
total_patient=get_model('clinic.patient').search_browse(dom) total_patient=get_model('clinic.patient').search_browse(dom)
dom=replace_quote('%s'%dom) dom=replace_quote('%s'%dom)
total_patient_qty=len(total_patient) or 0 total_patient_qty=len(total_patient) or 0
@ -223,16 +231,22 @@ class ReportHDCaseSummary(Model):
time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day) time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
dom.append(['reg_date','<=',time_stop]) dom.append(['reg_date','<=',time_stop])
dom.append(['type_id','=',ptype['id']]) dom.append(['type_id','=',ptype['id']])
dom.append(['name','not in', resign_patients]) if branch_id:
dom.append(['branch_id','=',branch_id])
if department_id:
dom.append(['department_id','=',department_id])
dom.append(['walkin','=',"no"])
dom.append(['dispose','=',False])
npatients_qty=0 npatients_qty=0
for pt in get_model("clinic.patient").search(dom): for pt in get_model("clinic.patient").search(dom):
npatients_qty+=1 npatients_qty+=1
dom=replace_quote('%s'%dom) dom=replace_quote('%s'%dom)
print(">>> <<< ", dom)
items[tkey]={ items[tkey]={
'month': '', 'month': '',
'qty': npatients_qty, 'qty': npatients_qty,
'action': 'clinic_patient', 'action': 'clinic_patient',
'action_options': 'mode=list&search_domain=%s'%dom, 'action_options': 'mode=list&tab_no=0&search_domain=%s'%dom,
} }
count+=1 count+=1
@ -306,5 +320,4 @@ class ReportHDCaseSummary(Model):
} }
} }
ReportHDCaseSummary.register() ReportHDCaseSummary.register()

View File

@ -206,7 +206,7 @@ class Staff(Model):
if res.get("department_ids"): if res.get("department_ids"):
dpt_ids=res['department_ids'] dpt_ids=res['department_ids']
else: else:
dpt_ids=res['department_id'] dpt_ids=[res['department_id']]
dpts=get_model("clinic.department").browse(dpt_ids) dpts=get_model("clinic.department").browse(dpt_ids)
code=','.join([dpt.code for dpt in dpts]) code=','.join([dpt.code for dpt in dpts])
return code return code