diff --git a/netforce_clinic/actions/clinic_matching_payment.xml b/netforce_clinic/actions/clinic_matching_payment.xml
index be54106..7f23370 100644
--- a/netforce_clinic/actions/clinic_matching_payment.xml
+++ b/netforce_clinic/actions/clinic_matching_payment.xml
@@ -1,8 +1,8 @@
-
- clinic_matching_payment
- form_view
+
+ Payment Matching
+ report
clinic.matching.payment
- clinic_matching_payment
- account_menu
-
-
+ matching_payment
+ matching_payment
+ clinic_menu
+
diff --git a/netforce_clinic/layouts/clinic_matching_hdcase.xml b/netforce_clinic/layouts/clinic_matching_hdcase.xml
index 1838681..61b69ad 100644
--- a/netforce_clinic/layouts/clinic_matching_hdcase.xml
+++ b/netforce_clinic/layouts/clinic_matching_hdcase.xml
@@ -1,4 +1,5 @@
diff --git a/netforce_clinic/layouts/clinic_matching_payment.xml b/netforce_clinic/layouts/clinic_matching_payment.xml
index be99ddf..0a409d9 100644
--- a/netforce_clinic/layouts/clinic_matching_payment.xml
+++ b/netforce_clinic/layouts/clinic_matching_payment.xml
@@ -1,31 +1,18 @@
-
diff --git a/netforce_clinic/layouts/clinic_menu.xml b/netforce_clinic/layouts/clinic_menu.xml
index fc615f1..b4ebe25 100644
--- a/netforce_clinic/layouts/clinic_menu.xml
+++ b/netforce_clinic/layouts/clinic_menu.xml
@@ -44,13 +44,13 @@
-
-
-
+
diff --git a/netforce_clinic/models/matching_hdcase.py b/netforce_clinic/models/matching_hdcase.py
index dd4132f..436c7f3 100644
--- a/netforce_clinic/models/matching_hdcase.py
+++ b/netforce_clinic/models/matching_hdcase.py
@@ -10,6 +10,7 @@ class MatchingHDCase(Model):
_fields={
"date": fields.Date("Date", required=True),
'file': fields.File("File"),
+ 'state': fields.Selection([["match","Math"],["not_match","Not Match"]],"State"),
}
def _get_date(self,context={}):
@@ -58,8 +59,10 @@ class MatchingHDCase(Model):
hdcases={}
date=time.strftime("%Y-%m-%d")
lines=[]
+ state="all"
if ids:
obj=self.browse(ids)[0]
+ state=obj.state
date=obj.date
if obj.file:
fpath=get_file_path(obj.file)
@@ -174,6 +177,11 @@ class MatchingHDCase(Model):
'prod_id': prod_id,
'fee_amt': fee_amt,
'note': '',
+ 'nf_date': '',
+ 'nf_hn': '',
+ 'nf_hct': '',
+ 'nf_epo': '',
+ 'nf_fee': '',
}
if hdcase:
line_vals['is_match']=True
@@ -186,11 +194,24 @@ class MatchingHDCase(Model):
line_vals['is_match']=False
line_vals['hd_case_id']=hdcase2['id']
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)
no=1
lines2=[]
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
lines2.append(line)
no+=1
diff --git a/netforce_clinic/models/matching_payment.py b/netforce_clinic/models/matching_payment.py
index 86e3ef0..046bf3f 100644
--- a/netforce_clinic/models/matching_payment.py
+++ b/netforce_clinic/models/matching_payment.py
@@ -80,7 +80,7 @@ class MatchingPayment(Model):
raise Exception("No data to match")
return lines
- def match(self,ids,context={}):
+ def match_old(self,ids,context={}):
obj=self.browse(ids)[0]
lines=obj.get_line()
@@ -88,6 +88,7 @@ class MatchingPayment(Model):
db.execute("truncate m2m_clinic_hd_case_expense_clinic_matching_payment;")
matches1={}
matches2={}
+ matches3={}
if obj.pcode=='SSO':
for line in lines:
hcode=line.get('hcode18')
@@ -101,6 +102,7 @@ class MatchingPayment(Model):
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:
@@ -116,16 +118,33 @@ class MatchingPayment(Model):
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]=0
+ matches1[key1]=vals
if not matches2.get(key2):
- matches2[key2]=0
+ matches2[key2]=vals
+ if not matches3.get(key3):
+ matches2[key2]=vals
elif obj.pcode=='UC':
for line in lines:
@@ -156,13 +175,6 @@ class MatchingPayment(Model):
matches1[key1]={
'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=""
exp_ids=[]
dom=[]
@@ -182,8 +194,6 @@ class MatchingPayment(Model):
if categ.code=='FEE':
fee_amt+=line.amount or 0
key='%s-%s-%s'%(pt.hn_no,date,amt)
- #if pt.hn_no=='11712556':
- #print('key ', key)
found=matches1.get(key)
if found:
exp.write({
@@ -236,6 +246,191 @@ class MatchingPayment(Model):
'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={}):
data=context['data']
date=data['date']
@@ -330,4 +525,12 @@ class MatchingPayment(Model):
})
print("Done!")
+ def get_report_data(self,ids,context={}):
+ obj=self.browse(ids)[0]
+ lines=obj.match()
+ data={
+ 'lines': lines,
+ }
+ return data
+
MatchingPayment.register()
diff --git a/netforce_clinic/reports/matching_hdcase.xlsx b/netforce_clinic/reports/matching_hdcase.xlsx
index 33e8a9a..95a8019 100644
Binary files a/netforce_clinic/reports/matching_hdcase.xlsx and b/netforce_clinic/reports/matching_hdcase.xlsx differ
diff --git a/netforce_clinic/reports/matching_payment.xlsx b/netforce_clinic/reports/matching_payment.xlsx
new file mode 100644
index 0000000..33e8a9a
Binary files /dev/null and b/netforce_clinic/reports/matching_payment.xlsx differ
diff --git a/netforce_clinic/templates/matching_hdcase.hbs b/netforce_clinic/templates/matching_hdcase.hbs
index 7b13dff..cb778fc 100644
--- a/netforce_clinic/templates/matching_hdcase.hbs
+++ b/netforce_clinic/templates/matching_hdcase.hbs
@@ -1,5 +1,14 @@
+
+
+
+
+
+ Import File |
+ Netforce |
+
+
# |
Date |
HN |
@@ -7,10 +16,16 @@
Type |
HCT |
EPO |
- Fee Amount |
- HD Case |
- Note (fmt: date,hn,hct,epo,fee) |
+ Fee |
+ Match |
+ Date |
+ HN |
+ HCT |
+ EPO |
+ Fee |
+
+
{{#each lines }}
@@ -39,10 +54,15 @@
{{hd_case_number}}
{{/if}}
- {{note}} |
+ {{nf_date}} |
+ {{nf_hn}} |
+ {{nf_hct}} |
+ {{nf_epo}} |
+ {{currency nf_fee zero=""}} |
{{/each}}
+
diff --git a/netforce_clinic/templates/matching_payment.hbs b/netforce_clinic/templates/matching_payment.hbs
new file mode 100644
index 0000000..fa213a9
--- /dev/null
+++ b/netforce_clinic/templates/matching_payment.hbs
@@ -0,0 +1,29 @@
+
+
+ # |
+ Date |
+ HN |
+ Patient |
+ EPO Amount |
+ Service Medical |
+ Fee Amount |
+ HD Case |
+ Note |
+
+
+ {{#each lines }}
+
+ {{no}} |
+ {{date}} |
+ {{hn}} |
+ {{view "link" string=patient_name action="clinic_patient" action_options="mode=form" active_id=patient_id}} |
+ {{currency epo_amt zero=""}} |
+ {{currency service_amt zero=""}} |
+ {{currency fee_amt zero=""}} |
+ {{note}} |
+
+ {{/each}}
+
+
+
+
diff --git a/netforce_clinic/todo.txt b/netforce_clinic/todo.txt
index c849921..8782d4a 100644
--- a/netforce_clinic/todo.txt
+++ b/netforce_clinic/todo.txt
@@ -1,86 +1,5 @@
todo:
- - report doctor & nurse ***
- matching payment ***
- 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