From bab0040f0c2117177534c4a37fa865c72c3ab665 Mon Sep 17 00:00:00 2001 From: Steve Nyemba Date: Tue, 8 Feb 2022 15:43:06 -0600 Subject: [PATCH] bug fix, putting orphaned attributes in references at top level upon export --- healthcareio/export/export.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/healthcareio/export/export.py b/healthcareio/export/export.py index ed7baaf..ea74064 100644 --- a/healthcareio/export/export.py +++ b/healthcareio/export/export.py @@ -84,11 +84,10 @@ def meta(config) : config[key]['map'][field] = -100 add_index = {} #-- tells if we should add _index attribute or not for prefix in config : - # if 'map' in config[prefix] : - # label = list(set(['label','field']) & set(config[prefix].keys())) - # label = None if not label else config[prefix][label[0]] - # _map = config[prefix]['map'] - # _info += (field_info(_map,label)) + # + # Running through every element that we can parse (from the configuration) + # This allows us to create ER-Like structures from the data we have + # if type(config[prefix]) != dict : continue @@ -98,9 +97,12 @@ def meta(config) : _entry = config[prefix]['@ref'][subprefix] _id = list(set(['label','field']) & set(config[prefix]['@ref'][subprefix].keys())) - _id = _id[0] - table = config[prefix]['@ref'][subprefix][_id] - add_index[table] = 1 if _id == 'label' else 0 + if _id : + # + # In case a reference item has a parent field/label + _id = _id[0] + table = config[prefix]['@ref'][subprefix][_id] + add_index[table] = 1 if _id == 'label' else 0 if 'map' in _entry : _info += get_field(_entry)