Skip to content

Commit 85efa9e

Browse files
NRL-518 Better model inheritance
1 parent e505b70 commit 85efa9e

File tree

7 files changed

+261
-223
lines changed

7 files changed

+261
-223
lines changed

api/consumer/swagger.yaml

Lines changed: 62 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,65 +1195,77 @@ components:
11951195
pattern: \S*
11961196
description: The reference details for the link.
11971197
ContentStabilityExtension:
1198-
type: object
1199-
properties:
1200-
url:
1201-
type: string
1202-
enum:
1203-
- "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
1204-
valueCodeableConcept:
1205-
type: object
1198+
allOf:
1199+
- $ref: "#/components/schemas/Extension"
1200+
- type: object
1201+
properties:
1202+
url:
1203+
type: string
1204+
enum:
1205+
- "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
1206+
valueCodeableConcept:
1207+
$ref: "#/components/schemas/ContentStabilityExtensionValueCodeableConcept"
1208+
required:
1209+
- url
1210+
- valueCodeableConcept
1211+
ContentStabilityExtensionValueCodeableConcept:
1212+
allOf:
1213+
- $ref: "#/components/schemas/CodeableConcept"
1214+
- type: object
12061215
properties:
12071216
coding:
12081217
type: array
12091218
items:
1210-
type: object
1211-
properties:
1212-
system:
1213-
type: string
1214-
enum:
1215-
- "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability"
1216-
code:
1217-
type: string
1218-
enum: ["static", "dynamic"]
1219-
display:
1220-
type: string
1221-
enum: ["Static", "Dynamic"]
1222-
required:
1223-
- system
1224-
- code
1225-
- display
1219+
$ref: "#/components/schemas/ContentStabilityExtensionCoding"
12261220
minItems: 1
12271221
maxItems: 1
12281222
required:
12291223
- coding
1230-
required:
1231-
- url
1232-
- valueCodeableConcept
1224+
ContentStabilityExtensionCoding:
1225+
allOf:
1226+
- $ref: "#/components/schemas/Coding"
1227+
- type: object
1228+
properties:
1229+
system:
1230+
type: string
1231+
enum:
1232+
- "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability"
1233+
code:
1234+
type: string
1235+
enum: ["static", "dynamic"]
1236+
display:
1237+
type: string
1238+
enum: ["Static", "Dynamic"]
1239+
required:
1240+
- system
1241+
- code
1242+
- display
12331243
NRLFormatCode:
1234-
type: object
1235-
properties:
1236-
system:
1237-
type: string
1238-
enum:
1239-
- "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"
1240-
description: The system URL for the NRLF Format Code.
1241-
code:
1242-
type: string
1243-
enum:
1244-
- "urn:nhs-ic:record-contact"
1245-
- "urn:nhs-ic:unstructured"
1246-
description: The code representing the format of the document.
1247-
display:
1248-
type: string
1249-
enum:
1250-
- "Contact details (HTTP Unsecured)"
1251-
- "Unstructured Document"
1252-
description: The display text for the code.
1253-
required:
1254-
- system
1255-
- code
1256-
- display
1244+
allOf:
1245+
- $ref: "#/components/schemas/Coding"
1246+
- type: object
1247+
properties:
1248+
system:
1249+
type: string
1250+
enum:
1251+
- "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"
1252+
description: The system URL for the NRLF Format Code.
1253+
code:
1254+
type: string
1255+
enum:
1256+
- "urn:nhs-ic:record-contact"
1257+
- "urn:nhs-ic:unstructured"
1258+
description: The code representing the format of the document.
1259+
display:
1260+
type: string
1261+
enum:
1262+
- "Contact details (HTTP Unsecured)"
1263+
- "Unstructured Document"
1264+
description: The display text for the code.
1265+
required:
1266+
- system
1267+
- code
1268+
- display
12571269
Identifier:
12581270
type: object
12591271
properties:

api/producer/swagger.yaml

Lines changed: 62 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,6 @@ components:
17231723
items:
17241724
$ref: "#/components/schemas/Extension"
17251725
description: Additional content defined by implementations.
1726-
17271726
Coding:
17281727
type: object
17291728
properties:
@@ -1761,65 +1760,77 @@ components:
17611760
pattern: \S*
17621761
description: The reference details for the link.
17631762
ContentStabilityExtension:
1764-
type: object
1765-
properties:
1766-
url:
1767-
type: string
1768-
enum:
1769-
- "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
1770-
valueCodeableConcept:
1771-
type: object
1763+
allOf:
1764+
- $ref: "#/components/schemas/Extension"
1765+
- type: object
1766+
properties:
1767+
url:
1768+
type: string
1769+
enum:
1770+
- "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
1771+
valueCodeableConcept:
1772+
$ref: "#/components/schemas/ContentStabilityExtensionValueCodeableConcept"
1773+
required:
1774+
- url
1775+
- valueCodeableConcept
1776+
ContentStabilityExtensionValueCodeableConcept:
1777+
allOf:
1778+
- $ref: "#/components/schemas/CodeableConcept"
1779+
- type: object
17721780
properties:
17731781
coding:
17741782
type: array
17751783
items:
1776-
type: object
1777-
properties:
1778-
system:
1779-
type: string
1780-
enum:
1781-
- "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability"
1782-
code:
1783-
type: string
1784-
enum: ["static", "dynamic"]
1785-
display:
1786-
type: string
1787-
enum: ["Static", "Dynamic"]
1788-
required:
1789-
- system
1790-
- code
1791-
- display
1784+
$ref: "#/components/schemas/ContentStabilityExtensionCoding"
17921785
minItems: 1
17931786
maxItems: 1
17941787
required:
17951788
- coding
1796-
required:
1797-
- url
1798-
- valueCodeableConcept
1789+
ContentStabilityExtensionCoding:
1790+
allOf:
1791+
- $ref: "#/components/schemas/Coding"
1792+
- type: object
1793+
properties:
1794+
system:
1795+
type: string
1796+
enum:
1797+
- "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability"
1798+
code:
1799+
type: string
1800+
enum: ["static", "dynamic"]
1801+
display:
1802+
type: string
1803+
enum: ["Static", "Dynamic"]
1804+
required:
1805+
- system
1806+
- code
1807+
- display
17991808
NRLFormatCode:
1800-
type: object
1801-
properties:
1802-
system:
1803-
type: string
1804-
enum:
1805-
- "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"
1806-
description: The system URL for the NRLF Format Code.
1807-
code:
1808-
type: string
1809-
enum:
1810-
- "urn:nhs-ic:record-contact"
1811-
- "urn:nhs-ic:unstructured"
1812-
description: The code representing the format of the document.
1813-
display:
1814-
type: string
1815-
enum:
1816-
- "Contact details (HTTP Unsecured)"
1817-
- "Unstructured Document"
1818-
description: The display text for the code.
1819-
required:
1820-
- system
1821-
- code
1822-
- display
1809+
allOf:
1810+
- $ref: "#/components/schemas/Coding"
1811+
- type: object
1812+
properties:
1813+
system:
1814+
type: string
1815+
enum:
1816+
- "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"
1817+
description: The system URL for the NRLF Format Code.
1818+
code:
1819+
type: string
1820+
enum:
1821+
- "urn:nhs-ic:record-contact"
1822+
- "urn:nhs-ic:unstructured"
1823+
description: The code representing the format of the document.
1824+
display:
1825+
type: string
1826+
enum:
1827+
- "Contact details (HTTP Unsecured)"
1828+
- "Unstructured Document"
1829+
description: The display text for the code.
1830+
required:
1831+
- system
1832+
- code
1833+
- display
18231834
Identifier:
18241835
type: object
18251836
properties:

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

Lines changed: 43 additions & 39 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-06T04:10:37+00:00
3+
# timestamp: 2024-12-11T16:30:20+00:00
44

55
from __future__ import annotations
66

@@ -230,26 +230,15 @@ class Coding(BaseModel):
230230
] = None
231231

232232

233-
class CodingItem(BaseModel):
233+
class ContentStabilityExtensionCoding(Coding):
234234
system: Literal[
235235
"https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability"
236236
]
237237
code: Literal["static", "dynamic"]
238238
display: Literal["Static", "Dynamic"]
239239

240240

241-
class ValueCodeableConcept(BaseModel):
242-
coding: Annotated[List[CodingItem], Field(max_length=1, min_length=1)]
243-
244-
245-
class ContentStabilityExtension(BaseModel):
246-
url: Literal[
247-
"https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
248-
]
249-
valueCodeableConcept: ValueCodeableConcept
250-
251-
252-
class NRLFormatCode(BaseModel):
241+
class NRLFormatCode(Coding):
253242
system: Annotated[
254243
Literal["https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"],
255244
Field(description="The system URL for the NRLF Format Code."),
@@ -461,31 +450,6 @@ class RequestHeaderCorrelationId(RootModel[str]):
461450
root: Annotated[str, Field(examples=["11C46F5F-CDEF-4865-94B2-0EE0EDCC26DA"])]
462451

463452

464-
class DocumentReferenceContent(BaseModel):
465-
id: Annotated[
466-
Optional[str],
467-
Field(
468-
description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
469-
pattern="[A-Za-z0-9\\-\\.]{1,64}",
470-
),
471-
] = None
472-
attachment: Annotated[
473-
Attachment,
474-
Field(
475-
description="The document or URL of the document along with critical metadata to prove content has integrity."
476-
),
477-
]
478-
format: Annotated[
479-
NRLFormatCode,
480-
Field(
481-
description="An identifier of the document encoding, structure, and template that the document conforms to beyond the base format indicated in the mimeType."
482-
),
483-
]
484-
extension: Annotated[
485-
List[ContentStabilityExtension], Field(max_length=1, min_length=1)
486-
]
487-
488-
489453
class RequestHeader(BaseModel):
490454
odsCode: RequestHeaderOdsCode
491455

@@ -877,6 +841,31 @@ class DocumentReferenceContext(BaseModel):
877841
related: Optional[List[Reference]] = None
878842

879843

844+
class DocumentReferenceContent(BaseModel):
845+
id: Annotated[
846+
Optional[str],
847+
Field(
848+
description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.",
849+
pattern="[A-Za-z0-9\\-\\.]{1,64}",
850+
),
851+
] = None
852+
attachment: Annotated[
853+
Attachment,
854+
Field(
855+
description="The document or URL of the document along with critical metadata to prove content has integrity."
856+
),
857+
]
858+
format: Annotated[
859+
NRLFormatCode,
860+
Field(
861+
description="An identifier of the document encoding, structure, and template that the document conforms to beyond the base format indicated in the mimeType."
862+
),
863+
]
864+
extension: Annotated[
865+
List[ContentStabilityExtension], Field(max_length=1, min_length=1)
866+
]
867+
868+
880869
class DocumentReferenceRelatesTo(BaseModel):
881870
id: Annotated[
882871
Optional[str],
@@ -1062,12 +1051,27 @@ class Signature(BaseModel):
10621051
] = None
10631052

10641053

1054+
class ContentStabilityExtensionValueCodeableConcept(CodeableConcept):
1055+
coding: Annotated[
1056+
List[ContentStabilityExtensionCoding], Field(max_length=1, min_length=1)
1057+
]
1058+
1059+
1060+
class ContentStabilityExtension(Extension):
1061+
url: Literal[
1062+
"https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
1063+
]
1064+
valueCodeableConcept: ContentStabilityExtensionValueCodeableConcept
1065+
1066+
10651067
OperationOutcome.model_rebuild()
10661068
OperationOutcomeIssue.model_rebuild()
10671069
DocumentReference.model_rebuild()
10681070
Bundle.model_rebuild()
10691071
BundleEntry.model_rebuild()
10701072
DocumentReferenceContext.model_rebuild()
1073+
DocumentReferenceContent.model_rebuild()
10711074
DocumentReferenceRelatesTo.model_rebuild()
10721075
CodeableConcept.model_rebuild()
10731076
Identifier.model_rebuild()
1077+
ContentStabilityExtensionValueCodeableConcept.model_rebuild()

0 commit comments

Comments
 (0)