-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NRL-786 new parent class that does not allow extra fields for pydantic models #781
Open
eesa456
wants to merge
11
commits into
develop
Choose a base branch
from
feature/eema1-NRL-786-rejectExtraFields
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7affc4c
NRL-786 new parent class that does not allow extra fields for pydanti…
eesa456 2f6eac9
NRL-786 fix test
eesa456 7be7738
NRL-786 update import to remove layer
eesa456 d50ae24
NRL-786 fix error message
eesa456 93025f1
NRL-786 fix warning in test
eesa456 dcf3a83
Merge branch 'develop' of github.com:NHSDigital/NRLF into feature/eem…
eesa456 a4b10ac
NRL-786 add extension to parent model
eesa456 5b00fcf
NRL-786 update model
eesa456 ccbdfab
NRL-786 update import
eesa456 03e79f5
NRL-786 add other classes needed
eesa456 ec405a5
NRL-786 fix tests
eesa456 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
from typing import Annotated, List, Optional | ||
|
||
from pydantic import BaseModel, ConfigDict, Field | ||
|
||
|
||
class ParentCoding(BaseModel): | ||
model_config = ConfigDict(regex_engine="python-re", extra="forbid") | ||
id: Annotated[ | ||
Optional[str], | ||
Field( | ||
description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", | ||
pattern="[A-Za-z0-9\\-\\.]{1,64}", | ||
), | ||
] = None | ||
system: Annotated[ | ||
Optional[str], | ||
Field( | ||
description="The identification of the code system that defines the meaning of the symbol in the code.", | ||
pattern="\\S*", | ||
), | ||
] = None | ||
version: Annotated[ | ||
Optional[str], | ||
Field( | ||
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.", | ||
pattern="[ \\r\\n\\t\\S]+", | ||
), | ||
] = None | ||
code: Annotated[ | ||
Optional[str], | ||
Field( | ||
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).", | ||
pattern="[^\\s]+(\\s[^\\s]+)*", | ||
), | ||
] = None | ||
display: Annotated[ | ||
Optional[str], | ||
Field( | ||
description="A representation of the meaning of the code in the system, following the rules of the system.", | ||
pattern="[ \\r\\n\\t\\S]+", | ||
), | ||
] = None | ||
userSelected: Annotated[ | ||
Optional[bool], | ||
Field( | ||
description="Indicates that this coding was chosen by a user directly – e.g. off a pick list of available items (codes or displays)." | ||
), | ||
] = None | ||
|
||
|
||
class ParentCodeableConcept(BaseModel): | ||
model_config = ConfigDict(regex_engine="python-re", extra="forbid") | ||
id: Annotated[ | ||
Optional[str], | ||
Field( | ||
description="Unique id for the element within a resource (for internal references). This may be any string value that does not contain spaces.", | ||
pattern="[A-Za-z0-9\\-\\.]{1,64}", | ||
), | ||
] = None | ||
coding: Optional[List[ParentCoding]] = None | ||
text: Annotated[ | ||
Optional[str], | ||
Field( | ||
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.", | ||
pattern="[ \\r\\n\\t\\S]+", | ||
), | ||
] = None | ||
|
||
|
||
class ParentExtension(BaseModel): | ||
valueCodeableConcept: Annotated[ | ||
Optional[ParentCodeableConcept], | ||
Field( | ||
description="A name which details the functional use for this link – see [http://www.iana.org/assignments/link–relations/link–relations.xhtml#link–relations–1](http://www.iana.org/assignments/link–relations/link–relations.xhtml#link–relations–1)." | ||
), | ||
] = None | ||
url: Annotated[ | ||
Optional[str], | ||
Field(description="The reference details for the link.", pattern="\\S*"), | ||
] = None | ||
|
||
|
||
class Parent(BaseModel): | ||
model_config = ConfigDict(regex_engine="python-re", extra="forbid") | ||
extension: Annotated[ | ||
Optional[List[ParentExtension]], | ||
Field(description="A list of relevant extensions"), | ||
] = None |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to allow producers to define their own extensions, do we need
value
to be more generic to support extensions with values of types other than CodableConcepts?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I've just kept the extension as its always been defined but could make it more generic ?