-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #820 from openhealthcare/seperated-out-to-dict
Seperated out to dict
- Loading branch information
Showing
9 changed files
with
196 additions
and
153 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## OPAL mixins | ||
|
||
### SerialisableFields | ||
provides the fields that are on the model for example | ||
if we have an allergy model with a field drug | ||
it might serialise like below | ||
|
||
Allergy._get_fieldnames_to_serialize() -> ["id", "drug"] | ||
|
||
|
||
### ToDictMixin | ||
provides a method that serialises a model | ||
to a dictionary for example | ||
if we have an allergy model with a field drug | ||
it might serialise like below | ||
|
||
allergy.to_dict() -> {"id": 1, "drug": "penicillin"} | ||
|
||
### UpdateFromDict | ||
provides a method that updates a model | ||
based on a dictionary of fields, for example | ||
|
||
For example on a new allergy | ||
|
||
allergy.update_from_dict({"drug": "penicillin"}) | ||
|
||
will update the allergy to have the drug penicillin |
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
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
Oops, something went wrong.