Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1166 | Bullet-proof identifier and extra lo…
Browse files Browse the repository at this point in the history
…gging
  • Loading branch information
rkorytkowski committed Mar 15, 2022
1 parent 794f5ae commit e5e1941
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions core/code_systems/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ def get_meta(obj):
return {'lastUpdated': obj.updated_at}

def to_representation(self, instance):
rep = super().to_representation(instance)
try:
rep = super().to_representation(instance)
except Exception as e:
raise Exception(f'Failed to deserialize {instance.uri}') from e

self.include_ocl_identifier(instance, rep)
return rep
Expand Down Expand Up @@ -271,12 +274,13 @@ def convert_ocl_to_fhir_url(instance):
def find_ocl_identifier(identifiers):
found = None
for ident in identifiers:
if ident['type'] and ident['type']['coding']:
if isinstance(ident.get('type', {}).get('coding', None), list):
codings = ident['type']['coding']
for coding in codings:
if coding['code'] == 'ACSN' and coding['system'] == 'http://hl7.org/fhir/v2/0203':
found = ident['value']
break
if coding.get('code', None) == 'ACSN' and coding.get('system', None) == 'http://hl7.org/fhir/v2/0203':
found = ident.get('value', None)
if found:
break
if found:
break
return found
Expand Down

0 comments on commit e5e1941

Please sign in to comment.