File tree Expand file tree Collapse file tree 2 files changed +27
-18
lines changed
Expand file tree Collapse file tree 2 files changed +27
-18
lines changed Original file line number Diff line number Diff line change @@ -1553,3 +1553,30 @@ def test_validate_content_extension_invalid_code_and_display_mismatch():
15531553 "content[0].extension[0].valueCodeableConcept.coding[0].display"
15541554 ],
15551555 }
1556+
1557+
1558+ def test_validate_content_invalid_content_type ():
1559+ validator = DocumentReferenceValidator ()
1560+ document_ref_data = load_document_reference_json ("Y05868-736253002-Valid" )
1561+
1562+ document_ref_data ["content" ][0 ]["attachment" ]["contentType" ] = "invalid/type"
1563+
1564+ result = validator .validate (document_ref_data )
1565+
1566+ assert result .is_valid is False
1567+ assert len (result .issues ) == 1
1568+ assert result .issues [0 ].model_dump (exclude_none = True ) == {
1569+ "severity" : "error" ,
1570+ "code" : "value" ,
1571+ "details" : {
1572+ "coding" : [
1573+ {
1574+ "system" : "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1" ,
1575+ "code" : "INVALID_RESOURCE" ,
1576+ "display" : "Invalid validation of resource" ,
1577+ }
1578+ ]
1579+ },
1580+ "diagnostics" : "Invalid contentType: invalid/type. Must be 'application/pdf' or 'text/html'" ,
1581+ "expression" : ["content[0].attachment.contentType" ],
1582+ }
Original file line number Diff line number Diff line change @@ -612,24 +612,6 @@ def _validate_content(self, model: DocumentReference):
612612 logger .log (LogReference .VALIDATOR001 , step = "content" )
613613
614614 for i , content in enumerate (model .content ):
615- if not content .attachment :
616- self .result .add_error (
617- issue_code = "required" ,
618- error_code = "INVALID_RESOURCE" ,
619- diagnostics = "Missing attachment in content" ,
620- field = f"content[{ i } ].attachment" ,
621- )
622- continue
623-
624- if not content .attachment .contentType :
625- self .result .add_error (
626- issue_code = "required" ,
627- error_code = "INVALID_RESOURCE" ,
628- diagnostics = "Missing contentType in content.attachment" ,
629- field = f"content[{ i } ].attachment.contentType" ,
630- )
631- continue
632-
633615 if content .attachment .contentType not in ["application/pdf" , "text/html" ]:
634616 self .result .add_error (
635617 issue_code = "value" ,
You can’t perform that action at this time.
0 commit comments