Procházet zdrojové kódy

adding place of service handling for 837

Steve Nyemba před 5 roky
rodič
revize
e485477361
2 změnil soubory, kde provedl 36 přidání a 8 odebrání
  1. 26 7
      edi/parser.py
  2. 10 1
      setup.py

+ 26 - 7
edi/parser.py

@@ -19,6 +19,7 @@
 """
 import os
 import sys
+import json
 def split(row,sep='*',prefix='HI'):
     """
     This function is designed to split an x12 row and 
@@ -30,10 +31,13 @@ def split(row,sep='*',prefix='HI'):
             if '>' in row_value :
                 if row_value.startswith('HC') or row_value.startswith('AD'):
                 
-                    value += row_value.split('>')[:2]
+                    value += row_value.split('>')[:2] 
                 else:
-                    value += row_value.split('>')
+                    
+                    value += row_value.split('>')   if row.startswith('CLM') is False else [row_value]
+                    
             else :
+                
                 value.append(row_value)
         return [xchar.replace('\r','') for xchar in value] #row.replace('~','').split(sep)
     else:
@@ -88,13 +92,20 @@ def format_proc(value):
 def format_diag(value):
 
     return [ {"code":item[2], "type":item[1]} for item in value if len(item) > 1]
+def format_pos(value):
+    
+    xchar = '>' if '>' in value else ':'
+    x = value.split(xchar)    
+    x =  {"code":x[0],"indicator":x[1],"frequency":x[2]} if len(x) == 3 else {"code":x[0],"indicator":None,"frequency":None}
+    return x
+    
 def get_map(row,config,version):
     
     label = config['label'] if 'label' in config else None    
     
     omap = config['map'] if version not in config else config[version]
     anchors = config['anchors'] if 'anchors' in config else []
-    if type(row[0]) == str:
+    if type(row[0]) == str:        
         object_value = {}
         for key in omap :
             index = omap[key]
@@ -108,13 +119,21 @@ def get_map(row,config,version):
                 value = row[index] 
                 
                 if 'cast' in config and key in config['cast'] and value.strip() != '' :
+                    
                     value = eval(config['cast'][key])(value)
                     
-                    pass
-                if 'syn' in config and value in config['syn'] :
-                    value = config['syn'][value]
                 if type(value) == dict :
-                    object_value = dict(object_value, **value)
+                    
+                    for objkey in value :
+                        if 'syn' in config and value[objkey] in config['syn'] :
+                            value[objkey] = config['syn'][ value[objkey]]
+                    value = {key:value}
+                else:
+                    if 'syn' in config and value in config['syn'] :
+                        value = config['syn'][value]
+                if type(value) == dict :
+                    
+                    object_value = dict(object_value, **value) 
                 else:
                     object_value[key] = value
     else:

+ 10 - 1
setup.py

@@ -7,9 +7,18 @@ import sys
 
 def read(fname):
     return open(os.path.join(os.path.dirname(__file__), fname)).read() 
-args = {"name":"parse-edi","version":"1.0.0","author":"Vanderbilt University Medical Center","author_email":"steve.l.nyemba@vanderbilt.edu","license":"MIT","packages":["edi"],"keywords":["healthcare","edi","x12","data","transport","protocol"]}
+args = {
+    "name":"parse-edi","version":"1.0.2",
+    "author":"Vanderbilt University Medical Center",
+    "author_email":"steve.l.nyemba@vumc.org",
+    "license":"MIT",
+    "packages":["edi"],
+    "keywords":["healthcare","edi","x12","analytics","835","837","data","transport","protocol"]
+}
 args["install_requires"] = ['data-transport@git+https://dev.the-phi.com/git/steve/data-transport.git','pymongo','numpy','cloudant','pika','boto','flask-session','smart_open']
 args['url'] = 'https://hiplab.mc.vanderbilt.edu'
+# args['scripts']= ['bin/parse-claims']
+
 if sys.version_info[0] == 2 :
     args['use_2to3'] = False
     args['use_2to3_exclude_fixers'] = ['lib2to3.fixes.fix_import']