diff --git a/netforce_clinic/models/report_cycle_setting.py b/netforce_clinic/models/report_cycle_setting.py index 5dd0c52..f35239a 100644 --- a/netforce_clinic/models/report_cycle_setting.py +++ b/netforce_clinic/models/report_cycle_setting.py @@ -128,7 +128,6 @@ class ReportCycleSetting(Model): pts[key]['sun_cycle_id']=cycle.name lines=[] - no=1 for k, vals in pts.items(): pt_id, dpt_id=k if pt_id: @@ -138,12 +137,17 @@ class ReportCycleSetting(Model): dpt_id=pt.department_id.id if dpt_id: vals['department_id']=dpt_id - vals['no']=no lines.append(vals) - no+=1 + no=1 + nlines=[] + for line in sorted(lines,key=lambda x:x['patient_name']): + line['no']=no + nlines.append(line) + no+=1 + data={ - 'lines': lines, + 'lines': nlines, 'department_id': department_id, } return data