|
|
|
"""
|
|
|
|
(c) 2019 Claims Toolkit,
|
|
|
|
Health Information Privacy Lab, Vanderbilt University Medical Center
|
|
|
|
|
|
|
|
Steve L. Nyemba <steve.l.nyemba@vanderbilt.edu>
|
|
|
|
Khanhly Nguyen <khanhly.t.nguyen@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
This code is intended to process and parse healthcare x12 837 (claims) and x12 835 (remittances) into human readable JSON format.
|
|
|
|
The claims/outpout can be forwarded to a NoSQL Data store like couchdb and mongodb
|
|
|
|
Usage :
|
|
|
|
Commandline :
|
|
|
|
python edi --scope --config <path> --folder <path> --store <[mongo|disk|couch]> --<db|path]> <id|path>
|
|
|
|
|
|
|
|
with :
|
|
|
|
--scope <claims|remits>
|
|
|
|
--config path of the x12 to be parsed i.e it could be 835, or 837
|
|
|
|
--folder location of the files (they must be decompressed)
|
|
|
|
--store data store could be disk, mongodb, couchdb
|
|
|
|
--db|path name of the folder to store the output or the database name
|
|
|
|
|
|
|
|
Embedded in Code :
|
|
|
|
|
|
|
|
import edi.parser
|
|
|
|
import json
|
|
|
|
|
|
|
|
file = '/data/claim_1.x12'
|
|
|
|
conf = json.loads(open('config/837.json').read())
|
|
|
|
edi.parser.get_content(filename,conf)
|
|
|
|
"""
|
|
|
|
from params import SYS_ARGS
|
|
|
|
from transport import factory
|
|
|
|
from parser import *
|
|
|
|
import os
|
|
|
|
import json
|
|
|
|
import sys
|
|
|
|
if __name__ == '__main__' :
|
|
|
|
"""
|
|
|
|
The program was called from the command line thus we are expecting
|
|
|
|
parse in [claims,remits]
|
|
|
|
config os.sep.path.exists(path)
|
|
|
|
folder os.sep.path.exists(path)
|
|
|
|
store store ()
|
|
|
|
"""
|
|
|
|
p = len( set(['store','config','folder']) & set(SYS_ARGS.keys())) == 3 and ('db' in SYS_ARGS or 'path' in SYS_ARGS)
|
|
|
|
TYPE = {
|
|
|
|
'mongo':'mongo.MongoWriter',
|
|
|
|
'couch':'couch.CouchWriter',
|
|
|
|
'disk':'disk.DiskWriter'
|
|
|
|
}
|
|
|
|
INFO = {
|
|
|
|
'837':{'scope':'claims','section':'HL'},
|
|
|
|
'835':{'scope':'remits','section':'CLP'}
|
|
|
|
}
|
|
|
|
if p :
|
|
|
|
args = {}
|
|
|
|
scope = SYS_ARGS['config'][:-5].split(os.sep)[-1]
|
|
|
|
CONTEXT = INFO[scope]['scope']
|
|
|
|
#
|
|
|
|
# @NOTE:
|
|
|
|
# improve how database and data stores are handled.
|
|
|
|
if SYS_ARGS['store'] == 'couch' :
|
|
|
|
args = {'url': SYS_ARGS['url'] if 'url' in SYS_ARGS else 'http://localhost:5984'}
|
|
|
|
args['dbname'] = SYS_ARGS['db']
|
|
|
|
|
|
|
|
elif SYS_ARGS ['store'] == 'mongo':
|
|
|
|
if sys.version_info[0] > 2 :
|