Skip to content

Commit

Permalink
Fixing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rkorytkowski committed Nov 26, 2024
1 parent 28c3c34 commit fc90744
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions core/code_systems/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from collections import OrderedDict

from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from rest_framework.fields import CharField, BooleanField, SerializerMethodField, ChoiceField, \
DateTimeField

Expand Down Expand Up @@ -288,6 +289,9 @@ def create(self, validated_data):
else:
owner = UserProfile.objects.filter(username=ident['owner_id']).first()

if not owner:
raise ValidationError(f"Cannot find owner of type {ident['owner_type']} and id {ident['owner_id']}")

source.set_parent(owner)
source.source_type = 'CodeSystem'

Expand Down
2 changes: 1 addition & 1 deletion core/common/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def convert_ocl_uri_to_fhir_url(uri, resource_type):
@staticmethod
def convert_fhir_url_to_ocl_uri(uri, resource_type):
resource_type_uri = f"/{resource_type}/"
if uri.startswith('/orgs/') or uri.startswith('/users/'):
if uri and (uri.startswith('/orgs/') or uri.startswith('/users/')):
# Recognize OCL FHIR relative URI
uri = uri.replace('/ConceptMap/', resource_type_uri).replace('/CodeSystem/', resource_type_uri) \
.replace('/ValueSet/', resource_type_uri)
Expand Down
4 changes: 4 additions & 0 deletions core/concept_maps/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import OrderedDict

from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from rest_framework.fields import CharField, SerializerMethodField, \
DateTimeField

Expand Down Expand Up @@ -164,6 +165,9 @@ def create(self, validated_data):
else:
owner = UserProfile.objects.filter(username=ident['owner_id']).first()

if not owner:
raise ValidationError(f"Cannot find owner of type {ident['owner_type']} and id {ident['owner_id']}")

source.set_parent(owner)
source.source_type = 'ConceptMap'

Expand Down

0 comments on commit fc90744

Please sign in to comment.