new: resume functionality

This commit is contained in:
Steve Nyemba 2020-10-01 11:43:57 -05:00
parent 9d0173424d
commit 99d5804c9e
3 changed files with 37 additions and 3 deletions

View File

@ -144,7 +144,20 @@ def parse(**args):
return get_content(args['filename'],CONFIG,SECTION) return get_content(args['filename'],CONFIG,SECTION)
def resume (files,id,config):
_args = config['store'].copy()
if 'mongo' in config['store']['type'] :
_args['type'] = 'mongo.MongoReader'
reader = factory.instance(**_args)
_files = []
if 'resume' in config['analytics'] :
_args = config['analytics']['resume'][id]
_files = reader.read(**_args)
_files = [item['name'] for item in _files if item['name'] != None]
return list(set(files) - set(_files))
return files
pass
def apply(files,store_info,logger_info=None): def apply(files,store_info,logger_info=None):
""" """
:files list of files to be processed in this given thread/process :files list of files to be processed in this given thread/process
@ -166,6 +179,7 @@ def apply(files,store_info,logger_info=None):
# #
try: try:
content,logs = parse(filename = filename,type=SYS_ARGS['parse']) content,logs = parse(filename = filename,type=SYS_ARGS['parse'])
if content : if content :
writer.write(content) writer.write(content)
if logs : if logs :
@ -173,6 +187,7 @@ def apply(files,store_info,logger_info=None):
else: else:
logger.write({"parse":SYS_ARGS['parse'],"name":filename,"completed":True,"rows":len(content)}) logger.write({"parse":SYS_ARGS['parse'],"name":filename,"completed":True,"rows":len(content)})
except Exception as e: except Exception as e:
logger.write({"parse":SYS_ARGS['parse'],"filename":filename,"completed":False,"rows":-1,"msg":e.args[0]}) logger.write({"parse":SYS_ARGS['parse'],"filename":filename,"completed":False,"rows":-1,"msg":e.args[0]})
# print ([filename,len(content)]) # print ([filename,len(content)])
# #
@ -233,6 +248,12 @@ if __name__ == '__main__' :
# raise an erro # raise an erro
pass pass
# #
# if the user has specified to resume, we should look into the logs and pull the files processed and those that haven't
#
if 'resume' in SYS_ARGS :
files = resume(files,SYS_ARGS['parse'],info)
print (["Found ",len(files)," files unprocessed"])
#
# @TODO: Log this here so we know what is being processed or not # @TODO: Log this here so we know what is being processed or not
SCOPE = None SCOPE = None
@ -348,11 +369,12 @@ if __name__ == '__main__' :
healthcare-io.py --<[signup|init]> <email> --store <sqlite|mongo> [--batch <value>] healthcare-io.py --<[signup|init]> <email> --store <sqlite|mongo> [--batch <value>]
healthcare-io.py --parse claims --folder <path> [--batch <value>] healthcare-io.py --parse claims --folder <path> [--batch <value>]
healthcare-io.py --parse remits --folder <path> [--batch <value>] healthcare-io.py --parse remits --folder <path> [--batch <value>] [--resume]
parameters : parameters :
--<[signup|init]> signup or get a configuration file from a parsing server --<[signup|init]> signup or get a configuration file from a parsing server
--store data store mongo or sqlite or mongodb --store data store mongo or sqlite or mongodb
--resume will attempt to resume if there was an interruption
""" """
print(msg) print(msg)
pass pass

View File

@ -21,6 +21,18 @@ import os
import sys import sys
import hashlib import hashlib
import json import json
class X12 :
def split(self,row,sep='*',prefix='HI') :
pass
def get_config(self,config,row):
pass
def hash(self,value):
pass
def suppress (self,value):
pass
def format_date(self,value):
pass
def split(row,sep='*',prefix='HI'): def split(row,sep='*',prefix='HI'):
""" """
This function is designed to split an x12 row and This function is designed to split an x12 row and

View File

@ -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.3.0", "name":"healthcareio","version":"1.3.1",
"author":"Vanderbilt University Medical Center", "author":"Vanderbilt University Medical Center",
"author_email":"steve.l.nyemba@vumc.org", "author_email":"steve.l.nyemba@vumc.org",
"license":"MIT", "license":"MIT",