Skip to content

Commit fc90744

Browse files
committed
Fixing errors
1 parent 28c3c34 commit fc90744

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

core/code_systems/serializers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from collections import OrderedDict
44

55
from rest_framework import serializers
6+
from rest_framework.exceptions import ValidationError
67
from rest_framework.fields import CharField, BooleanField, SerializerMethodField, ChoiceField, \
78
DateTimeField
89

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

292+
if not owner:
293+
raise ValidationError(f"Cannot find owner of type {ident['owner_type']} and id {ident['owner_id']}")
294+
291295
source.set_parent(owner)
292296
source.source_type = 'CodeSystem'
293297

core/common/serializers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def convert_ocl_uri_to_fhir_url(uri, resource_type):
112112
@staticmethod
113113
def convert_fhir_url_to_ocl_uri(uri, resource_type):
114114
resource_type_uri = f"/{resource_type}/"
115-
if uri.startswith('/orgs/') or uri.startswith('/users/'):
115+
if uri and (uri.startswith('/orgs/') or uri.startswith('/users/')):
116116
# Recognize OCL FHIR relative URI
117117
uri = uri.replace('/ConceptMap/', resource_type_uri).replace('/CodeSystem/', resource_type_uri) \
118118
.replace('/ValueSet/', resource_type_uri)

core/concept_maps/serializers.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from collections import OrderedDict
33

44
from rest_framework import serializers
5+
from rest_framework.exceptions import ValidationError
56
from rest_framework.fields import CharField, SerializerMethodField, \
67
DateTimeField
78

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

168+
if not owner:
169+
raise ValidationError(f"Cannot find owner of type {ident['owner_type']} and id {ident['owner_id']}")
170+
167171
source.set_parent(owner)
168172
source.source_type = 'ConceptMap'
169173

0 commit comments

Comments
 (0)