diff --git a/netforce_clinic/models/report_cycle_item.py b/netforce_clinic/models/report_cycle_item.py
index ebf89a2..d715663 100644
--- a/netforce_clinic/models/report_cycle_item.py
+++ b/netforce_clinic/models/report_cycle_item.py
@@ -19,6 +19,7 @@ class ReportCycleItem(Model):
"ptype_id": fields.Many2One("clinic.patient.type","Patient Type"),
'branch_id': fields.Many2One("clinic.branch","Branch"),
'department_id': fields.Many2One("clinic.department","Department"),
+ 'sort_by': fields.Selection([['hdcase_number','HDCase Number'],['pname','Patient Name'],['mdc_name','EPO']],'Sort By'),
}
def default_get(self,field_names=None,context={},**kw):
@@ -51,6 +52,7 @@ class ReportCycleItem(Model):
'branch_id': branch_id,
'department_id': department_id,
'ptype_id': ptype_id,
+ 'sort_by': 'mdc_name',
}
print('report.cycle.item.defautls', res)
return res
@@ -67,6 +69,7 @@ class ReportCycleItem(Model):
print('date_from ', date_from)
month=date_from.split("-")[1]
cycle_id=None
+ sort_by='mdc_name'
if ids:
obj=self.browse(ids)[0]
month=obj.date_from.split("-")[1]
@@ -76,6 +79,7 @@ class ReportCycleItem(Model):
department_id=obj.department_id.id
cycle_id=obj.cycle_id.id
ptype_id=obj.ptype_id.id
+ sort_by=obj.sort_by or 'mdc_name'
# new patient of this month
dom=[]
dom.append(['date','>=',date_from])
@@ -201,6 +205,7 @@ class ReportCycleItem(Model):
branch=get_model("clinic.branch").browse(branch_id)
company_name+=" ("+branch.name+")"
nlines=[]
+ clines=[]
index=0
old=[]
total_fee=0
@@ -266,11 +271,47 @@ class ReportCycleItem(Model):
'nfirst_name': cres[i]['first_name'],
'ctid': cres[i]['cycle_item_id'],
})
- nlines.append(line)
+ #nlines.append(line)
+ clines.append(line)
# if nurse more that cres, should show name of nurses
nlines+=more_lines
if no==count:
epo_items=[{'name': k, 'qty': v} for k,v in epos.items() if k ]
+ #sort item
+ clines=sorted(clines,key=lambda cl: cl[sort_by])
+ no=1
+ index=len(nlines)
+ date_txt=''
+ cseq_txt=''
+ nurse_items=[]
+ for cline in clines:
+ if cline.get('nfirst_name'):
+ nurse_items.append({
+ 'nurse': cline.get('nurse'),
+ 'nfirst_name': cline.get('nfirst_name'),
+ 'ctid': cline.get('ctid'),
+ })
+ cline['nurse']=''
+ cline['nfirst_name']=''
+ cline['ctid']=''
+ if cline.get('cseq_txt'):
+ date_txt=cline.get('date_txt')
+ cseq_txt=cline.get('cseq_txt')
+ cline['date_txt']=''
+ cline['cseq_txt']=''
+ cline['no']=no
+ nlines.append(cline)
+ no+=1
+ nlines[index]['date_txt']=date_txt
+ nlines[index]['cseq_txt']=cseq_txt
+ for nurse_item in nurse_items:
+ nlines[index].update({
+ 'nurse': nurse_item['nurse'],
+ 'nfirst_name': nurse_item['nfirst_name'],
+ 'ctid': nurse_item['ctid'],
+ })
+ index+=1
+ clines=[]
nlines.append({
'sub': 'show',
'is_sub': True,