-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added pipelines WIP * Added pipeline and io components * Added validation and tests * Tidied up typing, added property utils to pipeline, updated tests * Fix component name string in stages property * Changed model name to be generic * Added methods to data containers * Add simple preprocessing and postprocessing components * Update dependencies * Remove print statement * Fix preprocessor name * Remove configs from pre and postprocessors * Fix Discord link * Update documentation * Make pipeline wrapper callable method less verbose * Fail removing/replacing non-existing components louder * Update README.md * Added built-in .build() when pipeline is first called * Update docs with usage * README.md * README.md - link
- Loading branch information
1 parent
cdfabb9
commit 032f07e
Showing
49 changed files
with
4,682 additions
and
1,127 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 |
---|---|---|
|
@@ -160,5 +160,7 @@ cython_debug/ | |
#.idea/ | ||
|
||
output/ | ||
scrap/ | ||
.DS_Store | ||
.vscode/ | ||
.ruff_cache/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Component | ||
|
||
::: healthchain.pipeline.components.basecomponent | ||
::: healthchain.pipeline.components.preprocessors | ||
::: healthchain.pipeline.components.models | ||
::: healthchain.pipeline.components.postprocessors |
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,3 @@ | ||
# Containers | ||
|
||
::: healthchain.io.containers |
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,3 @@ | ||
# Pipeline | ||
|
||
::: healthchain.pipeline.basepipeline |
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 @@ | ||
# Contribution Guide |
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 @@ | ||
# Resources |
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,48 @@ | ||
# Build a CDS sandbox | ||
|
||
A CDS sandbox which uses `gpt-4o` to summarise patient information from synthetically generated FHIR resources received from the `patient-view` CDS hook. | ||
|
||
```python | ||
import healthchain as hc | ||
|
||
from healthchain.use_cases import ClinicalDecisionSupport | ||
from healthchain.data_generators import CdsDataGenerator | ||
from healthchain.models import Card, CdsFhirData, CDSRequest | ||
|
||
from langchain_openai import ChatOpenAI | ||
from langchain_core.prompts import PromptTemplate | ||
from langchain_core.output_parsers import StrOutputParser | ||
|
||
from typing import List | ||
|
||
@hc.sandbox | ||
class CdsSandbox(ClinicalDecisionSupport): | ||
def __init__(self): | ||
self.chain = self._init_llm_chain() | ||
self.data_generator = CdsDataGenerator() | ||
|
||
def _init_llm_chain(self): | ||
prompt = PromptTemplate.from_template( | ||
"Extract conditions from the FHIR resource below and summarize in one sentence using simple language \n'''{text}'''" | ||
) | ||
model = ChatOpenAI(model="gpt-4o") | ||
parser = StrOutputParser() | ||
|
||
chain = prompt | model | parser | ||
return chain | ||
|
||
@hc.ehr(workflow="patient-view") | ||
def load_data_in_client(self) -> CdsFhirData: | ||
data = self.data_generator.generate() | ||
return data | ||
|
||
@hc.api | ||
def my_service(self, request: CDSRequest) -> List[Card]: | ||
result = self.chain.invoke(str(request.prefetch)) | ||
return Card( | ||
summary="Patient summary", | ||
indicator="info", | ||
source={"label": "openai"}, | ||
detail=result, | ||
) | ||
``` |
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 |
---|---|---|
@@ -1 +1,6 @@ | ||
# Cookbook | ||
# Examples | ||
|
||
The best way to learn is by example! Here are some to get you started: | ||
|
||
- [Build a CDS sandbox](./cds_sandbox.md): Build a clinical decision support (CDS) system that uses *patient-view* to greet the patient. | ||
- [Build a Clinical Documentation sandbox](./notereader_sandbox.md): Build a NoteReader system which extracts problem, medication, and allergy concepts from free-text clinical notes. |
Oops, something went wrong.