xxxx
parent
616e172447
commit
639522b85d
|
@ -1,5 +1,5 @@
|
|||
<action>
|
||||
<field name="string">NHSO</field>
|
||||
<field name="string">Social Security</field>
|
||||
<field name="view_cls">multi_view</field>
|
||||
<field name="tabs">[["All",[]],["Success",[["type","=","success"]]],["Fail",[["type","=","fail"]]]]</field>
|
||||
<field name="model">clinic.data.sc</field>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<field name="hn"/>
|
||||
<field name="name14"/>
|
||||
<field name="hcode18"/>
|
||||
<field name="dttran"/>
|
||||
<field name="amount23"/>
|
||||
<field name="cur"/>
|
||||
<field name="epoadm29"/>
|
||||
|
@ -9,4 +10,5 @@
|
|||
<field name="ln"/>
|
||||
<field name="st"/>
|
||||
<field name="allow37"/>
|
||||
<field name="type"/>
|
||||
</form>
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<list model="clinic.data.sc">
|
||||
<list model="clinic.data.sc" colors='{"red":[["type","=","fail"]]}'>
|
||||
<field name="hn"/>
|
||||
<field name="name14"/>
|
||||
<field name="hcode18"/>
|
||||
<field name="dttran"/>
|
||||
<field name="amount23"/>
|
||||
<field name="cur"/>
|
||||
<field name="epoadm29"/>
|
||||
|
@ -9,4 +10,5 @@
|
|||
<field name="ln"/>
|
||||
<field name="st"/>
|
||||
<field name="allow37"/>
|
||||
<field name="type"/>
|
||||
</list>
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<field name="file"/>
|
||||
</group>
|
||||
<group span="6" columns="1">
|
||||
<separator string="Result"/>
|
||||
<field name="result" nolabel="1" height="240" width="540"/>
|
||||
<!--<separator string="Result"/>-->
|
||||
<!--<field name="result" nolabel="1" height="240" width="540"/>-->
|
||||
</group>
|
||||
<foot replace="1">
|
||||
<button string="Import Data" method="import_nhso" type="primary" icon="arrow-right"/>
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
</group>
|
||||
<group span="6" columns="1">
|
||||
<separator string="Result"/>
|
||||
<template>
|
||||
<a href="ui#name=clinic_data_sc" target="_blank"><span class="glyphicon glyphicon-arrow-right"></span> Review Data</a>
|
||||
</template>
|
||||
<field name="result" nolabel="1" height="240" width="540"/>
|
||||
</group>
|
||||
<foot replace="1">
|
||||
|
|
|
@ -14,6 +14,7 @@ class ImportDataSC(Model):
|
|||
'ln': fields.Char('ln'),
|
||||
'st': fields.Char('st'),
|
||||
'allow37': fields.Char('allow37'),
|
||||
'dttran': fields.Date("dttran"),
|
||||
'type': fields.Selection([['success','Succes'],['fail','Fail']],'Type', search=True),
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import time
|
||||
import datetime
|
||||
import xlrd
|
||||
import xmltodict
|
||||
|
||||
|
@ -33,8 +34,18 @@ class ImportPayment(Model):
|
|||
keys = [sheet.cell(0, col_index).value for col_index in range(sheet.ncols)]
|
||||
data=[]
|
||||
for row_index in range(1, sheet.nrows):
|
||||
d = {(keys[col_index] or "").lower(): sheet.cell(row_index, col_index).value
|
||||
for col_index in range(sheet.ncols)}
|
||||
#d = {(keys[col_index] or "").lower(): sheet.cell(row_index, col_index).value for col_index in range(sheet.ncols)}
|
||||
d={}
|
||||
for col_index in range(sheet.ncols):
|
||||
ctype=sheet.cell(row_index,col_index).ctype
|
||||
if ctype==3:
|
||||
value=sheet.cell(row_index, col_index).value
|
||||
year, month, day, hour, minute, second = xlrd.xldate_as_tuple(value,wb.datemode)
|
||||
value=datetime.datetime(year, month, day, hour, minute,second)
|
||||
value=value.strftime("%Y-%m-%d")
|
||||
else:
|
||||
value=sheet.cell(row_index, col_index).value
|
||||
d.update({(keys[col_index] or "").lower():value})
|
||||
data.append(d)
|
||||
return data
|
||||
|
||||
|
@ -95,12 +106,6 @@ class ImportPayment(Model):
|
|||
'result': result,
|
||||
})
|
||||
|
||||
def import_mg(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
print("fpath ", fpath)
|
||||
|
||||
def import_sc(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
fname=obj.file
|
||||
|
@ -114,6 +119,8 @@ class ImportPayment(Model):
|
|||
st={}
|
||||
patient=get_model("clinic.patient")
|
||||
old_patient=[x['hn'] for x in patient.search_read([],['hn']) if x['hn']]
|
||||
fail_qty=0
|
||||
success_qty=0
|
||||
for line in lines:
|
||||
hn=line.get('hn')
|
||||
if not hn:
|
||||
|
@ -128,10 +135,16 @@ class ImportPayment(Model):
|
|||
})
|
||||
st.update({hn: line.get('name14')})
|
||||
print("create %s ok"%hn)
|
||||
hcode=int((line.get('hcode18') or "0")) # XXX
|
||||
type=hcode==23869 and 'success' or 'fail'
|
||||
if type=='success':
|
||||
success_qty+=1
|
||||
else:
|
||||
fail_qty+=1
|
||||
vals={
|
||||
'hn': hn,
|
||||
'name14': line.get('name14'),
|
||||
'hcode18': line.get('hcode18'),
|
||||
'hcode18': hcode,
|
||||
'amount23': line.get('amount23'),
|
||||
"cur": line.get('cur'),
|
||||
'epoadm29': line.get('epoadm29'),
|
||||
|
@ -139,14 +152,26 @@ class ImportPayment(Model):
|
|||
'ln': line.get('ln'),
|
||||
'st': line.get('st'),
|
||||
'allow37': line.get('allow37'),
|
||||
'type': 'success',
|
||||
'dttran': line.get("dttran"),
|
||||
'type': type,
|
||||
}
|
||||
data_sc.create(vals)
|
||||
msg="%s -OK "%("*"*50)
|
||||
msg=''
|
||||
msg+="%s\n"%("*"*50)
|
||||
msg+='success: %s\n'%success_qty
|
||||
msg+='fail: %s\n'%fail_qty
|
||||
msg+="%s\n"%("*"*50)
|
||||
|
||||
obj.write({
|
||||
'result': msg,
|
||||
})
|
||||
print("OK")
|
||||
|
||||
def import_mg(self,ids,context={}):
|
||||
obj=self.browse(ids)[0]
|
||||
fname=obj.file
|
||||
fpath=get_file_path(fname)
|
||||
print("fpath ", fpath)
|
||||
|
||||
|
||||
|
||||
ImportPayment.register()
|
||||
|
|
Loading…
Reference in New Issue