Is there a way to get to "Data Integration" files from SDK? #1662
Replies: 1 comment
|
Hi @nara-falconeer — good question. The For automating inbound-fax intake (most common case) — hook the
{
"sdk_version": "0.1.4",
"plugin_version": "0.0.1",
"name": "document_received_logger",
"description": "Logs DOCUMENT_RECEIVED event context for inspection.",
"components": {
"protocols": [
{
"class": "document_received_logger.handlers.document_received:DocumentReceivedLogger",
"description": "Logs the DOCUMENT_RECEIVED event context."
}
],
"commands": [], "content": [], "effects": [],
"views": [], "questionnaires": []
},
"secrets": [], "tags": {}, "references": [], "license": "",
"diagram": false, "readme": "./README.md"
}
import json
from canvas_sdk.effects import Effect
from canvas_sdk.events import EventType
from canvas_sdk.handlers import BaseHandler
from logger import log
class DocumentReceivedLogger(BaseHandler):
"""Log every DOCUMENT_RECEIVED event for inspection."""
RESPONDS_TO = EventType.Name(EventType.DOCUMENT_RECEIVED)
def compute(self) -> list[Effect]:
ctx = self.context or {}
document = ctx.get("document") or {}
patient = ctx.get("patient") or None
available_types = ctx.get("available_document_types") or []
# Use the IntegrationTask UUID as the correlation id so you can grep
# across DOCUMENT_RECEIVED, DOCUMENT_LINKED_TO_PATIENT, DOCUMENT_REVIEWED,
# etc. for the same task with a single search.
cid = getattr(self.event, "target", None) or document.get("id")
log.info(
f"[doc_received] short cid={cid} "
f"channel={document.get('channel')!r} "
f"status={document.get('status')!r} "
f"type={document.get('type')!r} "
f"title={document.get('title')!r} "
f"content_type={document.get('content_type')!r} "
f"content_url={document.get('content_url')!r} "
f"patient_id={(patient or {}).get('id')!r} "
f"available_document_types_count={len(available_types)}"
)
log.info(
f"[doc_received] full cid={cid} "
f"payload={json.dumps(ctx, default=str)}"
)
return []You'll see two log lines per event in your worker syslog. The full event payload looks like: {
"document": {
"id": "<task-uuid>",
"channel": "fax",
"content_url": "<file URL>",
"content_type": "application/pdf",
"title": "...",
"type": "...",
"status": "UNR",
"created_at": "..."
},
"patient": {"id": "<key>"} | null,
"available_document_types": [...]
}Branch on For processing documents that have already been triaged and attached to a clinical record — use the The polling case — "give me all unread integration tasks and let me fetch their files in a loop" — isn't supported via the SDK data class today (the file URL isn't projected onto But I did add the Github Issue #1663 to add the document to the IntegrationTask SDK module permanently, instead of relying on listening to the event because it would be nice to just have the document in the data module always. So I'll pass that back to our engineering team. |
Uh oh!
There was an error while loading. Please reload this page.
To process incoming files by fax, should I just go to Documo and pull up the files or does the SDK have an interface for this? I checked the IntegrationTask (https://docs.canvasmedical.com/sdk/data-integration-task/) but there is no DocumentReference or such in it.
All reactions