Skip to main content

Overview

The SampleHC API is a RESTful API that allows you to interact with workflows. It is used to start, stop, and manage workflows, as well as to retrieve workflow data.

Client

Workflows created before the client was released may not have the client installed. Please refer to the latest template to see how the client is set up.
If any methods are different/missing from the SDK, you may need to update the SDK version in requirements.txt to the latest version.
A Python SDK is available for ease of calling the SampleHC API. By default, a client manager is included in the new workflow template in src/client_manager.py that automatically configures the client with the correct backend URL and API key. Here is a minimal example of how to use the client manager to initiate a client and call the API in a workflow.
from workflows_py.workflow import ScreenStep, Step, Workflow
from client_manager import SampleHealthcareClient

def trigger_reasoning(documents, task):
    client = SampleHealthcareClient()
    return client.v2.documents.legacy.reason(
        documents=documents, task=task
    ).async_result_id

workflow = Workflow().then(
  Step("trigger-reasoning", trigger_reasoning)
).then(
  ScreenStep("reasoning-screen", screen_path="./screens/legacy-document-reasoning-screen.tsx", get_props=lambda resultIds: [ctx.get_step_result("trigger-reasoning")])
)

Gotchas

Our API generally uses camelCase for parameter names. However, for ease of use, the SDK also converts parameters to snake_case when calling the API. This means ** BOTH ** camelCase and snake_case are supported for parameter names when using the samplehc library. For example, the document metadata endpoint has a parameter called fileName which is converted to file_name in the SDK.
client = SampleHealthcareClient()
res = client.v2.documents.retrieve_metadata(
    document_id="fmd_xxxxxxxxxxx",
)

# This is valid
print(res.file_name)

# This is ALSO valid
print(res.fileName)
Refer to the SampleHC API Reference for more details on the available endpoints, required parameters, and the expected responses from the SDK.
I