Merge branch 'dev' of lab/parse-edi into master
This commit is contained in:
commit
94dec6887b
|
@ -108,6 +108,7 @@ def meta(config) :
|
||||||
def create (**_args) :
|
def create (**_args) :
|
||||||
skip = [] if 'skip' not in _args else _args['skip']
|
skip = [] if 'skip' not in _args else _args['skip']
|
||||||
fields = ([_args['key']] if 'key' in _args else []) + _args['fields']
|
fields = ([_args['key']] if 'key' in _args else []) + _args['fields']
|
||||||
|
fields = ['_id'] + fields
|
||||||
table = _args['table']
|
table = _args['table']
|
||||||
sql = ['CREATE TABLE :table ',"(",",\n".join(["\t".join(["\t",name,"VARCHAR(125)"]) for name in fields]),")"]
|
sql = ['CREATE TABLE :table ',"(",",\n".join(["\t".join(["\t",name,"VARCHAR(125)"]) for name in fields]),")"]
|
||||||
return " ".join(sql)
|
return " ".join(sql)
|
||||||
|
@ -145,7 +146,7 @@ def init (**_args) :
|
||||||
|
|
||||||
_name = "".join(["$",field_name])
|
_name = "".join(["$",field_name])
|
||||||
project[field_name] = {"$ifNull":[_name,""]}
|
project[field_name] = {"$ifNull":[_name,""]}
|
||||||
project["_id"] = 0
|
project["_id"] = 1
|
||||||
project = {"$project":project}
|
project = {"$project":project}
|
||||||
|
|
||||||
r = [{"table":TABLE_NAME,"mongo":{"aggregate":TABLE_NAME,"pipeline":[project],"cursor":{},"allowDiskUse":True},"sql":create(table=TABLE_NAME,fields=_info['main'])}]
|
r = [{"table":TABLE_NAME,"mongo":{"aggregate":TABLE_NAME,"pipeline":[project],"cursor":{},"allowDiskUse":True},"sql":create(table=TABLE_NAME,fields=_info['main'])}]
|
||||||
|
@ -154,12 +155,12 @@ def init (**_args) :
|
||||||
# NOTE: Adding _index to the fields
|
# NOTE: Adding _index to the fields
|
||||||
fields = _info['rel'][table] +["_index"]
|
fields = _info['rel'][table] +["_index"]
|
||||||
|
|
||||||
project = {"_id":0,"claim_id":1,"_index":1} #dict.fromkeys(["_id","claim_id"]+fields,[ ".".join([table,field_name]) for field_name in fields])
|
project = {"_id":1,"claim_id":1,"_index":1} #dict.fromkeys(["_id","claim_id"]+fields,[ ".".join([table,field_name]) for field_name in fields])
|
||||||
for field_name in fields :
|
for field_name in fields :
|
||||||
# project[field_name] = "$"+".".join([table,field_name])
|
# project[field_name] = "$"+".".join([table,field_name])
|
||||||
_name = "$"+".".join([table,field_name])
|
_name = "$"+".".join([table,field_name])
|
||||||
project[field_name] = {"$ifNull":[_name,""]} #{"$cond":[{"$eq":[_name,None]},"",_name]}
|
project[field_name] = {"$ifNull":[_name,""]} #{"$cond":[{"$eq":[_name,None]},"",_name]}
|
||||||
project["_id"] = 0
|
project["_id"] = 1
|
||||||
pipeline = [{"$unwind":"$"+table},{"$project":project}]
|
pipeline = [{"$unwind":"$"+table},{"$project":project}]
|
||||||
r += [{"table":table,"mongo":{"aggregate":TABLE_NAME,"cursor":{},"pipeline":pipeline,"allowDiskUse":True},"sql":create(table=table,key='claim_id',fields=fields)}]
|
r += [{"table":table,"mongo":{"aggregate":TABLE_NAME,"cursor":{},"pipeline":pipeline,"allowDiskUse":True},"sql":create(table=table,key='claim_id',fields=fields)}]
|
||||||
|
|
||||||
|
|
|
@ -183,8 +183,12 @@ class Writer(Worker):
|
||||||
# print (['segment # ',index,len(rows)])
|
# print (['segment # ',index,len(rows)])
|
||||||
self.log(**{"context":self.name(),"segment":(index+1),"args":{"rows":len(rows),"table":table}})
|
self.log(**{"context":self.name(),"segment":(index+1),"args":{"rows":len(rows),"table":table}})
|
||||||
if len(rows) :
|
if len(rows) :
|
||||||
|
#
|
||||||
writer.write(list(rows))
|
# @TODO: Upgrade to mongodb 4.0+ and remove the line below
|
||||||
|
# Upon upgrade use the operator "$toString" in export.init function
|
||||||
|
#
|
||||||
|
rows = [dict(item,**{"_id":str(item["_id"])}) for item in rows]
|
||||||
|
writer.write(rows)
|
||||||
index += 1
|
index += 1
|
||||||
# for _e in rows :
|
# for _e in rows :
|
||||||
# writer.write(_e)
|
# writer.write(_e)
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -8,7 +8,7 @@ import sys
|
||||||
def read(fname):
|
def read(fname):
|
||||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
||||||
args = {
|
args = {
|
||||||
"name":"healthcareio","version":"1.5.6",
|
"name":"healthcareio","version":"1.5.8",
|
||||||
"author":"Vanderbilt University Medical Center",
|
"author":"Vanderbilt University Medical Center",
|
||||||
"author_email":"steve.l.nyemba@vumc.org",
|
"author_email":"steve.l.nyemba@vumc.org",
|
||||||
"include_package_data":True,
|
"include_package_data":True,
|
||||||
|
|
Loading…
Reference in New Issue