matching payment

conv_bal
watcha.h 2015-02-11 14:51:21 +07:00
parent 7321ab3d01
commit 4583f43d0b
11 changed files with 312 additions and 132 deletions

View File

@ -1,8 +1,8 @@
<record model="action"> <action>
<field name="name">clinic_matching_payment</field> <field name="string">Payment Matching</field>
<field name="view">form_view</field> <field name="view_cls">report</field>
<field name="model">clinic.matching.payment</field> <field name="model">clinic.matching.payment</field>
<field name="view_xml">clinic_matching_payment</field> <field name="report_template">matching_payment</field>
<field name="menu">account_menu</field> <field name="report_template_xls">matching_payment</field>
</record> <field name="menu">clinic_menu</field>
</action>

View File

@ -1,4 +1,5 @@
<form model="clinic.matching.hdcase"> <form model="clinic.matching.hdcase">
<field name="date" span="2"/> <field name="date" span="2"/>
<field name="file" span="3"/> <field name="file" span="3"/>
<field name="state" span="3"/>
</form> </form>

View File

@ -1,31 +1,18 @@
<form model="clinic.matching.payment" title="Matching Payment"> <form model="clinic.matching.payment" title="Payment Matching">
<head> <head>
<button string="Options" dropdown="1"> <button string="Options" dropdown="1">
<item string="Update Identification" method="update_id"/> <item string="Update Identification" method="update_id"/>
<item string="Print Log" icon="print"/> <item string="Import Payment" method="do_import" type="default"/>
</button> </button>
</head> </head>
<tabs>
<tab string="General">
<separator string="1. Click Match > 2. Check Items > 3. Import Payment"/> <separator string="1. Click Match > 2. Check Items > 3. Import Payment"/>
<field name="date" onchange="onchange_date" mode="month" span="3"/> <field name="date" onchange="onchange_date" mode="month" span="2"/>
<field name="date_from" span="3"/> <field name="date_from" span="2"/>
<field name="date_to" span="3"/> <field name="date_to" span="2"/>
<field name="file" span="4"/>
<newline/> <newline/>
<field name="file" span="3"/> <field name="patient_type_id" onchange="onchange_ptype" span="2"/>
<field name="patient_type_id" onchange="onchange_ptype" span="3"/> <field name="pcode" span="2"/>
<field name="pcode" span="3"/> <field name="hcode_id" span="2"/>
<field name="hcode_id" span="3"/> <button string="Import Payment" method="do_import" type="default" icon='arrow-right' size="small"/>
</tab>
<tab string="Log">
<field name="note" nolabel="1" width="1000" height="250"/>
</tab>
</tabs>
<foot replace="1">
<button string="Match" method="match" icon="ok" type="success"/>
<button string="Import Payment" method="do_import" icon="arrow-right" type="default"/>
</foot>
<related>
<field name="expenes"/>
</related>
</form> </form>

View File

@ -44,13 +44,13 @@
</item> </item>
<item string="HD Cases" perm="clinic_hdcase"> <item string="HD Cases" perm="clinic_hdcase">
<item string="HD Cases" action="clinic_hd_case"/> <item string="HD Cases" action="clinic_hd_case"/>
<item string="HD Cases Matching" action="clinic_matching_hdcase"/>
<item string="RD Shop" action="clinic_shop" perm="clinic_shop"/> <item string="RD Shop" action="clinic_shop" perm="clinic_shop"/>
<item string="Sickbed" action="clinic_sickbed"/> <item string="Sickbed" action="clinic_sickbed"/>
</item> </item>
<item string="Reporting" perm="clinic_report"> <item string="Reporting" perm="clinic_report">
<item string="Visit Summary" action="clinic_report_visit"/> <item string="Visit Summary" action="clinic_report_visit"/>
<item string="HD Case Summary" action="clinic_report_hd_case_summary"/> <item string="HD Case Summary" action="clinic_report_hd_case_summary"/>
<item string="HD Cases Matching" action="clinic_matching_hdcase" perm="clinic_matching_hdcase"/>
<item string="Medical Summary" action="clinic_report_medical_summary"/> <item string="Medical Summary" action="clinic_report_medical_summary"/>
<item string="Recent Patient" action="clinic_report_recent_patient"/> <item string="Recent Patient" action="clinic_report_recent_patient"/>
<item string="Discontinue Patient" action="clinic_report_discontinue_patient"/> <item string="Discontinue Patient" action="clinic_report_discontinue_patient"/>

View File

@ -10,6 +10,7 @@ class MatchingHDCase(Model):
_fields={ _fields={
"date": fields.Date("Date", required=True), "date": fields.Date("Date", required=True),
'file': fields.File("File"), 'file': fields.File("File"),
'state': fields.Selection([["match","Math"],["not_match","Not Match"]],"State"),
} }
def _get_date(self,context={}): def _get_date(self,context={}):
@ -58,8 +59,10 @@ class MatchingHDCase(Model):
hdcases={} hdcases={}
date=time.strftime("%Y-%m-%d") date=time.strftime("%Y-%m-%d")
lines=[] lines=[]
state="all"
if ids: if ids:
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
state=obj.state
date=obj.date date=obj.date
if obj.file: if obj.file:
fpath=get_file_path(obj.file) fpath=get_file_path(obj.file)
@ -174,6 +177,11 @@ class MatchingHDCase(Model):
'prod_id': prod_id, 'prod_id': prod_id,
'fee_amt': fee_amt, 'fee_amt': fee_amt,
'note': '', 'note': '',
'nf_date': '',
'nf_hn': '',
'nf_hct': '',
'nf_epo': '',
'nf_fee': '',
} }
if hdcase: if hdcase:
line_vals['is_match']=True line_vals['is_match']=True
@ -186,11 +194,24 @@ class MatchingHDCase(Model):
line_vals['is_match']=False line_vals['is_match']=False
line_vals['hd_case_id']=hdcase2['id'] line_vals['hd_case_id']=hdcase2['id']
line_vals['hd_case_number']=hdcase2['number'] line_vals['hd_case_number']=hdcase2['number']
line_vals['note']=hdcase2['note'] line_vals['note']=''
nf_date,nf_hn,nf_hct,nf_epo,nf_fee=hdcase2['note'].split(",")
line_vals['nf_date']=nf_date
line_vals['nf_hn']=nf_hn
line_vals['nf_hct']=nf_hct
line_vals['nf_epo']=nf_epo
line_vals['nf_fee']=round(float((nf_fee or "0")),2)
lines.append(line_vals) lines.append(line_vals)
no=1 no=1
lines2=[] lines2=[]
for line in sorted(lines,key=lambda x: x['hn']): for line in sorted(lines,key=lambda x: x['hn']):
is_match=line.get('is_match',False)
if state=='not_match' and is_match:
continue
elif state=='match' and not is_match:
continue
else:
pass
line['no']=no line['no']=no
lines2.append(line) lines2.append(line)
no+=1 no+=1

View File

@ -80,7 +80,7 @@ class MatchingPayment(Model):
raise Exception("No data to match") raise Exception("No data to match")
return lines return lines
def match(self,ids,context={}): def match_old(self,ids,context={}):
obj=self.browse(ids)[0] obj=self.browse(ids)[0]
lines=obj.get_line() lines=obj.get_line()
@ -88,6 +88,7 @@ class MatchingPayment(Model):
db.execute("truncate m2m_clinic_hd_case_expense_clinic_matching_payment;") db.execute("truncate m2m_clinic_hd_case_expense_clinic_matching_payment;")
matches1={} matches1={}
matches2={} matches2={}
matches3={}
if obj.pcode=='SSO': if obj.pcode=='SSO':
for line in lines: for line in lines:
hcode=line.get('hcode18') hcode=line.get('hcode18')
@ -101,6 +102,7 @@ class MatchingPayment(Model):
lmdc_amt=line.get('allow37') or 0 lmdc_amt=line.get('allow37') or 0
dttran=line.get("dttran") dttran=line.get("dttran")
name=line.get("name14") name=line.get("name14")
pid=line.get('pid')
date=dttran[0:10] date=dttran[0:10]
time=dttran[11:] #XXX time=dttran[11:] #XXX
if not time: if not time:
@ -116,16 +118,33 @@ class MatchingPayment(Model):
lmdc_amt, lmdc_amt,
) )
key2='%s:%s:%s:%s:%s'%( key2='%s:%s:%s:%s:%s'%(
pid,
date,
lfee_amt,
lsrv_amt,
lmdc_amt,
)
key3='%s:%s:%s:%s:%s'%(
name, name,
date, date,
lfee_amt, lfee_amt,
lsrv_amt, lsrv_amt,
lmdc_amt, lmdc_amt,
) )
vals={
'pid': pid,
'name': name,
'date': date,
'fee_amt': lfee_amt,
'service_amt': lsrv_amt,
'epo_amt': lmdc_amt,
}
if not matches1.get(key1): if not matches1.get(key1):
matches1[key1]=0 matches1[key1]=vals
if not matches2.get(key2): if not matches2.get(key2):
matches2[key2]=0 matches2[key2]=vals
if not matches3.get(key3):
matches2[key2]=vals
elif obj.pcode=='UC': elif obj.pcode=='UC':
for line in lines: for line in lines:
@ -156,13 +175,6 @@ class MatchingPayment(Model):
matches1[key1]={ matches1[key1]={
'invno': line['invno'], 'invno': line['invno'],
} }
#print("="*50)
#for key, values in matches1.items():
#x=key.split("-")
#hn=x[0]
#if hn=='11712556':
#print(key)
#print("="*50)
note="" note=""
exp_ids=[] exp_ids=[]
dom=[] dom=[]
@ -182,8 +194,6 @@ class MatchingPayment(Model):
if categ.code=='FEE': if categ.code=='FEE':
fee_amt+=line.amount or 0 fee_amt+=line.amount or 0
key='%s-%s-%s'%(pt.hn_no,date,amt) key='%s-%s-%s'%(pt.hn_no,date,amt)
#if pt.hn_no=='11712556':
#print('key ', key)
found=matches1.get(key) found=matches1.get(key)
if found: if found:
exp.write({ exp.write({
@ -236,6 +246,191 @@ class MatchingPayment(Model):
'flash': flash, 'flash': flash,
} }
def match(self,ids,context={}):
obj=self.browse(ids)[0]
lines=obj.get_line()
return lines
matches1={}
matches2={}
matches3={}
dom=[]
dom.append(['date',">=",obj.date_from])
dom.append(['date',"<=",obj.date_to])
dom.append(['patient_id.type_id',"=",obj.patient_type_id.id])
dom.append(['state','!=', 'completed'])
for exp in get_model('clinic.hd.case.expense').search_browse(dom):
hn=''.join([x for x in hn if x.isdigit()])
key1='%s:%s:%s:%s:%s'%(
hn,
date,
lfee_amt,
lsrv_amt,
lmdc_amt,
)
key2='%s:%s:%s:%s:%s'%(
pid,
date,
lfee_amt,
lsrv_amt,
lmdc_amt,
)
key3='%s:%s:%s:%s:%s'%(
name,
date,
lfee_amt,
lsrv_amt,
lmdc_amt,
)
vals={
'pid': pid,
'name': name,
'date': date,
'fee_amt': lfee_amt,
'service_amt': lsrv_amt,
'epo_amt': lmdc_amt,
}
if not matches1.get(key1):
matches1[key1]=vals
if not matches2.get(key2):
matches2[key2]=vals
if not matches3.get(key3):
matches2[key2]=vals
if obj.pcode=='SSO':
for line in lines:
hcode=line.get('hcode18')
if not hcode:
hcode='0'
hcode=int(hcode)
hcode=str(hcode)
if obj.hcode==hcode:
lsrv_amt=line.get('epoadm29') or 0
lfee_amt=line.get('amount23') or 0
lmdc_amt=line.get('allow37') or 0
dttran=line.get("dttran")
name=line.get("name14")
pid=line.get('pid')
date=dttran[0:10]
time=dttran[11:] #XXX
if not time:
print("wrong format")
continue
hn=line.get('hn')
hn=''.join([x for x in hn if x.isdigit()])
key1='%s:%s:%s:%s:%s'%(
hn,
date,
lfee_amt,
lsrv_amt,
lmdc_amt,
)
key2='%s:%s:%s:%s:%s'%(
pid,
date,
lfee_amt,
lsrv_amt,
lmdc_amt,
)
key3='%s:%s:%s:%s:%s'%(
name,
date,
lfee_amt,
lsrv_amt,
lmdc_amt,
)
vals={
'pid': pid,
'name': name,
'date': date,
'fee_amt': lfee_amt,
'service_amt': lsrv_amt,
'epo_amt': lmdc_amt,
}
if not matches1.get(key1):
matches1[key1]=vals
if not matches2.get(key2):
matches2[key2]=vals
if not matches3.get(key3):
matches2[key2]=vals
elif obj.pcode=='UC':
for line in lines:
#{'amount': '1500.0000',
#'cstat': None,
#'dttran': '2014-09-27T10:00:00',
#'epostat': 'E',
#'hdflag': 'COU',
#'hdrate': '1500.0000',
#'hn': '98511252',
#'hreg': 'NHSO1',
#'invno': '437941480',
#'paid': '0.0000',
#'paychk': '1',
#'reimbpay': '0.0000',
#'rid': '2190',
#'station': '01'}
date,time=(line['dttran'] or "").split("T")
amt=line['amount'] or "0"
amt=float(amt)
if date and time:
key1='%s-%s-%s'%(
line['hn'],
date,
amt,
)
if not matches1.get(key1):
matches1[key1]={
'invno': line['invno'],
}
for exp in get_model('clinic.hd.case.expense').search_browse(dom):
pt=exp.patient_id
if obj.pcode=='UC':
hdcase=exp.hd_case_id
date=hdcase.date
fee_amt=0
for line in hdcase.lines:
categ=line.product_categ_id
if categ.code=='FEE':
fee_amt+=line.amount or 0
key='%s-%s-%s'%(pt.hn_no,date,amt)
found=matches1.get(key)
if found:
exp.write({
'state': 'match',
})
elif obj.pcode=='SSO':
key1='%s:%s:%s:%s:%s'%(
pt.hn_no,
exp.date,
exp.fee_amt and exp.fee_amt or 0,
exp.srv_amt and exp.srv_amt or 0,
exp.mdc_amt and exp.mdc_amt or 0,
)
key2='%s:%s:%s:%s:%s'%(
pt.name or "",
exp.date,
exp.fee_amt and exp.fee_amt or 0,
exp.srv_amt and exp.srv_amt or 0,
exp.mdc_amt and exp.mdc_amt or 0,
)
found=matches1.get(key1) or matches2.get(key2)
if found:
hdcase=exp.hd_case_id
exp.write({
'state': 'match',
})
flash='Done!'
return {
'next': {
'name': 'clinic_matching_payment',
'mode': 'form',
'active_id': obj.id,
},
'flash': flash,
}
def onchange_date(self,context={}): def onchange_date(self,context={}):
data=context['data'] data=context['data']
date=data['date'] date=data['date']
@ -330,4 +525,12 @@ class MatchingPayment(Model):
}) })
print("Done!") print("Done!")
def get_report_data(self,ids,context={}):
obj=self.browse(ids)[0]
lines=obj.match()
data={
'lines': lines,
}
return data
MatchingPayment.register() MatchingPayment.register()

Binary file not shown.

View File

@ -1,5 +1,14 @@
<center>
&nbsp;
</center>
<!--<table class="table table-bordered">-->
<table class="table table-condensed table-striped"> <table class="table table-condensed table-striped">
<thead> <thead>
<tr>
<th colspan="9" style="text-align:center;background-color:#f9e37d;">Import File</th>
<th colspan="5" style="text-align:center;background-color:#2d6ed2;color:white">Netforce</th>
</tr>
<tr>
<th>#</th> <th>#</th>
<th>Date</th> <th>Date</th>
<th>HN</th> <th>HN</th>
@ -7,10 +16,16 @@
<th>Type</th> <th>Type</th>
<th>HCT</th> <th>HCT</th>
<th>EPO</th> <th>EPO</th>
<th>Fee Amount</th> <th>Fee</th>
<th>HD Case</th> <th>Match</th>
<th>Note (fmt: date,hn,hct,epo,fee)</th> <th>Date</th>
<th>HN</th>
<th>HCT</th>
<th>EPO</th>
<th>Fee</th>
</tr>
</thead> </thead>
<tbody> <tbody>
{{#each lines }} {{#each lines }}
<tr> <tr>
@ -39,10 +54,15 @@
<a style="color:white" href="/ui#name=clinic_hd_case&mode=form&active_id={{hd_case_id}}">{{hd_case_number}}</a> <a style="color:white" href="/ui#name=clinic_hd_case&mode=form&active_id={{hd_case_id}}">{{hd_case_number}}</a>
</td> </td>
{{/if}} {{/if}}
<td>{{note}}</td> <td>{{nf_date}}</td>
<td>{{nf_hn}}</td>
<td>{{nf_hct}}</td>
<td>{{nf_epo}}</td>
<td>{{currency nf_fee zero=""}}</td>
</tr> </tr>
{{/each}} {{/each}}
</tbody> </tbody>
<tfoot> <tfoot>
</tfoot> </tfoot>
</table> </table>

View File

@ -0,0 +1,29 @@
<table class="table table-condensed table-striped">
<thead>
<th>#</th>
<th>Date</th>
<th>HN</th>
<th>Patient</th>
<th>EPO Amount</th>
<th>Service Medical</th>
<th>Fee Amount</th>
<th>HD Case</th>
<th>Note</th>
</thead>
<tbody>
{{#each lines }}
<tr>
<td>{{no}}</td>
<td>{{date}}</td>
<td>{{hn}}</td>
<td style="width:15%;">{{view "link" string=patient_name action="clinic_patient" action_options="mode=form" active_id=patient_id}}</td>
<td>{{currency epo_amt zero=""}}</td>
<td>{{currency service_amt zero=""}}</td>
<td>{{currency fee_amt zero=""}}</td>
<td>{{note}}</td>
</tr>
{{/each}}
</tbody>
<tfoot>
</tfoot>
</table>

View File

@ -1,86 +1,5 @@
todo: todo:
- report doctor & nurse ***
- matching payment *** - matching payment ***
- script generate hd case - script generate hd case
- report doctor & nurse ***
- urgent -> done:
- change department on user profile -> ok
- Because of one user can access more than branch
- move between branch -> next phase
- patient
- sale medicine -> ok
- payment
- accounting
- labor cost
- report ->ok
- nurse
- max cycle
- doctor
- total hd case
- invoice line -> account -> credit
- if user select product by them self -> testing
- credit <= product -> tab -> accounting -> sale -> sale account
- debit <= 1. contact -> tab accounting -> account receiaveble , 2. finacial setting -> account receiable
- patient
- link vascular access to patient profile and copy to hd case after confirm on visit -> ok
- can update date from hd case to patient
- hd case
- move membrane type to dialyzer -> ok
- make script to update membran type -> ok
- add option -> ok
- new shop
- related to hd case
- filter product by
1. company -> ok
2. category -> ok
3. code -> ok
- cycle item
- copy nurse only in the list -> ok
- problem after confirm visit -> ok
- import hd case ***
- add script
- report
- doctor labort cost detail ***
- how much hd of that doctor in that period
- working status
- matching payment ***
- show image of staff ->
- popup messagging -> Ask DK -> ok
- modify message of log -> Ask DJ -> ok
- copy old nurse from previous cycle item -> ok
- multi confirm on visit board **** -> ok
=======
generate visit ใหม่ -> ok
popup select dyalyzer -> ok
- visit
- confirm: if pt has dialyzer -> auto select else empty (need to select on hd case)
- click pay -> cash -> not update use time (dlz) -> ok
- reset use time after hd case is done! -> ok
=======
sharing setting
- filter by branch
- patient -> ok
- staff -> not yet
- nurse ยังไม่มีรายชื่อสาขาที่เขาเลือก -> ok
- doctor ยังไม่ match ก้ับคนไข้ ****
- visit -> ok
- hd case -> ok
- cycle item -> ok
- department -> ok
- sickbed -> ok
- schedule -> ok
- dialyser -> ok
user:
- update hd case
link:
clinic.rddialysis.co.th
test.rddialysis.co.th