Skip to content

Commit e59c768

Browse files
committed
Merge branch 'develop' of github.com:NHSDigital/NRLF into feature/eema1-NRL-478-validateContext
2 parents 94fd9cd + 25adafa commit e59c768

File tree

7 files changed

+36
-16
lines changed

7 files changed

+36
-16
lines changed

api/consumer/swagger.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,8 +1052,6 @@ components:
10521052
items:
10531053
$ref: "#/components/schemas/Reference"
10541054
description: Related identifiers or resources associated with the DocumentReference.
1055-
required:
1056-
- practiceSetting
10571055
DocumentReferenceContent:
10581056
type: object
10591057
properties:

api/producer/swagger.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,6 @@ components:
13981398
- status
13991399
- content
14001400
- author
1401-
- context
14021401
Bundle:
14031402
type: object
14041403
properties:
@@ -1608,8 +1607,6 @@ components:
16081607
items:
16091608
$ref: "#/components/schemas/Reference"
16101609
description: Related identifiers or resources associated with the DocumentReference.
1611-
required:
1612-
- practiceSetting
16131610
DocumentReferenceContent:
16141611
type: object
16151612
properties:

layer/nrlf/consumer/fhir/r4/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,11 +804,11 @@ class DocumentReferenceContext(BaseModel):
804804
Field(description="The kind of facility where the patient was seen."),
805805
] = None
806806
practiceSetting: Annotated[
807-
CodeableConcept,
807+
Optional[CodeableConcept],
808808
Field(
809809
description="This property may convey specifics about the practice setting where the content was created, often reflecting the clinical specialty."
810810
),
811-
]
811+
] = None
812812
sourcePatientInfo: Annotated[
813813
Optional[Reference],
814814
Field(

layer/nrlf/core/tests/test_model.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import pytest
2+
from pydantic import ValidationError
3+
14
from nrlf.core.model import (
25
ConnectionMetadata,
36
ConsumerRequestParams,
@@ -91,6 +94,28 @@ def test_consumer_request_params():
9194
assert params.nhs_number == "9999999999"
9295

9396

97+
def test_producer_request_params_extra_fields():
98+
with pytest.raises(ValidationError):
99+
ProducerRequestParams.model_validate(
100+
{
101+
"subject:identifier": "https://fhir.nhs.uk/Id/nhs-number|9999999999",
102+
"type": "test-type",
103+
"extra_field": "extra_value",
104+
}
105+
)
106+
107+
108+
def test_consumer_request_params_extra_fields():
109+
with pytest.raises(ValidationError):
110+
ConsumerRequestParams.model_validate(
111+
{
112+
"subject:identifier": "https://fhir.nhs.uk/Id/nhs-number|9999999999",
113+
"type": "test-type",
114+
"extra_field": "extra_value",
115+
}
116+
)
117+
118+
94119
def test_count_request_params():
95120
params = CountRequestParams.model_validate(
96121
{

layer/nrlf/producer/fhir/r4/model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,9 +611,9 @@ class DocumentReference(BaseModel):
611611
securityLabel: Optional[List[CodeableConcept]] = None
612612
content: Annotated[List[DocumentReferenceContent], Field(min_length=1)]
613613
context: Annotated[
614-
DocumentReferenceContext,
614+
Optional[DocumentReferenceContext],
615615
Field(description="The clinical context in which the document was prepared."),
616-
]
616+
] = None
617617

618618

619619
class Bundle(BaseModel):
@@ -788,11 +788,11 @@ class DocumentReferenceContext(BaseModel):
788788
Field(description="The kind of facility where the patient was seen."),
789789
] = None
790790
practiceSetting: Annotated[
791-
CodeableConcept,
791+
Optional[CodeableConcept],
792792
Field(
793793
description="This property may convey specifics about the practice setting where the content was created, often reflecting the clinical specialty."
794794
),
795-
]
795+
] = None
796796
sourcePatientInfo: Annotated[
797797
Optional[Reference],
798798
Field(

layer/nrlf/producer/fhir/r4/strict_model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,9 @@ class DocumentReference(BaseModel):
531531
securityLabel: Optional[List[CodeableConcept]] = None
532532
content: Annotated[List[DocumentReferenceContent], Field(min_length=1)]
533533
context: Annotated[
534-
DocumentReferenceContext,
534+
Optional[DocumentReferenceContext],
535535
Field(description="The clinical context in which the document was prepared."),
536-
]
536+
] = None
537537

538538

539539
class Bundle(BaseModel):
@@ -693,11 +693,11 @@ class DocumentReferenceContext(BaseModel):
693693
Field(description="The kind of facility where the patient was seen."),
694694
] = None
695695
practiceSetting: Annotated[
696-
CodeableConcept,
696+
Optional[CodeableConcept],
697697
Field(
698698
description="This property may convey specifics about the practice setting where the content was created, often reflecting the clinical specialty."
699699
),
700-
]
700+
] = None
701701
sourcePatientInfo: Annotated[
702702
Optional[Reference],
703703
Field(

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ sonar.exclusions=scripts/**, **/scripts/**, api/tests/**, tests/**, api/**/tests
1010
# Exclude snomed urls as being unsafe
1111
sonar.issue.ignore.multicriteria=exclude_snomed_urls
1212
sonar.issue.ignore.multicriteria.exclude_snomed_urls.ruleKey=python:S5332
13-
sonar.issue.ignore.multicriteria.exclude_snomed_urls.pattern=http://snomed\.info(/sct)?$
13+
sonar.issue.ignore.multicriteria.exclude_snomed_urls.pattern=**http://snomed\.info(/sct)?**

0 commit comments

Comments
 (0)