improve
							parent
							
								
									22f8dbda52
								
							
						
					
					
						commit
						e9253f1712
					
				| 
						 | 
					@ -2,5 +2,6 @@
 | 
				
			||||||
    <field name="string">New Dialyzer</field>
 | 
					    <field name="string">New Dialyzer</field>
 | 
				
			||||||
    <field name="view_cls">form_popup</field>
 | 
					    <field name="view_cls">form_popup</field>
 | 
				
			||||||
    <field name="model">clinic.hd.case.popup.dlz</field>
 | 
					    <field name="model">clinic.hd.case.popup.dlz</field>
 | 
				
			||||||
 | 
					    <field name="width">800</field>
 | 
				
			||||||
    <field name="target">_popup</field>
 | 
					    <field name="target">_popup</field>
 | 
				
			||||||
</action>
 | 
					</action>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,78 @@
 | 
				
			||||||
 | 
					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()
 | 
				
			||||||
| 
						 | 
					@ -133,3 +133,6 @@ from . import report_shop
 | 
				
			||||||
from . import account_tax_component
 | 
					from . import account_tax_component
 | 
				
			||||||
from . import report_thai_wht_certif
 | 
					from . import report_thai_wht_certif
 | 
				
			||||||
from . import num2word
 | 
					from . import num2word
 | 
				
			||||||
 | 
					from . import province
 | 
				
			||||||
 | 
					#from . import district
 | 
				
			||||||
 | 
					#from . import subdistrict
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					from netforce.model import Model, fields
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class District(Model):
 | 
				
			||||||
 | 
					    _inherit="district"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _get_sort_name(self,ids,context={}):
 | 
				
			||||||
 | 
					        res={}
 | 
				
			||||||
 | 
					        for obj in self.browse(ids):
 | 
				
			||||||
 | 
					            sname=''
 | 
				
			||||||
 | 
					            if obj.name:
 | 
				
			||||||
 | 
					                sname=obj.name[0:1]
 | 
				
			||||||
 | 
					            res[obj.id]=sname
 | 
				
			||||||
 | 
					        return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _fields={
 | 
				
			||||||
 | 
					        "name": fields.Char("Name",required=True,search=True,translate=True),
 | 
				
			||||||
 | 
					        "sort_name": fields.Char("Sort Name",function="_get_sort_name",store=True),
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    _order="sort_name asc"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					District.register()
 | 
				
			||||||
| 
						 | 
					@ -868,8 +868,8 @@ class HDCase(Model):
 | 
				
			||||||
        for obj in self.browse(ids):
 | 
					        for obj in self.browse(ids):
 | 
				
			||||||
            is_decrease=context.get('is_decrease')
 | 
					            is_decrease=context.get('is_decrease')
 | 
				
			||||||
            for dlz_line in obj.dialyzers:
 | 
					            for dlz_line in obj.dialyzers:
 | 
				
			||||||
                membrane_type=dlz_line.membrane_type or ''
 | 
					                membrane_type=dlz_line.membrane_type or 'unsub'
 | 
				
			||||||
                dialyzer_type=dlz_line.dialyzer_type or ''
 | 
					                dialyzer_type=dlz_line.dialyzer_type or 'low'
 | 
				
			||||||
                use_time=dlz_line.use_time or 0
 | 
					                use_time=dlz_line.use_time or 0
 | 
				
			||||||
                max_use_time=dlz_line.max_use_time or 0
 | 
					                max_use_time=dlz_line.max_use_time or 0
 | 
				
			||||||
                desc=dlz_line.description or ''
 | 
					                desc=dlz_line.description or ''
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,18 +14,40 @@ class HDCasePopupDlz(Model):
 | 
				
			||||||
        "membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
 | 
					        "membrane_type": fields.Selection([("unsub","Unsub cellul"),("sub","Sub cellul"),("synthetic","Synthetic")],"Membrane Type"),
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def _get_hd_case_id(self,context={}):
 | 
					    def __get_hd_case_id(self,context={}):
 | 
				
			||||||
        hd_case_id=context.get("refer_id")
 | 
					        hd_case_id=context.get("refer_id")
 | 
				
			||||||
        print("clinic.hd.case.popup.dlz default")
 | 
					        print("clinic.hd.case.popup.dlz default")
 | 
				
			||||||
        if not hd_case_id:
 | 
					        if not hd_case_id:
 | 
				
			||||||
            return None
 | 
					            return None
 | 
				
			||||||
        return int(hd_case_id)
 | 
					        return int(hd_case_id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    _defaults={
 | 
					    def default_get(self,field_names=None,context={},**kw):
 | 
				
			||||||
        'hd_case_id': _get_hd_case_id,
 | 
					        defaults=context.get("defaults",{})
 | 
				
			||||||
        'dialyzer_type': 'low',
 | 
					        hdcase_id=defaults.get('hd_case_id')
 | 
				
			||||||
        'max_use_time': 10,
 | 
					        dialyzer_type=defaults.get('dialyzer_type', "low")
 | 
				
			||||||
    }
 | 
					        membrane_type=defaults.get('membrane_type', "unsub")
 | 
				
			||||||
 | 
					        product_id=defaults.get('product_id', None)
 | 
				
			||||||
 | 
					        max_use_time=defaults.get('max_use_time', 10)
 | 
				
			||||||
 | 
					        if not hdcase_id:
 | 
				
			||||||
 | 
					            hdcase_id=context.get("refer_id")
 | 
				
			||||||
 | 
					        if hdcase_id:
 | 
				
			||||||
 | 
					            hdcase_id=int(hdcase_id)
 | 
				
			||||||
 | 
					            hdcase=get_model('clinic.hd.case').browse(hdcase_id)
 | 
				
			||||||
 | 
					            for line in hdcase.dialyzers:
 | 
				
			||||||
 | 
					                dlz=line.dialyzer_id
 | 
				
			||||||
 | 
					                product_id=dlz.product_id.id
 | 
				
			||||||
 | 
					                dialyzer_type=dlz.dialyzer_type or "low"
 | 
				
			||||||
 | 
					                membrane_type=dlz.membrane_type or "unsub"
 | 
				
			||||||
 | 
					                max_use_time=dlz.max_use_time or 10
 | 
				
			||||||
 | 
					        res={
 | 
				
			||||||
 | 
					            'hd_case_id': hdcase_id,
 | 
				
			||||||
 | 
					            'dialyzer_type': dialyzer_type,
 | 
				
			||||||
 | 
					            'membrane_type': membrane_type,
 | 
				
			||||||
 | 
					            'max_use_time': max_use_time,
 | 
				
			||||||
 | 
					            'product_id': product_id,
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        print('res', res)
 | 
				
			||||||
 | 
					        return res
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def new_dlz(self,ids,context={}):
 | 
					    def new_dlz(self,ids,context={}):
 | 
				
			||||||
        obj=self.browse(ids)[0]
 | 
					        obj=self.browse(ids)[0]
 | 
				
			||||||
| 
						 | 
					@ -40,17 +62,37 @@ class HDCasePopupDlz(Model):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def onchange_product(self,context={}):
 | 
					    def onchange_product(self,context={}):
 | 
				
			||||||
        data=context['data']
 | 
					        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']
 | 
					        product_id=data['product_id']
 | 
				
			||||||
        data['membrane_type']=None
 | 
					        data['membrane_type']=None
 | 
				
			||||||
        data['dialyzer_type']=None
 | 
					        data['dialyzer_type']=None
 | 
				
			||||||
        #data['max_use_time']=None
 | 
					        data['max_use_time']=10
 | 
				
			||||||
        for dlz in get_model("clinic.dialyzer").search_browse([]):
 | 
					        dom=[]
 | 
				
			||||||
 | 
					        if patient:
 | 
				
			||||||
 | 
					            dom.append(['patient_id','=',patient.id])
 | 
				
			||||||
 | 
					        count=0
 | 
				
			||||||
 | 
					        for dlz in get_model("clinic.dialyzer").search_browse(dom):
 | 
				
			||||||
            prod=dlz.product_id
 | 
					            prod=dlz.product_id
 | 
				
			||||||
            if prod.id==product_id:
 | 
					            if prod.id==product_id:
 | 
				
			||||||
 | 
					                count+=1
 | 
				
			||||||
                data['membrane_type']=dlz.membrane_type
 | 
					                data['membrane_type']=dlz.membrane_type
 | 
				
			||||||
                data['dialyzer_type']=dlz.dialyzer_type or "low"
 | 
					                data['dialyzer_type']=dlz.dialyzer_type or "low"
 | 
				
			||||||
                data['max_use_time']=dlz.max_use_time or 0
 | 
					                data['max_use_time']=dlz.max_use_time or 10
 | 
				
			||||||
                break
 | 
					                break
 | 
				
			||||||
 | 
					        # search from another patient
 | 
				
			||||||
 | 
					        if not count:
 | 
				
			||||||
 | 
					            dom=[]
 | 
				
			||||||
 | 
					            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
 | 
					        return data
 | 
				
			||||||
 | 
					
 | 
				
			||||||
HDCasePopupDlz.register()
 | 
					HDCasePopupDlz.register()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -328,6 +328,24 @@ class Patient(Model):
 | 
				
			||||||
        super().delete(ids)
 | 
					        super().delete(ids)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def write(self,ids,vals,**kw):
 | 
					    def write(self,ids,vals,**kw):
 | 
				
			||||||
 | 
					        if 'cycles' in vals.keys():
 | 
				
			||||||
 | 
					            index=0
 | 
				
			||||||
 | 
					            for cvals in vals['cycles']:
 | 
				
			||||||
 | 
					                mode=cvals[0]
 | 
				
			||||||
 | 
					                if mode=='delete':
 | 
				
			||||||
 | 
					                    continue
 | 
				
			||||||
 | 
					                elif mode=='create':
 | 
				
			||||||
 | 
					                    cycle_vals=cvals[1]
 | 
				
			||||||
 | 
					                elif mode=='write':
 | 
				
			||||||
 | 
					                    continue
 | 
				
			||||||
 | 
					                    cycle_vals=cvals[2]
 | 
				
			||||||
 | 
					                cdom=[]
 | 
				
			||||||
 | 
					                for f, v in cycle_vals.items():
 | 
				
			||||||
 | 
					                    cdom.append([f,'=',v])
 | 
				
			||||||
 | 
					                print('cdom ', cdom)
 | 
				
			||||||
 | 
					                for c in get_model('clinic.patient.cycle').search_browse(cdom):
 | 
				
			||||||
 | 
					                    c.delete()
 | 
				
			||||||
 | 
					                index+=1
 | 
				
			||||||
        if 'type_id' in vals.keys():
 | 
					        if 'type_id' in vals.keys():
 | 
				
			||||||
            #update patient in hd case which state is condition below
 | 
					            #update patient in hd case which state is condition below
 | 
				
			||||||
            for obj in self.browse(ids):
 | 
					            for obj in self.browse(ids):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					from netforce.model import Model, fields
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Province(Model):
 | 
				
			||||||
 | 
					    _inherit="province"
 | 
				
			||||||
 | 
					    def _get_sort_name(self,ids,context={}):
 | 
				
			||||||
 | 
					        res={}
 | 
				
			||||||
 | 
					        for obj in self.browse(ids):
 | 
				
			||||||
 | 
					            sname=''
 | 
				
			||||||
 | 
					            if obj.name:
 | 
				
			||||||
 | 
					                sname=obj.name[0:1]
 | 
				
			||||||
 | 
					            res[obj.id]=sname
 | 
				
			||||||
 | 
					        return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _fields={
 | 
				
			||||||
 | 
					        "name": fields.Char("Name",required=True,search=True,translate=True),
 | 
				
			||||||
 | 
					        "sort_name": fields.Char("Sort Name",function="_get_sort_name",store=True),
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    _order="sort_name asc"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Province.register()
 | 
				
			||||||
| 
						 | 
					@ -97,7 +97,10 @@ class ReportCycleItem(Model):
 | 
				
			||||||
                cycles[cycle.id]=[]
 | 
					                cycles[cycle.id]=[]
 | 
				
			||||||
                for line in citem.lines:
 | 
					                for line in citem.lines:
 | 
				
			||||||
                    nurse=line.nurse_id
 | 
					                    nurse=line.nurse_id
 | 
				
			||||||
                    cycles[cycle.id].append(nurse.name)
 | 
					                    cycles[cycle.id].append({
 | 
				
			||||||
 | 
					                        'name': nurse.name,
 | 
				
			||||||
 | 
					                        'first_name': nurse.first_name or "",
 | 
				
			||||||
 | 
					                        })
 | 
				
			||||||
            for hdcase in citem.hd_cases:
 | 
					            for hdcase in citem.hd_cases:
 | 
				
			||||||
                patient=hdcase.patient_id
 | 
					                patient=hdcase.patient_id
 | 
				
			||||||
                vascular=patient.vascular_acc
 | 
					                vascular=patient.vascular_acc
 | 
				
			||||||
| 
						 | 
					@ -116,11 +119,14 @@ class ReportCycleItem(Model):
 | 
				
			||||||
                    dlz_use="%sทิ้ง"%dlz_use
 | 
					                    dlz_use="%sทิ้ง"%dlz_use
 | 
				
			||||||
                    dlz_drop=True
 | 
					                    dlz_drop=True
 | 
				
			||||||
                cancel=False
 | 
					                cancel=False
 | 
				
			||||||
 | 
					                row_color=''
 | 
				
			||||||
                if hdcase.state=='cancelled':
 | 
					                if hdcase.state=='cancelled':
 | 
				
			||||||
                    cancel=True
 | 
					                    cancel=True
 | 
				
			||||||
 | 
					                    row_color='#b6b6b6'
 | 
				
			||||||
                lines.append({
 | 
					                lines.append({
 | 
				
			||||||
                   'dlz_drop': dlz_drop,
 | 
					                   'dlz_drop': dlz_drop,
 | 
				
			||||||
                   'cancel': cancel,
 | 
					                   'cancel': cancel,
 | 
				
			||||||
 | 
					                   'row_color': row_color,
 | 
				
			||||||
                   'pname': patient.name or '',
 | 
					                   'pname': patient.name or '',
 | 
				
			||||||
                   'pid': patient.id or '',
 | 
					                   'pid': patient.id or '',
 | 
				
			||||||
                   'hn': patient.hn_no,
 | 
					                   'hn': patient.hn_no,
 | 
				
			||||||
| 
						 | 
					@ -154,13 +160,38 @@ class ReportCycleItem(Model):
 | 
				
			||||||
        elif branch_id:
 | 
					        elif branch_id:
 | 
				
			||||||
            branch=get_model("clinic.branch").browse(branch_id)
 | 
					            branch=get_model("clinic.branch").browse(branch_id)
 | 
				
			||||||
            company_name+=" ("+branch.name+")"
 | 
					            company_name+=" ("+branch.name+")"
 | 
				
			||||||
        no=1
 | 
					 | 
				
			||||||
        nlines=[]
 | 
					        nlines=[]
 | 
				
			||||||
        index=0
 | 
					        index=0
 | 
				
			||||||
        old=[]
 | 
					        old=[]
 | 
				
			||||||
        total_fee=0
 | 
					        total_fee=0
 | 
				
			||||||
        total_mdc=0
 | 
					        total_mdc=0
 | 
				
			||||||
 | 
					        dates={}
 | 
				
			||||||
 | 
					        no=0
 | 
				
			||||||
 | 
					        count=0
 | 
				
			||||||
 | 
					        sub_fee=0
 | 
				
			||||||
 | 
					        sub_mdc=0
 | 
				
			||||||
 | 
					        pt=0
 | 
				
			||||||
        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
 | 
				
			||||||
 | 
					            date=line['date'] or ''
 | 
				
			||||||
 | 
					            key='%s-%s'%(date,line['cseq'])
 | 
				
			||||||
 | 
					            if key not in dates.keys():
 | 
				
			||||||
 | 
					                no=1
 | 
				
			||||||
 | 
					                count=0
 | 
				
			||||||
 | 
					                sub_fee=0
 | 
				
			||||||
 | 
					                sub_mdc=0
 | 
				
			||||||
 | 
					                for x in lines:
 | 
				
			||||||
 | 
					                    if x['cseq']==line['cseq'] and x['date']==date:
 | 
				
			||||||
 | 
					                        sub_fee+=x['fee'] or 0
 | 
				
			||||||
 | 
					                        sub_mdc+=x['mdc'] or 0
 | 
				
			||||||
 | 
					                        count+=1
 | 
				
			||||||
 | 
					                line['date_txt']=line['date']
 | 
				
			||||||
 | 
					                line['cseq_txt']=line['cseq']
 | 
				
			||||||
 | 
					                dates[key]=0
 | 
				
			||||||
 | 
					            else:
 | 
				
			||||||
 | 
					                no+=1
 | 
				
			||||||
 | 
					            dates[key]+=1
 | 
				
			||||||
 | 
					            line['no']=no
 | 
				
			||||||
            total_fee+=line.get("fee",0)
 | 
					            total_fee+=line.get("fee",0)
 | 
				
			||||||
            total_mdc+=line.get("mdc",0)
 | 
					            total_mdc+=line.get("mdc",0)
 | 
				
			||||||
            cid=line['cid']
 | 
					            cid=line['cid']
 | 
				
			||||||
| 
						 | 
					@ -172,10 +203,17 @@ class ReportCycleItem(Model):
 | 
				
			||||||
            cres=cycles[cid]
 | 
					            cres=cycles[cid]
 | 
				
			||||||
            line['nurse']=''
 | 
					            line['nurse']=''
 | 
				
			||||||
            if index < len(cres):
 | 
					            if index < len(cres):
 | 
				
			||||||
                line['nurse']=cres[index]
 | 
					                line['nurse']=cres[index]['name']
 | 
				
			||||||
            line['no']=no
 | 
					                line['nfirst_name']=cres[index]['first_name']
 | 
				
			||||||
            nlines.append(line)
 | 
					            nlines.append(line)
 | 
				
			||||||
            no+=1
 | 
					            if no==count:
 | 
				
			||||||
 | 
					                nlines.append({
 | 
				
			||||||
 | 
					                    'sub': 'show',
 | 
				
			||||||
 | 
					                    'row_color': '#dfdfdf',
 | 
				
			||||||
 | 
					                    'no': count,
 | 
				
			||||||
 | 
					                    'fee': sub_fee,
 | 
				
			||||||
 | 
					                    'mdc': sub_mdc,
 | 
				
			||||||
 | 
					                })
 | 
				
			||||||
        vscl_lines=[]
 | 
					        vscl_lines=[]
 | 
				
			||||||
        for k,v in vasculars.items():
 | 
					        for k,v in vasculars.items():
 | 
				
			||||||
            vscl_lines.append({
 | 
					            vscl_lines.append({
 | 
				
			||||||
| 
						 | 
					@ -198,6 +236,7 @@ class ReportCycleItem(Model):
 | 
				
			||||||
            'month': month_str,
 | 
					            'month': month_str,
 | 
				
			||||||
            'date_from': date_from,
 | 
					            'date_from': date_from,
 | 
				
			||||||
            'date_to': date_to,
 | 
					            'date_to': date_to,
 | 
				
			||||||
 | 
					            'total_pt': pt,
 | 
				
			||||||
            'total_fee': total_fee,
 | 
					            'total_fee': total_fee,
 | 
				
			||||||
            'total_mdc': total_mdc,
 | 
					            'total_mdc': total_mdc,
 | 
				
			||||||
            'total_pt': total_pt,
 | 
					            'total_pt': total_pt,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -161,15 +161,21 @@ class ClinicSetting(Model):
 | 
				
			||||||
        if user_id !=1:
 | 
					        if user_id !=1:
 | 
				
			||||||
            print("Only admin!!")
 | 
					            print("Only admin!!")
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
        for sline in get_model("clinic.hd.case.staff").search_browse([]):
 | 
					        for pv in get_model("province").search_browse([]):
 | 
				
			||||||
            hdcase=sline.hd_case_id
 | 
					            name=(pv.name or "")[0:1]
 | 
				
			||||||
            sline.write({
 | 
					            pv.write({
 | 
				
			||||||
                'date': hdcase.date,
 | 
					                'sort_name': name,
 | 
				
			||||||
            })
 | 
					            })
 | 
				
			||||||
            print('update ', sline.id, hdcase.date)
 | 
					        #for dt in get_model("district").search_browse([]):
 | 
				
			||||||
        #obj=self.browse(ids)[0]
 | 
					            #name=(dt.name or "")[0:1]
 | 
				
			||||||
        #obj.del_duplicate_staff()
 | 
					            #dt.write({
 | 
				
			||||||
        #obj.merge_staff()
 | 
					                #'sort_name': name,
 | 
				
			||||||
 | 
					            #})
 | 
				
			||||||
 | 
					        #for sdt in get_model("subdistrict").search_browse([]):
 | 
				
			||||||
 | 
					            #name=(sdt.name or "")[0:1]
 | 
				
			||||||
 | 
					            #sdt.write({
 | 
				
			||||||
 | 
					                #'sort_name': name,
 | 
				
			||||||
 | 
					            #})
 | 
				
			||||||
        print("Done!")
 | 
					        print("Done!")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def merge_staff(self,ids,context={}):
 | 
					    def merge_staff(self,ids,context={}):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,21 @@
 | 
				
			||||||
 | 
					from netforce.model import Model, fields
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class SubDistrict(Model):
 | 
				
			||||||
 | 
					    _inherit="subdistrict"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _get_sort_name(self,ids,context={}):
 | 
				
			||||||
 | 
					        res={}
 | 
				
			||||||
 | 
					        for obj in self.browse(ids):
 | 
				
			||||||
 | 
					            sname=''
 | 
				
			||||||
 | 
					            if obj.name:
 | 
				
			||||||
 | 
					                sname=obj.name[0:1]
 | 
				
			||||||
 | 
					            res[obj.id]=sname
 | 
				
			||||||
 | 
					        return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    _fields={
 | 
				
			||||||
 | 
					        "name": fields.Char("Name",required=True,search=True,translate=True),
 | 
				
			||||||
 | 
					        "sort_name": fields.Char("Sort Name",function="_get_sort_name",store=True),
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    _order="sort_name asc"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SubDistrict.register()
 | 
				
			||||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -4,16 +4,16 @@
 | 
				
			||||||
        ระหว่างวันที่ {{date_from}} ถึง {{date_to}}
 | 
					        ระหว่างวันที่ {{date_from}} ถึง {{date_to}}
 | 
				
			||||||
    </h4>
 | 
					    </h4>
 | 
				
			||||||
</center>
 | 
					</center>
 | 
				
			||||||
<table class="table table-condensed table-striped">
 | 
					<table class="table table-condensed table-striped" style="margin-bottom:0px;">
 | 
				
			||||||
    <thead>
 | 
					    <thead>
 | 
				
			||||||
        <th>#</th>
 | 
					 | 
				
			||||||
        <th>วันที่</th>
 | 
					        <th>วันที่</th>
 | 
				
			||||||
        <th>รอบ</th>
 | 
					        <th>รอบ</th>
 | 
				
			||||||
 | 
					        <th>No</th>
 | 
				
			||||||
        <th>ชื่อ-สกุล</th>
 | 
					        <th>ชื่อ-สกุล</th>
 | 
				
			||||||
        <th>แพทย์</th>
 | 
					        <th>แพทย์</th>
 | 
				
			||||||
        <th>สิทธ์</th>
 | 
					        <th>สิทธ์</th>
 | 
				
			||||||
        <th style="text-align:right">จ.น.เงิน</th>
 | 
					        <th style="text-align:right">จ.น.เงิน</th>
 | 
				
			||||||
        <th>ยาฉีด</th>
 | 
					        <th style="text-align:right">ยาฉีด</th>
 | 
				
			||||||
        <th>DZ</th>
 | 
					        <th>DZ</th>
 | 
				
			||||||
        <th>N/U</th>
 | 
					        <th>N/U</th>
 | 
				
			||||||
        <th>พยาบาล</th>
 | 
					        <th>พยาบาล</th>
 | 
				
			||||||
| 
						 | 
					@ -22,39 +22,70 @@
 | 
				
			||||||
    <tbody>
 | 
					    <tbody>
 | 
				
			||||||
        {{#each lines }}
 | 
					        {{#each lines }}
 | 
				
			||||||
            {{#if cancel}}
 | 
					            {{#if cancel}}
 | 
				
			||||||
                <tr style="background-color:#b6b6b6;">
 | 
					                <tr class="active">
 | 
				
			||||||
            {{else}}
 | 
					            {{else}}
 | 
				
			||||||
                <tr>
 | 
					                <tr>
 | 
				
			||||||
            {{/if}}
 | 
					            {{/if}}
 | 
				
			||||||
                    <td>{{no}}</td>
 | 
					            {{#ifeq sub "show"}}
 | 
				
			||||||
                    <td><a href="/ui#name=clinic_hd_case&active_id={{hdcase_id}}&mode=form">{{date}}</a></td>
 | 
					                <tr class="info" style="font-weight:bold;">
 | 
				
			||||||
                    <td>{{cname}}</td>
 | 
					            {{/ifeq}}
 | 
				
			||||||
 | 
					                {{#if cseq_txt}}
 | 
				
			||||||
 | 
					                    <th>{{date_txt}}</th>
 | 
				
			||||||
 | 
					                    <th>{{cseq_txt}}</th>
 | 
				
			||||||
 | 
					                    <td style="text-align:center">{{no}}</td>
 | 
				
			||||||
                    <td><a href="/ui#name=clinic_patient&active_id={{pid}}&mode=form">{{pname}}</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_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><a href="/ui#name=clinic_patient_type&active_id={{tid}}&mode=form">{{tname}}</a></td>
 | 
				
			||||||
                    <td style="text-align:right">{{fee}}</td>
 | 
					                    <td style="text-align:right">{{currency fee zero=""}}</td>
 | 
				
			||||||
                    <td style="text-align:right">{{mdc}}</td>
 | 
					                    <td style="text-align:right">{{currency mdc zero=""}}</td>
 | 
				
			||||||
                    <td><a href="/ui#name=clinic_dialyzer&active_id={{dlz_id}}&mode=form">{{dlz_name}}</a></td>
 | 
					                    <td><a href="/ui#name=clinic_dialyzer&active_id={{dlz_id}}&mode=form">{{dlz_name}}</a></td>
 | 
				
			||||||
                    <td>{{dlz_use}}</td>
 | 
					                    <td>{{dlz_use}}</td>
 | 
				
			||||||
                    <td><a href="/ui#name=clinic_cycle_item&active_id={{ctid}}&mode=form">View</a></td>
 | 
					                    <td><a href="/ui#name=clinic_cycle_item&active_id={{ctid}}&mode=form">{{nfirst_name}}</a></td>
 | 
				
			||||||
                    <!--<td>{{note}}</td>-->
 | 
					                {{else}}
 | 
				
			||||||
                </tr>
 | 
					                    {{#ifeq sub "show"}}
 | 
				
			||||||
 | 
					                        <td>รวม</td>
 | 
				
			||||||
 | 
					                    {{else}}
 | 
				
			||||||
 | 
					                        <td></td>
 | 
				
			||||||
 | 
					                    {{/ifeq}}
 | 
				
			||||||
 | 
					                    <td></td>
 | 
				
			||||||
 | 
					                    <td style="text-align:center">{{no}}</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:right">{{currency fee zero=""}}</td>
 | 
				
			||||||
 | 
					                    <td style="text-align:right">{{currency mdc}}</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}}
 | 
				
			||||||
 | 
					            </tr>
 | 
				
			||||||
        {{/each}}
 | 
					        {{/each}}
 | 
				
			||||||
    </tbody>
 | 
					    </tbody>
 | 
				
			||||||
    <tfoot>
 | 
					    <tfoot>
 | 
				
			||||||
        <th></th>
 | 
					        <th class="active">รวมทั้งหมด</th>
 | 
				
			||||||
        <th></th>
 | 
					        <th class="active"></th>
 | 
				
			||||||
        <th></th>
 | 
					        <th class="active">{{total_pt}}</th>
 | 
				
			||||||
        <th></th>
 | 
					        <th class="active"></th>
 | 
				
			||||||
        <th></th>
 | 
					        <th class="active"></th>
 | 
				
			||||||
        <th></th>
 | 
					        <th class="active"></th>
 | 
				
			||||||
        <th style="text-align:right">{{currency total_fee zero=""}}</th>
 | 
					        <th class="active" style="text-align:right">{{currency total_fee zero=""}}</th>
 | 
				
			||||||
        <th style="text-align:right">{{currency total_mdc}}</th>
 | 
					        <th class="active" style="text-align:right">{{currency total_mdc}}</th>
 | 
				
			||||||
        <th></th>
 | 
					        <th class="active"></th>
 | 
				
			||||||
        <th></th>
 | 
					        <th class="active"></th>
 | 
				
			||||||
        <th></th>
 | 
					        <th class="active"></th>
 | 
				
			||||||
    </tfoot>
 | 
					    </tfoot>
 | 
				
			||||||
</table>
 | 
					</table>
 | 
				
			||||||
 | 
					<table class="table table-condensed table-striped">
 | 
				
			||||||
 | 
					    <tbody>
 | 
				
			||||||
 | 
					        <tr>
 | 
				
			||||||
 | 
					            {{#each vscl_lines}}
 | 
				
			||||||
 | 
					                <th style="text-align:right;">{{description}} = </th>
 | 
				
			||||||
 | 
					                <th style="text-align:left">{{qty}}</th>
 | 
				
			||||||
 | 
					            {{/each}}
 | 
				
			||||||
 | 
					        </tr>
 | 
				
			||||||
 | 
					    </tbody>
 | 
				
			||||||
 | 
					</table>
 | 
				
			||||||
 | 
					<!--
 | 
				
			||||||
<table class="table table-condensed table-striped">
 | 
					<table class="table table-condensed table-striped">
 | 
				
			||||||
        <tr>
 | 
					        <tr>
 | 
				
			||||||
            <td colspan="5" style="width:50%">
 | 
					            <td colspan="5" style="width:50%">
 | 
				
			||||||
| 
						 | 
					@ -93,3 +124,4 @@
 | 
				
			||||||
            </td>
 | 
					            </td>
 | 
				
			||||||
        </tr>
 | 
					        </tr>
 | 
				
			||||||
</table>
 | 
					</table>
 | 
				
			||||||
 | 
					-->
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue