Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
107 changed files
with
4,839 additions
and
846 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
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
File renamed without changes.
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
File renamed without changes.
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,42 @@ | ||
# opal.core.serialization | ||
|
||
Helpers for serializing and deserializing data | ||
|
||
## `deserialize_datetime(value)` | ||
|
||
Given a string which represents a date time, deserialize it to a Python datetime | ||
object using the first value of `settings.DATETIME_INPUT_FORMATS`. | ||
|
||
```python | ||
as_datetime = deserialize_datetime('22/04/1959 21:20:22') | ||
``` | ||
|
||
## `deserialize_time(value)` | ||
|
||
Given a string which represents a time, deserialize it to a Python time | ||
object using the first value of `settings.TIME_INPUT_FORMATS`. | ||
|
||
```python | ||
as_time = deserialize_time('14:30:59') | ||
``` | ||
|
||
## `deserialize_date(value)` | ||
|
||
Given a string which represents a date, deserialize it to a Python date | ||
object using the first value of `settings.DATE_INPUT_FORMATS`. | ||
|
||
```python | ||
as_date = deserialize_date('22/04/1959') | ||
``` | ||
|
||
## OpalSerializer | ||
|
||
A JSON serializer that will serialize the output of `to_dict` calls. This serializer | ||
uses date formats that can be understood by the Opal javascript applications. | ||
|
||
```python | ||
import json | ||
|
||
as_dict = episode.to_dict(user) | ||
as_json = json.dumps(as_dict, cls=OpalSerializer) | ||
``` |
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,75 @@ | ||
# opal.core.subrecords | ||
|
||
The `opal.core.subrecords` module contains utility functions for working with | ||
subrecords. | ||
|
||
## `episode_subrecords()` | ||
|
||
Generator function that iterates through all episode subrecords. | ||
|
||
```python | ||
for s in episode_subrecords(): | ||
print(s) | ||
|
||
# -> Location, Diagosis et cetera | ||
``` | ||
|
||
## `patient_subrecords()` | ||
|
||
Generator function that iterates through all patient subrecords. | ||
|
||
```python | ||
for s in patient_subrecords(): | ||
print(s) | ||
|
||
# -> Allergies, ContactDetails et cetera | ||
``` | ||
|
||
## `subrecords()` | ||
|
||
Generator function that iterates through all subrecords. | ||
|
||
```python | ||
for s in subrecords(): | ||
print(s) | ||
|
||
# -> Allergies, ContactDetails, Location, Diagnosis et cetera | ||
``` | ||
|
||
## `singletons()` | ||
|
||
Generator function that iterates through all singleton subrecords. | ||
|
||
```python | ||
for s in singletons(): | ||
print(s) | ||
|
||
# -> Location, Demographics | ||
``` | ||
|
||
## Fetchers | ||
|
||
### `get_subrecord_from_api_name(api_name)` | ||
|
||
Return a subrecord given the relevant API name for it. Raise a ValueError | ||
if no matching subrecord is found. | ||
|
||
|
||
```python | ||
get_subrecord_from_api_name('demographics') | ||
|
||
# -> <class Demographics> | ||
``` | ||
|
||
|
||
### `get_subrecord_from_model_name(model_name)` | ||
|
||
Return a subrecord given the relevant model name for it. Raise a ValueError | ||
if no matching subrecord is found. | ||
|
||
|
||
```python | ||
get_subrecord_from_api_name('Demographics') | ||
|
||
# -> <class Demographics> | ||
``` |
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.