Skip to content

Commit 2ab68b4

Browse files
committed
NRL-1051 add imaging values to model
1 parent 3e5892f commit 2ab68b4

File tree

7 files changed

+172
-22
lines changed

7 files changed

+172
-22
lines changed

api/consumer/swagger.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,18 +1244,23 @@ components:
12441244
type: string
12451245
enum:
12461246
- "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"
1247+
- "https://profiles.ihe.net/fhir/ihe.formatcode.fhir/1.2.0/ValueSet-formatcode.html"
12471248
description: The system URL for the NRLF Format Code.
12481249
code:
12491250
type: string
12501251
enum:
12511252
- "urn:nhs-ic:record-contact"
12521253
- "urn:nhs-ic:unstructured"
1254+
- "direct"
1255+
- "apiplatform"
12531256
description: The code representing the format of the document.
12541257
display:
12551258
type: string
12561259
enum:
12571260
- "Contact details (HTTP Unsecured)"
12581261
- "Unstructured Document"
1262+
- "Direct"
1263+
- "API Platform"
12591264
description: The display text for the code.
12601265
required:
12611266
- system

api/producer/processTransaction/tests/test_process_transaction_bundle.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,110 @@ def test_create_single_mhds_document_reference_with_transaction_happy_path(
211211
}
212212

213213

214+
@mock_aws
215+
@mock_repository
216+
@freeze_time("2024-03-21T12:34:56.789")
217+
@freeze_uuid("00000000-0000-0000-0000-000000000001")
218+
def test_create_single_mhds_document_reference_imaging_format_with_transaction_happy_path(
219+
repository: DocumentPointerRepository,
220+
):
221+
raw_doc_ref = load_document_reference("Y05868-736253002-Valid").model_dump(
222+
exclude_none=True
223+
)
224+
225+
raw_doc_ref.pop("author")
226+
raw_doc_ref.pop("context")
227+
raw_doc_ref["content"][0]["attachment"]["contentType"] = "application/dicom"
228+
raw_doc_ref["content"][0]["format"][
229+
"system"
230+
] = "https://profiles.ihe.net/fhir/ihe.formatcode.fhir/1.2.0/ValueSet-formatcode.html"
231+
raw_doc_ref["content"][0]["format"]["code"] = "direct"
232+
raw_doc_ref["content"][0]["format"]["display"] = "Direct"
233+
234+
request_bundle = Bundle(
235+
meta=Meta(
236+
profile=[
237+
ProfileItem(
238+
"http://hl7.org/fhir/profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.UnContained.Comprehensive.ProvideBundle"
239+
)
240+
]
241+
),
242+
entry=[
243+
BundleEntry(
244+
resource=raw_doc_ref, request=BundleEntryRequest(url="/", method="POST")
245+
)
246+
],
247+
resourceType="Bundle",
248+
type="transaction",
249+
)
250+
251+
event = create_test_api_gateway_event(
252+
headers=create_headers(),
253+
body=request_bundle.model_dump_json(),
254+
)
255+
256+
result = handler(event, create_mock_context())
257+
body = result.pop("body")
258+
259+
assert result == {
260+
"statusCode": "200",
261+
"headers": {
262+
**default_response_headers(),
263+
},
264+
"isBase64Encoded": False,
265+
}
266+
267+
parsed_body = json.loads(body)
268+
assert parsed_body == {
269+
"resourceType": "Bundle",
270+
"type": "transaction-response",
271+
"entry": [
272+
{
273+
"response": {
274+
"status": "201",
275+
"location": "/producer/FHIR/R4/DocumentReference/Y05868-00000000-0000-0000-0000-000000000001",
276+
"outcome": {
277+
"resourceType": "OperationOutcome",
278+
"issue": [
279+
{
280+
"severity": "information",
281+
"code": "informational",
282+
"details": {
283+
"coding": [
284+
{
285+
"system": "https://fhir.nhs.uk/ValueSet/NRL-ResponseCode",
286+
"code": "RESOURCE_CREATED",
287+
"display": "Resource created",
288+
}
289+
]
290+
},
291+
"diagnostics": "The document has been created",
292+
}
293+
],
294+
},
295+
},
296+
},
297+
],
298+
}
299+
300+
created_doc_pointer = repository.get_by_id(
301+
"Y05868-00000000-0000-0000-0000-000000000001"
302+
)
303+
304+
assert created_doc_pointer is not None
305+
assert created_doc_pointer.created_on == "2024-03-21T12:34:56.789Z"
306+
assert created_doc_pointer.updated_on is None
307+
assert json.loads(created_doc_pointer.document) == {
308+
**raw_doc_ref,
309+
**DEFAULT_MHDS_PROPERTIES,
310+
"meta": {
311+
"lastUpdated": "2024-03-21T12:34:56.789Z",
312+
},
313+
"date": "2024-03-21T12:34:56.789Z",
314+
"id": "Y05868-00000000-0000-0000-0000-000000000001",
315+
}
316+
317+
214318
@mock_aws
215319
@mock_repository
216320
@freeze_time("2024-03-21T12:34:56.789")

api/producer/swagger.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,18 +1836,23 @@ components:
18361836
type: string
18371837
enum:
18381838
- "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"
1839+
- "https://profiles.ihe.net/fhir/ihe.formatcode.fhir/1.2.0/ValueSet-formatcode.html"
18391840
description: The system URL for the NRLF Format Code.
18401841
code:
18411842
type: string
18421843
enum:
18431844
- "urn:nhs-ic:record-contact"
18441845
- "urn:nhs-ic:unstructured"
1846+
- "direct"
1847+
- "apiplatform"
18451848
description: The code representing the format of the document.
18461849
display:
18471850
type: string
18481851
enum:
18491852
- "Contact details (HTTP Unsecured)"
18501853
- "Unstructured Document"
1854+
- "Direct"
1855+
- "API Platform"
18511856
description: The display text for the code.
18521857
required:
18531858
- system

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: swagger.yaml
3-
# timestamp: 2024-12-16T09:14:29+00:00
3+
# timestamp: 2024-12-17T12:48:16+00:00
44

55
from __future__ import annotations
66

@@ -240,15 +240,28 @@ class ContentStabilityExtensionCoding(Coding):
240240

241241
class NRLFormatCode(Coding):
242242
system: Annotated[
243-
Literal["https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"],
243+
Literal[
244+
"https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
245+
"https://profiles.ihe.net/fhir/ihe.formatcode.fhir/1.2.0/ValueSet-formatcode.html",
246+
],
244247
Field(description="The system URL for the NRLF Format Code."),
245248
]
246249
code: Annotated[
247-
Literal["urn:nhs-ic:record-contact", "urn:nhs-ic:unstructured"],
250+
Literal[
251+
"urn:nhs-ic:record-contact",
252+
"urn:nhs-ic:unstructured",
253+
"direct",
254+
"apiplatform",
255+
],
248256
Field(description="The code representing the format of the document."),
249257
]
250258
display: Annotated[
251-
Literal["Contact details (HTTP Unsecured)", "Unstructured Document"],
259+
Literal[
260+
"Contact details (HTTP Unsecured)",
261+
"Unstructured Document",
262+
"Direct",
263+
"API Platform",
264+
],
252265
Field(description="The display text for the code."),
253266
]
254267

layer/nrlf/core/validators.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def validate(
139139
self._validate_category(resource)
140140
self._validate_author(resource)
141141
self._validate_type_category_mapping(resource)
142-
self._validate_content(resource)
143-
self._validate_content_format(resource, is_imaging)
142+
self._validate_content(resource, is_imaging)
143+
self._validate_content_format(resource)
144144
self._validate_content_extension(resource)
145145
self._validate_practiceSetting(resource)
146146

@@ -481,16 +481,10 @@ def _validate_type_category_mapping(self, model: DocumentReference):
481481
field="category.coding[0].code",
482482
)
483483

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

496490
logger.debug("Validating format")
@@ -643,10 +637,13 @@ def _validate_practiceSetting(self, model: DocumentReference):
643637
)
644638
return
645639

646-
def _validate_content(self, model: DocumentReference):
640+
def _validate_content(self, model: DocumentReference, is_imaging: bool = False):
647641
"""
648642
Validate that the contentType is present and is either 'application/pdf' or 'text/html'.
649643
"""
644+
if is_imaging:
645+
return
646+
650647
logger.log(LogReference.VALIDATOR001, step="content")
651648

652649
format_code_display_map = {

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: swagger.yaml
3-
# timestamp: 2024-12-16T09:14:26+00:00
3+
# timestamp: 2024-12-17T12:48:12+00:00
44

55
from __future__ import annotations
66

@@ -240,15 +240,28 @@ class ContentStabilityExtensionCoding(Coding):
240240

241241
class NRLFormatCode(Coding):
242242
system: Annotated[
243-
Literal["https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"],
243+
Literal[
244+
"https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
245+
"https://profiles.ihe.net/fhir/ihe.formatcode.fhir/1.2.0/ValueSet-formatcode.html",
246+
],
244247
Field(description="The system URL for the NRLF Format Code."),
245248
]
246249
code: Annotated[
247-
Literal["urn:nhs-ic:record-contact", "urn:nhs-ic:unstructured"],
250+
Literal[
251+
"urn:nhs-ic:record-contact",
252+
"urn:nhs-ic:unstructured",
253+
"direct",
254+
"apiplatform",
255+
],
248256
Field(description="The code representing the format of the document."),
249257
]
250258
display: Annotated[
251-
Literal["Contact details (HTTP Unsecured)", "Unstructured Document"],
259+
Literal[
260+
"Contact details (HTTP Unsecured)",
261+
"Unstructured Document",
262+
"Direct",
263+
"API Platform",
264+
],
252265
Field(description="The display text for the code."),
253266
]
254267

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: swagger.yaml
3-
# timestamp: 2024-12-16T09:14:27+00:00
3+
# timestamp: 2024-12-17T12:48:14+00:00
44

55
from __future__ import annotations
66

@@ -217,15 +217,28 @@ class ContentStabilityExtensionCoding(Coding):
217217

218218
class NRLFormatCode(Coding):
219219
system: Annotated[
220-
Literal["https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"],
220+
Literal[
221+
"https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
222+
"https://profiles.ihe.net/fhir/ihe.formatcode.fhir/1.2.0/ValueSet-formatcode.html",
223+
],
221224
Field(description="The system URL for the NRLF Format Code."),
222225
]
223226
code: Annotated[
224-
Literal["urn:nhs-ic:record-contact", "urn:nhs-ic:unstructured"],
227+
Literal[
228+
"urn:nhs-ic:record-contact",
229+
"urn:nhs-ic:unstructured",
230+
"direct",
231+
"apiplatform",
232+
],
225233
Field(description="The code representing the format of the document."),
226234
]
227235
display: Annotated[
228-
Literal["Contact details (HTTP Unsecured)", "Unstructured Document"],
236+
Literal[
237+
"Contact details (HTTP Unsecured)",
238+
"Unstructured Document",
239+
"Direct",
240+
"API Platform",
241+
],
229242
Field(description="The display text for the code."),
230243
]
231244

0 commit comments

Comments
 (0)