Browse Source

bug fix, procedure code processing

Steve Nyemba 4 years ago
parent
commit
086d08906f
1 changed files with 13 additions and 8 deletions
  1. 13 8
      healthcareio/x12/__init__.py

+ 13 - 8
healthcareio/x12/__init__.py

@@ -56,10 +56,12 @@ class Formatters :
             
             for row_value in row.replace('~','').split(sep) :
                 
-                if '>' in row_value :
-                    if row_value.startswith('HC') or row_value.startswith('AD'):
+                if '>' in row_value and not row_value.startswith('HC'):
+                    # if row_value.startswith('HC') or row_value.startswith('AD'):
+                    if row_value.startswith('AD'):
                     
                         value += row_value.split('>')[:2] 
+                        pass
                     else:
                         
                         value += row_value.split('>')   if row.startswith('CLM') is False else [row_value]
@@ -159,17 +161,20 @@ class Formatters :
     
         
     def procedure(self,value):
-        for xchar in [':','<','|'] :
+        
+        for xchar in [':','<','|','>'] :
+            
             if xchar in value and len(value.split(xchar)) > 1 :
                 #_value = {"type":value.split(':')[0].strip(),"code":value.split(':')[1].strip()}
                 _value = {"type":value.split(xchar)[0].strip(),"code":value.split(xchar)[1].strip()}
-                if value.split(xchar) >= 3 :
+                
+                if len(value.split(xchar)) >2 :
                     _value['modifier'] = value.split(xchar)[2]
                 break
             else:
                 _value = str(value)
         return _value
-    def diagnosis(self,alue):
+    def diagnosis(self,value):
 
         return [ {"code":item[2], "type":item[1]} for item in value if len(item) > 1]
     def pos(self,value):
@@ -220,8 +225,7 @@ class Parser (Process):
             
             files = os.listdir(_path)
             if files :
-                fullname = os.sep.join([_path,files[0]])
-                
+                fullname = os.sep.join([_path,files[0]])                
                 _config = json.loads ( (open(fullname)).read() )
         return _config
 
@@ -258,7 +262,8 @@ class Parser (Process):
                         if config['cast'][key] in ['float','int'] :
                             value = eval(config['cast'][key])(value)
                         elif hasattr(handler,config['cast'][key]):
-                            pointer = getattr(handler,config['cast'][key])
+                            
+                            pointer = getattr(handler,config['cast'][key])                            
                             value   = pointer(value)
                         else:
                             print ("Missing Pointer ",config['cast'][key])