Skip to content

Commit

Permalink
Update docs with usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferjiangkells committed Oct 4, 2024
1 parent 3cb008e commit 546b02b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
17 changes: 4 additions & 13 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Components are stateful - they're classes instead of functions. They can be usef

HealthChain comes with a few pre-built components, but you can also easily add your own. You can find more details on the [Components](./reference/pipeline/component.md) and [Models](./reference/pipeline/models/models.md) documentation pages.

Add components to your pipeline with the `.add()` method.
Add components to your pipeline with the `.add()` method and compile with `.build()`.

```python
from healthchain.pipeline import Pipeline
Expand Down Expand Up @@ -80,10 +80,9 @@ For a full list of available prebuilt pipelines and details on how to configure
from healthchain.pipeline import MedicalCodingPipeline

pipeline = MedicalCodingPipeline.load("./path/to/model")
pipe = pipeline.build()

doc = Document("Patient diagnosed with myocardial infarction.")
doc = pipe(doc)
doc = pipeline(doc)
```

### Sandbox 🧪
Expand All @@ -107,8 +106,7 @@ from healthchain.pipeline import MedicalCodingPipeline
class MyCoolSandbox(ClinicalDocumentation):
def __init__(self) -> None:
# Load your pipeline
pipeline = MedicalCodingPipeline.load("./path/to/model")
self.pipe = self.pipeline.build()
self.pipeline = MedicalCodingPipeline.load("./path/to/model")

@hc.ehr(workflow="sign-note-inpatient")
def load_data_in_client(self) -> CcdData:
Expand Down Expand Up @@ -139,13 +137,6 @@ healthchain run my_sandbox.py

This will start a server by default at `http://127.0.0.1:8000`, and you can interact with the exposed endpoints at `/docs`. Data generated from your sandbox runs is saved at `./output/` by default.

## Inspect generated data in Streamlit 🎈
The streamlit dashboard is run separately and is currently purely for visualisation purposes.

You need to install streamlit separately first:
```bash
pip install streamlit
```
Then run:

```bash
Expand All @@ -158,7 +149,7 @@ streamlit run app.py

You can use the data generator to generate synthetic data for your sandbox runs.

The `.generate()` is dependent on use case and workflow. For example, `CdsDataGenerator` will generate synthetic [FHIR](https://build.fhir.org/) data suitable for the workflow specified by the use case.
The `.generate()` is dependent on use case and workflow. For example, `CdsDataGenerator` will generate synthetic [FHIR](https://hl7.org/fhir/) data suitable for the workflow specified by the use case.

We're currently working on generating synthetic [CDA](https://www.hl7.org.uk/standards/hl7-standards/cda-clinical-document-architecture/) data. If you're interested in contributing, please [reach out](https://discord.gg/UQC6uAepUz)!

Expand Down
19 changes: 13 additions & 6 deletions docs/reference/pipeline/pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ HealthChain comes with a set of prebuilt pipelines that are out-of-the-box imple
| **QAPipeline** [TODO] | `Document` | N/A | A Question Answering pipeline suitable for conversational AI applications | Developing a chatbot to answer patient queries about their medical records |
| **ClassificationPipeline** [TODO] | `Tabular` | `FhirConnector` | A pipeline for machine learning classification tasks | Predicting patient readmission risk based on historical health data |

To use a pipeline, compile it by running `.build()` on it. This will return a compiled pipeline that you can run on your data.

Pipeline inputs and outputs are defined by the container type.

```python
from healthchain.pipeline import Pipeline
from healthchain.io.containers import Document

pipeline = MedicalCodingPipeline.load('/path/to/model')
pipeline = pipeline.build()

doc = Document(text="Patient is diagnosed with diabetes")
doc = Document("Patient is diagnosed with diabetes")
doc = pipeline(doc)
```

Expand All @@ -36,7 +33,7 @@ To customize a prebuilt pipeline, you can use the [pipeline management methods](

If you need even more control and don't mind writing more code, you can subclass `BasePipeline` and implement your own pipeline logic.

(BasePipeline API Reference)
[(BasePipeline API Reference)](../../api/pipeline.md#healthchain.pipeline.basepipeline.BasePipeline)

## Freestyle 🕺

Expand All @@ -50,6 +47,16 @@ from healthchain.io.containers import Document

pipeline = Pipeline[Document]()
```

To use a built pipeline, compile it by running `.build()` on it. This will return a compiled pipeline that you can run on your data.

```python
pipe = pipeline.build()
doc = pipe(Document("Patient is diagnosed with diabetes"))

print(doc.entities)
```

There are three types of nodes you can add to your pipeline:

- Inline Functions
Expand Down Expand Up @@ -100,7 +107,7 @@ stopwords = ["the", "a", "an", "in", "on", "at"]
pipeline.add(RemoveStopwords(stopwords))
```

(BaseComponent API Reference)
[(BaseComponent API Reference)](../../api/component.md#healthchain.pipeline.components.basecomponent.BaseComponent)

## Pipeline Management 🔨

Expand Down
10 changes: 4 additions & 6 deletions docs/reference/sandbox/service.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ Here are minimal examples for each use case:
class MyCoolSandbox(ClinicalDocumentation):
def __init__(self) -> None:
# Load your pipeline
pipeline = MedicalCodingPipeline.load("./path/to/model")
self.pipe = pipeline.build()
self.pipeline = MedicalCodingPipeline.load("./path/to/model")

@hc.ehr(workflow="sign-note-inpatient")
def load_data_in_client(self) -> CcdData:
Expand All @@ -36,7 +35,7 @@ Here are minimal examples for each use case:
@hc.api
def my_service(self, ccd_data: CcdData) -> CcdData:
# Run your pipeline
results = self.pipe(ccd_data)
results = self.pipeline(ccd_data)
return results
```

Expand All @@ -52,8 +51,7 @@ Here are minimal examples for each use case:
@hc.sandbox
class MyCoolSandbox(ClinicalDecisionSupport):
def __init__(self):
pipeline = Pipeline.load("./path/to/pipeline")
self.pipe = pipeline.build()
self.pipeline = Pipeline.load("./path/to/pipeline")

@hc.ehr(workflow="patient-view")
def load_data_in_client(self) -> CdsFhirData:
Expand All @@ -64,7 +62,7 @@ Here are minimal examples for each use case:

@hc.api
def my_service(self, request: CDSRequest) -> List[Card]:
result = self.pipe(str(request.prefetch))
result = self.pipeline(str(request.prefetch))
return [
Card(
summary="Patient summary",
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/sandbox/use_cases/cds.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CDS workflows are based on [CDS Hooks](https://cds-hooks.org/). CDS Hooks is an
| Triggered at certain events during a clinician's workflow, e.g. when a patient record is opened. | EHR | The context of the event and FHIR resources that are requested by your service. e.g. patient ID, `Encounter` and `Patient`. | “Cards” displaying text, actionable suggestions, or links to launch a [SMART](https://smarthealthit.org/) app from within the workflow. |


CDS hooks communicate using [HL7 FHIR (Fast Healthcare Interoperability Resources)](https://hl7.org/fhir/R4/). FHIR data are represented internally as `CdsFhirData` in HealthChain, so a CDS client must return a `CdsFhirData` object.
CDS hooks communicate using [HL7 FHIR (Fast Healthcare Interoperability Resources)](https://hl7.org/fhir/). FHIR data are represented internally as `CdsFhirData` in HealthChain, so a CDS client must return a `CdsFhirData` object.

CDS service functions receive `CdsRequest` and return a list of `Card`. [Improved documentation coming soon]

Expand Down

0 comments on commit 546b02b

Please sign in to comment.