import { processPatientRecords } from './patientUtils.js' function getPbApi() { if (!window.api?.pb) { throw new Error('PocketBase IPC bridge unavailable. Please launch inside CTM Concierge desktop app.') } return window.api.pb } export async function fetchEntries() { const data = await getPbApi().fetchEntries() return processPatientRecords(data) } export async function fetchTravellers() { return getPbApi().fetchTravellers() } export async function createTraveller(data) { return getPbApi().createTraveller(data) } export async function createEntry(tripData) { const payload = tripData?.trip ? tripData.trip : tripData return getPbApi().createEntry(payload) } export async function updateEntry(id, data) { return getPbApi().updateEntry(id, data) } export async function deleteEntry(id) { return getPbApi().deleteEntry(id) } export async function fetchVaccines() { return getPbApi().fetchVaccines() } export async function fetchVaccineRecords() { return getPbApi().fetchVaccineRecords() } export async function saveVaccineRecord(recordData) { return getPbApi().saveVaccineRecord(recordData) } export async function updateVaccineRecord(id, recordData) { return getPbApi().updateVaccineRecord(id, recordData) } export async function fetchNotifications(options) { return getPbApi().fetchNotifications(options) } export async function updateNotification(id, data) { return getPbApi().updateNotification(id, data) } export async function markNotificationRead(id, isRead = true) { return getPbApi().markNotificationRead(id, isRead) } export async function markAllNotificationsRead() { return getPbApi().markAllNotificationsRead() } export async function archiveNotification(id, isArchived = true) { return getPbApi().archiveNotification(id, isArchived) }