Skip to content

Commit 9cb69ca

Browse files
committed
NRL-0000 Merge branch 'develop' into feature/imaging
2 parents e2f9012 + 86d8ad1 commit 9cb69ca

File tree

81 files changed

+8489
-645
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+8489
-645
lines changed

.github/workflows/pr-env-deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
set-environment-id:
2121
name: Set Environment ID
2222
runs-on: [self-hosted, ci]
23+
environment: pull-request
2324
steps:
2425
- name: Set a ID based on the branch name
2526
id: set_environment_id
@@ -44,6 +45,7 @@ jobs:
4445
build:
4546
name: Build Application
4647
runs-on: [self-hosted, ci]
48+
environment: pull-request
4749
steps:
4850
- name: Git Clone - ${{ github.event.pull_request.head.ref }}
4951
uses: actions/checkout@v4

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,22 @@ generate-models: check-warn ## Generate Pydantic Models
198198
--input ./api/producer/swagger.yaml \
199199
--input-file-type openapi \
200200
--output ./layer/nrlf/producer/fhir/r4/model.py \
201-
--output-model-type "pydantic_v2.BaseModel"
201+
--output-model-type "pydantic_v2.BaseModel" \
202+
--base-class nrlf.core.parent_model.Parent
202203
poetry run datamodel-codegen \
203204
--strict-types {str,bytes,int,float,bool} \
204205
--input ./api/producer/swagger.yaml \
205206
--input-file-type openapi \
206207
--output ./layer/nrlf/producer/fhir/r4/strict_model.py \
208+
--base-class nrlf.core.parent_model.Parent \
207209
--output-model-type "pydantic_v2.BaseModel"
208210

211+
209212
@echo "Generating consumer model"
210213
mkdir -p ./layer/nrlf/consumer/fhir/r4
211214
poetry run datamodel-codegen \
212215
--input ./api/consumer/swagger.yaml \
213216
--input-file-type openapi \
214217
--output ./layer/nrlf/consumer/fhir/r4/model.py \
218+
--base-class nrlf.core.parent_model.Parent \
215219
--output-model-type "pydantic_v2.BaseModel"

api/consumer/searchDocumentReference/tests/test_search_document_reference_consumer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from moto import mock_aws
44

55
from api.consumer.searchDocumentReference.search_document_reference import handler
6+
from nrlf.consumer.fhir.r4.model import CodeableConcept, Identifier
67
from nrlf.core.constants import (
78
CATEGORY_ATTRIBUTES,
89
TYPE_ATTRIBUTES,
@@ -66,7 +67,9 @@ def test_search_document_reference_accession_number_in_pointer(
6667
):
6768
doc_ref = load_document_reference("Y05868-736253002-Valid")
6869
doc_ref.identifier = [
69-
{"type": {"text": "Accession-Number"}, "value": "Y05868.123456789"}
70+
Identifier(
71+
type=CodeableConcept(text="Accession-Number"), value="Y05868.123456789"
72+
)
7073
]
7174
doc_pointer = DocumentPointer.from_document_reference(doc_ref)
7275
repository.create(doc_pointer)

api/producer/createDocumentReference/tests/test_create_document_reference.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,36 @@ def test_create_document_reference_invalid_body():
239239
"diagnostics": "Request body could not be parsed (status: Field required)",
240240
"expression": ["status"],
241241
},
242+
{
243+
"severity": "error",
244+
"code": "invalid",
245+
"details": {
246+
"coding": [
247+
{
248+
"code": "MESSAGE_NOT_WELL_FORMED",
249+
"display": "Message not well formed",
250+
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
251+
}
252+
],
253+
},
254+
"diagnostics": "Request body could not be parsed (type: Field required)",
255+
"expression": ["type"],
256+
},
257+
{
258+
"severity": "error",
259+
"code": "invalid",
260+
"details": {
261+
"coding": [
262+
{
263+
"code": "MESSAGE_NOT_WELL_FORMED",
264+
"display": "Message not well formed",
265+
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
266+
}
267+
],
268+
},
269+
"diagnostics": "Request body could not be parsed (category: Field required)",
270+
"expression": ["category"],
271+
},
242272
{
243273
"severity": "error",
244274
"code": "invalid",

api/producer/swagger.yaml

Lines changed: 71 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,12 +1381,12 @@ components:
13811381
enum: ["entered-in-error", "amended", "preliminary", "final"]
13821382
description: The status of the underlying document.
13831383
type:
1384-
$ref: "#/components/schemas/CodeableConcept"
1384+
$ref: "#/components/schemas/NRLCodeableConcept"
13851385
description: Specifies the particular kind of document referenced (e.g. History and Physical, Discharge Summary, Progress Note). This usually equates to the purpose of making the document referenced.
13861386
category:
13871387
type: array
13881388
items:
1389-
$ref: "#/components/schemas/CodeableConcept"
1389+
$ref: "#/components/schemas/NRLCodeableConcept"
13901390
description: A categorization for the type of document referenced – helps for indexing and searching. This may be implied by or derived from the code specified in the DocumentReference.type.
13911391
subject:
13921392
$ref: "#/components/schemas/Reference"
@@ -1413,7 +1413,7 @@ components:
14131413
description: Relationships that this document has with other document references that already exist.
14141414
description:
14151415
type: string
1416-
pattern: "[ \\r\\n\\t\\S]+"
1416+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
14171417
description: Human–readable description of the source document.
14181418
securityLabel:
14191419
type: array
@@ -1435,6 +1435,8 @@ components:
14351435
- content
14361436
- author
14371437
- context
1438+
- type
1439+
- category
14381440
Bundle:
14391441
type: object
14401442
properties:
@@ -1634,7 +1636,7 @@ components:
16341636
$ref: "#/components/schemas/CodeableConcept"
16351637
description: The kind of facility where the patient was seen.
16361638
practiceSetting:
1637-
$ref: "#/components/schemas/CodeableConcept"
1639+
$ref: "#/components/schemas/NRLCodeableConcept"
16381640
description: This property may convey specifics about the practice setting where the content was created, often reflecting the clinical specialty.
16391641
sourcePatientInfo:
16401642
$ref: "#/components/schemas/Reference"
@@ -1720,7 +1722,7 @@ components:
17201722
description: The calculated hash of the data using SHA–1. Represented using base64.
17211723
title:
17221724
type: string
1723-
pattern: "[ \\r\\n\\t\\S]+"
1725+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
17241726
description: A label or set of text to display in place of the data.
17251727
creation:
17261728
type: string
@@ -1743,8 +1745,29 @@ components:
17431745
description: A reference to a code defined by a terminology system.
17441746
text:
17451747
type: string
1746-
pattern: "[ \\r\\n\\t\\S]+"
1748+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
1749+
description: A human language representation of the concept as seen/selected/uttered by the user who entered the data and/or which represents the intended meaning of the user.
1750+
NRLCodeableConcept:
1751+
type: object
1752+
properties:
1753+
id:
1754+
type: string
1755+
pattern: "[A-Za-z0-9\\-\\.]{1,64}"
1756+
description: Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.
1757+
coding:
1758+
type: array
1759+
items:
1760+
$ref: "#/components/schemas/NRLCoding"
1761+
description: A reference to a code defined by a terminology system.
1762+
minItems: 1
1763+
maxItems: 1
1764+
text:
1765+
type: string
1766+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
17471767
description: A human language representation of the concept as seen/selected/uttered by the user who entered the data and/or which represents the intended meaning of the user.
1768+
required:
1769+
- coding
1770+
17481771
Coding:
17491772
type: object
17501773
properties:
@@ -1754,23 +1777,53 @@ components:
17541777
description: Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.
17551778
system:
17561779
type: string
1757-
pattern: \S*
1780+
pattern: \S+
17581781
description: The identification of the code system that defines the meaning of the symbol in the code.
17591782
version:
17601783
type: string
1761-
pattern: "[ \\r\\n\\t\\S]+"
1784+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
17621785
description: The version of the code system which was used when choosing this code. Note that a well–maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured, and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged.
17631786
code:
17641787
type: string
17651788
pattern: "[^\\s]+(\\s[^\\s]+)*"
17661789
description: A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post–coordination).
17671790
display:
17681791
type: string
1769-
pattern: "[ \\r\\n\\t\\S]+"
1792+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
17701793
description: A representation of the meaning of the code in the system, following the rules of the system.
17711794
userSelected:
17721795
type: boolean
17731796
description: Indicates that this coding was chosen by a user directly – e.g. off a pick list of available items (codes or displays).
1797+
NRLCoding:
1798+
type: object
1799+
properties:
1800+
id:
1801+
type: string
1802+
pattern: "[A-Za-z0-9\\-\\.]{1,64}"
1803+
description: Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.
1804+
system:
1805+
type: string
1806+
pattern: \S+
1807+
description: The identification of the code system that defines the meaning of the symbol in the code.
1808+
version:
1809+
type: string
1810+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
1811+
description: The version of the code system which was used when choosing this code. Note that a well–maintained code system does not need the version reported, because the meaning of codes is consistent across versions. However this cannot consistently be assured, and when the meaning is not guaranteed to be consistent, the version SHOULD be exchanged.
1812+
code:
1813+
type: string
1814+
pattern: "[^\\s]+(\\s[^\\s]+)*"
1815+
description: A symbol in syntax defined by the system. The symbol may be a predefined code or an expression in a syntax defined by the coding system (e.g. post–coordination).
1816+
display:
1817+
type: string
1818+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
1819+
description: A representation of the meaning of the code in the system, following the rules of the system.
1820+
userSelected:
1821+
type: boolean
1822+
description: Indicates that this coding was chosen by a user directly – e.g. off a pick list of available items (codes or displays).
1823+
required:
1824+
- system
1825+
- code
1826+
- display
17741827
Extension:
17751828
type: object
17761829
properties:
@@ -1874,11 +1927,11 @@ components:
18741927
description: A coded type for the identifier that can be used to determine which identifier to use for a specific purpose.
18751928
system:
18761929
type: string
1877-
pattern: \S*
1930+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
18781931
description: Establishes the namespace for the value – that is, a URL that describes a set values that are unique.
18791932
value:
18801933
type: string
1881-
pattern: "[ \\r\\n\\t\\S]+"
1934+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
18821935
description: The portion of the identifier typically relevant to the user and which is unique within the context of the system.
18831936
period:
18841937
$ref: "#/components/schemas/Period"
@@ -1917,11 +1970,11 @@ components:
19171970
description: How the value should be understood and represented &ndash; whether the actual value is greater or less than the stated value due to measurement issues; e.g. if the comparator is "<" , then the real value is < stated value.
19181971
unit:
19191972
type: string
1920-
pattern: "[ \\r\\n\\t\\S]+"
1973+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
19211974
description: A human&ndash;readable form of the unit.
19221975
system:
19231976
type: string
1924-
pattern: \S*
1977+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
19251978
description: The identification of the system that provides the coded form of the unit.
19261979
code:
19271980
type: string
@@ -1936,11 +1989,11 @@ components:
19361989
description: Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.
19371990
reference:
19381991
type: string
1939-
pattern: "[ \\r\\n\\t\\S]+"
1992+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
19401993
description: A reference to a location at which the other resource is found. The reference may be a relative reference, in which case it is relative to the service base URL, or an absolute URL that resolves to the location where the resource is found. The reference may be version specific or not. If the reference is not to a FHIR RESTful server, then it should be assumed to be version specific. Internal fragment references (start with '#') refer to contained resources.
19411994
type:
19421995
type: string
1943-
pattern: \S*
1996+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
19441997
description: |-
19451998
The expected type of the target of the reference. If both Reference.type and Reference.reference are populated and Reference.reference is a FHIR URL, both SHALL be consistent.
19461999
The type is the Canonical URL of Resource Definition that is the type this reference refers to. References are URLs that are relative to http://hl7.org/fhir/StructureDefinition/ e.g. "Patient" is a reference to http://hl7.org/fhir/StructureDefinition/Patient. Absolute URLs are only allowed for logical models (and can only be used in references in logical models, not resources).
@@ -1949,7 +2002,7 @@ components:
19492002
description: An identifier for the target resource. This is used when there is no way to reference the other resource directly, either because the entity it represents is not available through a FHIR server, or because there is no way for the author of the resource to convert a known identifier to an actual location. There is no requirement that a Reference.identifier point to something that is actually exposed as a FHIR instance, but it SHALL point to a business concept that would be expected to be exposed as a FHIR instance, and that instance would need to be of a FHIR resource type allowed by the reference.
19502003
display:
19512004
type: string
1952-
pattern: "[ \\r\\n\\t\\S]+"
2005+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
19532006
description: Plain text narrative that identifies the resource in addition to the resource reference.
19542007
Signature:
19552008
type: object
@@ -2007,13 +2060,13 @@ components:
20072060
description: When the resource last changed &ndash; e.g. when the version changed.
20082061
source:
20092062
type: string
2010-
pattern: \S*
2063+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
20112064
description: A uri that identifies the source system of the resource. This provides a minimal amount of [Provenance](provenance.html#) information that can be used to track or differentiate the source of information in the resource. The source may identify another FHIR server, document, message, database, etc.
20122065
profile:
20132066
type: array
20142067
items:
20152068
type: string
2016-
pattern: \S*
2069+
pattern: "[\\S]+[ \\r\\n\\t\\S]*"
20172070
description: A list of profiles (references to [StructureDefinition](structuredefinition.html#) resources) that this resource claims to conform to. The URL is a reference to [StructureDefinition.url](structuredefinition&ndash;definitions.html#StructureDefinition.url).
20182071
security:
20192072
type: array

api/producer/updateDocumentReference/tests/test_update_document_reference.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def test_create_document_reference_no_body():
195195
}
196196

197197

198-
def test_create_document_reference_invalid_body():
198+
def test_update_document_reference_invalid_body():
199199
event = create_test_api_gateway_event(
200200
headers=create_headers(),
201201
path_parameters={"id": "Y05868-99999-99999-999999"},
@@ -246,6 +246,36 @@ def test_create_document_reference_invalid_body():
246246
"diagnostics": "Request body could not be parsed (status: Field required)",
247247
"expression": ["status"],
248248
},
249+
{
250+
"severity": "error",
251+
"code": "invalid",
252+
"details": {
253+
"coding": [
254+
{
255+
"code": "MESSAGE_NOT_WELL_FORMED",
256+
"display": "Message not well formed",
257+
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
258+
}
259+
],
260+
},
261+
"diagnostics": "Request body could not be parsed (type: Field required)",
262+
"expression": ["type"],
263+
},
264+
{
265+
"severity": "error",
266+
"code": "invalid",
267+
"details": {
268+
"coding": [
269+
{
270+
"code": "MESSAGE_NOT_WELL_FORMED",
271+
"display": "Message not well formed",
272+
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
273+
}
274+
],
275+
},
276+
"diagnostics": "Request body could not be parsed (category: Field required)",
277+
"expression": ["category"],
278+
},
249279
{
250280
"severity": "error",
251281
"code": "invalid",
@@ -562,7 +592,6 @@ def test_update_document_reference_immutable_fields(repository):
562592
)
563593
],
564594
text=None,
565-
extension=None,
566595
)
567596

568597
event = create_test_api_gateway_event(

api/producer/upsertDocumentReference/tests/test_upsert_document_reference.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,36 @@ def test_upsert_document_reference_invalid_body():
324324
"diagnostics": "Request body could not be parsed (status: Field required)",
325325
"expression": ["status"],
326326
},
327+
{
328+
"severity": "error",
329+
"code": "invalid",
330+
"details": {
331+
"coding": [
332+
{
333+
"code": "MESSAGE_NOT_WELL_FORMED",
334+
"display": "Message not well formed",
335+
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
336+
}
337+
],
338+
},
339+
"diagnostics": "Request body could not be parsed (type: Field required)",
340+
"expression": ["type"],
341+
},
342+
{
343+
"severity": "error",
344+
"code": "invalid",
345+
"details": {
346+
"coding": [
347+
{
348+
"code": "MESSAGE_NOT_WELL_FORMED",
349+
"display": "Message not well formed",
350+
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
351+
}
352+
],
353+
},
354+
"diagnostics": "Request body could not be parsed (category: Field required)",
355+
"expression": ["category"],
356+
},
327357
{
328358
"severity": "error",
329359
"code": "invalid",

0 commit comments

Comments
 (0)