@oystehr/sdk
Version:
Oystehr SDK
28 lines (26 loc) • 1.37 kB
JavaScript
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;
}
export { ENCOUNTER_VS_EXTENSION_RELATIVE_URL, ENCOUNTER_VS_EXTENSION_URL, getConversationIdFromEncounter };
//# sourceMappingURL=conversation-ext.js.map