Chat

Learn how to open chat threads, send messages with files, and mark threads read with the Java SDK.

  • Stable unknown
  • Release candidate not available
  • Development since 0.2.0-dev.33+8af64df

ovok.chat() is person-to-person chat between patients and their care team. threads() opens and lists the signed-in person's threads, messages() reads and sends messages in a thread, and attachments() uploads files to send with them.

Open a thread and send a message

JsonNode thread = ovok.chat().threads().open(
        Map.of("patient", "Patient/123", "participants", List.of("Practitioner/456")),
        RequestOptions.defaults());
String threadId = thread.get("id").asText();

ovok.chat().messages().send(threadId, Map.of("text", "How are you feeling today?"), RequestOptions.defaults());
ovok.chat().read(threadId, null, RequestOptions.defaults());
  • open answers the thread these participants already have about the patient, if there is one. Every participant must be allowed to read the patient.
  • send adds a random clientId when you pass none. The server remembers it, so a retried send is stored once.
  • read marks the thread read now, or at the readAt you pass.

Send a file

JsonNode attachment = ovok.chat().attachments().upload(
        Files.readAllBytes(scan), "scan.pdf", "application/pdf", RequestOptions.defaults());

ovok.chat().messages().send(threadId,
        Map.of("text", "My latest results", "attachments", List.of(attachment.get("id").asText())),
        RequestOptions.defaults());
  • upload takes a PDF, PNG, JPEG or WebP of up to 10 MB and keeps it private. It stores the file where the server says, and throws OvokServiceException when the store refuses it.
  • An upload can go out in as many threads as you like.
  • attachments().link(attachmentId, options) and messages().attachmentLink(threadId, messageId, attachmentId, options) answer a download url that works for the next hour.

Read threads and messages

threads().list and messages().list return a Page<JsonNode> that follows the cursor. Iterating the page loads the next ones. See paging.

CallWhat it does
threads().list(params, options)Lists threads, newest message first. Filter by patient or updatedSince, and set limit.
threads().retrieve(threadId, options)Reads one thread.
messages().list(threadId, params, options)Lists messages, newest first. Later pages go further back.

Every method is in the ChatResource reference.

See also

Last updated on

On this page