Files
medreport_mrb2b/lib/services/audit/notificationEntries.service.ts
Helena 86dc221cc6 MED-145: send notification to patient when summary completed (#61)
* MED-145: send notification to patient when summary completed

* MED-145: send notification to patient when summary completed

* use aliased imports where possible, revert cart service urls

* save language preference to local db

* remove unnecessary optional chaning
2025-08-28 13:05:07 +03:00

36 lines
850 B
TypeScript

import { Database } from '@kit/supabase/database';
import { getSupabaseServerClient } from '@kit/supabase/server-client';
export enum NotificationAction {
DOCTOR_FEEDBACK_RECEIVED = 'DOCTOR_FEEDBACK_RECEIVED',
}
export const createNotificationLog = async ({
action,
status,
comment,
relatedRecordId,
}: {
action: NotificationAction;
status: Database['audit']['Enums']['action_status'];
comment?: string;
relatedRecordId?: string | number;
}) => {
try {
const supabase = getSupabaseServerClient();
await supabase
.schema('audit')
.from('notification_entries')
.insert({
action,
status,
comment,
related_record_key: relatedRecordId?.toString(),
})
.throwOnError();
} catch (error) {
console.error('Failed to insert doctor page view log', error);
}
};