MED-82: add patient notification emails (#74)
* MED-82: add patient notification emails * remove console.log * clean up * remove extra paragraph from email
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import type { Tables } from '@/packages/supabase/src/database.types';
|
||||
|
||||
import { AccountWithParams } from '@kit/accounts/api';
|
||||
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
|
||||
@@ -26,6 +25,19 @@ export async function getAccount(id: string): Promise<AccountWithMemberships> {
|
||||
return data as unknown as AccountWithMemberships;
|
||||
}
|
||||
|
||||
export async function getUserContactAdmin(userId: string) {
|
||||
const { data } = await getSupabaseServerAdminClient()
|
||||
.schema('medreport')
|
||||
.from('accounts')
|
||||
.select('name, last_name, email, preferred_locale')
|
||||
.eq('primary_owner_user_id', userId)
|
||||
.eq('is_personal_account', true)
|
||||
.single()
|
||||
.throwOnError();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getAccountAdmin({
|
||||
primaryOwnerUserId,
|
||||
}: {
|
||||
|
||||
@@ -2,9 +2,12 @@ import { Database } from '@kit/supabase/database';
|
||||
import { getSupabaseServerAdminClient } from '@kit/supabase/server-admin-client';
|
||||
|
||||
export enum NotificationAction {
|
||||
DOCTOR_FEEDBACK_RECEIVED = 'DOCTOR_FEEDBACK_RECEIVED',
|
||||
NEW_JOBS_ALERT = 'NEW_JOBS_ALERT',
|
||||
PATIENT_RESULTS_RECEIVED_ALERT = 'PATIENT_RESULTS_RECEIVED_ALERT',
|
||||
DOCTOR_NEW_JOBS = 'DOCTOR_NEW_JOBS',
|
||||
DOCTOR_PATIENT_RESULTS_RECEIVED = 'DOCTOR_PATIENT_RESULTS_RECEIVED',
|
||||
PATIENT_DOCTOR_FEEDBACK_RECEIVED = 'PATIENT_DOCTOR_FEEDBACK_RECEIVED',
|
||||
PATIENT_ORDER_PROCESSING = 'PATIENT_ORDER_PROCESSING',
|
||||
PATIENT_FIRST_RESULTS_RECEIVED = 'PATIENT_FIRST_RESULTS_RECEIVED',
|
||||
PATIENT_FULL_RESULTS_RECEIVED = 'PATIENT_FULL_RESULTS_RECEIVED',
|
||||
}
|
||||
|
||||
export const createNotificationLog = async ({
|
||||
|
||||
@@ -37,7 +37,6 @@ export const createPageViewLog = async ({
|
||||
account_id: accountId,
|
||||
action,
|
||||
changed_by: user.id,
|
||||
extra_data: extraData,
|
||||
})
|
||||
.throwOnError();
|
||||
} catch (error) {
|
||||
|
||||
@@ -13,7 +13,7 @@ type EmailTemplate = {
|
||||
subject: string;
|
||||
};
|
||||
|
||||
type EmailRenderer<T = any> = (params: T) => Promise<EmailTemplate>;
|
||||
export type EmailRenderer<T = any> = (params: T) => Promise<EmailTemplate>;
|
||||
|
||||
export const sendEmailFromTemplate = async <T>(
|
||||
renderer: EmailRenderer<T>,
|
||||
|
||||
Reference in New Issue
Block a user