report hd case summary
							parent
							
								
									96a6d721f9
								
							
						
					
					
						commit
						88fa7ac039
					
				| 
						 | 
					@ -1,9 +1,10 @@
 | 
				
			||||||
<form model="clinic.report.hd.case.detail">
 | 
					<form model="clinic.report.hd.case.detail">
 | 
				
			||||||
    <!--<field name="date" span="3" mode="month" onchange="onchange_date"/>-->
 | 
					    <field name="date" mode="month" onchange="onchange_date" span="2"/>
 | 
				
			||||||
    <field name="date_from" onchange="onchange_date_from" span="2"/>
 | 
					    <field name="date_from" onchange="onchange_date_from" span="2"/>
 | 
				
			||||||
    <field name="date_to" span="2"/>
 | 
					    <field name="date_to" span="2"/>
 | 
				
			||||||
    <field name="patient_id" span="2"/>
 | 
					    <field name="patient_type_id" attrs='{"required":[["report_type","=","topic6"]]}' span="2"/>
 | 
				
			||||||
    <field name="patient_type_id" span="2"/>
 | 
					 | 
				
			||||||
    <field name="branch_id" span="2"/>
 | 
					    <field name="branch_id" span="2"/>
 | 
				
			||||||
    <field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
 | 
					    <field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
 | 
				
			||||||
 | 
					    <field name="report_type" span="6"/>
 | 
				
			||||||
 | 
					    <field name="hdcase_type" attrs='{"required":[["report_type","=","topic1"]]}' span="2"/>
 | 
				
			||||||
</form>
 | 
					</form>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,7 @@
 | 
				
			||||||
    <field name="date" span="2" mode="month" onchange="onchange_date"/>
 | 
					    <field name="date" span="2" mode="month" onchange="onchange_date"/>
 | 
				
			||||||
    <field name="date_from" span="2"/>
 | 
					    <field name="date_from" span="2"/>
 | 
				
			||||||
    <field name="date_to" span="2"/>
 | 
					    <field name="date_to" span="2"/>
 | 
				
			||||||
 | 
					    <field name="hdcase_type" required="1" span="2"/>
 | 
				
			||||||
    <field name="branch_id" onchange="onchange_branch" span="2"/>
 | 
					    <field name="branch_id" onchange="onchange_branch" span="2"/>
 | 
				
			||||||
    <field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
 | 
					    <field name="department_id" domain='[["branch_id","=",branch_id]]' span="2"/>
 | 
				
			||||||
    <field name="report_type" span="2"/>
 | 
					 | 
				
			||||||
</form>
 | 
					</form>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,78 +0,0 @@
 | 
				
			||||||
from netforce.model import Model, fields, get_model
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class HDCasePopupDlz(Model):
 | 
					 | 
				
			||||||
    _name="clinic.hd.case.popup.dlz"
 | 
					 | 
				
			||||||
    _transient=True
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    _fields={
 | 
					 | 
				
			||||||
        "hd_case_id": fields.Many2One("clinic.hd.case","HdCase",required=True,on_delete="cascade"),
 | 
					 | 
				
			||||||
        'product_id': fields.Many2One("product", "Product",required=True),
 | 
					 | 
				
			||||||
        "dialyzer_type": fields.Selection([("low","low flux"),("high","high flux"),("dbl","dbl hifulx")],"Dialyzer Type"),
 | 
					 | 
				
			||||||
        "max_use_time": fields.Integer("Max Use Time"),
 | 
					 | 
				
			||||||
        "exp_date": fields.Date("Expiry Date"),
 | 
					 | 
				
			||||||
        "note": fields.Text("Note"),
 | 
					 | 
				
			||||||
        "membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    def __get_hd_case_id(self,context={}):
 | 
					 | 
				
			||||||
        hd_case_id=context.get("refer_id")
 | 
					 | 
				
			||||||
        print("clinic.hd.case.popup.dlz default")
 | 
					 | 
				
			||||||
        if not hd_case_id:
 | 
					 | 
				
			||||||
            return None
 | 
					 | 
				
			||||||
        return int(hd_case_id)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def default_get(self,field_names=None,context={},**kw):
 | 
					 | 
				
			||||||
        defaults=context.get("defaults",{})
 | 
					 | 
				
			||||||
        hdcase_id=defaults.get('hd_case_id')
 | 
					 | 
				
			||||||
        dialyzer_type=defaults.get('dialyzer_type')
 | 
					 | 
				
			||||||
        if not hdcase_id:
 | 
					 | 
				
			||||||
            hdcase_id=context.get("refer_id")
 | 
					 | 
				
			||||||
        if hdcase_id:
 | 
					 | 
				
			||||||
            hdcase=get_model('clinic.hd.case').browse(hdcase_id)
 | 
					 | 
				
			||||||
            dom=[]
 | 
					 | 
				
			||||||
            for dlz in get_model('clinic.dialyzer').search_browse(dom):
 | 
					 | 
				
			||||||
                dialyzer_type=dlz.dialyzer_type or "low"
 | 
					 | 
				
			||||||
                pass
 | 
					 | 
				
			||||||
        res={
 | 
					 | 
				
			||||||
            'hd_case_id': hdcase_id,
 | 
					 | 
				
			||||||
            'dialyzer_type': 'low',
 | 
					 | 
				
			||||||
            'max_use_time': 10,
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        print('res', res)
 | 
					 | 
				
			||||||
        return res
 | 
					 | 
				
			||||||
    
 | 
					 | 
				
			||||||
    def new_dlz(self,ids,context={}):
 | 
					 | 
				
			||||||
        obj=self.browse(ids)[0]
 | 
					 | 
				
			||||||
        hd_case=obj.hd_case_id
 | 
					 | 
				
			||||||
        res={}
 | 
					 | 
				
			||||||
        if hd_case:
 | 
					 | 
				
			||||||
            context['is_wiz']=True
 | 
					 | 
				
			||||||
            context['pop_id']=obj.id
 | 
					 | 
				
			||||||
            res=hd_case.new_dialyzer(context=context)
 | 
					 | 
				
			||||||
        print('res ', res)
 | 
					 | 
				
			||||||
        return res
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    def onchange_product(self,context={}):
 | 
					 | 
				
			||||||
        data=context['data']
 | 
					 | 
				
			||||||
        hdcase_id=data['hd_case_id']
 | 
					 | 
				
			||||||
        patient=None
 | 
					 | 
				
			||||||
        if hdcase_id:
 | 
					 | 
				
			||||||
            hdcase=get_model('clinic.hd.case').browse(hdcase_id) 
 | 
					 | 
				
			||||||
            patient=hdcase.patient_id
 | 
					 | 
				
			||||||
        product_id=data['product_id']
 | 
					 | 
				
			||||||
        data['membrane_type']=None
 | 
					 | 
				
			||||||
        data['dialyzer_type']=None
 | 
					 | 
				
			||||||
        data['max_use_time']=10
 | 
					 | 
				
			||||||
        dom=[]
 | 
					 | 
				
			||||||
        if patient:
 | 
					 | 
				
			||||||
            dom.append(['patient_id','=',patient.id])
 | 
					 | 
				
			||||||
        for dlz in get_model("clinic.dialyzer").search_browse(dom):
 | 
					 | 
				
			||||||
            prod=dlz.product_id
 | 
					 | 
				
			||||||
            if prod.id==product_id:
 | 
					 | 
				
			||||||
                data['membrane_type']=dlz.membrane_type
 | 
					 | 
				
			||||||
                data['dialyzer_type']=dlz.dialyzer_type or "low"
 | 
					 | 
				
			||||||
                data['max_use_time']=dlz.max_use_time or 10
 | 
					 | 
				
			||||||
                break
 | 
					 | 
				
			||||||
        return data
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
HDCasePopupDlz.register()
 | 
					 | 
				
			||||||
| 
						 | 
					@ -28,8 +28,12 @@ class ReportCycleItem(Model):
 | 
				
			||||||
        date_from=defaults.get('date_from','%s-%s-01'%(year,month))
 | 
					        date_from=defaults.get('date_from','%s-%s-01'%(year,month))
 | 
				
			||||||
        date_to=defaults.get('date_to','%s-%s-01'%(year,month))
 | 
					        date_to=defaults.get('date_to','%s-%s-01'%(year,month))
 | 
				
			||||||
        branch_id=defaults.get('branch_id')
 | 
					        branch_id=defaults.get('branch_id')
 | 
				
			||||||
        ptype_id=defaults.get('ptype_id')
 | 
					        if branch_id:
 | 
				
			||||||
 | 
					            branch_id=int(branch_id)
 | 
				
			||||||
        department_id=defaults.get('department_id')
 | 
					        department_id=defaults.get('department_id')
 | 
				
			||||||
 | 
					        if department_id:
 | 
				
			||||||
 | 
					            department_id=int(department_id)
 | 
				
			||||||
 | 
					        ptype_id=defaults.get('ptype_id')
 | 
				
			||||||
        res=get_model('select.company').get_select()
 | 
					        res=get_model('select.company').get_select()
 | 
				
			||||||
        if res:
 | 
					        if res:
 | 
				
			||||||
            if not branch_id:
 | 
					            if not branch_id:
 | 
				
			||||||
| 
						 | 
					@ -45,8 +49,9 @@ class ReportCycleItem(Model):
 | 
				
			||||||
            'date_to': date_to,
 | 
					            'date_to': date_to,
 | 
				
			||||||
            'branch_id': branch_id,
 | 
					            'branch_id': branch_id,
 | 
				
			||||||
            'department_id': department_id,
 | 
					            'department_id': department_id,
 | 
				
			||||||
 | 
					            'ptype_id': ptype_id,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        print('res', res)
 | 
					        print('report.cycle.item.defautls', res)
 | 
				
			||||||
        return res
 | 
					        return res
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def get_report_data(self,ids,context={}):
 | 
					    def get_report_data(self,ids,context={}):
 | 
				
			||||||
| 
						 | 
					@ -122,9 +127,11 @@ class ReportCycleItem(Model):
 | 
				
			||||||
                    dlz_drop=True
 | 
					                    dlz_drop=True
 | 
				
			||||||
                cancel=False
 | 
					                cancel=False
 | 
				
			||||||
                row_color=''
 | 
					                row_color=''
 | 
				
			||||||
                if hdcase.state=='cancelled':
 | 
					                if hdcase.state not in ('paid', 'waiting_payment'):
 | 
				
			||||||
                    cancel=True
 | 
					                    continue
 | 
				
			||||||
                    row_color='#b6b6b6'
 | 
					                #if hdcase.state=='cancelled':
 | 
				
			||||||
 | 
					                    #cancel=True
 | 
				
			||||||
 | 
					                    #row_color='#b6b6b6'
 | 
				
			||||||
                lines.append({
 | 
					                lines.append({
 | 
				
			||||||
                   'dlz_drop': dlz_drop,
 | 
					                   'dlz_drop': dlz_drop,
 | 
				
			||||||
                   'cancel': cancel,
 | 
					                   'cancel': cancel,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,8 @@ from calendar import monthrange
 | 
				
			||||||
from netforce.model import Model,fields,get_model
 | 
					from netforce.model import Model,fields,get_model
 | 
				
			||||||
from netforce.access import get_active_company
 | 
					from netforce.access import get_active_company
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from . import utils
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ReportHDCaseDetail(Model):
 | 
					class ReportHDCaseDetail(Model):
 | 
				
			||||||
    _name="clinic.report.hd.case.detail"
 | 
					    _name="clinic.report.hd.case.detail"
 | 
				
			||||||
| 
						 | 
					@ -14,139 +16,332 @@ class ReportHDCaseDetail(Model):
 | 
				
			||||||
        "date": fields.Date("Month"),
 | 
					        "date": fields.Date("Month"),
 | 
				
			||||||
        "date_from": fields.Date("From", required=True),
 | 
					        "date_from": fields.Date("From", required=True),
 | 
				
			||||||
        "date_to": fields.Date("To", required=True),
 | 
					        "date_to": fields.Date("To", required=True),
 | 
				
			||||||
        'patient_type_id': fields.Many2One("clinic.patient.type","Payers"),
 | 
					 | 
				
			||||||
        'patient_id': fields.Many2One("clinic.patient","Patient",domain=[['state','=','admit']]),
 | 
					 | 
				
			||||||
        'branch_id': fields.Many2One("clinic.branch","Branch"),
 | 
					        'branch_id': fields.Many2One("clinic.branch","Branch"),
 | 
				
			||||||
        'department_id': fields.Many2One("clinic.department","Department"),
 | 
					        'department_id': fields.Many2One("clinic.department","Department"),
 | 
				
			||||||
 | 
					        'patient_type_id': fields.Many2One("clinic.patient.type","Patient Type"),
 | 
				
			||||||
 | 
					        'hdcase_type': fields.Selection([['completed','Completed'],['not_completed','Not Completed']],"HDCase Type"),
 | 
				
			||||||
 | 
					        'report_type': fields.Selection([
 | 
				
			||||||
 | 
					                ['topic1','จำนวนครั้งการทำ Hemodialysis'],
 | 
				
			||||||
 | 
					                ['topic2','จำนวนผู้ป่วยยกมาจากเดือน'],
 | 
				
			||||||
 | 
					                ['topic3','จำนวนผู้ป่วยรับใหม่เดือน'],
 | 
				
			||||||
 | 
					                ['topic4','จำนวนผู้ป่วยจำหน่ายเดือน'],
 | 
				
			||||||
 | 
					                ['topic5','จำนวนผู้ป่วยยกไปเดือน'],
 | 
				
			||||||
 | 
					                ['topic6','ประเภทผู้ป่วย'],
 | 
				
			||||||
 | 
					            ],"Repor Type",required=True),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _get_date_from(self,context={}):
 | 
					    def default_get(self,field_names=None,context={},**kw):
 | 
				
			||||||
        return time.strftime("%Y-%m-%d")
 | 
					        defaults=context.get("defaults",{})
 | 
				
			||||||
 | 
					        date=defaults.get('date',time.strftime("%Y-%m-%d"))
 | 
				
			||||||
    def _get_date_to(self,context={}):
 | 
					        year,month=time.strftime("%Y-%m").split("-")
 | 
				
			||||||
        return time.strftime("%Y-%m-%d")
 | 
					        weekday, total_day=monthrange(int(year), int(month))
 | 
				
			||||||
 | 
					        date_from=defaults.get('date_from','%s-%s-01'%(year,month))
 | 
				
			||||||
    _defaults={
 | 
					        date_to=defaults.get('date_to',"%s-%s-%s"%(year,month,total_day))
 | 
				
			||||||
        'date': lambda *a: time.strftime("%Y-%m-%d"),
 | 
					        report_type=defaults.get('report_type',"topic1")
 | 
				
			||||||
        'date_from': _get_date_from,
 | 
					        if report_type:
 | 
				
			||||||
        'date_to': _get_date_to,
 | 
					            index=''
 | 
				
			||||||
 | 
					            for r in report_type:
 | 
				
			||||||
 | 
					                if r.isdigit():
 | 
				
			||||||
 | 
					                    index+=r
 | 
				
			||||||
 | 
					            if int(index)>=6:
 | 
				
			||||||
 | 
					                report_type='topic6'
 | 
				
			||||||
 | 
					        branch_id=defaults.get('branch_id',None)
 | 
				
			||||||
 | 
					        hdcase_type=defaults.get("hdcase_type","completed")
 | 
				
			||||||
 | 
					        patient_type_id=defaults.get('patient_type_id')
 | 
				
			||||||
 | 
					        if patient_type_id:
 | 
				
			||||||
 | 
					            patient_type_id=int(patient_type_id)
 | 
				
			||||||
 | 
					        select_dpt=get_model('select.company').get_select()
 | 
				
			||||||
 | 
					        if not branch_id:
 | 
				
			||||||
 | 
					            if select_dpt:
 | 
				
			||||||
 | 
					                branch_id=select_dpt['branch_id']
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            branch_id=int(branch_id or "0")
 | 
				
			||||||
 | 
					        department_id=defaults.get('department_id',None)
 | 
				
			||||||
 | 
					        if not department_id:
 | 
				
			||||||
 | 
					            if select_dpt.get('department_ids'):
 | 
				
			||||||
 | 
					                department_id=select_dpt['department_ids'][0]
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
 | 
					                department_id=select_dpt['department_id']
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            department_id=int(department_id)
 | 
				
			||||||
 | 
					        res={
 | 
				
			||||||
 | 
					            'date': date,
 | 
				
			||||||
 | 
					            'date_from': date_from,
 | 
				
			||||||
 | 
					            'date_to': date_to,
 | 
				
			||||||
 | 
					            'branch_id': branch_id,
 | 
				
			||||||
 | 
					            'department_id': department_id,
 | 
				
			||||||
 | 
					            'report_type': report_type,
 | 
				
			||||||
 | 
					            'hdcase_type': hdcase_type,
 | 
				
			||||||
 | 
					            'patient_type_id': patient_type_id,
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        #print('report.hd.case.detail.defaults ', res)
 | 
				
			||||||
 | 
					        return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_report_data(self,ids,context={}):
 | 
					    def get_report_data(self,ids,context={}):
 | 
				
			||||||
        company_id=get_active_company()
 | 
					        company_id=get_active_company()
 | 
				
			||||||
        company=get_model('company').browse(company_id)
 | 
					        company=get_model("company").browse(company_id)
 | 
				
			||||||
        date_from=time.strftime("%Y-%m-%d")
 | 
					        defaults=self.default_get(context=context)
 | 
				
			||||||
        date_to=time.strftime("%Y-%m-%d")
 | 
					        date=defaults.get('date',time.strftime("%Y-%m-%d"))
 | 
				
			||||||
        ptype_id=None
 | 
					        year=int(date[0:4])
 | 
				
			||||||
        pid=None
 | 
					        crr_month=int(date[5:7])
 | 
				
			||||||
        dpt_id=None
 | 
					        weekday, crr_total_day=monthrange(year, crr_month)
 | 
				
			||||||
        bid=None
 | 
					        date_from=defaults.get('date_from',date)
 | 
				
			||||||
 | 
					        date_to=defaults.get('date_to',date)
 | 
				
			||||||
 | 
					        branch_id=defaults.get("branch_id",None)
 | 
				
			||||||
 | 
					        department_id=defaults.get("department_id",None)
 | 
				
			||||||
 | 
					        hdcase_type=defaults.get('hdcase_type')
 | 
				
			||||||
 | 
					        report_type=defaults.get('report_type','topic1')
 | 
				
			||||||
 | 
					        patient_type_id=defaults.get('patient_type_id')
 | 
				
			||||||
 | 
					        time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
 | 
				
			||||||
 | 
					        time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
 | 
				
			||||||
 | 
					        titles=dict(self._fields['report_type'].selection)
 | 
				
			||||||
 | 
					        title=titles.get(report_type,'no title')
 | 
				
			||||||
        if ids:
 | 
					        if ids:
 | 
				
			||||||
            obj=self.browse(ids)[0]
 | 
					            obj=self.browse(ids)[0]
 | 
				
			||||||
 | 
					            branch_id=obj.branch_id.id
 | 
				
			||||||
 | 
					            department_id=obj.department_id.id
 | 
				
			||||||
 | 
					            date=obj.date 
 | 
				
			||||||
 | 
					            crr_month=int(date[5:7])
 | 
				
			||||||
 | 
					            time_start=obj.date_from
 | 
				
			||||||
 | 
					            time_stop=obj.date_to
 | 
				
			||||||
 | 
					            year=int(date[0:4])
 | 
				
			||||||
            date_from=obj.date_from
 | 
					            date_from=obj.date_from
 | 
				
			||||||
            date_to=obj.date_to
 | 
					            date_to=obj.date_to
 | 
				
			||||||
            pid=obj.patient_id.id
 | 
					            report_type=obj.report_type or 'topic1'
 | 
				
			||||||
            ptype_id=obj.patient_type_id.id
 | 
					            hdcase_type=obj.hdcase_type or 'completed'
 | 
				
			||||||
            dpt_id=obj.department_id.id
 | 
					            patient_type_id=obj.patient_type_id.id
 | 
				
			||||||
            bid=obj.branch_id.id
 | 
					        prev_year=year
 | 
				
			||||||
        lines=[]
 | 
					        next_year=year
 | 
				
			||||||
 | 
					        prev_month=crr_month-1
 | 
				
			||||||
 | 
					        next_month=crr_month+1
 | 
				
			||||||
 | 
					        if crr_month==1:
 | 
				
			||||||
 | 
					            prev_month=12
 | 
				
			||||||
 | 
					            prev_year-=1
 | 
				
			||||||
 | 
					        if crr_month==12:
 | 
				
			||||||
 | 
					            next_month=1
 | 
				
			||||||
 | 
					            next_year+=1
 | 
				
			||||||
 | 
					        month_str=utils.MONTHS['th_TH'][crr_month]
 | 
				
			||||||
 | 
					        next_month_str=utils.MONTHS['th_TH'][next_month]
 | 
				
			||||||
 | 
					        prev_month_str=utils.MONTHS['th_TH'][prev_month]
 | 
				
			||||||
 | 
					              
 | 
				
			||||||
 | 
					        def replace_quote(dom=""):
 | 
				
			||||||
 | 
					            dom=dom.replace("False","false")
 | 
				
			||||||
 | 
					            dom=dom.replace("True","true")
 | 
				
			||||||
 | 
					            return dom.replace("'","\"")
 | 
				
			||||||
        dom=[]
 | 
					        dom=[]
 | 
				
			||||||
        dom.append(['date','>=',date_from])
 | 
					        lines=[]
 | 
				
			||||||
        dom.append(['date','<=',date_to])
 | 
					        total=0
 | 
				
			||||||
        if pid:
 | 
					        # current hd case
 | 
				
			||||||
            dom.append(['patient_id','=',pid])
 | 
					        if report_type=='topic1':
 | 
				
			||||||
        if ptype_id:
 | 
					            title=titles.get(report_type,'no title')
 | 
				
			||||||
            dom.append(['patient_type_id','=',ptype_id])
 | 
					            dom=[]
 | 
				
			||||||
        if dpt_id:
 | 
					            dom.append(["date",">=",date_from])
 | 
				
			||||||
            dom.append(['department_id','=',dpt_id])
 | 
					            dom.append(["date","<=",date_to])
 | 
				
			||||||
        if bid:
 | 
					            if hdcase_type=='completed':
 | 
				
			||||||
            dom.append(['branch_id','=',bid])
 | 
					                dom.append(["state","in",["waiting_payment","paid"]])
 | 
				
			||||||
 | 
					 | 
				
			||||||
        draft=0
 | 
					 | 
				
			||||||
        wait_treat=0
 | 
					 | 
				
			||||||
        wait_pay=0
 | 
					 | 
				
			||||||
        in_progress=0
 | 
					 | 
				
			||||||
        finish_treat=0
 | 
					 | 
				
			||||||
        cancel=0
 | 
					 | 
				
			||||||
        paid=0
 | 
					 | 
				
			||||||
        no=1
 | 
					 | 
				
			||||||
        for hdcase in get_model("clinic.hd.case").search_browse(dom):
 | 
					 | 
				
			||||||
            state=hdcase.state
 | 
					 | 
				
			||||||
            if state=='in_progress':
 | 
					 | 
				
			||||||
                in_progress+=1
 | 
					 | 
				
			||||||
            elif state=='paid':
 | 
					 | 
				
			||||||
                paid+=1
 | 
					 | 
				
			||||||
            elif state=='cancelled':
 | 
					 | 
				
			||||||
                cancel+=1
 | 
					 | 
				
			||||||
            elif state=='waiting_treatment':
 | 
					 | 
				
			||||||
                wait_treat+=1
 | 
					 | 
				
			||||||
            elif state=='waiting_payment':
 | 
					 | 
				
			||||||
                wait_pay+=1
 | 
					 | 
				
			||||||
            elif state=='completed':
 | 
					 | 
				
			||||||
                finish_treat+=1
 | 
					 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                draft+=1
 | 
					                dom.append(["state","not in",["waiting_payment","paid"]])
 | 
				
			||||||
                
 | 
					            if branch_id:
 | 
				
			||||||
            epo=[]
 | 
					                dom.append(['branch_id','=',branch_id])
 | 
				
			||||||
            fee_amt=0
 | 
					            if department_id:
 | 
				
			||||||
            dlz_new='N'
 | 
					                dom.append(['department_id','=',department_id])
 | 
				
			||||||
            for dlz in hdcase.dialyzers:
 | 
					            total=0
 | 
				
			||||||
                if dlz.use_time==1:
 | 
					            for hdcase in get_model("clinic.hd.case").search_browse(dom,order="number"):
 | 
				
			||||||
                    dlz_new='Y'
 | 
					 | 
				
			||||||
            for line in hdcase.lines:
 | 
					 | 
				
			||||||
                prod=line.product_id
 | 
					 | 
				
			||||||
                categ=line.product_categ_id
 | 
					 | 
				
			||||||
                if categ.code=='EPO':
 | 
					 | 
				
			||||||
                    epo.append(line.description or '')
 | 
					 | 
				
			||||||
                elif categ.code=='FEE':
 | 
					 | 
				
			||||||
                    fee_amt+=line.amount 
 | 
					 | 
				
			||||||
            if not epo:
 | 
					 | 
				
			||||||
                epo='-'
 | 
					 | 
				
			||||||
            else:
 | 
					 | 
				
			||||||
                epo=', '.join([e for e in epo])
 | 
					 | 
				
			||||||
                patient=hdcase.patient_id
 | 
					                patient=hdcase.patient_id
 | 
				
			||||||
            rmb_amt=hdcase.rmb_amount or 0
 | 
					 | 
				
			||||||
            more_amt=hdcase.due_amount or 0
 | 
					 | 
				
			||||||
            rmb=0
 | 
					 | 
				
			||||||
            if rmb_amt > 0:
 | 
					 | 
				
			||||||
                rmb=1
 | 
					 | 
				
			||||||
                lines.append({
 | 
					                lines.append({
 | 
				
			||||||
                'no': no,
 | 
					                    'number': hdcase.number,
 | 
				
			||||||
                'number': hdcase.number or '',
 | 
					                    'date': hdcase.date,
 | 
				
			||||||
                'hd_case_id': hdcase.id or '',
 | 
					                    'name': patient.name,
 | 
				
			||||||
                'time_start': hdcase.time_start,
 | 
					                    'note': hdcase.note,
 | 
				
			||||||
                'epo': epo,
 | 
					 | 
				
			||||||
                'patient_name': patient.name,
 | 
					 | 
				
			||||||
                'patient_id': patient.id,
 | 
					 | 
				
			||||||
                'patient_number': patient.number or '',
 | 
					 | 
				
			||||||
                'patient_type': patient.type_id.name or '',
 | 
					 | 
				
			||||||
                'hct': hdcase.hct or 0,
 | 
					 | 
				
			||||||
                'rmb': rmb,
 | 
					 | 
				
			||||||
                'more_amt': more_amt,
 | 
					 | 
				
			||||||
                'fee_amt': fee_amt,
 | 
					 | 
				
			||||||
                'dlz_new': dlz_new,
 | 
					 | 
				
			||||||
                })
 | 
					                })
 | 
				
			||||||
 | 
					                total+=1 
 | 
				
			||||||
 | 
					        # number of patient from previous month
 | 
				
			||||||
 | 
					        elif report_type=='topic2':
 | 
				
			||||||
 | 
					            title=titles.get(report_type,'no title')
 | 
				
			||||||
 | 
					            title+=' '+prev_month_str
 | 
				
			||||||
 | 
					            prev_weekday, prev_total_day=monthrange(prev_year, prev_month)
 | 
				
			||||||
 | 
					            reg_date='%s-%s-%s'%(prev_year,str(prev_month).zfill(2),str(prev_total_day).zfill(2))
 | 
				
			||||||
 | 
					            print('topic2 ', reg_date)
 | 
				
			||||||
 | 
					            dom=[]
 | 
				
			||||||
 | 
					            dom.append(['reg_date','<=',reg_date])
 | 
				
			||||||
 | 
					            dom.append(['walkin','=',"no"])
 | 
				
			||||||
 | 
					            #dom.append(['dispose','=',False])
 | 
				
			||||||
 | 
					            if branch_id:
 | 
				
			||||||
 | 
					                dom.append(['branch_id','=',branch_id])
 | 
				
			||||||
 | 
					            if department_id:
 | 
				
			||||||
 | 
					                dom.append(['department_id','=',department_id])
 | 
				
			||||||
 | 
					            total=0
 | 
				
			||||||
 | 
					            for patient in get_model("clinic.patient").search_browse(dom):
 | 
				
			||||||
 | 
					                if patient.dispose and patient.resign_date:
 | 
				
			||||||
 | 
					                    if patient.resign_date < date_from:
 | 
				
			||||||
 | 
					                        print('continue >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                        continue
 | 
				
			||||||
 | 
					                    elif patient.resign_date > date_to:
 | 
				
			||||||
 | 
					                        pass
 | 
				
			||||||
 | 
					                    elif not patient.resign_date > date_to:
 | 
				
			||||||
 | 
					                        print('pass >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                    elif not (patient.resign_date>=date_from and patient.resign_date<=date_to):
 | 
				
			||||||
 | 
					                        print('continue >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                        continue
 | 
				
			||||||
 | 
					                    print('pass >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                lines.append({
 | 
				
			||||||
 | 
					                    'number': patient.hn_no,
 | 
				
			||||||
 | 
					                    'pid': patient.id,
 | 
				
			||||||
 | 
					                    'name': patient.name,
 | 
				
			||||||
 | 
					                    'note': patient.note,
 | 
				
			||||||
 | 
					                    'date': patient.reg_date,
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                total+=1
 | 
				
			||||||
 | 
					        # new patient of this month
 | 
				
			||||||
 | 
					        elif report_type=='topic3':
 | 
				
			||||||
 | 
					            title=titles.get(report_type,'no title')
 | 
				
			||||||
 | 
					            title+=' '+month_str
 | 
				
			||||||
 | 
					            dom=[]
 | 
				
			||||||
 | 
					            dom.append(['reg_date','>=',time_start])
 | 
				
			||||||
 | 
					            dom.append(['reg_date','<=',time_stop])
 | 
				
			||||||
 | 
					            dom.append(['walkin','=',"no"])
 | 
				
			||||||
 | 
					            dom.append(['dispose','=',False])
 | 
				
			||||||
 | 
					            if branch_id:
 | 
				
			||||||
 | 
					                dom.append(['branch_id','=',branch_id])
 | 
				
			||||||
 | 
					            if department_id:
 | 
				
			||||||
 | 
					                dom.append(['department_id','=',department_id])
 | 
				
			||||||
 | 
					            total=0
 | 
				
			||||||
 | 
					            for patient in get_model('clinic.patient').search_browse(dom):
 | 
				
			||||||
 | 
					                #if patient.dispose and patient.resign_date < date_from:
 | 
				
			||||||
 | 
					                    #continue
 | 
				
			||||||
 | 
					                lines.append({
 | 
				
			||||||
 | 
					                    'number': patient.hn_no,
 | 
				
			||||||
 | 
					                    'pid': patient.id,
 | 
				
			||||||
 | 
					                    'name': patient.name,
 | 
				
			||||||
 | 
					                    'note': patient.note,
 | 
				
			||||||
 | 
					                    'date': patient.reg_date,
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                total+=1
 | 
				
			||||||
 | 
					        # number for patient who resign for this month
 | 
				
			||||||
 | 
					        elif report_type=='topic4':
 | 
				
			||||||
 | 
					            title=titles.get(report_type,'no title')
 | 
				
			||||||
 | 
					            title+=' '+month_str
 | 
				
			||||||
 | 
					            dom=[]
 | 
				
			||||||
 | 
					            dom.append(['resign_date','>=',time_start])
 | 
				
			||||||
 | 
					            dom.append(['resign_date','<=',time_stop])
 | 
				
			||||||
 | 
					            dom.append(['walkin','=',"no"])
 | 
				
			||||||
 | 
					            dom.append(['dispose','=',True])
 | 
				
			||||||
 | 
					            if branch_id:
 | 
				
			||||||
 | 
					                dom.append(['branch_id','=',branch_id])
 | 
				
			||||||
 | 
					            if department_id:
 | 
				
			||||||
 | 
					                dom.append(['department_id','=',department_id])
 | 
				
			||||||
 | 
					            total=0
 | 
				
			||||||
 | 
					            for patient in get_model('clinic.patient').search_browse(dom):
 | 
				
			||||||
 | 
					                lines.append({
 | 
				
			||||||
 | 
					                    'number': patient.hn_no,
 | 
				
			||||||
 | 
					                    'pid': patient.id,
 | 
				
			||||||
 | 
					                    'name': patient.name,
 | 
				
			||||||
 | 
					                    'note': patient.note,
 | 
				
			||||||
 | 
					                    'date': patient.resign_date,
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                total+=1
 | 
				
			||||||
 | 
					        # all patient who are in hospital on select month
 | 
				
			||||||
 | 
					        elif report_type=='topic5':
 | 
				
			||||||
 | 
					            title=titles.get(report_type,'no title')
 | 
				
			||||||
 | 
					            title+=' '+next_month_str
 | 
				
			||||||
 | 
					            dom=[]
 | 
				
			||||||
 | 
					            dom.append(['reg_date','<=',time_stop])
 | 
				
			||||||
 | 
					            print('topic5 ', time_stop)
 | 
				
			||||||
 | 
					            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])
 | 
				
			||||||
 | 
					            total=0
 | 
				
			||||||
 | 
					            for patient in get_model('clinic.patient').search_browse(dom,order="reg_date"):
 | 
				
			||||||
 | 
					                if patient.dispose and patient.resign_date:
 | 
				
			||||||
 | 
					                    if patient.resign_date < date_from:
 | 
				
			||||||
 | 
					                        print('1. continue >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                        continue
 | 
				
			||||||
 | 
					                    elif patient.resign_date > date_to:
 | 
				
			||||||
 | 
					                        pass
 | 
				
			||||||
 | 
					                    elif patient.resign_date > date_to:
 | 
				
			||||||
 | 
					                        print('2. pass >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                    elif (patient.resign_date>=date_from and patient.resign_date<=date_to):
 | 
				
			||||||
 | 
					                        print('3. continue >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                        continue
 | 
				
			||||||
 | 
					                    print('4. pass >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                lines.append({
 | 
				
			||||||
 | 
					                    'number': patient.hn_no,
 | 
				
			||||||
 | 
					                    'pid': patient.id,
 | 
				
			||||||
 | 
					                    'name': patient.name,
 | 
				
			||||||
 | 
					                    'note': patient.note,
 | 
				
			||||||
 | 
					                    'date': patient.reg_date,
 | 
				
			||||||
 | 
					                    'dispose': patient.dispose and 'yes' or 'no',
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                total+=1
 | 
				
			||||||
 | 
					        elif report_type=='topic6':
 | 
				
			||||||
 | 
					            #title=titles.get(report_type,'no title')
 | 
				
			||||||
 | 
					            ptype=None
 | 
				
			||||||
 | 
					            if patient_type_id:
 | 
				
			||||||
 | 
					                ptype=get_model('clinic.patient.type').browse(patient_type_id)
 | 
				
			||||||
 | 
					            if not ptype:
 | 
				
			||||||
 | 
					                return {'total': 0}
 | 
				
			||||||
 | 
					            title=ptype.name or ''
 | 
				
			||||||
 | 
					            dom=[]
 | 
				
			||||||
 | 
					            dom.append(['reg_date','<=',time_stop])
 | 
				
			||||||
 | 
					            dom.append(['type_id','=',ptype['id']])
 | 
				
			||||||
 | 
					            dom.append(['walkin','=',"no"])
 | 
				
			||||||
 | 
					            #dom.append(['dispose','=',False])
 | 
				
			||||||
 | 
					            dom.append(['type_id','=',ptype.id])
 | 
				
			||||||
 | 
					            if branch_id:
 | 
				
			||||||
 | 
					                dom.append(['branch_id','=',branch_id])
 | 
				
			||||||
 | 
					            if department_id:
 | 
				
			||||||
 | 
					                dom.append(['department_id','=',department_id])
 | 
				
			||||||
 | 
					            total=0
 | 
				
			||||||
 | 
					            print('topic6')
 | 
				
			||||||
 | 
					            for patient in get_model("clinic.patient").search_browse(dom):
 | 
				
			||||||
 | 
					                if patient.resign_date:
 | 
				
			||||||
 | 
					                    if patient.dispose and patient.resign_date < date_from:
 | 
				
			||||||
 | 
					                        print('1. continue >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                        continue
 | 
				
			||||||
 | 
					                    elif patient.resign_date > date_to:
 | 
				
			||||||
 | 
					                        pass
 | 
				
			||||||
 | 
					                    elif patient.resign_date > date_to:
 | 
				
			||||||
 | 
					                        print('2. pass >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                    elif (patient.resign_date>=date_from and patient.resign_date<=date_to):
 | 
				
			||||||
 | 
					                        print('3. continue >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                        continue
 | 
				
			||||||
 | 
					                    print('4. pass >>> ', patient.name, patient.resign_date, date_from, date_to)
 | 
				
			||||||
 | 
					                lines.append({
 | 
				
			||||||
 | 
					                    'pid': patient.id,
 | 
				
			||||||
 | 
					                    'number': patient.hn_no,
 | 
				
			||||||
 | 
					                    'name': patient.name or '',
 | 
				
			||||||
 | 
					                    'date': patient.reg_date,
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					                total+=1
 | 
				
			||||||
 | 
					        sub_name=''
 | 
				
			||||||
 | 
					        if department_id:
 | 
				
			||||||
 | 
					            dpt=get_model("clinic.department").browse(department_id)
 | 
				
			||||||
 | 
					            sub_name="(%s)" % dpt.name or ""
 | 
				
			||||||
 | 
					        elif branch_id:
 | 
				
			||||||
 | 
					            branch=get_model("clinic.branch").browse(branch_id)
 | 
				
			||||||
 | 
					            sub_name="(%s)" % branch.name or ""
 | 
				
			||||||
 | 
					        no=1
 | 
				
			||||||
 | 
					        for line in lines:
 | 
				
			||||||
 | 
					            line['no']="{0:,.0f}".format(no)
 | 
				
			||||||
            no+=1
 | 
					            no+=1
 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        sub_title=''
 | 
					 | 
				
			||||||
        if bid:
 | 
					 | 
				
			||||||
            sub_title+="%s "%(obj.branch_id.name or "")
 | 
					 | 
				
			||||||
        if dpt_id:
 | 
					 | 
				
			||||||
            sub_title+="%s "%(obj.department_id.name or "")
 | 
					 | 
				
			||||||
        data={
 | 
					        data={
 | 
				
			||||||
            'company_name': company.name or "",
 | 
					            'total_txt': "{0:,.0f}".format(total),
 | 
				
			||||||
            'parent_company_name': company.parent_id.name or "",
 | 
					            'total': total, 
 | 
				
			||||||
            'lines': lines,
 | 
					            'title': title,
 | 
				
			||||||
 | 
					            'report_type': report_type,
 | 
				
			||||||
 | 
					            'date': date,
 | 
				
			||||||
            'date_from': date_from,
 | 
					            'date_from': date_from,
 | 
				
			||||||
            'date_to': date_to,
 | 
					            'date_to': date_to,
 | 
				
			||||||
            'sub_title': sub_title,
 | 
					            'month': month_str,
 | 
				
			||||||
            'draft': draft,
 | 
					            'year': year,
 | 
				
			||||||
            'wait_treat': wait_treat,
 | 
					            'branch_id': branch_id,
 | 
				
			||||||
            'wait_pay': wait_pay,
 | 
					            'department_id': department_id,
 | 
				
			||||||
            'in_progress': in_progress,
 | 
					            'lines': lines,
 | 
				
			||||||
            'cancel': cancel,
 | 
					            'company_name': '%s %s'% (company.name or "", sub_name),
 | 
				
			||||||
            'paid': paid,
 | 
					            'parent_company_name': company.parent_id.name or "",
 | 
				
			||||||
            'finish_treat': finish_treat,
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return data
 | 
					        return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,7 +19,7 @@ class ReportHDCaseSummary(Model):
 | 
				
			||||||
        "date_to": fields.Date("To", required=True),
 | 
					        "date_to": fields.Date("To", required=True),
 | 
				
			||||||
        'branch_id': fields.Many2One("clinic.branch","Branch"),
 | 
					        'branch_id': fields.Many2One("clinic.branch","Branch"),
 | 
				
			||||||
        'department_id': fields.Many2One("clinic.department","Departments"),
 | 
					        'department_id': fields.Many2One("clinic.department","Departments"),
 | 
				
			||||||
        'report_type': fields.Selection([['completed','Completed'],['not_completed','Not Completed']],"Report Type"),
 | 
					        'hdcase_type': fields.Selection([['completed','Completed'],['not_completed','Not Completed']],"HDCase Type"),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _get_date_from(self,context={}):
 | 
					    def _get_date_from(self,context={}):
 | 
				
			||||||
| 
						 | 
					@ -50,7 +50,7 @@ class ReportHDCaseSummary(Model):
 | 
				
			||||||
        'date_to': _get_date_to,
 | 
					        'date_to': _get_date_to,
 | 
				
			||||||
        'branch_id': _get_branch,
 | 
					        'branch_id': _get_branch,
 | 
				
			||||||
        'department_id': _get_department,
 | 
					        'department_id': _get_department,
 | 
				
			||||||
        'report_type': 'completed',
 | 
					        'hdcase_type': 'completed',
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def get_report_data(self,ids,context={}):
 | 
					    def get_report_data(self,ids,context={}):
 | 
				
			||||||
| 
						 | 
					@ -65,25 +65,21 @@ class ReportHDCaseSummary(Model):
 | 
				
			||||||
        date_to=defaults.get('date_to',date)
 | 
					        date_to=defaults.get('date_to',date)
 | 
				
			||||||
        branch_id=defaults.get("branch_id",None)
 | 
					        branch_id=defaults.get("branch_id",None)
 | 
				
			||||||
        department_id=defaults.get("department_id",None)
 | 
					        department_id=defaults.get("department_id",None)
 | 
				
			||||||
        report_type=defaults.get('report_type','completed')
 | 
					        hdcase_type=defaults.get('hdcase_type','completed')
 | 
				
			||||||
        if branch_id:
 | 
					        if branch_id:
 | 
				
			||||||
            branch_id=branch_id[0]
 | 
					            branch_id=branch_id[0]
 | 
				
			||||||
        if department_id:
 | 
					        if department_id:
 | 
				
			||||||
            department_id=department_id[0]
 | 
					            department_id=department_id[0]
 | 
				
			||||||
        time_start='%s-%s-01 00:00:00'%(year,str(crr_month).zfill(2))
 | 
					 | 
				
			||||||
        time_stop='%s-%s-%s 23:59:59'%(year,str(crr_month).zfill(2),crr_total_day)
 | 
					 | 
				
			||||||
        if ids:
 | 
					        if ids:
 | 
				
			||||||
            obj=self.browse(ids)[0]
 | 
					            obj=self.browse(ids)[0]
 | 
				
			||||||
            branch_id=obj.branch_id.id
 | 
					            branch_id=obj.branch_id.id
 | 
				
			||||||
            department_id=obj.department_id.id
 | 
					            department_id=obj.department_id.id
 | 
				
			||||||
            date=obj.date 
 | 
					            date=obj.date 
 | 
				
			||||||
            crr_month=int(date[5:7]) #XXX
 | 
					            crr_month=int(date[5:7]) #XXX
 | 
				
			||||||
            time_start='%s 00:00:00'%obj.date_from
 | 
					 | 
				
			||||||
            time_stop='%s 23:59:59'%obj.date_to
 | 
					 | 
				
			||||||
            year=int(date[0:4])
 | 
					            year=int(date[0:4])
 | 
				
			||||||
            date_from=obj.date_from
 | 
					            date_from=obj.date_from
 | 
				
			||||||
            date_to=obj.date_to
 | 
					            date_to=obj.date_to
 | 
				
			||||||
            report_type=obj.report_type or 'completed'
 | 
					            hdcase_type=obj.hdcase_type or 'completed'
 | 
				
			||||||
        prev_year=year
 | 
					        prev_year=year
 | 
				
			||||||
        next_year=year
 | 
					        next_year=year
 | 
				
			||||||
        prev_month=crr_month-1
 | 
					        prev_month=crr_month-1
 | 
				
			||||||
| 
						 | 
					@ -105,171 +101,145 @@ class ReportHDCaseSummary(Model):
 | 
				
			||||||
            return dom
 | 
					            return dom
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        def replace_quote(dom=""):
 | 
					        def replace_quote(dom=""):
 | 
				
			||||||
            dom=dom.replace("False","false") #XXX
 | 
					            dom=dom.replace("False","false")
 | 
				
			||||||
            dom=dom.replace("True","true") #XXX
 | 
					            dom=dom.replace("True","true")
 | 
				
			||||||
            return dom.replace("'","\"")
 | 
					            return dom.replace("'","\"")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        count=1
 | 
					        def set_default(dom=[],topic='topic1'):
 | 
				
			||||||
 | 
					            dom_txt=''
 | 
				
			||||||
 | 
					            for f,op,v in dom:
 | 
				
			||||||
 | 
					                if 'in' in op: #XXX
 | 
				
			||||||
 | 
					                    continue
 | 
				
			||||||
 | 
					                dom_txt+='defaults.%s%s%s&'%(f,op,v)
 | 
				
			||||||
 | 
					            if date:
 | 
				
			||||||
 | 
					                dom_txt+='&defaults.date=%s'%date
 | 
				
			||||||
 | 
					            if date_from:
 | 
				
			||||||
 | 
					                dom_txt+='&defaults.date_from=%s'%date_from
 | 
				
			||||||
 | 
					            if date_to:
 | 
				
			||||||
 | 
					                dom_txt+='&defaults.date_to=%s'%date_to
 | 
				
			||||||
 | 
					            if topic:
 | 
				
			||||||
 | 
					                dom_txt+='&defaults.report_type=%s'%topic
 | 
				
			||||||
 | 
					            if hdcase_type:
 | 
				
			||||||
 | 
					                dom_txt+='&defaults.hdcase_type=%s'%hdcase_type
 | 
				
			||||||
 | 
					            return dom_txt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def set_ctx(dom=[],topic='topic1'):
 | 
				
			||||||
 | 
					            ctx={'defaults': {}}
 | 
				
			||||||
 | 
					            ctx['defaults'].update({
 | 
				
			||||||
 | 
					                'report_type': topic,
 | 
				
			||||||
 | 
					                'hdcase_type': hdcase_type,
 | 
				
			||||||
 | 
					                'date': date,
 | 
				
			||||||
 | 
					                'date_from': date_from,
 | 
				
			||||||
 | 
					                'date_to': date_to,
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					            for f,op,v in dom:
 | 
				
			||||||
 | 
					                if 'in' in op: #XXX
 | 
				
			||||||
 | 
					                    continue
 | 
				
			||||||
 | 
					                ctx['defaults'].update({
 | 
				
			||||||
 | 
					                    f: v,
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
 | 
					            return ctx
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # number of hd case of this month
 | 
					        # number of hd case of this month
 | 
				
			||||||
        dom=[]
 | 
					        dom=[]
 | 
				
			||||||
        dom.append(["date",">=",date_from])
 | 
					 | 
				
			||||||
        dom.append(["date","<=",date_to])
 | 
					 | 
				
			||||||
        if report_type=='completed':
 | 
					 | 
				
			||||||
            dom.append(["state","in",["waiting_payment","paid"]])
 | 
					 | 
				
			||||||
        else:
 | 
					 | 
				
			||||||
            dom.append(["state","not in",["waiting_payment","paid"]])
 | 
					 | 
				
			||||||
        #dom.append(['patient_id.walkin','=','no'])
 | 
					 | 
				
			||||||
        if branch_id:
 | 
					        if branch_id:
 | 
				
			||||||
            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])
 | 
				
			||||||
        crr_total=len(get_model("clinic.hd.case").search(dom))
 | 
					
 | 
				
			||||||
        print('---> dom ', dom)
 | 
					        topic='topic1'
 | 
				
			||||||
 | 
					        dom_txt=set_default(dom,topic)
 | 
				
			||||||
 | 
					        ctx=set_ctx(dom,topic) 
 | 
				
			||||||
        items={}
 | 
					        items={}
 | 
				
			||||||
        items['topic%s'%count]={
 | 
					        item_vals={
 | 
				
			||||||
                'month': month_str,
 | 
					                'month': month_str,
 | 
				
			||||||
                'qty': crr_total or 0,
 | 
					                'qty': get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total'],
 | 
				
			||||||
                'action': 'clinic_hd_case',
 | 
					                'link': 'clinic_report_cycle_item&%s'%dom_txt,
 | 
				
			||||||
                'action_options': 'mode=list&search_domain=%s&tab_no=0'%replace_quote('%s'%dom),
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        count+=1
 | 
					        if hdcase_type!='completed':
 | 
				
			||||||
 | 
					            item_vals['link']='clinic_report_hd_case_detail&%s'%dom_txt
 | 
				
			||||||
 | 
					        items[topic]=item_vals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # number of patient from previous
 | 
					        # number of patient from previous
 | 
				
			||||||
        dom=[]
 | 
					 | 
				
			||||||
        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)
 | 
					        topic='topic2'
 | 
				
			||||||
        dom.append(['reg_date','<=',time_stop])
 | 
					        dom_txt=set_default(dom,topic)
 | 
				
			||||||
        dom.append(['walkin','=',"no"])
 | 
					        ctx=set_ctx(dom,topic) 
 | 
				
			||||||
        dom.append(['dispose','=',False])
 | 
					        items[topic]={
 | 
				
			||||||
        if branch_id:
 | 
					 | 
				
			||||||
            dom.append(['branch_id','=',branch_id])
 | 
					 | 
				
			||||||
        if department_id:
 | 
					 | 
				
			||||||
            dom.append(['department_id','=',department_id])
 | 
					 | 
				
			||||||
        print("dom ==> ", dom)
 | 
					 | 
				
			||||||
        npatient=len(get_model("clinic.patient").search(dom))
 | 
					 | 
				
			||||||
        dom=replace_quote('%s'%dom)
 | 
					 | 
				
			||||||
        items['topic%s'%count]={
 | 
					 | 
				
			||||||
                'month': prev_month_str,
 | 
					                'month': prev_month_str,
 | 
				
			||||||
                'qty': npatient or 0,
 | 
					                'qty': get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total'],
 | 
				
			||||||
                'action': 'clinic_patient',
 | 
					                'link': 'clinic_report_hd_case_detail&%s'%dom_txt,
 | 
				
			||||||
                'action_options': 'mode=list&search_domain=%s'%dom,
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        count+=1
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        topic='topic3'
 | 
				
			||||||
 | 
					        dom_txt=set_default(dom,topic)
 | 
				
			||||||
 | 
					        ctx=set_ctx(dom,topic) 
 | 
				
			||||||
        # new patient of this month
 | 
					        # new patient of this month
 | 
				
			||||||
        dom=[]
 | 
					        items[topic]={
 | 
				
			||||||
        weekday, crr_total_day=monthrange(prev_year, crr_month)
 | 
					 | 
				
			||||||
        time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
 | 
					 | 
				
			||||||
        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_stop])
 | 
					 | 
				
			||||||
        dom.append(['walkin','=',"no"])
 | 
					 | 
				
			||||||
        dom.append(['dispose','=',False])
 | 
					 | 
				
			||||||
        if branch_id:
 | 
					 | 
				
			||||||
            dom.append(['branch_id','=',branch_id])
 | 
					 | 
				
			||||||
        if department_id:
 | 
					 | 
				
			||||||
            dom.append(['department_id','=',department_id])
 | 
					 | 
				
			||||||
        new_patients=get_model('clinic.patient').search_browse(dom)
 | 
					 | 
				
			||||||
        dom=replace_quote('%s'%dom)
 | 
					 | 
				
			||||||
        items['topic%s'%count]={
 | 
					 | 
				
			||||||
                'month': month_str,
 | 
					                'month': month_str,
 | 
				
			||||||
                'qty': len(new_patients) or 0,
 | 
					                'qty': get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total'],
 | 
				
			||||||
                'action': 'clinic_patient',
 | 
					                'action': 'clinic_patient',
 | 
				
			||||||
                'action_options': 'mode=list&search_domain=%s'%dom,
 | 
					                'link': 'clinic_report_hd_case_detail&%s'%dom_txt,
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        count+=1
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # number for patient who resign for this month
 | 
					        # number for patient who resign for this month
 | 
				
			||||||
        dom=[]
 | 
					        topic='topic4'
 | 
				
			||||||
        time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
 | 
					        dom_txt=set_default(dom,topic)
 | 
				
			||||||
        time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
 | 
					        ctx=set_ctx(dom,topic) 
 | 
				
			||||||
        dom.append(['resign_date','>=',time_start])
 | 
					        resign_qty=get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total']
 | 
				
			||||||
        dom.append(['resign_date','<=',time_stop])
 | 
					        items[topic]={
 | 
				
			||||||
        dom.append(['walkin','=',"no"])
 | 
					 | 
				
			||||||
        dom.append(['dispose','=',True])
 | 
					 | 
				
			||||||
        if branch_id:
 | 
					 | 
				
			||||||
            dom.append(['branch_id','=',branch_id])
 | 
					 | 
				
			||||||
        if department_id:
 | 
					 | 
				
			||||||
            dom.append(['department_id','=',department_id])
 | 
					 | 
				
			||||||
        resign_patients_qty=0
 | 
					 | 
				
			||||||
        resign_patients=[]
 | 
					 | 
				
			||||||
        for pt in get_model('clinic.patient').search_browse(dom):
 | 
					 | 
				
			||||||
            resign_patients_qty+=1
 | 
					 | 
				
			||||||
            resign_patients.append(pt.id)
 | 
					 | 
				
			||||||
        dom=replace_quote('%s'%dom)
 | 
					 | 
				
			||||||
        items['topic%s'%count]={
 | 
					 | 
				
			||||||
                'month': month_str,
 | 
					                'month': month_str,
 | 
				
			||||||
                'qty':  resign_patients_qty,
 | 
					                'qty': resign_qty,
 | 
				
			||||||
                'action': 'clinic_patient',
 | 
					                'action': 'clinic_patient',
 | 
				
			||||||
                'action_options': 'mode=list&search_domain=%s&tab_no=3'%dom,
 | 
					                'link': 'clinic_report_hd_case_detail&%s'%dom_txt,
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        count+=1
 | 
					 | 
				
			||||||
        # all patient who are in hospital on select month
 | 
					        # all patient who are in hospital on select month
 | 
				
			||||||
        dom=[]
 | 
					        topic='topic5'
 | 
				
			||||||
        weekday, crr_total_day=monthrange(year, crr_month)
 | 
					        dom_txt=set_default(dom,topic)
 | 
				
			||||||
        time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
 | 
					        ctx=set_ctx(dom,topic) 
 | 
				
			||||||
        dom.append(['reg_date','<=',time_stop])
 | 
					        total_qty=get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total']
 | 
				
			||||||
        if branch_id:
 | 
					
 | 
				
			||||||
            dom.append(['branch_id','=',branch_id])
 | 
					        items[topic]={
 | 
				
			||||||
        if 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)
 | 
					 | 
				
			||||||
        dom=replace_quote('%s'%dom)
 | 
					 | 
				
			||||||
        total_patient_qty=len(total_patient) or 0
 | 
					 | 
				
			||||||
        items['topic%s'%count]={
 | 
					 | 
				
			||||||
                'month': next_month_str,
 | 
					                'month': next_month_str,
 | 
				
			||||||
                'qty': total_patient_qty-resign_patients_qty,
 | 
					                #'qty': total_qty-resign_qty,
 | 
				
			||||||
 | 
					                'qty': total_qty,
 | 
				
			||||||
                'action': 'clinic_patient',
 | 
					                'action': 'clinic_patient',
 | 
				
			||||||
                'action_options': 'mode=list&search_domain=%s'%dom,
 | 
					                'link': 'clinic_report_hd_case_detail&%s'%dom_txt,
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        count+=1
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        topics=utils.TOPICS
 | 
					        topics=utils.TOPICS
 | 
				
			||||||
        for ptype in get_model("clinic.patient.type").search_read([[]],['name']):
 | 
					        count=6
 | 
				
			||||||
            tkey='topic%s'%count
 | 
					        for ptype in get_model("clinic.patient.type").search_browse([[]]):
 | 
				
			||||||
 | 
					            topic='topic%s'%count
 | 
				
			||||||
            topics.update({
 | 
					            topics.update({
 | 
				
			||||||
                tkey:{
 | 
					                topic:{
 | 
				
			||||||
                    'name': ptype['name'],
 | 
					                    'name': ptype.name,
 | 
				
			||||||
                    'unit': 'คน',
 | 
					                    'unit': 'คน',
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
            dom=[]
 | 
					            dom2=dom+[['patient_type_id','=',ptype.id]]
 | 
				
			||||||
            time_start='%s-%s-01'%(year,str(crr_month).zfill(2))
 | 
					            dom_txt=set_default(dom2,topic)
 | 
				
			||||||
            time_stop='%s-%s-%s'%(year,str(crr_month).zfill(2),crr_total_day)
 | 
					            ctx=set_ctx(dom2,topic) 
 | 
				
			||||||
            dom.append(['reg_date','<=',time_stop])
 | 
					            qty=get_model("clinic.report.hd.case.detail").get_report_data(ids=[],context=ctx)['total']
 | 
				
			||||||
            dom.append(['type_id','=',ptype['id']])
 | 
					            items[topic]={
 | 
				
			||||||
            dom.append(['walkin','=',"no"])
 | 
					 | 
				
			||||||
            dom.append(['dispose','=',False])
 | 
					 | 
				
			||||||
            if branch_id:
 | 
					 | 
				
			||||||
                dom.append(['branch_id','=',branch_id])
 | 
					 | 
				
			||||||
            if department_id:
 | 
					 | 
				
			||||||
                dom.append(['department_id','=',department_id])
 | 
					 | 
				
			||||||
            npatients_qty=0
 | 
					 | 
				
			||||||
            for pt in get_model("clinic.patient").search(dom):
 | 
					 | 
				
			||||||
                npatients_qty+=1
 | 
					 | 
				
			||||||
            dom=replace_quote('%s'%dom)
 | 
					 | 
				
			||||||
            items[tkey]={
 | 
					 | 
				
			||||||
                    'month': '',
 | 
					                    'month': '',
 | 
				
			||||||
                    'qty': npatients_qty,
 | 
					                    'qty': qty,
 | 
				
			||||||
                    'action': 'clinic_patient',
 | 
					                    'action': 'clinic_patient',
 | 
				
			||||||
                    'action_options': 'mode=list&tab_no=0&search_domain=%s'%dom,
 | 
					                    'link': 'clinic_report_hd_case_detail&%s'%dom_txt,
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            count+=1
 | 
					            count+=1
 | 
				
			||||||
 | 
					 | 
				
			||||||
        lines=[] 
 | 
					        lines=[] 
 | 
				
			||||||
        index=1
 | 
					        index=1
 | 
				
			||||||
        for item in items:
 | 
					        for item in items:
 | 
				
			||||||
            topic='topic%s'%index
 | 
					            topic='topic%s'%index
 | 
				
			||||||
            name=utils.TOPICS[topic]['name']
 | 
					            name=topics[topic]['name']
 | 
				
			||||||
            unit=utils.TOPICS[topic]['unit']
 | 
					            unit=topics[topic]['unit']
 | 
				
			||||||
            line=items[topic]
 | 
					            line=items[topic]
 | 
				
			||||||
            line['topic']=name
 | 
					            line['topic']=name
 | 
				
			||||||
            line['unit']=unit
 | 
					            line['unit']=unit
 | 
				
			||||||
            lines.append(line)
 | 
					            lines.append(line)
 | 
				
			||||||
            index+=1
 | 
					            index+=1
 | 
				
			||||||
        if report_type=='not_completed':
 | 
					        if hdcase_type=='not_completed':
 | 
				
			||||||
            lines[0]['topic']='%s (ไม่สำเร็จ)'%lines[0]['topic']
 | 
					            lines[0]['topic']='%s (ไม่สำเร็จ)'%lines[0]['topic']
 | 
				
			||||||
        context['defaults']={
 | 
					        context['defaults']={
 | 
				
			||||||
            'date': date,
 | 
					            'date': date,
 | 
				
			||||||
| 
						 | 
					@ -277,7 +247,7 @@ class ReportHDCaseSummary(Model):
 | 
				
			||||||
            'date_to': date_to,
 | 
					            'date_to': date_to,
 | 
				
			||||||
            'branch_id': branch_id,
 | 
					            'branch_id': branch_id,
 | 
				
			||||||
            'department_id': department_id,
 | 
					            'department_id': department_id,
 | 
				
			||||||
            'report_type': report_type,
 | 
					            'hdcase_type': hdcase_type,
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context)
 | 
					        medicals=get_model("clinic.report.medical.summary").get_report_data(ids=[],context=context)
 | 
				
			||||||
| 
						 | 
					@ -290,7 +260,7 @@ class ReportHDCaseSummary(Model):
 | 
				
			||||||
            branch=get_model("clinic.branch").browse(branch_id)
 | 
					            branch=get_model("clinic.branch").browse(branch_id)
 | 
				
			||||||
            sub_name="(%s)" % branch.name or ""
 | 
					            sub_name="(%s)" % branch.name or ""
 | 
				
			||||||
        data={
 | 
					        data={
 | 
				
			||||||
            'report_type': report_type,
 | 
					            'hdcase_type': hdcase_type,
 | 
				
			||||||
            'branch_id': branch_id,
 | 
					            'branch_id': branch_id,
 | 
				
			||||||
            'department_id': department_id,
 | 
					            'department_id': department_id,
 | 
				
			||||||
            'date_from': date_from,
 | 
					            'date_from': date_from,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -96,7 +96,7 @@ class VisitBoard(Model):
 | 
				
			||||||
            branch_id=obj.branch_id.id
 | 
					            branch_id=obj.branch_id.id
 | 
				
			||||||
        def auto_gen_visit(dom=[]):
 | 
					        def auto_gen_visit(dom=[]):
 | 
				
			||||||
            dom.append(['dispose','=',False])
 | 
					            dom.append(['dispose','=',False])
 | 
				
			||||||
            dom.append(['walkin','=','no'])
 | 
					            #dom.append(['walkin','=','no']) #XXX
 | 
				
			||||||
            def daterange(start_date, end_date):
 | 
					            def daterange(start_date, end_date):
 | 
				
			||||||
                for n in range(int ((end_date - start_date).days)):
 | 
					                for n in range(int ((end_date - start_date).days)):
 | 
				
			||||||
                    yield start_date + timedelta(n)
 | 
					                    yield start_date + timedelta(n)
 | 
				
			||||||
| 
						 | 
					@ -123,10 +123,9 @@ class VisitBoard(Model):
 | 
				
			||||||
                        department=pc.department_id
 | 
					                        department=pc.department_id
 | 
				
			||||||
                        if weekday==w:
 | 
					                        if weekday==w:
 | 
				
			||||||
                            dom2=[
 | 
					                            dom2=[
 | 
				
			||||||
                                ['visit_date','>=',date_txt],
 | 
					                                ['visit_date','=',date_txt],
 | 
				
			||||||
                                ['visit_date','<=',date_txt],
 | 
					 | 
				
			||||||
                                ['patient_id','=',pt.id],
 | 
					                                ['patient_id','=',pt.id],
 | 
				
			||||||
                                ['cycle_id','=',cycle.id],
 | 
					                                #['cycle_id','=',cycle.id], #XXX
 | 
				
			||||||
                                ['department_id','=',department.id],
 | 
					                                ['department_id','=',department.id],
 | 
				
			||||||
                            ]
 | 
					                            ]
 | 
				
			||||||
                            res=get_model("clinic.visit").search(dom2)
 | 
					                            res=get_model("clinic.visit").search(dom2)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -1,57 +1,43 @@
 | 
				
			||||||
<center>
 | 
					<center>
 | 
				
			||||||
    <h3>
 | 
					    <h3>
 | 
				
			||||||
        {{parent_company_name}} {{company_name}}
 | 
					        {{title}}
 | 
				
			||||||
    </h3>
 | 
					    </h3>
 | 
				
			||||||
    <h4>
 | 
					 | 
				
			||||||
        {{sub_title}}</br>
 | 
					 | 
				
			||||||
        From {{date_from}} To {{date_to}}
 | 
					 | 
				
			||||||
    </h4>
 | 
					 | 
				
			||||||
    <h5>Draft: {{draft}} Waiting Treatment: {{wait_treat}}, In progress : {{in_progress}}, Finish Treatment: {{finish_treat}}, Waiting Payment: {{wait_pay}} Paid: {{paid}}, Cancelled: {{cancel}} </h5>
 | 
					 | 
				
			||||||
</center>
 | 
					</center>
 | 
				
			||||||
<table class="table">
 | 
					<table class="table">
 | 
				
			||||||
    <thead class="scroll-header">
 | 
					    <thead class="scroll-header">
 | 
				
			||||||
        <th>#</th>
 | 
					        <tr>
 | 
				
			||||||
 | 
					            <th colspan="6" style="text-align:center">
 | 
				
			||||||
 | 
					                <span class="label label-primary">TOTAL: {{total_txt}}</span>
 | 
				
			||||||
 | 
					            </th>
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
 | 
					        <tr>
 | 
				
			||||||
 | 
					            <th style="text-align:left">#</th>
 | 
				
			||||||
 | 
					            <th>Date</th>
 | 
				
			||||||
            <th>Number</th>
 | 
					            <th>Number</th>
 | 
				
			||||||
        <th>BegHD</th>
 | 
					            <th>Name</th>
 | 
				
			||||||
        <th>Epo</th>
 | 
					            <th>Note</th>
 | 
				
			||||||
        <th>HN</th>
 | 
					            <th>Dispose</th>
 | 
				
			||||||
        <th>Patient</th>
 | 
					        </tr>
 | 
				
			||||||
        <th>Payers</th>
 | 
					 | 
				
			||||||
        <th>DlzNew</th>
 | 
					 | 
				
			||||||
        <th>HCT</th>
 | 
					 | 
				
			||||||
        <th>Paychk</th>
 | 
					 | 
				
			||||||
        <th>Amount</th>
 | 
					 | 
				
			||||||
        <th>HDCharge</th>
 | 
					 | 
				
			||||||
    </thead>
 | 
					    </thead>
 | 
				
			||||||
    <tbody>
 | 
					    <tbody>
 | 
				
			||||||
        {{#if lines}}
 | 
					 | 
				
			||||||
        {{#each lines}}
 | 
					        {{#each lines}}
 | 
				
			||||||
            <tr> 
 | 
					            <tr> 
 | 
				
			||||||
                    <td>{{no}}</td>
 | 
					                <td style="text-align:left;width:3%">{{no}}</td>
 | 
				
			||||||
                    <td>
 | 
					                <td style="width:10%">{{date}}</td>
 | 
				
			||||||
                        {{view "link" string=number action="clinic_hd_case" action_options="mode=form" active_id=hd_case_id}}
 | 
					                <td style="width:10%">{{number}}</td>
 | 
				
			||||||
                    </td>
 | 
					                <td>{{name}}</td>
 | 
				
			||||||
                    <td>{{time_start}}</td>
 | 
					                <td>{{note}}</td>
 | 
				
			||||||
                    <td>{{epo}}</td>
 | 
					                <td>{{dispose}}</td>
 | 
				
			||||||
                    <td>{{patient_number}}</td>
 | 
					 | 
				
			||||||
                    <td>
 | 
					 | 
				
			||||||
                        {{view "link" string=patient_name action="clinic_patient" action_options="mode=form" active_id=patient_id}}
 | 
					 | 
				
			||||||
                    </td>
 | 
					 | 
				
			||||||
                    <td>{{patient_type}}</td>
 | 
					 | 
				
			||||||
                    <td>{{dlz_new}}</td>
 | 
					 | 
				
			||||||
                    <td>{{hct}}</td>
 | 
					 | 
				
			||||||
                    <td>{{rmb}}</td>
 | 
					 | 
				
			||||||
                    <td>{{more_amt}}</td>
 | 
					 | 
				
			||||||
                    <td>{{fee_amt}}</td>
 | 
					 | 
				
			||||||
            </tr>
 | 
					            </tr>
 | 
				
			||||||
        {{/each}}
 | 
					        {{/each}}
 | 
				
			||||||
        {{else}}
 | 
					 | 
				
			||||||
            <tr>
 | 
					 | 
				
			||||||
                <td>
 | 
					 | 
				
			||||||
                    No items to display.
 | 
					 | 
				
			||||||
                </td>
 | 
					 | 
				
			||||||
            </tr>
 | 
					 | 
				
			||||||
        {{/if}}
 | 
					 | 
				
			||||||
    </tbody>
 | 
					    </tbody>
 | 
				
			||||||
 | 
					    <tfoot>
 | 
				
			||||||
 | 
					        <th></th>
 | 
				
			||||||
 | 
					        <th></th>
 | 
				
			||||||
 | 
					        <th></th>
 | 
				
			||||||
 | 
					        <th></th>
 | 
				
			||||||
 | 
					        <th></th>
 | 
				
			||||||
 | 
					        <th></th>
 | 
				
			||||||
 | 
					    </tfoot>
 | 
				
			||||||
</table>
 | 
					</table>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,12 +1,12 @@
 | 
				
			||||||
<center>
 | 
					<center>
 | 
				
			||||||
    <h2>
 | 
					    <h2>
 | 
				
			||||||
    ใบสรุปการทำ Hemodialysis
 | 
					        {{title}}
 | 
				
			||||||
    </h2>
 | 
					    </h2>
 | 
				
			||||||
    <h3>
 | 
					    <h3>
 | 
				
			||||||
        {{parent_company_name}} {{company_name}}<br/>
 | 
					        {{parent_company_name}} {{company_name}}<br/>
 | 
				
			||||||
    </h3>
 | 
					    </h3>
 | 
				
			||||||
    <h4>
 | 
					    <h4>
 | 
				
			||||||
        ประจำเดือน {{month}} {{year}}
 | 
					        From {{date_from}} To {{date_to}}
 | 
				
			||||||
    </h4>
 | 
					    </h4>
 | 
				
			||||||
</center>
 | 
					</center>
 | 
				
			||||||
<table class="table">
 | 
					<table class="table">
 | 
				
			||||||
| 
						 | 
					@ -25,7 +25,10 @@
 | 
				
			||||||
                <td>เท่ากับ</td>
 | 
					                <td>เท่ากับ</td>
 | 
				
			||||||
                {{#if qty}}
 | 
					                {{#if qty}}
 | 
				
			||||||
                    <td>
 | 
					                    <td>
 | 
				
			||||||
 | 
					                        <!--
 | 
				
			||||||
                        {{view "link" string=qty action=action action_options=action_options}}
 | 
					                        {{view "link" string=qty action=action action_options=action_options}}
 | 
				
			||||||
 | 
					                        -->
 | 
				
			||||||
 | 
					                        <a href='/ui#name={{link}}' target="_blank">{{qty}}</a>
 | 
				
			||||||
                    </td>
 | 
					                    </td>
 | 
				
			||||||
                {{else}}
 | 
					                {{else}}
 | 
				
			||||||
                    <td>
 | 
					                    <td>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,3 +8,6 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
> note:
 | 
					> note:
 | 
				
			||||||
    แก้ไขยาก หากมาเจอข้อผิดพลาดบางครั้ง
 | 
					    แก้ไขยาก หากมาเจอข้อผิดพลาดบางครั้ง
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					> report K. boy
 | 
				
			||||||
 | 
					    - number of treatment is not correct
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue