UNPKG

@oystehr/sdk

Version:

Oystehr SDK

103 lines (100 loc) 5.39 kB
// AUTOGENERATED -- DO NOT EDIT import { ConversationAddParticipantParams, ConversationCreateParams, ConversationCreateResponse, ConversationGetTokenResponse, ConversationMessageParams, ConversationRemoveParticipantParams, OystehrClientRequest, } from '../..'; import { SDKResource } from '../../client/client'; import { OystehrConfig } from '../../config'; import * as ext from './conversation-ext'; export class Conversation extends SDKResource { constructor(config: OystehrConfig) { super(config); } #baseUrlThunk(): string { return this.config.services?.['projectApiUrl'] ?? 'https://project-api.zapehr.com/v1'; } ENCOUNTER_VS_EXTENSION_URL = ext.ENCOUNTER_VS_EXTENSION_URL; ENCOUNTER_VS_EXTENSION_RELATIVE_URL = ext.ENCOUNTER_VS_EXTENSION_RELATIVE_URL; /** * Helper function to get a conversationId from an encounter created as an Oystehr Conversation * @param encounter well-formed FHIR R4B or R5 Encounter * @returns conversationId */ getConversationIdFromEncounter = ext.getConversationIdFromEncounter; /** * Create a new Conversation. [Conversations](https://docs.oystehr.com/oystehr/services/messaging/conversations/) allow you to build multi-channel bi-directional messaging workflows. For example, you might create a Conversation where a provider messages with a patient through a web app, and the patient receives and responds to messages via SMS on their phone. * * Access Policy Requirements: * Action: `Messaging:CreateConversation` * Access Policy Resource: `Messaging:Conversation` * Action: `FHIR:Create` * Access Policy Resource: `FHIR:Encounter` * Action: `FHIR:Update` * Access Policy Resource: `FHIR:Encounter` */ create(params: ConversationCreateParams, request?: OystehrClientRequest): Promise<ConversationCreateResponse> { return this.request('/messaging/conversation', 'post', this.#baseUrlThunk.bind(this))(params, request); } /** * Get a Conversation Token. Conversation Tokens are used to join the Conversation with the Twilio Conversations SDKs. [Conversations](https://docs.oystehr.com/oystehr/services/messaging/conversations/) allow you to build multi-channel bi-directional messaging workflows. For example, you might create a Conversation where a provider messages with a patient through a web app, and the patient receives and responds to messages via SMS on their phone. * * Access Policy Action: `Messaging:GetConversationToken` * Access Policy Resource: `Messaging:Conversation`. */ getToken(request?: OystehrClientRequest): Promise<ConversationGetTokenResponse> { return this.request('/messaging/conversation/token', 'get', this.#baseUrlThunk.bind(this))(request); } /** * Add a participant to a Conversation. [Conversations](https://docs.oystehr.com/oystehr/services/messaging/conversations/) allow you to build multi-channel bi-directional messaging workflows. For example, you might create a Conversation where a provider messages with a patient through a web app, and the patient receives and responds to messages via SMS on their phone. * * Access Policy Requirements: * Action: `Messaging:ConversationAddParticipant` * Access Policy Resource: `Messaging:Conversation` * Action: `FHIR:Read` * Access Policy Resource: `FHIR:Encounter` * Action: `FHIR:Update` * Access Policy Resource: `FHIR:Encounter` */ addParticipant(params: ConversationAddParticipantParams, request?: OystehrClientRequest): Promise<void> { return this.request( '/messaging/conversation/{conversationId}/participant', 'post', this.#baseUrlThunk.bind(this) )(params, request); } /** * Remove a participant from a Conversation. [Conversations](https://docs.oystehr.com/oystehr/services/messaging/conversations/) allow you to build multi-channel bi-directional messaging workflows. For example, you might create a Conversation where a provider messages with a patient through a web app, and the patient receives and responds to messages via SMS on their phone. * * Access Policy Requirements: * Action: `Messaging:ConversationRemoveParticipant` * Access Policy Resource: `Messaging:Conversation` * Action: `FHIR:Read` * Access Policy Resource: `FHIR:Patient`, `FHIR:Practitioner`, or `FHIR:RelatedPerson` */ removeParticipant(params: ConversationRemoveParticipantParams, request?: OystehrClientRequest): Promise<void> { return this.request( '/messaging/conversation/{conversationId}/participant', 'delete', this.#baseUrlThunk.bind(this) )(params, request); } /** * Send a message to a Conversation. [Conversations](https://docs.oystehr.com/oystehr/services/messaging/conversations/) allow you to build multi-channel bi-directional messaging workflows. For example, you might create a Conversation where a provider messages with a patient through a web app, and the patient receives and responds to messages via SMS on their phone. * * Access Policy Requirements: * Action: `Messaging:ConversationSendMessage` * Access Policy Resource: `Messaging:Conversation` */ message(params: ConversationMessageParams, request?: OystehrClientRequest): Promise<void> { return this.request( '/messaging/conversation/{conversationId}/message', 'post', this.#baseUrlThunk.bind(this) )(params, request); } }