Skip to content

Commit 3e5892f

Browse files
committed
NRL-1051 bypass content format validation
1 parent dce1b5d commit 3e5892f

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

api/producer/processTransaction/process_transaction_bundle.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ def create_document_reference(
245245
metadata: ConnectionMetadata,
246246
repository: DocumentPointerRepository,
247247
body: DocumentReference,
248+
is_imaging_profile: bool = False,
248249
) -> Response:
249250

250251
logger.log(LogReference.PROCREATE000)
@@ -254,7 +255,7 @@ def create_document_reference(
254255
body.id = f"{id_prefix}-{uuid4()}"
255256

256257
validator = DocumentReferenceValidator()
257-
result = validator.validate(body)
258+
result = validator.validate(body, is_imaging_profile)
258259

259260
if not result.is_valid:
260261
logger.log(LogReference.PROCREATE002)
@@ -335,10 +336,11 @@ def handler(
335336
requested_profile = (
336337
body.meta.profile[0].root if body.meta and body.meta.profile else None
337338
)
338-
339+
is_imaging_profile = False
339340
if requested_profile and not requested_profile.endswith(
340341
"profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.UnContained.Comprehensive.ProvideBundle"
341342
):
343+
is_imaging_profile = True
342344
logger.log(LogReference.PROTRAN001, requested_profile=requested_profile)
343345
return SpineErrorResponse.BAD_REQUEST(
344346
diagnostics="Only IHE.MHD.UnContained.Comprehensive.ProvideBundle profiles are supported",
@@ -402,7 +404,7 @@ def handler(
402404
document_reference = DocumentReference(**(entry.resource))
403405

404406
create_response = create_document_reference(
405-
metadata, repository, document_reference
407+
metadata, repository, document_reference, is_imaging_profile
406408
)
407409
responses.append(create_response)
408410
except OperationOutcomeError as e:

layer/nrlf/core/validators.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ def parse(cls, data: Dict[str, Any]):
118118
msg="Failed to parse DocumentReference resource",
119119
) from None
120120

121-
def validate(self, data: Dict[str, Any] | DocumentReference):
121+
def validate(
122+
self, data: Dict[str, Any] | DocumentReference, is_imaging: bool = False
123+
):
122124
"""
123125
Validate the document reference
124126
"""
@@ -138,7 +140,7 @@ def validate(self, data: Dict[str, Any] | DocumentReference):
138140
self._validate_author(resource)
139141
self._validate_type_category_mapping(resource)
140142
self._validate_content(resource)
141-
self._validate_content_format(resource)
143+
self._validate_content_format(resource, is_imaging)
142144
self._validate_content_extension(resource)
143145
self._validate_practiceSetting(resource)
144146

@@ -479,10 +481,16 @@ def _validate_type_category_mapping(self, model: DocumentReference):
479481
field="category.coding[0].code",
480482
)
481483

482-
def _validate_content_format(self, model: DocumentReference):
484+
def _validate_content_format(
485+
self, model: DocumentReference, is_imaging: bool = False
486+
):
483487
"""
484488
Validate the content.format field contains an appropriate coding.
485489
"""
490+
if is_imaging:
491+
# Add validation for imaging content format later
492+
return
493+
486494
logger.log(LogReference.VALIDATOR001, step="content_format")
487495

488496
logger.debug("Validating format")

0 commit comments

Comments
 (0)