Namespaces

Chat

Learn how patients and their care team open threads, send messages with files and mark threads read.

  • Stable unknown
  • Release candidate not available
  • Development since 0.2.0-dev.34+53a6a64

ovok.chat holds threads between a patient and their care team. A Patient, Practitioner or RelatedPerson session sees the threads about patients it may see, and chat must be on for the project.

Open a thread and send a message

thread = ovok.chat.threads.open({"patient": "Patient/123", "participants": ["Practitioner/456"]})

message = ovok.chat.messages.send(thread["id"], {"text": "How are you feeling today?"})
  • open answers the open thread with the same people when one exists.
  • send adds a random clientId when you send none. A retry with the same clientId answers the message already sent, so the SDK retries a send safely.
  • replyTo names the message you answer.

Send a file

attachment = ovok.chat.attachments.upload(
    file=Path("scan.pdf").read_bytes(), file_name="scan.pdf", content_type="application/pdf"
)
ovok.chat.messages.send(thread["id"], {"text": "My scan", "attachments": [attachment["id"]]})
  • upload sends the file straight to the file store, without your bearer token. It accepts PDF, PNG, JPEG and WebP files.
  • attachments.link and messages.attachment_link answer a url that downloads the file without a bearer, until expiresAt.

Read threads and messages

for thread in ovok.chat.threads.list({"patient": "Patient/123"}).auto_paging_iter():
    print(thread["title"], thread["unreadCount"])

ovok.chat.read(thread["id"])
  • threads.list takes patient, updatedSince and limit. messages.list takes since and limit and lists the newest messages first.
  • read marks the thread read for the signed-in person, now or at readAt.
  • The TypeScript SDK's live listen is not in the Python SDK, because it needs a Socket.IO client. Poll with updatedSince and since instead.

See also

Last updated on

On this page