import type { CommunicationRequest } from 'fhir/r4'; import { isEncounterRoomThreadId } from '../encounterRoomThread'; // A VISIT'S OWN THREAD HAS NO SINGLE PERSON TO NAME, WHICH IS THE SAME SHAPE AS THE POOL. // // The room's roster is whoever was admitted to it, written server-side at admission. So the swap every // other surface uses - *"if I am the sender the other party is the recipient, otherwise the sender"* - // has nothing to land on, exactly as `poolThread.ts` records for the front desk. // // MEASURED on journey C11, from the patient's own inbox after a video visit: the row read // **"Unknown - Staff"**, and opening it threw `Unable to resolve practitioner for selected chat`, // which cleared the unread badge and rendered nothing. The patient was told they had no unread // messages and never saw the message. That is the step's own subject - *the visit's own thread, // open to whoever entered the room, outliving the call* - failing after the call. // // THE THREAD ID IS THE REQUEST ID on these shells, which is the same assumption every send on this // surface already makes (`createCommunicationForThread(text, request.id, ...)`). The predicate itself // is the server-mirrored one, which counts '#' rather than matching a prefix, so a patient whose FHIR // id is literally `encounter` cannot route a direct thread through the room roster. export const isEncounterRoomThreadRequest = (request: CommunicationRequest | undefined): boolean => isEncounterRoomThreadId(request?.id); // NAMED FOR THE VISIT, not for the practice and not for a person. // // "Great River Health Center" is already on the row's organization line, and repeating it as the title // would tell the reader nothing about which conversation this is. A patient recognises this thread as // the visit it belongs to. export const ROOM_THREAD_LABEL = 'Video visit'; // The line UNDER the name, on the pool's reasoning: it says what the thread IS, so it stays useful // when the practice name has not resolved, and it does not repeat the title. export const ROOM_THREAD_DESCRIPTION = 'Messages from your visit';