-
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
fhirpy client example #4
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Aleksandr Penskoi <[email protected]>
|
||
This example shows how to use the [fhir-py client](https://github.com/beda-software/fhir-py "fhir-py") with an Aidbox instance, demonstrating the Python SDK client in action. | ||
|
||
Here, we provide several options for using the fhir-py SDK, including basic usage and advanced typing features. The examples start with the simplest solution, which does not include typings, and incrementally incorporate features related to typings. |
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.
Here, we provide several options for using the fhir-py SDK, including basic usage and advanced typing features. The examples start with the simplest solution, which does not include typings, and incrementally incorporate features related to typings. | |
In the example we demonstrate a several ways to implement import patient data from CSV file in Python. We describe it in the following steps: | |
1. Setup Aidbox Instance | |
1. Install [fhir-py](https://github.com/beda-software/fhir-py). | |
1. Use [fhir-py](https://github.com/beda-software/fhir-py): | |
1. with raw data (dictionaries and lists), | |
1. with manually defined dataclasses for FHIR Resources, | |
1. with generated dataclasses for FHIR Resources by [fhir-py-types](https://github.com/beda-software/fhir-py-types) from StructureDefinitions | |
1. (recommended) with generated dataclasses for FHIR Resources by [fhir-schema-codegen](https://github.com/fhir-schema/fhir-schema-codegen) from FHIR Schemas. |
#### Detailed example | ||
|
||
For a more detailed example of how to use fhir-py client with raw data, including working code snippets, check out the [fhirpy_raw_data.py](fhirpy_raw_data.py) |
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.
#### Detailed example | |
For a more detailed example of how to use fhir-py client with raw data, including working code snippets, check out the [fhirpy_raw_data.py](fhirpy_raw_data.py) | |
See full CSV import example: [fhirpy_raw_data.py](fhirpy_raw_data.py) |
@@ -0,0 +1,122 @@ | |||
##################################################################### | |||
# Use <https://github.com/beda-software/fhir-py>. With custom data models |
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.
Need to be more similar to README text.
#### Installation | ||
|
||
``` shell | ||
poetry add [email protected] |
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.
And we need to explain how to generate dataclasses. Ideally, it will be nice to have similar structure for that and next section.
#### Detailed example | ||
|
||
For a more detailed example of how to use `fhirpy-types-r4b` in fhir-py client, check out the [fhirpy_fhirtypes.py](fhirpy_fhirtypes.py) | ||
|
||
|
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.
#### Detailed example | |
For a more detailed example of how to use `fhirpy-types-r4b` in fhir-py client, check out the [fhirpy_fhirtypes.py](fhirpy_fhirtypes.py) | |
See CSV import example: [fhirpy_fhirtypes.py](fhirpy_fhirtypes.py) |
- Be iterable | ||
- Implement ResourceProtocol interface |
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.
- Be iterable | |
- Implement ResourceProtocol interface | |
- Be iterable (implemented by inheritance from `dict`). | |
- Implement `ResourceProtocol` interface (defined in fhir-py). |
|
||
- Be iterable | ||
- Implement ResourceProtocol interface | ||
|
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.
Usage dataclasses for FHIR Resource representation allow programmers to use autocomplete and type checking. This approach allows user to have full control (including custom validations and hiding unused resource elements) but requires to write a lot of boilerplate code. | |
#### Detailed example | ||
|
||
For a more detailed example of how to write custom data models and use them in fhir-py client, check out the [fhirpy_custom_models.py](fhirpy_custom_models.py) |
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.
#### Detailed example | |
For a more detailed example of how to write custom data models and use them in fhir-py client, check out the [fhirpy_custom_models.py](fhirpy_custom_models.py) | |
See full CSV import example: [fhirpy_custom_models.py](fhirpy_custom_models.py) |
#### Detailed Example | ||
|
||
For a more detailed example of how to use `fhir-schema-codegen` generated data models in fhir-py client, check out the [fhirpy_fhir_schema_codegen.py](fhirpy_fhir_schema_codegen.py) |
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.
#### Detailed Example | |
For a more detailed example of how to use `fhir-schema-codegen` generated data models in fhir-py client, check out the [fhirpy_fhir_schema_codegen.py](fhirpy_fhir_schema_codegen.py) | |
See full CSV import example: [fhirpy_fhir_schema_codegen.py](fhirpy_fhir_schema_codegen.py) |
|
||
```sh | ||
# generate FHIR data models | ||
fscg generate --generator python --output generated --package hl7.fhir.r4.core:4.0.1 |
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.
Can we also generate classes for our custom resources? E.g. AidboxSubscriptionTopic?
No description provided.