From 1ffb4da5d80933ebd0a32b7603af3a39e9fe3f36 Mon Sep 17 00:00:00 2001 From: Kate Bobyn Date: Thu, 22 May 2025 18:48:35 +0100 Subject: [PATCH 1/7] NRL-1472 add requisite new entries to ValueSets --- layer/nrlf/core/constants.py | 10 ++++++++++ resources/fhir/NRLF-FormatCode-ValueSet.json | 8 ++++++-- resources/fhir/NRLF-PracticeSetting-ValueSet.json | 8 ++++++-- resources/fhir/NRLF-RecordCategory-ValueSet.json | 8 ++++++-- resources/fhir/NRLF-RecordType-ValueSet.json | 8 ++++++-- 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/layer/nrlf/core/constants.py b/layer/nrlf/core/constants.py index d7b94f366..af3fd17e5 100644 --- a/layer/nrlf/core/constants.py +++ b/layer/nrlf/core/constants.py @@ -66,6 +66,7 @@ class PointerTypes(Enum): PERSONALISED_CARE_AND_SUPPORT_PLAN = "http://snomed.info/sct|2181441000000107" MRA_UPPER_LIMB_ARTERY = "https://nicip.nhs.uk|MAULR" MRI_AXILLA_BOTH = "https://nicip.nhs.uk|MAXIB" + APPOINTMENT = "http://snomed.info/sct|749001000000101" @staticmethod def list(): @@ -84,6 +85,7 @@ class Categories(Enum): CLINICAL_NOTE = "http://snomed.info/sct|823651000000106" DIAGNOSTIC_STUDIES_REPORT = "http://snomed.info/sct|721981007" DIAGNOSTIC_PROCEDURE = "http://snomed.info/sct|103693007" + RECORD_ARTIFACT = "http://snomed.info/sct|419891008" @staticmethod def list(): @@ -112,6 +114,7 @@ def coding_value(self): Categories.DIAGNOSTIC_PROCEDURE.value: { "display": "Diagnostic procedure", }, + Categories.RECORD_ARTIFACT.value: {"display": "Record artifact"}, } TYPE_ATTRIBUTES = { @@ -157,6 +160,9 @@ def coding_value(self): PointerTypes.MRI_AXILLA_BOTH.value: { "display": "MRI Axilla Both", }, + PointerTypes.APPOINTMENT.value: { + "display": "Appointment", + }, } TYPE_CATEGORIES = { @@ -182,6 +188,9 @@ def coding_value(self): # Imaging PointerTypes.MRA_UPPER_LIMB_ARTERY.value: Categories.DIAGNOSTIC_STUDIES_REPORT.value, PointerTypes.MRI_AXILLA_BOTH.value: Categories.DIAGNOSTIC_PROCEDURE.value, + # + # Bookings and Referrals + PointerTypes.APPOINTMENT.value: Categories.RECORD_ARTIFACT.value, } PRACTICE_SETTING_VALUE_SET_URL = ( @@ -653,6 +662,7 @@ def coding_value(self): "24291000087104": "Geriatric chronic pain management service", "1323501000000109": "Special care dentistry service", "1423561000000102": "Acute oncology service", + "394802001": "General medicine", } diff --git a/resources/fhir/NRLF-FormatCode-ValueSet.json b/resources/fhir/NRLF-FormatCode-ValueSet.json index 17df9fec7..4f48ee992 100644 --- a/resources/fhir/NRLF-FormatCode-ValueSet.json +++ b/resources/fhir/NRLF-FormatCode-ValueSet.json @@ -2,10 +2,10 @@ "resourceType": "ValueSet", "id": "NRLF-FormatCode", "url": "https://fhir.nhs.uk/England/ValueSet/England-NRLFormatCode", - "version": "1.0.0", + "version": "1.0.3", "name": "NRLF Format Code", "status": "draft", - "date": "2025-01-28T00:00:00+00:00", + "date": "2025-05-22T00:00:00+00:00", "publisher": "NHS Digital", "contact": { "name": "NRL Team at NHS Digital", @@ -29,6 +29,10 @@ { "code": "urn:nhs-ic:unstructured", "display": "Unstructured Document" + }, + { + "code": "urn:nhs-ic:structured", + "display": "Structured Document" } ] } diff --git a/resources/fhir/NRLF-PracticeSetting-ValueSet.json b/resources/fhir/NRLF-PracticeSetting-ValueSet.json index 41f53fd47..0048df36c 100644 --- a/resources/fhir/NRLF-PracticeSetting-ValueSet.json +++ b/resources/fhir/NRLF-PracticeSetting-ValueSet.json @@ -2,10 +2,10 @@ "resourceType": "ValueSet", "id": "NRLF-PracticeSetting", "url": "https://fhir.nhs.uk/England/ValueSet/England-NRLPracticeSetting", - "version": "1.1.2", + "version": "1.1.3", "name": "NRLF Record Practice Setting", "status": "draft", - "date": "2025-01-28T00:00:00+00:00", + "date": "2025-05-22T00:00:00+00:00", "publisher": "NHS Digital", "contact": { "name": "NRL Team at NHS Digital", @@ -1881,6 +1881,10 @@ { "code": "1423561000000102", "display": "Acute oncology service" + }, + { + "code": "394802001", + "display": "General medicine" } ] } diff --git a/resources/fhir/NRLF-RecordCategory-ValueSet.json b/resources/fhir/NRLF-RecordCategory-ValueSet.json index 385113ea9..1cc60ab77 100644 --- a/resources/fhir/NRLF-RecordCategory-ValueSet.json +++ b/resources/fhir/NRLF-RecordCategory-ValueSet.json @@ -2,10 +2,10 @@ "resourceType": "ValueSet", "id": "NRLF-RecordCategory", "url": "https://fhir.nhs.uk/England/ValueSet/England-NRLRecordCategory", - "version": "1.1.2", + "version": "1.1.3", "name": "NRLF Record Category", "status": "draft", - "date": "2025-01-28T00:00:00+00:00", + "date": "2025-05-25T00:00:00+00:00", "publisher": "NHS Digital", "contact": { "name": "NRL Team at NHS Digital", @@ -41,6 +41,10 @@ { "code": "103693007", "display": "Diagnostic procedure" + }, + { + "code": "419891008", + "display": "Record artifact" } ] } diff --git a/resources/fhir/NRLF-RecordType-ValueSet.json b/resources/fhir/NRLF-RecordType-ValueSet.json index 2292f2fbd..90c523b14 100644 --- a/resources/fhir/NRLF-RecordType-ValueSet.json +++ b/resources/fhir/NRLF-RecordType-ValueSet.json @@ -2,10 +2,10 @@ "resourceType": "ValueSet", "id": "NRLF-RecordType", "url": "https://fhir.nhs.uk/England/ValueSet/England-NRLRecordType", - "version": "1.1.1", + "version": "1.1.3", "name": "NRLF Record Type", "status": "draft", - "date": "2025-01-28T00:00:00+00:00", + "date": "2025-05-22T00:00:00+00:00", "publisher": "NHS Digital", "contact": { "name": "NRL Team at NHS Digital", @@ -69,6 +69,10 @@ { "code": "2181441000000107", "display": "Personalised Care and Support Plan" + }, + { + "code": "749001000000101", + "display": "Appointment" } ] }, From 9703cdb7be2e40ed5f4e05767d81f5fb859c5362 Mon Sep 17 00:00:00 2001 From: Kate Bobyn Date: Thu, 22 May 2025 19:29:51 +0100 Subject: [PATCH 2/7] NRL-1472 add validation for structured document contentTypes --- layer/nrlf/consumer/fhir/r4/model.py | 12 ++++++-- layer/nrlf/core/constants.py | 13 +++++++++ layer/nrlf/core/tests/test_validators.py | 32 +++++++++++++++++++++ layer/nrlf/core/validators.py | 30 +++++++++++++------ layer/nrlf/producer/fhir/r4/model.py | 14 +++++++-- layer/nrlf/producer/fhir/r4/strict_model.py | 14 +++++++-- 6 files changed, 98 insertions(+), 17 deletions(-) diff --git a/layer/nrlf/consumer/fhir/r4/model.py b/layer/nrlf/consumer/fhir/r4/model.py index 5f9b911a6..fdd65dc83 100644 --- a/layer/nrlf/consumer/fhir/r4/model.py +++ b/layer/nrlf/consumer/fhir/r4/model.py @@ -246,11 +246,19 @@ class NRLFormatCode(Coding): Field(description="The system URL for the NRLF Format Code."), ] code: Annotated[ - Literal["urn:nhs-ic:record-contact", "urn:nhs-ic:unstructured"], + Literal[ + "urn:nhs-ic:record-contact", + "urn:nhs-ic:unstructured", + "urn:nhs-ic:structured", + ], Field(description="The code representing the format of the document."), ] display: Annotated[ - Literal["Contact details (HTTP Unsecured)", "Unstructured Document"], + Literal[ + "Contact details (HTTP Unsecured)", + "Unstructured Document", + "Structured Document", + ], Field(description="The display text for the code."), ] diff --git a/layer/nrlf/core/constants.py b/layer/nrlf/core/constants.py index af3fd17e5..fb4cf4eff 100644 --- a/layer/nrlf/core/constants.py +++ b/layer/nrlf/core/constants.py @@ -674,3 +674,16 @@ def coding_value(self): "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability" ) CONTENT_FORMAT_CODE_URL = "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode" +CONTENT_FORMAT_CODE_MAP = { + "urn:nhs-ic:record-contact": "Contact details (HTTP Unsecured)", + "urn:nhs-ic:unstructured": "Unstructured Document", + "urn:nhs-ic:structured": "Structured Document", +} + +ATTACHMENT_CONTENT_TYPES = { + "application/pdf", + "text/html", + "application/json", + "application/fhir+json", + "application/json+fhir", +} diff --git a/layer/nrlf/core/tests/test_validators.py b/layer/nrlf/core/tests/test_validators.py index d1440f429..69366b5e8 100644 --- a/layer/nrlf/core/tests/test_validators.py +++ b/layer/nrlf/core/tests/test_validators.py @@ -1157,6 +1157,38 @@ def test_validate_content_format_invalid_code_for_unstructured_document(): } +def test_validate_content_format_invalid_code_for_structured_document(): + validator = DocumentReferenceValidator() + document_ref_data = load_document_reference_json("Y05868-736253002-Valid") + + document_ref_data["content"][0]["format"] = { + "system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode", + "code": "urn:nhs-ic:record-contact", + "display": "Contact details (HTTP Unsecured)", + } + + result = validator.validate(document_ref_data) + + assert result.is_valid is False + assert result.resource.id == "Y05868-99999-99999-999999" + assert len(result.issues) == 1 + assert result.issues[0].model_dump(exclude_none=True) == { + "severity": "error", + "code": "business-rule", + "details": { + "coding": [ + { + "system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1", + "code": "UNPROCESSABLE_ENTITY", + "display": "Unprocessable Entity", + } + ] + }, + "diagnostics": "Invalid content format code: urn:nhs-ic:record-contact format code must be 'urn:nhs-ic:structured' for Structured Document attachments.", + "expression": ["content[0].format.code"], + } + + def test_validate_content_format_invalid_code_for_contact_details(): validator = DocumentReferenceValidator() document_ref_data = load_document_reference_json("Y05868-736253002-Valid") diff --git a/layer/nrlf/core/validators.py b/layer/nrlf/core/validators.py index efe8bd433..266e93ab3 100644 --- a/layer/nrlf/core/validators.py +++ b/layer/nrlf/core/validators.py @@ -7,7 +7,9 @@ from nrlf.consumer.fhir.r4.model import RequestQueryCategory from nrlf.core.codes import SpineErrorConcept from nrlf.core.constants import ( + ATTACHMENT_CONTENT_TYPES, CATEGORY_ATTRIBUTES, + CONTENT_FORMAT_CODE_MAP, ODS_SYSTEM, PRACTICE_SETTING_VALUE_SET_URL, REQUIRED_CREATE_FIELDS, @@ -483,6 +485,21 @@ def _validate_content_format(self, model: DocumentReference): diagnostics=f"Invalid content format code: {content.format.code} format code must be 'urn:nhs-ic:unstructured' for Unstructured Document attachments.", field=f"content[{i}].format.code", ) + elif ( + content.attachment.contentType + in { + "application/json", + "application/fhir+json", + "application/json+fhir", + } + and content.format.code != "urn:nhs-ic:structured" + ): + self.result.add_error( + issue_code="business-rule", + error_code="UNPROCESSABLE_ENTITY", + diagnostics=f"Invalid content format code: {content.format.code} format code must be 'urn:nhs-ic:structured' for Structured Document attachments.", + field=f"content[{i}].format.code", + ) def _validate_content_extension(self, model: DocumentReference): """ @@ -613,28 +630,23 @@ def _validate_practiceSetting(self, model: DocumentReference): def _validate_content(self, model: DocumentReference): """ - Validate that the contentType is present and is either 'application/pdf' or 'text/html'. + Validate that the contentType is present and supported. """ logger.log(LogReference.VALIDATOR001, step="content") - format_code_display_map = { - "urn:nhs-ic:record-contact": "Contact details (HTTP Unsecured)", - "urn:nhs-ic:unstructured": "Unstructured Document", - } - for i, content in enumerate(model.content): - if content.attachment.contentType not in ["application/pdf", "text/html"]: + if content.attachment.contentType not in ATTACHMENT_CONTENT_TYPES: self.result.add_error( issue_code="business-rule", error_code="UNPROCESSABLE_ENTITY", - diagnostics=f"Invalid contentType: {content.attachment.contentType}. Must be 'application/pdf' or 'text/html'", + diagnostics=f"Invalid contentType: {content.attachment.contentType}. Must be 'application/pdf', 'text/html' or 'application/fhir+json'", field=f"content[{i}].attachment.contentType", ) # Validate NRLFormatCode format_code = content.format.code format_display = content.format.display - expected_display = format_code_display_map.get(format_code) + expected_display = CONTENT_FORMAT_CODE_MAP.get(format_code) if expected_display and format_display != expected_display: self.result.add_error( issue_code="business-rule", diff --git a/layer/nrlf/producer/fhir/r4/model.py b/layer/nrlf/producer/fhir/r4/model.py index 715a7e12e..3c0ff6d83 100644 --- a/layer/nrlf/producer/fhir/r4/model.py +++ b/layer/nrlf/producer/fhir/r4/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: swagger.yaml -# timestamp: 2025-02-07T14:10:35+00:00 +# timestamp: 2025-05-22T18:53:21+00:00 from __future__ import annotations @@ -290,11 +290,19 @@ class NRLFormatCode(Coding): Field(description="The system URL for the NRLF Format Code."), ] code: Annotated[ - Literal["urn:nhs-ic:record-contact", "urn:nhs-ic:unstructured"], + Literal[ + "urn:nhs-ic:record-contact", + "urn:nhs-ic:unstructured", + "urn:nhs-ic:structured", + ], Field(description="The code representing the format of the document."), ] display: Annotated[ - Literal["Contact details (HTTP Unsecured)", "Unstructured Document"], + Literal[ + "Contact details (HTTP Unsecured)", + "Unstructured Document", + "Structured Document", + ], Field(description="The display text for the code."), ] diff --git a/layer/nrlf/producer/fhir/r4/strict_model.py b/layer/nrlf/producer/fhir/r4/strict_model.py index d7849f154..b425da897 100644 --- a/layer/nrlf/producer/fhir/r4/strict_model.py +++ b/layer/nrlf/producer/fhir/r4/strict_model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: swagger.yaml -# timestamp: 2025-02-07T14:10:37+00:00 +# timestamp: 2025-05-22T18:53:21+00:00 from __future__ import annotations @@ -261,11 +261,19 @@ class NRLFormatCode(Coding): Field(description="The system URL for the NRLF Format Code."), ] code: Annotated[ - Literal["urn:nhs-ic:record-contact", "urn:nhs-ic:unstructured"], + Literal[ + "urn:nhs-ic:record-contact", + "urn:nhs-ic:unstructured", + "urn:nhs-ic:structured", + ], Field(description="The code representing the format of the document."), ] display: Annotated[ - Literal["Contact details (HTTP Unsecured)", "Unstructured Document"], + Literal[ + "Contact details (HTTP Unsecured)", + "Unstructured Document", + "Structured Document", + ], Field(description="The display text for the code."), ] From 6ae0797cfe8fd01b9ba9dc62eaa2d2b44756730e Mon Sep 17 00:00:00 2001 From: Kate Bobyn Date: Thu, 22 May 2025 19:58:15 +0100 Subject: [PATCH 3/7] NRL-1472 include new format and content type in parameterised tests --- layer/nrlf/core/tests/test_validators.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/layer/nrlf/core/tests/test_validators.py b/layer/nrlf/core/tests/test_validators.py index 69366b5e8..cb6370c5b 100644 --- a/layer/nrlf/core/tests/test_validators.py +++ b/layer/nrlf/core/tests/test_validators.py @@ -1385,7 +1385,7 @@ def test_validate_content_invalid_content_type(): } ] }, - "diagnostics": "Invalid contentType: invalid/type. Must be 'application/pdf' or 'text/html'", + "diagnostics": "Invalid contentType: invalid/type. Must be 'application/pdf', 'text/html' or 'application/fhir+json'", "expression": ["content[0].attachment.contentType"], } @@ -1415,27 +1415,34 @@ def test_validate_nrl_format_code_valid_match(format_code, format_display): @pytest.mark.parametrize( - "format_code, format_display, expected_display", + "content_type, format_code, format_display, expected_display", [ ( + "application/pdf", "urn:nhs-ic:unstructured", "Contact details (HTTP Unsecured)", "Unstructured Document", ), ( + "text/html", "urn:nhs-ic:record-contact", "Unstructured Document", "Contact details (HTTP Unsecured)", ), + ( + "application/fhir+json", + "urn:nhs-ic:structured", + "Unstructured Document", + "Structured Document", + ), ], ) def test_validate_nrl_format_code_display_mismatch( - format_code, format_display, expected_display + content_type, format_code, format_display, expected_display ): validator = DocumentReferenceValidator() document_ref_data = load_document_reference_json("Y05868-736253002-Valid") - if format_code == "urn:nhs-ic:record-contact": - document_ref_data["content"][0]["attachment"]["contentType"] = "text/html" + document_ref_data["content"][0]["attachment"]["contentType"] = content_type document_ref_data["content"][0]["format"] = { "system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode", From d55641e9296595429a002af635d76b001f8477bc Mon Sep 17 00:00:00 2001 From: Kate Bobyn Date: Thu, 22 May 2025 20:08:23 +0100 Subject: [PATCH 4/7] NRL-1472 include new format and content type in parameterised tests --- layer/nrlf/core/tests/test_validators.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/layer/nrlf/core/tests/test_validators.py b/layer/nrlf/core/tests/test_validators.py index cb6370c5b..00634ef77 100644 --- a/layer/nrlf/core/tests/test_validators.py +++ b/layer/nrlf/core/tests/test_validators.py @@ -1161,6 +1161,8 @@ def test_validate_content_format_invalid_code_for_structured_document(): validator = DocumentReferenceValidator() document_ref_data = load_document_reference_json("Y05868-736253002-Valid") + document_ref_data["content"][0]["attachment"]["contentType"] = "application/json" + document_ref_data["content"][0]["format"] = { "system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode", "code": "urn:nhs-ic:record-contact", From c0fac58493e2ccc27b9a1c988d3322bc3316a8ec Mon Sep 17 00:00:00 2001 From: Kate Bobyn Date: Thu, 22 May 2025 20:50:03 +0100 Subject: [PATCH 5/7] NRL-1472 update error diagnostics in affected integration test scenarios --- tests/features/producer/createDocumentReference-failure.feature | 2 +- tests/features/producer/updateDocumentReference-failure.feature | 2 +- tests/features/producer/upsertDocumentReference-failure.feature | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/features/producer/createDocumentReference-failure.feature b/tests/features/producer/createDocumentReference-failure.feature index 262719d3d..6f064d065 100644 --- a/tests/features/producer/createDocumentReference-failure.feature +++ b/tests/features/producer/createDocumentReference-failure.feature @@ -840,7 +840,7 @@ Feature: Producer - createDocumentReference - Failure Scenarios } ] }, - "diagnostics": "Invalid contentType: application/invalid. Must be 'application/pdf' or 'text/html'", + "diagnostics": "Invalid contentType: application/invalid. Must be 'application/pdf', 'text/html' or 'application/fhir+json'", "expression": [ "content[0].attachment.contentType" ] diff --git a/tests/features/producer/updateDocumentReference-failure.feature b/tests/features/producer/updateDocumentReference-failure.feature index b7d1ed22c..e7c211ec7 100644 --- a/tests/features/producer/updateDocumentReference-failure.feature +++ b/tests/features/producer/updateDocumentReference-failure.feature @@ -229,7 +229,7 @@ Feature: Producer - updateDocumentReference - Failure Scenarios } ] }, - "diagnostics": "Invalid contentType: application/invalid. Must be 'application/pdf' or 'text/html'", + "diagnostics": "Invalid contentType: application/invalid. Must be 'application/pdf', 'text/html' or 'application/fhir+json'", "expression": [ "content[0].attachment.contentType" ] diff --git a/tests/features/producer/upsertDocumentReference-failure.feature b/tests/features/producer/upsertDocumentReference-failure.feature index 5281b4b2e..f714fe282 100644 --- a/tests/features/producer/upsertDocumentReference-failure.feature +++ b/tests/features/producer/upsertDocumentReference-failure.feature @@ -362,7 +362,7 @@ Feature: Producer - upsertDocumentReference - Failure Scenarios } ] }, - "diagnostics": "Invalid contentType: application/invalid. Must be 'application/pdf' or 'text/html'", + "diagnostics": "Invalid contentType: application/invalid. Must be 'application/pdf', 'text/html' or 'application/fhir+json'", "expression": [ "content[0].attachment.contentType" ] From 5f3f8d33d0043033d5947287fa685acd3d6058fb Mon Sep 17 00:00:00 2001 From: Kate Bobyn Date: Thu, 22 May 2025 22:25:24 +0100 Subject: [PATCH 6/7] NRL-1472 add happy path scenarios with new valueset entries --- layer/nrlf/core/tests/test_validators.py | 1 + .../createDocumentReference-success.feature | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/layer/nrlf/core/tests/test_validators.py b/layer/nrlf/core/tests/test_validators.py index 00634ef77..aaaaf9550 100644 --- a/layer/nrlf/core/tests/test_validators.py +++ b/layer/nrlf/core/tests/test_validators.py @@ -1397,6 +1397,7 @@ def test_validate_content_invalid_content_type(): [ ("urn:nhs-ic:record-contact", "Contact details (HTTP Unsecured)"), ("urn:nhs-ic:unstructured", "Unstructured Document"), + ("urn:nhs-ic:structured", "Structured Document"), ], ) def test_validate_nrl_format_code_valid_match(format_code, format_display): diff --git a/tests/features/producer/createDocumentReference-success.feature b/tests/features/producer/createDocumentReference-success.feature index 8842111fb..ba081c3d6 100644 --- a/tests/features/producer/createDocumentReference-success.feature +++ b/tests/features/producer/createDocumentReference-success.feature @@ -223,6 +223,10 @@ Feature: Producer - createDocumentReference - Success Scenarios | pointer-type | pointer-category | type-name | | 824321000000109 | 823651000000106 | SUMMARY_RECORD | + Examples: Record Artifacts + | pointer-type | pointer-category | type-name | + | 749001000000101 | 419891008 | APPOINTMENT | + # Create with content and contact details # Create with contact details only # Create with multiple attachments @@ -319,3 +323,56 @@ Feature: Producer - createDocumentReference - Success Scenarios | custodian | ANGY1 | | author | HAR1 | | url | https://example.org/my-doc.pdf | + + Scenario Outline: Successfully create a BaRS Appointment pointer + Given the application 'DataShare' (ID 'z00z-y11y-x22x') is registered to access the API + And the organisation 'BARS1' is authorised to access pointer types: + | system | value | + | http://snomed.info/sct | 749001000000101 | + When producer 'BARS1' creates a DocumentReference with values: + | property | value | + | subject | 9278693472 | + | status | current | + | type | 749001000000101 | + | category | 419891008 | + | custodian | BARS1 | + | author | HAR0 | + | url | https://example.org/appt-link | + | practiceSetting | 394802001 | + | contentType | application/json+fhir | + | formatCode | urn:nhs-ic:structured | + | formatDisplay | Structured Document | + Then the response status code is 201 + And the response is an OperationOutcome with 1 issue + And the OperationOutcome contains the issue: + """ + { + "severity": "information", + "code": "informational", + "details": { + "coding": [ + { + "system": "https://fhir.nhs.uk/ValueSet/NRL-ResponseCode", + "code": "RESOURCE_CREATED", + "display": "Resource created" + } + ] + }, + "diagnostics": "The document has been created" + } + """ + And the response has a Location header + And the Location header starts with '/producer/FHIR/R4/DocumentReference/ANGY1-' + And the resource in the Location header exists with values: + | property | value | + | subject | 9278693472 | + | status | current | + | type | 749001000000101 | + | category | 419891008 | + | custodian | BARS1 | + | author | HAR0 | + | url | https://example.org/appt-link | + | practiceSetting | 394802001 | + | contentType | application/json+fhir | + | formatCode | urn:nhs-ic:structured | + | formatDisplay | Structured Document | From 61ac5910828d95df8657aeb72db3ca58001122e9 Mon Sep 17 00:00:00 2001 From: Kate Bobyn Date: Fri, 23 May 2025 00:23:59 +0100 Subject: [PATCH 7/7] NRL-1472 add happy path scenarios with new valueset entries --- layer/nrlf/core/tests/test_validators.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/layer/nrlf/core/tests/test_validators.py b/layer/nrlf/core/tests/test_validators.py index aaaaf9550..9ed0eea15 100644 --- a/layer/nrlf/core/tests/test_validators.py +++ b/layer/nrlf/core/tests/test_validators.py @@ -1393,18 +1393,19 @@ def test_validate_content_invalid_content_type(): @pytest.mark.parametrize( - "format_code, format_display", + "content_type, format_code, format_display", [ - ("urn:nhs-ic:record-contact", "Contact details (HTTP Unsecured)"), - ("urn:nhs-ic:unstructured", "Unstructured Document"), - ("urn:nhs-ic:structured", "Structured Document"), + ("text/html", "urn:nhs-ic:record-contact", "Contact details (HTTP Unsecured)"), + ("application/pdf", "urn:nhs-ic:unstructured", "Unstructured Document"), + ("application/json+fhir", "urn:nhs-ic:structured", "Structured Document"), ], ) -def test_validate_nrl_format_code_valid_match(format_code, format_display): +def test_validate_nrl_format_code_valid_match( + content_type, format_code, format_display +): validator = DocumentReferenceValidator() document_ref_data = load_document_reference_json("Y05868-736253002-Valid") - if format_code == "urn:nhs-ic:record-contact": - document_ref_data["content"][0]["attachment"]["contentType"] = "text/html" + document_ref_data["content"][0]["attachment"]["contentType"] = content_type document_ref_data["content"][0]["format"] = { "system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",