UNPKG

@oystehr/sdk

Version:

Oystehr SDK

32 lines (29 loc) 1.5 kB
'use strict'; const ENCOUNTER_VS_EXTENSION_URL = 'https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release'; const ENCOUNTER_VS_EXTENSION_RELATIVE_URL = 'addressString'; const ENCOUNTER_VS_CODING_SYSTEM = 'https://fhir.zapehr.com/virtual-service-type'; function isR5Encounter(encounter) { return Object.hasOwn(encounter, 'virtualService'); } /** * 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 */ function getConversationIdFromEncounter(encounter) { if (isR5Encounter(encounter)) { const virtualService = encounter.virtualService?.find((vs) => vs.channelType?.system === ENCOUNTER_VS_CODING_SYSTEM); return virtualService?.addressString; } if (!encounter.extension) return; const virtualServiceExtension = encounter.extension.find((extension) => extension.url === ENCOUNTER_VS_EXTENSION_URL); if (!virtualServiceExtension?.extension) return; const conversationId = virtualServiceExtension.extension?.find((extension) => extension.url === ENCOUNTER_VS_EXTENSION_RELATIVE_URL)?.valueString; return conversationId; } exports.ENCOUNTER_VS_EXTENSION_RELATIVE_URL = ENCOUNTER_VS_EXTENSION_RELATIVE_URL; exports.ENCOUNTER_VS_EXTENSION_URL = ENCOUNTER_VS_EXTENSION_URL; exports.getConversationIdFromEncounter = getConversationIdFromEncounter; //# sourceMappingURL=conversation-ext.cjs.map