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