from workflows_py.workflow import ScreenStep, Step, Workflow
from client_manager import SampleHealthcareClient
workflow = Workflow(...)
def classify_document(ctx):
client = SampleHealthcareClient()
response = client.v2.documents.classify(
document=ctx.get_step_result("document-upload")["document"],
label_schemas=[{
"label": "Medical Record",
"description": "A medical record is a document that contains information about a patient's medical history.",
"keywords": ["medical", "record", "patient", "history"],
}, {
"label": "Discharge Summary",
"description": "A discharge summary is a document that contains information about a patient's discharge from the hospital.",
"keywords": ["discharge", "summary", "patient", "hospital"],
}, {
"label": "Progress Note",
"description": "A progress note is a document that contains information about a patient's progress in the hospital.",
"keywords": ["progress", "note", "patient", "hospital"],
}]
)
return response.async_result_id
workflow.then(
# See: Document Upload Screen template
ScreenStep(
"document-upload",
screen_path="./screens/document-upload-screen.tsx",
)
).then(
Step(
"classify-document",
classify_document,
)
)
.then(
ScreenStep(
"document-classification",
screen_path="./screens/document-classification-screen.tsx",
get_props=lambda ctx: {"resultId": ctx.get_step_result("classify-document")},
)
)