improve
parent
7e652ab9b5
commit
f54963aa4c
|
@ -3,17 +3,18 @@
|
||||||
<tab string="General">
|
<tab string="General">
|
||||||
<field name="date_from" onchange="onchange_date" span="2"/>
|
<field name="date_from" onchange="onchange_date" span="2"/>
|
||||||
<field name="date_to" span="2"/>
|
<field name="date_to" span="2"/>
|
||||||
<field name="file" span="3"/>
|
<field name="branch_id" span="3"/>
|
||||||
|
<field name="file" span="2"/>
|
||||||
<field name="state" span="3"/>
|
<field name="state" span="3"/>
|
||||||
<!--<group span="6" columns="1">-->
|
<group span="6" columns="1">
|
||||||
<!--<field name="file_lines" nolabel="1">-->
|
<template>
|
||||||
<!--<list>-->
|
<div>
|
||||||
<!--<field name="file"/>-->
|
<b>Note: </b> For Quick Matching, Please Define Branch.
|
||||||
<!--</list>-->
|
</div>
|
||||||
<!--</field>-->
|
</template>
|
||||||
<!--</group>-->
|
</group>
|
||||||
<!--<group span="6" columns="1">-->
|
<group span="6" columns="1">
|
||||||
<!--</group>-->
|
</group>
|
||||||
</tab>
|
</tab>
|
||||||
<tab string="Skip Type">
|
<tab string="Skip Type">
|
||||||
<group span="6" columns="1">
|
<group span="6" columns="1">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<form model="clinic.report.labor.cost">
|
<form model="clinic.report.labor.cost">
|
||||||
<field name="date" mode="month" onchange="onchange_date" span="2"/>
|
<field name="date" mode="month" onchange="onchange_date" span="2"/>
|
||||||
<field name="date_from" required="1" span="2"/>
|
<field name="date_from" onchange="onchange_from" required="1" span="2"/>
|
||||||
<field name="date_to" required="1" span="2"/>
|
<field name="date_to" 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"/>
|
||||||
|
|
|
@ -15,6 +15,7 @@ class MatchingHDCase(Model):
|
||||||
'skip_lines': fields.One2Many("clinic.matching.hdcase.line","matching_hdcase_id","Skip Lines"),
|
'skip_lines': fields.One2Many("clinic.matching.hdcase.line","matching_hdcase_id","Skip Lines"),
|
||||||
'file_lines': fields.One2Many("clinic.matching.hdcase.file","matching_hdcase_id","File Lines"),
|
'file_lines': fields.One2Many("clinic.matching.hdcase.file","matching_hdcase_id","File Lines"),
|
||||||
'msg': fields.Text("Message"),
|
'msg': fields.Text("Message"),
|
||||||
|
'branch_id': fields.Many2One("clinic.branch","Branch"),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _get_skip_lines(self,context={}):
|
def _get_skip_lines(self,context={}):
|
||||||
|
@ -68,10 +69,10 @@ class MatchingHDCase(Model):
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
def get_report_data(self,ids,context={}):
|
def get_report_data(self,ids,context={}):
|
||||||
hdcases={}
|
|
||||||
defaults=self.default_get(context=context)
|
defaults=self.default_get(context=context)
|
||||||
date_from=defaults.get("date_from")
|
date_from=defaults.get("date_from")
|
||||||
date_to=defaults.get("date_to")
|
date_to=defaults.get("date_to")
|
||||||
|
branch_id=defaults.get("branch_id")
|
||||||
lines=[]
|
lines=[]
|
||||||
state="all"
|
state="all"
|
||||||
if ids:
|
if ids:
|
||||||
|
@ -79,15 +80,16 @@ class MatchingHDCase(Model):
|
||||||
state=obj.state
|
state=obj.state
|
||||||
date_from=obj.date_from
|
date_from=obj.date_from
|
||||||
date_to=obj.date_to
|
date_to=obj.date_to
|
||||||
|
branch_id=obj.branch_id.id
|
||||||
skip_lines=[skip.type_id.name for skip in obj.skip_lines]
|
skip_lines=[skip.type_id.name for skip in obj.skip_lines]
|
||||||
print('skip_lines ', skip_lines)
|
|
||||||
if not obj.file:
|
if not obj.file:
|
||||||
return {}
|
return {}
|
||||||
#raise Exception("File Not found")
|
|
||||||
fpath=get_file_path(obj.file)
|
fpath=get_file_path(obj.file)
|
||||||
rows=self.get_rows(fpath)
|
rows=self.get_rows(fpath)
|
||||||
if not rows:
|
if not rows:
|
||||||
raise Exception("No Data")
|
return {
|
||||||
|
'message': 'No Data',
|
||||||
|
}
|
||||||
#{0: ' A 01',
|
#{0: ' A 01',
|
||||||
#1: ' 6',
|
#1: ' 6',
|
||||||
#2: ' 11686',
|
#2: ' 11686',
|
||||||
|
@ -132,7 +134,9 @@ class MatchingHDCase(Model):
|
||||||
dom.append(['date',">=",date_from])
|
dom.append(['date',">=",date_from])
|
||||||
dom.append(['date',"<=",date_to])
|
dom.append(['date',"<=",date_to])
|
||||||
dom.append(['state','!=','cancelled'])
|
dom.append(['state','!=','cancelled'])
|
||||||
hdcases={}
|
if branch_id:
|
||||||
|
dom.append(['branch_id','=',branch_id])
|
||||||
|
hdcases1={}
|
||||||
hdcases2={}
|
hdcases2={}
|
||||||
hdcases3={}
|
hdcases3={}
|
||||||
def get_account_patient_hn(patient_id):
|
def get_account_patient_hn(patient_id):
|
||||||
|
@ -140,11 +144,10 @@ class MatchingHDCase(Model):
|
||||||
if res:
|
if res:
|
||||||
return res[0]
|
return res[0]
|
||||||
return res
|
return res
|
||||||
|
print('hdcase get key ....')
|
||||||
for hdcase in get_model("clinic.hd.case").search_browse(dom):
|
for hdcase in get_model("clinic.hd.case").search_browse(dom):
|
||||||
date=hdcase.date
|
date=hdcase.date
|
||||||
hn=hdcase.patient_id.hn_no or ""
|
hn=hdcase.patient_id.hn_no or ""
|
||||||
#hn=hn[0:7] #XXX K.Ekk explain on 03/04/2015 : 0-7 is main of hn
|
|
||||||
fee_amt=0
|
fee_amt=0
|
||||||
hct=hdcase.hct or "0"
|
hct=hdcase.hct or "0"
|
||||||
hct=round(float(hct),2)
|
hct=round(float(hct),2)
|
||||||
|
@ -164,7 +167,7 @@ class MatchingHDCase(Model):
|
||||||
if prod_line:
|
if prod_line:
|
||||||
prod_name='-'.join(prod_line)
|
prod_name='-'.join(prod_line)
|
||||||
key1='%s-%s-%s-%s'%(date,hn,prod_name,fee_amt)
|
key1='%s-%s-%s-%s'%(date,hn,prod_name,fee_amt)
|
||||||
hdcases[key1]={
|
hdcases1[key1]={
|
||||||
'id': hdcase.id,
|
'id': hdcase.id,
|
||||||
'number': hdcase.number or '',
|
'number': hdcase.number or '',
|
||||||
'note': '',
|
'note': '',
|
||||||
|
@ -188,9 +191,12 @@ class MatchingHDCase(Model):
|
||||||
'patient_name': patient.name,
|
'patient_name': patient.name,
|
||||||
'patient_type': patient.type_id.name,
|
'patient_type': patient.type_id.name,
|
||||||
}
|
}
|
||||||
|
ddate=set()
|
||||||
|
print('match hdcase ....')
|
||||||
for row in rows:
|
for row in rows:
|
||||||
vals=list(row.values())
|
vals=list(row.values())
|
||||||
date,_time=(vals[5] or "").split()
|
date,_time=(vals[5] or "").split()
|
||||||
|
ddate.update({date})
|
||||||
if len(date)<3:
|
if len(date)<3:
|
||||||
raise Exception("Wrong format date")
|
raise Exception("Wrong format date")
|
||||||
d,m,y=date.split("/")
|
d,m,y=date.split("/")
|
||||||
|
@ -214,7 +220,7 @@ class MatchingHDCase(Model):
|
||||||
prod_name=prod_name.replace(" ", "")
|
prod_name=prod_name.replace(" ", "")
|
||||||
prod_id=products.get(prod_name.upper(),None)
|
prod_id=products.get(prod_name.upper(),None)
|
||||||
key1='%s-%s-%s-%s'%(date,hn,prod_name.upper(),fee_amt)
|
key1='%s-%s-%s-%s'%(date,hn,prod_name.upper(),fee_amt)
|
||||||
hdcase=hdcases.get(key1)
|
hdcase=hdcases1.get(key1)
|
||||||
unit_amt=float(vals[11])
|
unit_amt=float(vals[11])
|
||||||
line_vals={
|
line_vals={
|
||||||
'hn': hn,
|
'hn': hn,
|
||||||
|
@ -271,6 +277,7 @@ class MatchingHDCase(Model):
|
||||||
total_match=0
|
total_match=0
|
||||||
total_unmatch=0
|
total_unmatch=0
|
||||||
mdate=[]
|
mdate=[]
|
||||||
|
print('sorted line ...')
|
||||||
for line in sorted(lines,key=lambda x: x['hn']):
|
for line in sorted(lines,key=lambda x: x['hn']):
|
||||||
ldate=line.get('date') or ""
|
ldate=line.get('date') or ""
|
||||||
if ldate not in mdate:
|
if ldate not in mdate:
|
||||||
|
@ -320,14 +327,15 @@ class MatchingHDCase(Model):
|
||||||
'total': total,
|
'total': total,
|
||||||
'total_match': total_match,
|
'total_match': total_match,
|
||||||
'total_unmatch': total_unmatch,
|
'total_unmatch': total_unmatch,
|
||||||
|
'message': '',
|
||||||
}
|
}
|
||||||
if no <=1 and ids:
|
if no <=1 and ids:
|
||||||
raise Exception("File match only %s"%', '.join(sorted(mdate)))
|
data['message']="%s"%', '.join(sorted(ddate))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def onchange_date(self,context={}):
|
def onchange_date(self,context={}):
|
||||||
data=context['data']
|
data=context['data']
|
||||||
#data['date_to']=data['date_from']
|
data['date_to']=data['date_from']
|
||||||
return data
|
return data
|
||||||
|
|
||||||
MatchingHDCase.register()
|
MatchingHDCase.register()
|
||||||
|
|
|
@ -338,4 +338,9 @@ class ReportLaborCost(Model):
|
||||||
data['department_id']=None
|
data['department_id']=None
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
def onchange_from(self,context={}):
|
||||||
|
data=context['data']
|
||||||
|
data['date_to']=data['date_from']
|
||||||
|
return data
|
||||||
|
|
||||||
ReportLaborCost.register()
|
ReportLaborCost.register()
|
||||||
|
|
|
@ -74,4 +74,10 @@
|
||||||
<tfoot>
|
<tfoot>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
|
{{#if message}}
|
||||||
|
<strong>
|
||||||
|
File Math Only:
|
||||||
|
<span style="color:red">
|
||||||
|
{{message}}
|
||||||
|
</strong>
|
||||||
|
{{/if}}
|
||||||
|
|
Loading…
Reference in New Issue