improve cycle item
							parent
							
								
									fdef5622f3
								
							
						
					
					
						commit
						e204d4c135
					
				| 
						 | 
					@ -139,6 +139,13 @@ class ReportCycleItem(Model):
 | 
				
			||||||
                    number=number.replace("HDC/","")
 | 
					                    number=number.replace("HDC/","")
 | 
				
			||||||
                    number=number.replace("HDC-","")
 | 
					                    number=number.replace("HDC-","")
 | 
				
			||||||
                    return number
 | 
					                    return number
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                total_epo=0
 | 
				
			||||||
 | 
					                for line in hdcase.lines:
 | 
				
			||||||
 | 
					                    prod=line.product_id
 | 
				
			||||||
 | 
					                    if prod.categ_id.code=='EPO':
 | 
				
			||||||
 | 
					                        total_epo+=line.qty or 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                lines.append({
 | 
					                lines.append({
 | 
				
			||||||
                   'dlz_drop': dlz_drop,
 | 
					                   'dlz_drop': dlz_drop,
 | 
				
			||||||
                   'cancel': cancel,
 | 
					                   'cancel': cancel,
 | 
				
			||||||
| 
						 | 
					@ -170,6 +177,7 @@ class ReportCycleItem(Model):
 | 
				
			||||||
                   'tid': ptype.id,
 | 
					                   'tid': ptype.id,
 | 
				
			||||||
                   'dpt_id': dpt.id,
 | 
					                   'dpt_id': dpt.id,
 | 
				
			||||||
                   'dpt_name': dpt.name or "",
 | 
					                   'dpt_name': dpt.name or "",
 | 
				
			||||||
 | 
					                   'total_epo': total_epo,
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
        month_str=utils.MONTHS['th_TH'][int(month)]
 | 
					        month_str=utils.MONTHS['th_TH'][int(month)]
 | 
				
			||||||
        company_name=company.name or ""
 | 
					        company_name=company.name or ""
 | 
				
			||||||
| 
						 | 
					@ -190,6 +198,7 @@ class ReportCycleItem(Model):
 | 
				
			||||||
        sub_fee=0
 | 
					        sub_fee=0
 | 
				
			||||||
        sub_mdc=0
 | 
					        sub_mdc=0
 | 
				
			||||||
        pt=0
 | 
					        pt=0
 | 
				
			||||||
 | 
					        total_epos={}
 | 
				
			||||||
        for line in sorted(lines,key=lambda x:(x['date'],x['cseq'])):
 | 
					        for line in sorted(lines,key=lambda x:(x['date'],x['cseq'])):
 | 
				
			||||||
            pt+=1
 | 
					            pt+=1
 | 
				
			||||||
            date=line['date'] or ''
 | 
					            date=line['date'] or ''
 | 
				
			||||||
| 
						 | 
					@ -199,10 +208,14 @@ class ReportCycleItem(Model):
 | 
				
			||||||
                count=0
 | 
					                count=0
 | 
				
			||||||
                sub_fee=1
 | 
					                sub_fee=1
 | 
				
			||||||
                sub_mdc=0
 | 
					                sub_mdc=0
 | 
				
			||||||
 | 
					                epos={}
 | 
				
			||||||
                for x in lines:
 | 
					                for x in lines:
 | 
				
			||||||
                    if x['cseq']==line['cseq'] and x['date']==date:
 | 
					                    if x['cseq']==line['cseq'] and x['date']==date:
 | 
				
			||||||
                        sub_fee+=x['fee'] or 0
 | 
					                        sub_fee+=x['fee'] or 0
 | 
				
			||||||
                        sub_mdc+=x['mdc'] or 0
 | 
					                        sub_mdc+=x['mdc'] or 0
 | 
				
			||||||
 | 
					                        if not epos.get(x['mdc_name']):
 | 
				
			||||||
 | 
					                            epos[x['mdc_name']]=0
 | 
				
			||||||
 | 
					                        epos[x['mdc_name']]+=x['total_epo'] or 0
 | 
				
			||||||
                        count+=1
 | 
					                        count+=1
 | 
				
			||||||
                line['date_txt']=line['date']
 | 
					                line['date_txt']=line['date']
 | 
				
			||||||
                line['cseq_txt']=line['cseq']
 | 
					                line['cseq_txt']=line['cseq']
 | 
				
			||||||
| 
						 | 
					@ -227,6 +240,7 @@ class ReportCycleItem(Model):
 | 
				
			||||||
                line['nfirst_name']=cres[index]['first_name']
 | 
					                line['nfirst_name']=cres[index]['first_name']
 | 
				
			||||||
            nlines.append(line)
 | 
					            nlines.append(line)
 | 
				
			||||||
            if no==count:
 | 
					            if no==count:
 | 
				
			||||||
 | 
					                epo_items=[{'name': k, 'qty': v} for k,v in epos.items() if k ]
 | 
				
			||||||
                nlines.append({
 | 
					                nlines.append({
 | 
				
			||||||
                    'sub': 'show',
 | 
					                    'sub': 'show',
 | 
				
			||||||
                    'sub_txt': 'รวม',
 | 
					                    'sub_txt': 'รวม',
 | 
				
			||||||
| 
						 | 
					@ -234,7 +248,13 @@ class ReportCycleItem(Model):
 | 
				
			||||||
                    'no': count,
 | 
					                    'no': count,
 | 
				
			||||||
                    'fee': sub_fee,
 | 
					                    'fee': sub_fee,
 | 
				
			||||||
                    'mdc': sub_mdc,
 | 
					                    'mdc': sub_mdc,
 | 
				
			||||||
 | 
					                    'epo_items': epo_items,
 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
 | 
					                for epo_item in epo_items:
 | 
				
			||||||
 | 
					                    if not total_epos.get(epo_item['name']):
 | 
				
			||||||
 | 
					                        total_epos[epo_item['name']]=0
 | 
				
			||||||
 | 
					                    total_epos[epo_item['name']]+=epo_item['qty'] or 0
 | 
				
			||||||
 | 
					        total_epo_items=[{'name': k, 'qty': v} for k,v in total_epos.items() if k ]
 | 
				
			||||||
        vscl_lines=[]
 | 
					        vscl_lines=[]
 | 
				
			||||||
        for k,v in vasculars.items():
 | 
					        for k,v in vasculars.items():
 | 
				
			||||||
            vscl_lines.append({
 | 
					            vscl_lines.append({
 | 
				
			||||||
| 
						 | 
					@ -275,6 +295,8 @@ class ReportCycleItem(Model):
 | 
				
			||||||
            'total_fee': total_fee,
 | 
					            'total_fee': total_fee,
 | 
				
			||||||
            'total_mdc': total_mdc,
 | 
					            'total_mdc': total_mdc,
 | 
				
			||||||
            'total_pt': total_pt,
 | 
					            'total_pt': total_pt,
 | 
				
			||||||
 | 
					            'total_epo': sum([x['qty'] for x in total_epo_items]),
 | 
				
			||||||
 | 
					            'total_epo_items': total_epo_items,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return data
 | 
					        return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -44,40 +44,59 @@
 | 
				
			||||||
                    <td><a href="/ui#name=clinic_cycle_item&active_id={{ctid}}&mode=form">{{nfirst_name}}</a></td>
 | 
					                    <td><a href="/ui#name=clinic_cycle_item&active_id={{ctid}}&mode=form">{{nfirst_name}}</a></td>
 | 
				
			||||||
                {{else}}
 | 
					                {{else}}
 | 
				
			||||||
                    {{#ifeq sub "show"}}
 | 
					                    {{#ifeq sub "show"}}
 | 
				
			||||||
                        <td>รวม</td>
 | 
					                        <td>ผู้ป่วย | ยาฉีด</td>
 | 
				
			||||||
 | 
					                        <td></td>
 | 
				
			||||||
 | 
					                        <td style="text-align:center">{{no}}</td>
 | 
				
			||||||
 | 
					                        <td colspan="9">
 | 
				
			||||||
 | 
					                            {{#each epo_items}}
 | 
				
			||||||
 | 
					                                {{name}} : {{qty}}    
 | 
				
			||||||
 | 
					                            {{/each}}
 | 
				
			||||||
 | 
					                        </td>
 | 
				
			||||||
                    {{else}}
 | 
					                    {{else}}
 | 
				
			||||||
                        <td></td>
 | 
					                        <td></td>
 | 
				
			||||||
 | 
					                        <td></td>
 | 
				
			||||||
 | 
					                        <td style="text-align:center">{{no}}</td>
 | 
				
			||||||
 | 
					                        <td style="width:6%"><a href="/ui#name=clinic_hd_case&active_id={{hdcase_id}}&mode=form">{{hdcase_number}}</a></td>
 | 
				
			||||||
 | 
					                        <td><a href="/ui#name=clinic_patient&active_id={{pid}}&mode=form">{{pname}}</a></td>
 | 
				
			||||||
 | 
					                        <td><a href="/ui#name=clinic_staff&active_id={{did}}&mode=form">{{dname}}</a></td>
 | 
				
			||||||
 | 
					                        <td><a href="/ui#name=clinic_patient_type&active_id={{tid}}&mode=form">{{tname}}</a></td>
 | 
				
			||||||
 | 
					                        <td style="text-align:left">{{mdc_name}}</td>
 | 
				
			||||||
 | 
					                        <td style="text-align:right">{{hct}}</td>
 | 
				
			||||||
 | 
					                        <td><a href="/ui#name=clinic_dialyzer&active_id={{dlz_id}}&mode=form">{{dlz_name}}</a></td>
 | 
				
			||||||
 | 
					                        <td>{{dlz_use}}</td>
 | 
				
			||||||
 | 
					                        <td><a href="/ui#name=clinic_cycle_item&active_id={{ctid}}&mode=form">{{nfirst_name}}</a></td>
 | 
				
			||||||
                    {{/ifeq}}
 | 
					                    {{/ifeq}}
 | 
				
			||||||
                    <td></td>
 | 
					 | 
				
			||||||
                    <td style="text-align:center">{{no}}</td>
 | 
					 | 
				
			||||||
                    <td style="width:6%"><a href="/ui#name=clinic_hd_case&active_id={{hdcase_id}}&mode=form">{{hdcase_number}}</a></td>
 | 
					 | 
				
			||||||
                    <td><a href="/ui#name=clinic_patient&active_id={{pid}}&mode=form">{{pname}}</a></td>
 | 
					 | 
				
			||||||
                    <td><a href="/ui#name=clinic_staff&active_id={{did}}&mode=form">{{dname}}</a></td>
 | 
					 | 
				
			||||||
                    <td><a href="/ui#name=clinic_patient_type&active_id={{tid}}&mode=form">{{tname}}</a></td>
 | 
					 | 
				
			||||||
                    <td style="text-align:left">{{mdc_name}}</td>
 | 
					 | 
				
			||||||
                    <td style="text-align:right">{{hct}}</td>
 | 
					 | 
				
			||||||
                    <td><a href="/ui#name=clinic_dialyzer&active_id={{dlz_id}}&mode=form">{{dlz_name}}</a></td>
 | 
					 | 
				
			||||||
                    <td>{{dlz_use}}</td>
 | 
					 | 
				
			||||||
                    <td><a href="/ui#name=clinic_cycle_item&active_id={{ctid}}&mode=form">{{nfirst_name}}</a></td>
 | 
					 | 
				
			||||||
                {{/if}}
 | 
					                {{/if}}
 | 
				
			||||||
            </tr>
 | 
					            </tr>
 | 
				
			||||||
        {{/each}}
 | 
					        {{/each}}
 | 
				
			||||||
    </tbody>
 | 
					        <tr>
 | 
				
			||||||
    <tfoot>
 | 
					            <th class="active">ผู้ป่วยทั้งหมด</th>
 | 
				
			||||||
        <th rowspan="2" class="active">รวมผู้ป่วยทั้งหมด</th>
 | 
					            <th class="active"></th>
 | 
				
			||||||
        <th rowspan="2" class="active"></th>
 | 
					            <th class="active">{{total_pt}}</th>
 | 
				
			||||||
        <th class="active">{{total_pt}}</th>
 | 
					            <th colspan="9" class="active">
 | 
				
			||||||
        <th colspan="8" class="active">
 | 
					                <p>
 | 
				
			||||||
            <p>
 | 
					                    {{#each ptype_lines}}
 | 
				
			||||||
                {{#each ptype_lines}}
 | 
					                        {{name}} : {{qty}}    
 | 
				
			||||||
                    {{name}} : {{qty}}    
 | 
					                    {{/each}}
 | 
				
			||||||
 | 
					                </p>
 | 
				
			||||||
 | 
					                <p>
 | 
				
			||||||
 | 
					                    {{#each vscl_lines}}
 | 
				
			||||||
 | 
					                        {{description}} = {{qty}}    
 | 
				
			||||||
 | 
					                    {{/each}}
 | 
				
			||||||
 | 
					                </p>
 | 
				
			||||||
 | 
					            </th>
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
 | 
					        <tr>
 | 
				
			||||||
 | 
					            <th class="active">ยาฉีดทั้งหมด</th>
 | 
				
			||||||
 | 
					            <th class="active"></th>
 | 
				
			||||||
 | 
					            <th class="active">{{total_epo}}</th>
 | 
				
			||||||
 | 
					            <th colspan="9" class="active">
 | 
				
			||||||
 | 
					                <p>
 | 
				
			||||||
 | 
					                {{#each total_epo_items}}
 | 
				
			||||||
 | 
					                    {{name}} = {{qty}}    
 | 
				
			||||||
                {{/each}}
 | 
					                {{/each}}
 | 
				
			||||||
            </p>
 | 
					                </p>
 | 
				
			||||||
            <p>
 | 
					            </th>
 | 
				
			||||||
            {{#each vscl_lines}}
 | 
					        </tr>
 | 
				
			||||||
                {{description}} = {{qty}}    
 | 
					    </tbody>
 | 
				
			||||||
            {{/each}}
 | 
					 | 
				
			||||||
            </p>
 | 
					 | 
				
			||||||
        </th>
 | 
					 | 
				
			||||||
    </tfoot>
 | 
					 | 
				
			||||||
</table>
 | 
					</table>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue