You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Dynamically infer service func input type and return Card model instead of Dict
* Renamed DataGenerator -> CDSDatagenerator and output model -> GeneratedFhirData to make it more clear for users when importing
* Update tests
* Rename GeneratedFhirData -> CdsFhirData
* Update documentation
* Make save file name specific and shorter
* Add error checking to cds io
* Fix tests
* Added error check for non-Card return type in cds service function
* Added tests
* Rollback timestamp changes
---------
Co-authored-by: Jennifer Jiang-Kells <[email protected]>
Copy file name to clipboardExpand all lines: docs/quickstart.md
+69-56Lines changed: 69 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,21 +45,24 @@ A client is a healthcare system object that requests information and processing
45
45
46
46
A client is typically an EHR system, but we may also support other health objects in the future such as a CPOE (Computerized Ohysician Order Entry).
47
47
48
-
We can mark a client by using the decorator `@hc.ehr`. You **must** declare a **workflow** for EHR clients, which informs the sandbox how your data will be formatted (See [Use Cases](usecases.md)).
48
+
We can mark a client by using the decorator `@hc.ehr`. You must declare a particular **workflow** for the EHR client, which informs the sandbox how your data will be formatted (See [Use Cases](usecases.md)).
49
+
50
+
Data returned from the client should be wrapped in a [Pydantic](https://docs.pydantic.dev/latest/) model depending on use case, e.g. `CdsFhirData`.
49
51
50
52
You can optionally specify if you want more than 1 request generated with the `num` parameter.
51
53
52
54
```python
53
55
import healthchain as hc
54
56
from healthchain.use_cases import ClinicalDecisionSupport
57
+
from healthchain.models import CdsFhirData
55
58
56
59
@hc.sandbox
57
60
classMyCoolSandbox(ClinicalDecisionSupport):
58
61
def__init__(self) -> None:
59
62
pass
60
63
61
64
@hc.ehr(workflow="patient-view", num=10)
62
-
defload_data_in_client(self):
65
+
defload_data_in_client(self) -> CdsFhirData:
63
66
# Do things here to load in your data
64
67
pass
65
68
@@ -69,9 +72,9 @@ class MyCoolSandbox(ClinicalDecisionSupport):
69
72
### Data Generator
70
73
Healthcare data is interoperable, but not composable - every deployment site will have different ways of configuring data and terminology. This matters when you develop applications that need to integrate into these systems, especially when you need to reliably extract data for your model to consume.
71
74
72
-
The aim of the Data Generator is not to generate realistic data suitable for use cases such as patient population studies, but rather to generate data that is structurally compliant with what is expected of EHR configurations, and to be able to test and handle variations in this.
75
+
The aim of the data generator is not to generate realistic data suitable for use cases such as patient population studies, but rather to generate data that is structurally compliant with what is expected of EHR configurations, and to be able to test and handle variations in this.
73
76
74
-
For this reason the data generator is opiniated by use case and workflow. See [Use Cases](usecases.md).
77
+
For this reason the data generator is opiniated by use case and workflow. See [Use Cases](usecases.md) for more information.
75
78
76
79
!!! note
77
80
We're aware we may not cover everyone's use cases, so if you have strong opinions about this, please [reach out](https://discord.gg/jG4UWCUh)!
@@ -80,43 +83,54 @@ On the synthetic data spectrum defined by [this UK ONS methodology working paper
80
83
81
84

82
85
83
-
You can use the data generator within a Client function or on its own. The `.data` attribute contains a Pydantic class containing `context` and `resources`.
86
+
You can use the data generator within a client function or on its own. The `.generate()` is dependent on workflow. For CDS use cases, it will return a `CdsFhirData` model with the `prefetch` field populated with a [Bundle](https://www.hl7.org/fhir/bundle.html) of generated structural synthetic FHIR data.
84
87
85
88
=== "Within client"
86
89
```python
87
90
import healthchain as hc
88
-
from healthchain.data_generator import DataGenerator
89
91
from healthchain.use_cases import ClinicalDecisionSupport
92
+
from healthchain.models import CdsFhirData
93
+
from healthchain.data_generator import CdsDataGenerator
90
94
91
95
@hc.sandbox
92
96
class MyCoolSandbox(ClinicalDecisionSupport):
93
97
def __init__(self) -> None:
94
-
self.data_generator = DataGenerator()
98
+
self.data_generator = CdsDataGenerator()
95
99
96
100
@hc.ehr(workflow="patient-view")
97
-
def load_data_in_client(self):
98
-
self.data_generator.generate()
99
-
return self.data_generator.data
101
+
def load_data_in_client(self) -> CdsFhirData:
102
+
data = self.data_generator.generate()
103
+
return data
100
104
101
105
@hc.api
102
-
def my_server(self, text):
106
+
def my_server(self, request) -> None:
103
107
pass
104
108
```
105
109
106
110
107
111
=== "On its own"
108
112
```python
109
-
from healthchain.data_generator import DataGenerator
113
+
from healthchain.data_generator import CdsDataGenerator
<!-- You can pass in parameters in `contraint` argument to limit the general form of the FHIR resources you get back, but this feature is experimental. Arguments supported are:
A service is typically an API of an external AI/NLP system that returns data to the client. This is where you define your application logic - it can be anything from a simple regex to a highly sophisticated LLM agentic workflow. The only constraint is that you have to return your data as a `Dict` that your workflow expects.
164
+
A service is typically an API of an external AI/NLP system that returns data to the client. This is where you define your application logic - it can be anything from a simple regex to a highly sophisticated LLM agentic workflow.
151
165
152
166
When you decorate a function with `@hc.api` in a sandbox, the function is mounted to a HL7-compliant service endpoint an EHR client can make requests to. This is usually a set of standardised API routes depending on the use case. HealthChain will start a [FastAPI](https://fastapi.tiangolo.com/) server with these APIs pre-defined for you.
153
167
168
+
Your service function must accept and return models appropriate for your use case. Typically the service function should accept a `Request` model and return a use case specific model, such as a list of `Card` for CDS.
169
+
154
170
If you are using a model that requires initialisation steps, we recommend you initialise this in your class `__init__`.
155
171
156
172
=== "Transformers"
@@ -161,35 +177,34 @@ If you are using a model that requires initialisation steps, we recommend you in
161
177
import healthchain as hc
162
178
163
179
from healthchain.use_cases import ClinicalDecisionSupport
164
-
from healthchain.data_generator import DataGenerator
180
+
from healthchain.data_generator import CdsDataGenerator
181
+
from healthchain.models import Card, CDSRequest, CdsFhirData
0 commit comments