From 086d08906f8c6e13a7266ee75f76c1c7f53216a9 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Mon, 18 Jan 2021 14:49:56 -0600 Subject: [PATCH] bug fix, procedure code processing --- healthcareio/x12/__init__.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/healthcareio/x12/__init__.py b/healthcareio/x12/__init__.py index ea32026..fe8eb41 100644 --- a/healthcareio/x12/__init__.py +++ b/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])