diff --git a/netforce_clinic/models/report_cycle_item.py b/netforce_clinic/models/report_cycle_item.py index 9d01d74..3e030d1 100644 --- a/netforce_clinic/models/report_cycle_item.py +++ b/netforce_clinic/models/report_cycle_item.py @@ -98,17 +98,20 @@ class ReportCycleItem(Model): ptypes={} for ptype in get_model("clinic.patient.type").search_read([],['name']): ptypes[ptype['name'] or ""]=0 + cycle_check={} for citem in get_model('clinic.cycle.item').search_browse(dom,order="date"): cycle=citem.cycle_id date=citem.date key='%s-%s'%(date,cycle.id) if key not in cycles.keys(): cycles[key]=[] + cycle_check[key]=0 for line in citem.lines: nurse=line.nurse_id cycles[key].append({ 'name': nurse.name, 'first_name': nurse.first_name or "", + 'cycle_item_id': citem.id, }) for hdcase in citem.hd_cases: if hdcase.state not in ('paid', 'waiting_payment'): @@ -120,6 +123,8 @@ class ReportCycleItem(Model): ptype=patient.type_id if ptype_id and ptype_id!=ptype.id: continue + key='%s-%s'%(hdcase.date,hdcase.cycle_id.id) + cycle_check[key]+=1 ptypes[ptype.name or ""]+=1 doctor=hdcase.doctor_id cycle=hdcase.cycle_id @@ -221,7 +226,6 @@ class ReportCycleItem(Model): sub_mdc+=x['mdc'] or 0 if not epos.get(x['mdc_name']): epos[x['mdc_name']]=0 - #XXX if not epos.get(x['iron_name']): epos[x['iron_name']]=0 epos[x['iron_name']]+=x['total_ivr'] or 0 #XXX @@ -245,10 +249,20 @@ class ReportCycleItem(Model): key='%s-%s'%(date,cid) cres=cycles[key] line['nurse']='' + more_lines=[] if index < len(cres): line['nurse']=cres[index]['name'] line['nfirst_name']=cres[index]['first_name'] + if index+1==cycle_check[key]: + for i in range(index+1,len(cres)): + more_lines.append({ + 'nurse': cres[i]['name'], + 'nfirst_name': cres[i]['first_name'], + 'ctid': cres[i]['cycle_item_id'], + }) nlines.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 ] nlines.append({